1/***********************************************************/ 2/* tinyTips Plugin */ 3/* Version: 1.0 */ 4/* Mike Merritt */ 5/* Updated: Feb 4th, 2010 */ 6/** ******************************************************** */ 7var tinyTipsOptions = { 8 delayFadeIn : 200, 9 delayFadeOut : 100, 10 tooltipTimeout : 30000, 11 isEnabled : true 12}; 13(function($) { 14 $.fn.tinyTips = function(text, condition) { 15 condition = condition; 16 content = '<div class="tinyTip"><div class="content"></div><div class="bottom"> </div></div>'; 17 title = null; 18 self = this; 19 20 if(!tinyTipsOptions.isEnabled) { 21 return this; 22 } 23 24 if($('.tinyTip').length == 0) { 25 var element = $(content); 26 element.css({ 27 "display": "none" 28 }); 29 30 $("body").append(element); 31 } 32 33 var mouseOverFunction = function() { 34 var hoveredElement = $(this); 35 if(condition && typeof(condition) == typeof(Function) && !condition(hoveredElement)) { 36 self.hideTooltip(); 37 return; 38 } 39 40 var tinyTipsContainer = $("div.tinyTip"); 41 if(tinyTipsContainer.find('.content').html() == text && tinyTipsContainer.is(':visible')) { 42 //Do nothing if the tooltip is already visible 43 return; 44 } 45 46 var contentHtml = null; 47 if (text === "title") { 48 contentHtml = hoveredElement.attr("title"); 49 } else { 50 contentHtml = text; 51 } 52 53 if (contentHtml == null || contentHtml == "") { 54 self.hideTooltip(); 55 return; 56 } 57 58 $(".tinyTip .content").html(contentHtml); 59 60 if(hoveredElement.hasClass('highlightTinyTip')) { 61 self.highlightTooltip(true); 62 } else { 63 self.highlightTooltip(false); 64 } 65 66 title = hoveredElement.attr("title"); 67 hoveredElement.attr("title", ""); 68 69 var offset = hoveredElement.offset(); 70 var tinyTipsContainerPos = hoveredElement.offset(); 71 tinyTipsContainerPos.top = offset.top - tinyTipsContainer.height(); 72 tinyTipsContainerPos.left = offset.left - tinyTipsContainer.width() / 2 + 10; 73 74 var minLeftOffset = 100; 75 tinyTipsContainerPos.left = Math.max(tinyTipsContainerPos.left, minLeftOffset); 76 tinyTipsContainerPos.left = Math.min(tinyTipsContainerPos.left, $(window).width() - minLeftOffset * 2); 77 78 tinyTipsContainer.css({ 79 "display": "none", 80 "position": "absolute", 81 "z-index": "10000", 82 "left": tinyTipsContainerPos.left + "px", 83 "top": tinyTipsContainerPos.top + "px" 84 }); 85 86 tinyTipsContainer.fadeIn(tinyTipsOptions.delayFadeIn); 87 }; 88 89 var mouseOutFunction = function() { 90 var hoveredElement = $(this); 91 hoveredElement.attr("title", title); 92 93 $("div.tinyTip").fadeOut(tinyTipsOptions.delayFadeOut); 94 }; 95 96 this.showTooltip = function() { 97 var hoveredElement = $(this); 98 hoveredElement.trigger("mouseenter"); 99 }; 100 101 this.hideTooltip = function() { 102 var hoveredElement = $(this); 103 hoveredElement.trigger("mouseleave"); 104 }; 105 106 this.showTooltipWithTimeout = function() { 107 var self = this; 108 109 $(self).addClass('highlightTinyTip'); 110 self.showTooltip(); 111 112 setInterval(function() { 113 self.hideTooltip(); 114 }, tinyTipsOptions.tooltipTimeout); 115 }; 116 117 this.highlightTooltip = function(highlight) { 118 var tinyTipsContent = $(".tinyTip .content"); 119 120 if(highlight) { 121 tinyTipsContent.css({ 122 'font-weight' : 'bold', 123 'background-color' : '#c1eb59' 124 }); 125 } else { 126 tinyTipsContent.css({ 127 'font-weight' : 'normal', 128 'background-color' : '#ffffff' 129 }); 130 } 131 }; 132 133 $(this).unbind('mouseenter mouseleave'); 134 $(this).hover(mouseOverFunction, mouseOutFunction); 135 136 return this; 137 }; 138})(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.