1function EnhancedLinksPlugin() { 2 this._settings = { 3 expandText : '»', 4 contractText : '«', 5 leafText : '-', 6 expandImage : '', 7 contractImage : '', 8 leafImage : '', 9 buttonColor : '#CC0000', 10 buttonWidth : '10px', 11 buttonMargin : '0 5px 0 0', 12 isButtonAfter : false 13 }; 14} 15 16jQuery.extend(EnhancedLinksPlugin.prototype, { 17 setSettings: function(newSettings) { 18 jQuery.extend(this._settings, newSettings || {}); 19 }, 20 21 getSettings: function() { 22 return this._settings; 23 }, 24 25 getButtonText: function(text, image) { 26 var output = ''; 27 if (image=='') { 28 output += text; 29 } else { 30 output += '<img src="' + image + '" alt="' + text + '" title="' + text + '" />'; 31 } 32 33 return output; 34 } 35}); 36 37jQuery(document).ready(function() { 38 EnhancedLinksPlugin = new EnhancedLinksPlugin(); 39}); 40 41jQuery.fn.enhancedLinks = function(args) { 42 var defaults = EnhancedLinksPlugin.getSettings(); 43 jQuery.extend(defaults, args); 44 45 return jQuery('li.linkcat', this).each(function() { 46 var hasChildren = (jQuery(this).children('ul').length > 0); 47 var button = ''; 48 49 // Make button text 50 if (hasChildren) { 51 if (defaults.contractChildren==1) { 52 button += '<span class="button is_expanded" style="cursor: pointer;">'; 53 button += EnhancedLinksPlugin.getButtonText(defaults.expandText, defaults.expandImage); 54 button += '</span>'; 55 } else { 56 button += '<span class="button is_contracted" style="cursor: pointer;">'; 57 button += EnhancedLinksPlugin.getButtonText(defaults.contractText, defaults.contractImage); 58 button += '</span>'; 59 } 60 } else { 61 button += '<span class="button" style="">'; 62 button += EnhancedLinksPlugin.getButtonText(defaults.leafText, defaults.leafImage); 63 button += '</span>'; 64 } 65 66 // Add the button before or after the category 67 if (defaults.isButtonAfter) { 68 if (hasChildren) { 69 jQuery(this).children('ul').before(button); 70 } else { 71 jQuery(this).append(button); 72 } 73 } else { 74 jQuery(this).prepend(button); 75 } 76 77 // Behaviour of the category 78 jQuery(this) 79 .css({listStyleType: 'none'}) 80 .children('span.button, span.link-cat-title') 81 .css({ width: defaults.buttonWidth, 82 margin: defaults.buttonMargin, 83 color: defaults.buttonColor 84 }) 85 .click(function() { 86 jQuery(this).siblings('ul').slideToggle(); 87 88 if (jQuery(this).hasClass('link-cat-title')) 89 var buttons = jQuery(this).siblings('span.button'); 90 else 91 var buttons = jQuery(this); 92 93 buttons 94 .filter('span.button') 95 .each(function() { 96 if (jQuery(this).hasClass('is_expanded')) { 97 jQuery(this) 98 .html(EnhancedLinksPlugin.getButtonText(defaults.contractText, defaults.contractImage)) 99 .removeClass('is_expanded') 100 .addClass('is_contracted'); 101 } else { 102 jQuery(this) 103 .html(EnhancedLinksPlugin.getButtonText(defaults.expandText, defaults.expandImage)) 104 .removeClass('is_contracted') 105 .addClass('is_expanded'); 106 } 107 return this; 108 });
109 }); 110 111 jQuery(this).children('ul') 112 .css({ paddingLeft: defaults.buttonWidth }); 113 114 // Contract child categories if asked 115 if (defaults.contractChildren==1) { 116 jQuery(this).children('ul').hide(); 117 } 118 119 return this; 120 }); 121};
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.