1/* 2 treeMenu - jQuery plugin 3 version: 0.6 4 5 Copyright 2014 Stepan Krapivin 6 7*/ 8(function($){ 9 $.fn.treemenu = function(options) { 10 options = options || {}; 11 options.delay = options.delay || 0; 12 options.openActive = options.openActive || false; 13 options.closeOther = options.closeOther || false; 14 options.activeSelector = options.activeSelector || ".active"; 15 16 this.addClass("treemenu"); 17 18 if (!options.nonroot) { 19 this.addClass("treemenu-root"); 20 } 21 22 options.nonroot = true; 23 24 this.find("> li").each(function() { 25 e = $(this); 26 var subtree = e.find('> ul'); 27 var button = e.find('.toggler').eq(0); 28 29 if(button.length == 0) { 30 // create toggler 31 var button = $('<span>'); 32 button.addClass('toggler'); 33 e.prepend(button); 34 } 35 36 if(subtree.length > 0) { 37 subtree.hide(); 38 39 e.addClass('tree-closed'); 40 41 e.find(button).click(function() { 42 var li = $(this).parent('li'); 43 44 if (options.closeOther && li.hasClass('tree-closed')) { 45 var siblings = li.parent('ul').find("li:not(.tree-empty)"); 46 siblings.removeClass("tree-opened"); 47 siblings.addClass("tree-closed"); 48 siblings.removeClass(options.activeSelector); 49 siblings.find('> ul').slideUp(options.delay); 50 } 51 52 li.find('> ul').slideToggle(options.delay); 53 li.toggleClass('tree-opened'); 54 li.toggleClass('tree-closed'); 55 li.toggleClass(options.activeSelector); 56 }); 57 58 $(this).find('> ul').treemenu(options); 59 } else { 60 $(this).addClass('tree-empty'); 61 } 62 }); 63 64 if (options.openActive) { 65 var cls = this.attr("class"); 66 67 this.find(options.activeSelector).each(function(){ 68 var el = $(this).parent(); 69 70 while (el.attr("class") !== cls) { 71 el.find('> ul').show(); 72 if(el.prop("tagName") === 'UL') { 73 el.show(); 74 } else if (el.prop("tagName") === 'LI') { 75 el.removeClass('tree-closed'); 76 el.addClass("tree-opened"); 77 el.show(); 78 } 79 80 el = el.parent(); 81 } 82 }); 83 } 84 85 return this; 86 } 87})(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.