|
100 | 100 | left = conf.relative ? trigger.position().left : trigger.offset().left, |
101 | 101 | pos = conf.position[0]; |
102 | 102 |
|
103 | | - top -= tip.outerHeight() - conf.offset[0]; |
104 | | - left += trigger.outerWidth() + conf.offset[1]; |
| 103 | + top -= tip.outerHeight(false) - conf.offset[0]; |
| 104 | + left += trigger.outerWidth(false) + conf.offset[1]; |
105 | 105 |
|
106 | 106 | // iPad position fix |
107 | 107 | if (/iPad/i.test(navigator.userAgent)) { |
108 | 108 | top -= $(window).scrollTop(); |
109 | 109 | } |
110 | 110 |
|
111 | 111 | // adjust Y |
112 | | - var height = tip.outerHeight() + trigger.outerHeight(); |
| 112 | + var height = tip.outerHeight(false) + trigger.outerHeight(false); |
113 | 113 | if (pos == 'center') { top += height / 2; } |
114 | 114 | if (pos == 'bottom') { top += height; } |
115 | 115 |
|
116 | 116 |
|
117 | 117 | // adjust X |
118 | 118 | pos = conf.position[1]; |
119 | | - var width = tip.outerWidth() + trigger.outerWidth(); |
| 119 | + var width = tip.outerWidth(false) + trigger.outerWidth(false); |
120 | 120 | if (pos == 'center') { left -= width / 2; } |
121 | 121 | if (pos == 'left') { left -= width; } |
122 | 122 |
|
|
203 | 203 |
|
204 | 204 | // manual tooltip |
205 | 205 | } else { |
206 | | - tip = trigger.next(); |
| 206 | + tip = trigger.find('.' + conf.tipClass); |
| 207 | + if (!tip.length) { tip = trigger.next(); } |
207 | 208 | if (!tip.length) { tip = trigger.parent().next(); } |
208 | 209 | } |
209 | 210 |
|
|
331 | 332 |
|
332 | 333 | // jQuery plugin implementation |
333 | 334 | $.fn.tooltip = function(conf) { |
334 | | - |
335 | | - // return existing instance |
336 | | - var api = this.data("tooltip"); |
337 | | - if (api) { return api; } |
338 | 335 |
|
339 | 336 | conf = $.extend(true, {}, $.tools.tooltip.conf, conf); |
340 | 337 |
|
|
344 | 341 | } |
345 | 342 |
|
346 | 343 | // install tooltip for each entry in jQuery object |
| 344 | + // that is not an existing instance |
347 | 345 | this.each(function() { |
348 | | - api = new Tooltip($(this), conf); |
349 | | - $(this).data("tooltip", api); |
| 346 | + if ( $(this).data("tooltip")===null){ |
| 347 | + api = new Tooltip($(this), conf); |
| 348 | + $(this).data("tooltip", api); |
| 349 | + }; |
350 | 350 | }); |
351 | 351 |
|
352 | 352 | return conf.api ? api: this; |
|
0 commit comments