1;(function($, window, document) { 2 3 var effect = { 4 slideDown: { 5 height: "show", 6 paddingTop: "show", 7 marginTop: "show", 8 paddingBottom: "show", 9 marginBottom: "show" 10 }, 11 slideUp: { 12 height: "hide", 13 paddingTop: "hide", 14 marginTop: "hide", 15 paddingBottom: "hide", 16 marginBottom: "hide" 17 } 18 }; 19 20 Accordion = { 21 22 init: function(el, options) { 23 var that = this; 24 25 // add css style to link 26 $('[data-acc-link]').css({ 'cursor': 'pointer' }); 27 28 // hide content by default except content has class "acc-open" 29 $('[data-acc-content]').not('.acc-open').css({ 'display': 'none' }); 30 31 // bind click event 32 el.on('click', '[data-acc-link]', function(e) { 33 e.preventDefault(); 34 that.options = options; 35 var linkName = $(this).data('acc-link'); 36 var contentObj = $('[data-acc-content='+linkName+']'); 37 that.toggle(contentObj, el); 38 }); 39 }, 40 41 open: function(contentObj) { 42 contentObj.animate(effect.slideDown, this.options.duration).addClass('acc-open'); 43 }, 44 45 close: function(contentObj) { 46 contentObj.animate(effect.slideUp, this.options.duration).removeClass('acc-open'); 47 }, 48 49 50 toggle: function(contentObj, el) { 51 var that = this; 52 if(!this.options.multiOpen) { 53 var contentName = contentObj.data('acc-content'); 54 var contentObjs = $(el).find('[data-acc-content]:not([data-acc-content='+contentName+'])'); 55 contentObjs.each(function(i, v) { 56 that.close($(v)); 57 }); 58 } 59 contentObj.hasClass('acc-open') ? this.close(contentObj) : this.open(contentObj); 60 } 61 62 }; 63 64 $.fn.accordion = function(options) { 65 options = $.extend({ 66 multiOpen: true, 67 duration: 200 68 }, options); 69 70 return this.each(function() { 71 Accordion.init($(this), options); 72 }); 73 } 74 75})(jQuery, window, document);
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.