1$.fn.tooltip = function(options) 2{ 3 var defaults = { 4 speed: 200, 5 delay: 300, 6 attr : false 7 }; 8 9 var opt = $.extend(defaults, options); 10 var _tooltip = this; 11 12 _tooltip.getTip = function() { 13 return '<div class="tooltip black"></div>'; 14 } 15 16 if ($('body').find('.tooltip').length <= 0) 17 $("body").append(_tooltip.getTip()); 18 19 var tip = $('.tooltip'); 20 21 _tooltip.set_timer = function(that) 22 { 23 that.sho_tooltip_timer = setInterval("_tooltip.show_tooltip()", defaults.delay); 24 } 25 26 _tooltip.stop_timer = function(that) 27 { 28 clearInterval(that.sho_tooltip_timer); 29 } 30 31 _tooltip.set_position = function(that) 32 { 33 var _element_position = $(that).offset(); 34 if (_tooltip.autoNS(that) == 'n') 35 { 36 tip.addClass('top').css({ 37 top: _element_position.top - (tip.innerHeight() + 5), 38 left: _element_position.left + (that.innerWidth() / 2) - (tip.innerWidth() / 2) 39 }) 40 } 41 else 42 { 43 tip.addClass('bottom').css({ 44 top: _element_position.top + that.innerHeight() + 5 , 45 left: _element_position.left + (that.innerWidth() / 2) - (tip.innerWidth() / 2) 46 }) 47 } 48 } 49 50 _tooltip.autoNS = function(that) 51 { 52 return $(that).offset().top > ($(document).scrollTop() + $(window).height() / 2) ? 'n' : 's' 53 } 54 55 _tooltip.update = function(that) 56 { 57 var tooltip_content = ($(that).attr('tooltip') || $(that).attr('ititle')); 58 if (opt.attr) 59 { 60 var tooltip_content = $(that).attr(opt.attr); 61 } 62 63 if (tooltip_content == undefined) 64 { 65 _tooltip.destroy(); 66 tooltip_content = ''; 67 } 68 else 69 { 70 tip.html('<span>'+tooltip_content+'</span>'); 71 _tooltip.set_position(that); 72 tip.removeClass('hide') 73 } 74 75 return tooltip_content; 76 } 77 78 _tooltip.destroy = function(that) 79 { 80 $(that).off('mouseover mouseleave'); 81 tip.empty().addClass('hide') 82 } 83 84 _tooltip.show_tooltip = function() 85 { 86 tip.removeClass('hide').addClass('show') 87 } 88 89 if (typeof options == 'undefined' || typeof options == 'object') 90 { 91 return _tooltip.each(function() 92 { 93 94 var _this = $(this); 95 96 97 if (opt.attr) 98 { 99 _this.attr('tooltip', function() { 100 return $(this).attr(opt.attr); 101 }).removeAttr(opt.attr) 102 } 103 104 var tooltip_content = (_this.attr('tooltip') || _this.attr('ititle')); 105 106 _this.on('mouseover',function() { 107 if (tooltip_content != '' && tooltip_content != undefined) 108 { 109 tip.html('<span>'+tooltip_content+'</span>'); 110 _tooltip.set_position(_this); 111 _tooltip.show_tooltip(); 112 } 113 114 }) 115 116 _this.on('mouseleave',function() { 117 tip.removeClass('show top bottom') 118 }); 119 120 _this.on('update_tooltip',function() { 121 122 tooltip_content = _tooltip.update(_this); 123 }); 124 125 _this.on('destroy_tooltip',function() { 126 _tooltip.update(_this); 127 }); 128 }); 129 } 130 else 131 { 132 switch (options) 133 { 134 case 'update': 135 _tooltip.trigger('update_tooltip') 136 break; 137 138 case 'destroy': 139 break; 140 } 141 } 142}; 143 144 145
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.