1/* 2 * jQuery UI Multilevel Accordion v.1 3 * 4 * Copyright (c) 2011 Pieter Pareit 5 * 6 * http://www.scriptbreaker.com 7 * 8 */ 9 10//plugin definition 11(function($){ 12 $.fn.extend({ 13 14 //pass the options variable to the function 15 accordion: function(options) { 16 17 var defaults = { 18 accordion: 'true', 19 speed: 300, 20 closedSign: '[+]', 21 openedSign: '[-]' 22 }; 23 24 // Extend our default options with those provided. 25 var opts = $.extend(defaults, options); 26 //Assign current element to variable, in this case is UL element 27 var $this = $(this); 28 29 //add a mark [+] to a multilevel menu 30 $this.find("li").each(function() { 31 if($(this).find("ul").size() != 0){ 32 //add the multilevel sign next to the link 33 $(this).find("a:first").append("<span>"+ opts.closedSign +"</span>"); 34 35 //avoid jumping to the top of the page when the href is an # 36 if($(this).find("a:first").attr('href') == "#"){ 37 $(this).find("a:first").click(function(){return false;}); 38 } 39 } 40 }); 41 42 //open active level 43 $this.find("li.active").each(function() { 44 $(this).parents("ul").slideDown(opts.speed); 45 $(this).parents("ul").parent("li").find("span:first").html(opts.openedSign); 46 }); 47 48 $this.find("li a").click(function() { 49 if($(this).parent().find("ul").size() != 0){ 50 if(opts.accordion){ 51 //Do nothing when the list is open 52 if(!$(this).parent().find("ul").is(':visible')){ 53 parents = $(this).parent().parents("ul"); 54 visible = $this.find("ul:visible"); 55 visible.each(function(visibleIndex){ 56 var close = true; 57 parents.each(function(parentIndex){ 58 if(parents[parentIndex] == visible[visibleIndex]){ 59 close = false; 60 return false; 61 } 62 }); 63 if(close){ 64 if($(this).parent().find("ul") != visible[visibleIndex]){ 65 $(visible[visibleIndex]).slideUp(opts.speed, function(){ 66 $(this).parent("li").find("span:first").html(opts.closedSign); 67 }); 68 69 } 70 } 71 });
72 } 73 } 74 if($(this).parent().find("ul:first").is(":visible")){ 75 $(this).parent().find("ul:first").slideUp(opts.speed, function(){ 76 $(this).parent("li").find("span:first").delay(opts.speed).html(opts.closedSign); 77 }); 78 79 80 }else{ 81 $(this).parent().find("ul:first").slideDown(opts.speed, function(){ 82 $(this).parent("li").find("span:first").delay(opts.speed).html(opts.openedSign); 83 }); 84 } 85 } 86 }); 87 } 88}); 89})(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.