1var accordion = (function(){ 2 3 var $accordion = $('.js-accordion'); 4 var $accordion_header = $accordion.find('.js-accordion-header'); 5 var $accordion_item = $('.js-accordion-item'); 6 7 // default settings 8 var settings = { 9 // animation speed 10 speed: 400, 11 12 // close all other accordion items if true 13 oneOpen: false 14 }; 15 16 return { 17 // pass configurable object literal 18 init: function($settings) { 19 $accordion_header.on('click', function() { 20 accordion.toggle($(this)); 21 }); 22 23 $.extend(settings, $settings); 24 25 // ensure only one accordion is active if oneOpen is true 26 if(settings.oneOpen && $('.js-accordion-item.active').length > 1) { 27 $('.js-accordion-item.active:not(:first)').removeClass('active'); 28 } 29 30 // reveal the active accordion bodies 31 $('.js-accordion-item.active').find('> .js-accordion-body').show(); 32 }, 33 toggle: function($this) { 34 35 if(settings.oneOpen && $this[0] != $this.closest('.js-accordion').find('> .js-accordion-item.active > .js-accordion-header')[0]) { 36 $this.closest('.js-accordion') 37 .find('> .js-accordion-item') 38 .removeClass('active') 39 .find('.js-accordion-body') 40 .slideUp() 41 } 42 43 // show/hide the clicked accordion item 44 $this.closest('.js-accordion-item').toggleClass('active'); 45 $this.next().stop().slideToggle(settings.speed); 46 } 47 } 48 })(); 49 50 $(document).ready(function(){ 51 accordion.init({ speed: 300, oneOpen: true }); 52 });
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.