+(function ($) { var pending_ajax = false; var wedocs = { initialize: function () { $('.wedocs-feedback-wrap').on('click', 'a', this.feedback); $('#top-search-form .dropdown-menu').on('click', 'a', this.searchform); $('a.wedocs-print-article').on('click', this.printarticle); // sidebar toggle $('ul.doc-nav-list .page_item_has_children').on( 'click', '.wedocs-caret', function (event) { event.preventdefault(); var self = $(this), parent = self.closest('.page_item'); if (parent.hasclass('wd-state-closed')) { parent.removeclass('wd-state-closed').addclass('wd-state-open'); } else { parent.removeclass('wd-state-open').addclass('wd-state-closed'); } } ); // modal $('a#wedocs-stuck-modal').on('click', this.showmodal); $('a#wedocs-modal-close').on('click', this.closemodal); $('#wedocs-modal-backdrop').on('click', this.closemodal); $('form#wedocs-contact-modal-form').on('submit', this.contacthelp); }, feedback: function (e) { e.preventdefault(); // return if any request is in process already if (pending_ajax) { return; } pending_ajax = true; var self = $(this), wrap = self.closest('.wedocs-feedback-wrap'), data = { post_id: self.data('id'), type: self.data('type'), action: 'wedocs_ajax_feedback', _wpnonce: wedocs_vars.nonce, }; wrap.append( '  ' ); $.post(wedocs_vars.ajaxurl, data, function (resp) { wrap.html(resp.data); pending_ajax = false; }); }, searchform: function (e) { e.preventdefault(); var param = $(this).attr('href').replace('#', ''); var concept = $(this).text(); $('#top-search-form span#search_concept').text(concept); $('.input-group #search_param').val(param); }, printarticle: function (e) { e.preventdefault(); var article = $(this).closest('article'); var mywindow = window.open('', 'my div', 'height=600,width=800'); mywindow.document.write('print article'); mywindow.document.write( '' ); mywindow.document.write(''); mywindow.document.write(article.html()); mywindow.document.write( '
' + wedocs_vars.powered + '
' ); mywindow.document.write(''); mywindow.document.close(); // necessary for ie >= 10 mywindow.focus(); // necessary for ie >= 10 settimeout(function () { // mywindow.print(); // mywindow.close(); }, 2000); return true; }, showmodal: function (e) { e.preventdefault(); $('#wedocs-modal-backdrop').show(); $('#wedocs-contact-modal').show(); $('body').addclass('wedocs-overflow-hidden'); }, closemodal: function (e) { e.preventdefault(); $('#wedocs-modal-backdrop').hide(); $('#wedocs-contact-modal').hide(); $('body').removeclass('wedocs-overflow-hidden'); }, contacthelp: function (e) { e.preventdefault(); var self = $(this), submit = self.find('input[type=submit]'), body = self.closest('.wedocs-modal-body'), data = self.serialize() + '&_wpnonce=' + wedocs_vars.nonce; submit.prop('disabled', true); $.post(wedocs_vars.ajaxurl, data, function (resp) { if (resp.success === false) { submit.prop('disabled', false); $('#wedocs-modal-errors', body) .empty() .append( '
' + resp.data + '
' ); } else { body .empty() .append( '
' + resp.data + '
' ); } }); }, }; $(function () { wedocs.initialize(); }); // initialize anchor.js anchors.options = { icon: '#', }; anchors.add( '.wedocs-single-content .entry-content > h2, .wedocs-single-content .entry-content > h3' ); })(jquery);