1;(function($){ 2 $.fn.extend({ 3 sj_accordion_expand: function(options){ 4 $context = $(this); 5 if ( $context.hasClass(options.active_class) ) return; 6 if ( $context.hasClass(options.active_class) ) return; 7 8 var $content_inner = $(options.content, $context); 9 $content_inner.filter(':animated').stop(); 10 11 $height_to_fit = 0; 12 $content_inner.children().each(function(){ 13 if ($(this).height()>0){ 14 $height_to_fit += $(this).height(); 15 } 16 }); 17 18 $context.addClass(options.active_class); 19 $content_inner.animate({ 20 height: $height_to_fit 21 }, { 22 duration: options.duration 23 }); 24 }, 25 sj_accordion_close: function(options){ 26 $context = $(this); 27 $context.removeClass(options.active_class); 28 var $content_inner = $(options.content, $context); 29 30 $content_inner.filter(':animated').stop(); 31 32 $content_inner.animate({ 33 height: 0 34 }, { 35 duration: options.duration 36 }); 37 }, 38 sj_accordion: function(options){ 39 var defaults = {}; 40 var options = $.extend(defaults, options); 41 42 return this.each(function(){ 43 var panel = $(this); 44 var items = $(options.items, this); 45 var stack = []; 46 var stackProcess = function(){ 47 if (stack.length>0){ 48 var item = stack.pop(); 49 items.not(item).sj_accordion_close(options); 50 $(item).sj_accordion_expand(options); 51 } 52 }; 53 var stackTimeout = null; 54 55 items.each(function(i, item){ 56 if (options.active && options.active==(i+1)){ 57 $(item).sj_accordion_expand(options); 58 } 59 60 if (options.event=='click'){ 61 $(item).click(function(){ 62 console.log($(this)); 63 items.not(item).sj_accordion_close(options); 64 $(item).sj_accordion_expand(options); 65 }); 66 } else { 67 var delay = parseInt(options.delay); 68 if (!delay) delay = 100; 69 $(item).hover(function(){ 70 // action after 'delay' miliseconds. 71 if (stackTimeout){ 72 clearTimeout(stackTimeout); 73 } 74 stackTimeout = setTimeout(stackProcess, delay); 75 stack.push(item); 76 }, function(){ 77 stack.pop(); 78 }); 79 } 80 }); 81 82 83// var $items = $(options.items, this); 84// 85// $items.each(function(i, item){ 86// if (options.active && options.active==i+1){ 87// $(item).sj_accordion_expand(options); 88// } 89// 90// $(options.heading, item).bind(options.event, function(){ 91// var delay = options.event=='click'?10:options.delay; 92// setTimeout(function(){ 93// $items.not(item).sj_accordion_close(options); 94// $(item).sj_accordion_expand(options); 95// },delay); 96// }); 97// }); 98 }); 99 } 100 }); 101})(jQuery) 102 103
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.