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