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') == base_url+ "#"){
37 $(this).find("a:first").click(function(e){ 38 return false; 39 }); 40 } 41 } 42 }); 43 44 //open active level 45 $this.find("li.active").each(function() { 46 $(this).parents("ul").slideDown(opts.speed); 47 $(this).parents("ul").parent("li").find("span:first").html(opts.openedSign); 48 $(this).find("span:first").html(opts.openedSign); 49 }); 50 51 $this.find("li a").click(function(e) { 52 e.preventDefault(); 53 var href= $(this).attr('href'); 54 if($(this).parent().find("ul").size() != 0){ 55 if(opts.accordion){ 56 //Do nothing when the list is open 57 if(!$(this).parent().find("ul").is(':visible')){ 58 parents = $(this).parent().parents("ul"); 59 visible = $this.find("ul:visible"); 60 visible.each(function(visibleIndex){ 61 var close = true; 62 parents.each(function(parentIndex){ 63 if(parents[parentIndex] == visible[visibleIndex]){ 64 close = false; 65 return false; 66 } 67 }); 68 if(close){ 69 if($(this).parent().find("ul") != visible[visibleIndex]){ 70 $(visible[visibleIndex]).slideUp(opts.speed, function(){ 71 $(this).parent("li").find("span:first").html(opts.closedSign); 72 }); 73 74 } 75 } 76 }); 77 } 78 } 79 if($(this).parent().find("ul:first").is(":visible")){ 80 /* 81 $(this).parent().find("ul:first").slideUp(opts.speed, function(){ 82 $(this).parent("li").find("span:first").delay(opts.speed).html(opts.closedSign); 83 $(location).attr('href',href); 84 });*/ 85 if( href == base_url+ "#"){
86 return false; 87 } 88 $(location).attr('href',href); 89 90 91 92 }else{ 93 $(this).parent().find("ul:first").slideDown(opts.speed, function(){ 94 $(this).parent("li").find("span:first").delay(opts.speed).html(opts.openedSign); 95 if( href == base_url+ "#"){ 96 return false; 97 } 98 $(location).attr('href',href); 99 }); 100 } 101 } 102 else{ 103 if( href == base_url+ "#"){ 104 return false; 105 } 106 $(location).attr('href',href); 107 } 108 109 }); 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.