1/* 2The original expanding menu was created by Ross Cairns. 3Much thanks to him for creating something that became so useful. 4 5This version of expanding is suited to be used with Indexhibit v0.9....and greater. 6 7Vaska / Indexhibit.org 8*/ 9 10(function($){ 11$.fn.ndxzExpander = function(options) 12{ 13 var options = $.extend({ 14 active: "", 15 speed: 100, // speed of transitions 16 single: true, // only allow one node open at a time 17 _identifier: $(this) 18 }, options); 19 20 //var exclude = new Array(); 21 //exclude[0] = 'section_4'; 22 23 $.fn.ndxzExpander.init = function() 24 { 25 // let's add a feature to ignore certain sections altogether 26 // need to use each for this then 27 $('ul.section').each(function() 28 { 29 //if (jQuery.inArray(this.id, exclude)) 30 //{ 31 32 //alert( '#menu ul#' + this.id + ' span.section_title' ); 33 // need to rewrite the expander links 34 $('#menu ul#' + this.id + ' li a span.section_title').unwrap(); 35 $('#menu ul#' + this.id + ' li span.section_title').next().hide(); 36 $('#menu ul#' + this.id + ' li span.subsection_title').next().hide(); 37 $('#menu ul#' + this.id + ' span.section_title').bind('click', function(){ $.fn.ndxzExpander.expander(this); return false; }); 38 $('#menu ul#' + this.id + ' span.subsection_title').bind('click', function(){ $.fn.ndxzExpander.expander(this); return false; }); 39 //} 40 }); 41 42 // show active 43 $.fn.ndxzExpander.active(); 44 } 45 46 /* 47 <ul class='section active_section' id='section_2'> 48 <li id='section_title_2'> 49 <a href='http://www.indexhibit.dev/project/'><span id='section_link_2' class='section_title active'>Projects</span></a> 50 */ 51 52 $.fn.ndxzExpander.active = function() 53 { 54 //$('#menu ul.active_section li a span.active').nextAll('ul').toggle(options.speed); 55 56 // open up the pathway 57 // works with active pages - but not section tops... 58 $('li.active').parents('ul').show(); 59 60 // let's register the active ul - messy 61 var a = new Array(); var b; 62 //a = $('span.active').parents('ul').map(function () { return this.id; }).get().reverse(); 63 a = $('li.active').parents('ul').map(function () { return this.id; }).get().reverse(); 64 65 // if there is no active link at all 66 // review this later... 67 if (a == '') 68 { 69 // maybe we need to look/expand for an active section instead? 70 $('ul.active_section li ul.sub_section').show(); 71 return false; 72 } 73 else 74 { 75 b = a[0]; 76 b = b.replace('section_', ''); 77 b = 'section_link_' + b; 78 } 79 80 options.active = b; 81 } 82 83 $.fn.ndxzExpander.expander = function(obj) 84 { 85 // nothing if it's the active part 86 if (options.active == obj.id) return false; 87 88 // we need to make sure it's not themselves 89 if (options.single == true) 90 { 91 // this works but not with sub section clicks 92 if ($('span#' + obj.id).hasClass('subsection_title')) 93 { 94 var tmp = obj.id; 95 tmp = tmp.split('_'); 96 var subsection = tmp.pop(); 97 var section = tmp.pop(); 98 99 $('ul#section_' + section + ' ul.subsection:visible').hide(options.speed); 100 101 // register the new active part 102 options.active = 'section_link_' + section; 103 } 104 else 105 { 106 $('#menu ul li span.section_title').next().hide(options.speed); 107 108 // register the new active part 109 options.active = obj.id; 110 } 111 } 112 113 var found = $('span#' + obj.id).parent().find('ul').length; 114 115 if (found > 0) 116 { 117 // show all secondary 118 $('span#' + obj.id).nextAll('ul').toggle(options.speed); 119 } 120 else 121 { 122 $('span#' + obj.id + ' + ul').toggle(options.speed); 123 } 124 } 125 126 // Initalize the expander 127 $.fn.ndxzExpander.init(this); 128}; 129})(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.