1(function ($) { 2 $.fn.extend({ 3 4 akordeon: function (options) { 5 var settings = $.extend({ expandedItem: 0, expandSpeed: 200, toggle: false, expandText: '–', collapseText: '+', buttons: true, hiddenItem: -1, itemsOrder: [] }, options); 6 return this.each(function () { 7 8 var expandedItem = settings.expandedItem; 9 var speed = settings.expandSpeed; 10 var expandText = settings.expandText; 11 var collapseText = settings.collapseText; 12 var isToggle = settings.toggle; 13 14 var akordeon = $(this); 15 if (!akordeon.hasClass('akordeon')) 16 akordeon.addClass('akordeon'); 17 18 if (settings.itemsOrder != null && settings.itemsOrder != undefined && settings.itemsOrder.length > 0) { 19 if (settings.itemsOrder.length != akordeon.find('.akordeon-item').length) { 20 alert('Parameter value mismatch with total items'); 21 } 22 else { 23 var items = akordeon.find('.akordeon-item').clone(true); 24 akordeon.find('.akordeon-item').remove(); 25 26 $(settings.itemsOrder).each(function () { 27 akordeon.append(items.eq(this)); 28 }); 29 } 30 } 31 $('.akordeon-item', akordeon).each(function () { 32 var body = $(this).find('.akordeon-item-body'); 33 var h = body.outerHeight(); 34 body.data('h', h); 35 $(this).find('.akordeon-item-head').addClass('akordeon-border-bottom'); 36 body.addClass('akordeon-border-bottom'); 37 if (settings.buttons) 38 $(this).find('.akordeon-item-head-container').prepend('<div class="akordeon-icon"><span>' + collapseText + '</span></div>'); 39 }); 40 if (settings.hiddentItem > -1) { 41 var hiddenItem = $('.akordeon-item', akordeon).eq(settings.hiddenItem).hide(); 42 43 hiddenItem.find('.akordeon-item-head', akordeon).last().removeClass('akordeon-border-bottom'); 44 hiddenItem.find('.akordeon-item-body', akordeon).last().removeClass('akordeon-border-bottom'); 45 } 46 $('.akordeon-item .akordeon-item-head', akordeon).last().removeClass('akordeon-border-bottom'); 47 $('.akordeon-item .akordeon-item-body', akordeon).last().removeClass('akordeon-border-bottom'); 48 $('.akordeon-item:first').addClass('akordeon-item-first'); 49 $('.akordeon-item:last').addClass('akordeon-item-last'); 50 $('.akordeon-item', akordeon).removeClass('expanded').addClass('collapsed'); 51 $('.akordeon-item.collapsed .akordeon-item-body', akordeon).css({ height: 0 }); 52 expandItem($('.akordeon-item', akordeon).eq(expandedItem)); 53 54 $('.akordeon-item-head-container', akordeon).click(function () { 55 var currentItem = $(this).parents('.akordeon-item'); 56 var previousItem = akordeon.find('.akordeon-item.expanded'); 57 var isExpanded = currentItem.hasClass('expanded'); 58 if (!isToggle) { 59 if (!isExpanded) { 60 collapseItem(previousItem); 61 expandItem(currentItem); 62 } 63 } 64 else { 65 if (isExpanded) 66 collapseItem(currentItem); 67 else 68 expandItem(currentItem); 69 } 70 }); 71 72 function expandItem(item) { 73 var body = item.find('.akordeon-item-body'); 74 var h = body.data('h'); 75 body.animate({ height: h }, speed, function () { 76 item.removeClass('collapsed').addClass('expanded').find('.akordeon-icon span').html(expandText); 77 }); 78 } 79 function collapseItem(item) { 80 var body = item.find('.akordeon-item-body'); 81 body.animate({ height: 0 }, speed, function () { 82 item.removeClass('expanded').addClass('collapsed').find('.akordeon-icon span').html(collapseText); 83 }); 84 } 85 }); 86 } 87 }); 88})(jQuery);
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.