1var wptFaqAccordion = { 2 init: function() { 3 var self = this; 4 jQuery('.wpt-faq-accordion .wpt-faq-item').on('click', function(e){ 5 6 if((e.target.className === 'wpt-faq-answer')|| jQuery(e.target).closest('.wpt-faq-answer').length){ 7 return; 8 } 9 e.preventDefault(); 10 11 var el = jQuery(this); 12 var state = el.attr('data-wpt-faq-state'); 13 var id = el.attr('id'); 14 var new_state = (state == 'open') ? 'close' : 'open'; 15 // set the list as per settings 16 self.appear_as_per_state(el); 17 jQuery(this).attr('data-wpt-faq-state', new_state); 18 var update_browser_url = el.closest('.wpt-faq-accordion').data('wpt-update-browser-url'); 19 20 if(update_browser_url){ 21 // add hash 22 if(history.pushState) { 23 history.pushState(null, null, '#' + id); 24 } 25 else { 26 location.hash = id; 27 } 28 } 29 }); 30 }, 31 appear_as_per_state: function(el){ 32 var main_el = el.closest('.wpt-faq-accordion'); 33 var can_open = main_el.attr('data-wpt-faq-can-open'); 34 var initial_state = el.attr('data-wpt-faq-initial-state'); 35 var id = el.attr('id'); 36 if((can_open == 'one') && (initial_state == 'close') ) { 37 el.closest('.wpt-faq-accordion').find('.wpt-faq-item').each(function(){ 38 39 if(jQuery(this).attr('id') != id){ 40 jQuery(this).attr('data-wpt-faq-state', 'close'); 41 } 42 }); 43 } 44 }, 45 open_faq: function(id){ 46 var el = jQuery(id) 47 48 if(el.length && el.hasClass('wpt-faq-item')) { 49 el.attr('data-wpt-faq-state', 'open'); 50 this.appear_as_per_state(el); 51 } 52 } 53 54} 55 56jQuery(document).ready(function($) { 57 wptFaqAccordion.init(); 58 59 jQuery( window ).on( 'hashchange', function( e ) { 60 wptFaqAccordion.open_faq(window.location.hash); 61 }); 62 63 if(window.location.hash){ 64 wptFaqAccordion.open_faq(window.location.hash); 65 } 66 67});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.