1;(function($){ 2 $.fn.msAccordion = function(options) { 3 options = $.extend({ 4 currentDiv:'1', 5 width:'100%', 6 height:'300px', 7 previousDiv:'', 8 vertical: false, 9 defaultid:0, 10 currentcounter:0, 11 intervalid:0, 12 autodelay:0, 13 padding: '1px', 14 event:"click", 15 onemustopen: true, 16 autoResize: true, 17 alldivs_array:new Array() 18 }, options); 19 $(this).addClass("accordionWrapper").parent().css({'overflow':"hidden", 'width':options.width}); 20 $(this).show().width($(this).parent().width()); 21 var elementid = $(this).attr("id"); 22 var allDivs = this.children().addClass('accordion-item').css({'padding': options.padding, 'display': 'inline'}); 23 var totalTitleWidth = allDivs.length * $(this).find('.title').outerWidth(); 24 var contentWidth = ($(this).width() - totalTitleWidth) - (2*parseInt(options.padding)*allDivs.length); 25 if(options.autodelay>0) { 26 $("#"+ elementid +" > div").bind("mouseenter", function(){ pause(); }); 27 $("#"+ elementid +" > div").bind("mouseleave", function(){ startPlay(); }); 28 } 29 allDivs.each(function(current) { //set ids 30 var iCurrent = current; 31 var sTitleID = elementid+"_msTitle_"+(iCurrent); 32 var sContentID = sTitleID+"_msContent_"+(iCurrent); 33 var currentDiv = allDivs[iCurrent]; 34 var titleDiv = $(currentDiv).find("div.title"); 35 titleDiv.attr("id", sTitleID); 36 var contentDiv = $(currentDiv).find("div.content"); 37 contentDiv.attr("id", sContentID); 38 if(!options.vertical){ 39 titleDiv.height(options.height); 40 contentDiv.children().width(contentWidth); 41 $(this).find('.toggler').css({'width':parseInt(options.height)-20, 'top':parseInt(options.height)-25}); 42 } 43 options.alldivs_array.push(sTitleID); 44 if(!options.onemustopen){ 45 if($(currentDiv).css("display")!="none" && options.event == "click"){$("#"+sTitleID).bind(options.event,function(){pause();closeMe(sContentID);});}} 46 $("#"+sTitleID).bind(options.event, function(){pause();openMe(sTitleID);}); 47 }); 48 if(options.vertical) {makeVertical();}; //make vertical 49 openMe(elementid+"_msTitle_"+options.defaultid); //open default 50 if(options.autodelay>0) {startPlay();}; //Auto Play 51 if(options.autoResize){ //bind setsize function to window resize event 52 $(window).resize(function(){ 53 resizeWidth = $('#'+elementid).parent().width(); 54 resizeContentWidth = (resizeWidth - totalTitleWidth) - (2*parseInt(options.padding)*allDivs.length); 55 if(options.vertical) 56 $('#'+elementid).width(resizeWidth).children().width(parseInt(resizeWidth)-2).find('.content').children().width(parseInt(resizeWidth)-2); 57 else 58 $('#'+elementid).width(resizeWidth).find('.content').children().width(resizeContentWidth); 59 }); 60 } 61 function openMe(id) { 62 var sTitleID = id; 63 var iCurrent = sTitleID.split("_")[sTitleID.split("_").length-1]; 64 options.currentcounter = iCurrent; 65 var sContentID = id+"_msContent_"+iCurrent; 66 $("#"+sContentID).addClass("accordionActive"); 67 if($("#"+sContentID).css("display")=="none") { 68 if(options.previousDiv!="") { 69 closeMe(options.previousDiv); 70 }; 71 if(options.vertical) { 72 $("#"+sContentID).slideDown("slow").prev().addClass("active"); 73 } else { 74 $("#" + sContentID + " > div").css({'display':'inline', 'height': options.height}); 75 $("#"+sContentID).show("slow").prev().addClass("active"); 76 } 77 options.currentDiv = sContentID; 78 options.previousDiv = options.currentDiv; 79 }; 80 }; 81 function closeMe(div) { 82 if(options.vertical) { 83 $("#"+div).slideUp("slow").prev().removeClass("active"); 84 } else { 85 $("#"+div).removeClass("accordionActive"); 86 if(options.onemustopen){ 87 $("#"+div).hide("slow").css({ display: "none" }).prev().removeClass("active"); 88 }else{ 89 $("#"+div).hide("slow").prev().removeClass("active"); 90 } 91 $("#" + div + " > div").css({ display: "none" }).prev().removeClass("active"); 92 }; 93 }; 94 function makeVertical() { 95 $("#"+elementid +" > div").css({display:"block", float:"none", clear:"both", 'width': parseInt($('.accordionWrapper').width())-2});
96 $("#"+elementid +" > div > div.title").css({display:"block", float:"none", clear:"both", 'width':'100%'}); 97 $("#"+elementid +" > div > div.content").css({clear:"both", 'width':'100%'}).children().width(parseInt($('.accordionWrapper').width())-2); 98 }; 99 function startPlay() { 100 options.intervalid = window.setInterval(play, options.autodelay); 101 }; 102 function play() { 103 var sTitleId = options.alldivs_array[options.currentcounter]; 104 openMe(sTitleId); 105 options.currentcounter++; 106 if(options.currentcounter==options.alldivs_array.length) options.currentcounter = 0; 107 }; 108 function pause() { 109 window.clearInterval(options.intervalid); 110 }; 111 } 112})(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.