|
31 | 31 | width : 200,
|
32 | 32 | maxWidth : '',
|
33 | 33 | delay : 200,
|
| 34 | + hideDelay : 0, |
34 | 35 | animationIn : '',
|
35 | 36 | animationOut : '',
|
36 | 37 | offsetX : 0,
|
|
108 | 109 | $e = this.element,
|
109 | 110 | $doc = this.doc;
|
110 | 111 | $e.addClass('tipso_style').removeAttr('title');
|
111 |
| - if (isTouchSupported()) { |
112 |
| - $e.on('click' + '.' + pluginName, function(e) { |
113 |
| - obj.mode === 'hide' ? obj.show() : obj.hide(); |
114 |
| - e.stopPropagation(); |
| 112 | + |
| 113 | + if (obj.settings.tooltipHover) { |
| 114 | + var waitForHover = null, |
| 115 | + hoverHelper = null; |
| 116 | + $e.on('mouseover' + '.' + pluginName, function() { |
| 117 | + clearTimeout(waitForHover); |
| 118 | + clearTimeout(hoverHelper); |
| 119 | + hoverHelper = setTimeout(function(){ |
| 120 | + obj.show(); |
| 121 | + }, 150); |
115 | 122 | });
|
116 |
| - $doc.on('click', function closeTipso () { |
117 |
| - if (obj.mode === 'show') { |
| 123 | + $e.on('mouseout' + '.' + pluginName, function() { |
| 124 | + clearTimeout(waitForHover); |
| 125 | + clearTimeout(hoverHelper); |
| 126 | + waitForHover = setTimeout(function(){ |
118 | 127 | obj.hide();
|
119 |
| - } |
| 128 | + }, 200); |
| 129 | + |
| 130 | + obj.tooltip() |
| 131 | + .on('mouseover' + '.' + pluginName, function() { |
| 132 | + obj.mode = 'tooltipHover'; |
| 133 | + }) |
| 134 | + .on('mouseout' + '.' + pluginName, function() { |
| 135 | + obj.mode = 'show'; |
| 136 | + clearTimeout(waitForHover); |
| 137 | + waitForHover = setTimeout(function(){ |
| 138 | + obj.hide(); |
| 139 | + }, 200); |
| 140 | + }) |
| 141 | + ; |
120 | 142 | });
|
121 | 143 | } else {
|
122 |
| - if (obj.settings.tooltipHover) { |
123 |
| - var waitForHover = null, |
124 |
| - hoverHelper = null; |
125 |
| - $e.on('mouseover' + '.' + pluginName, function() { |
126 |
| - clearTimeout(waitForHover); |
127 |
| - clearTimeout(hoverHelper); |
128 |
| - hoverHelper = setTimeout(function(){ |
129 |
| - obj.show(); |
130 |
| - }, 150); |
131 |
| - }); |
132 |
| - $e.on('mouseout' + '.' + pluginName, function() { |
133 |
| - clearTimeout(waitForHover); |
134 |
| - clearTimeout(hoverHelper); |
135 |
| - waitForHover = setTimeout(function(){ |
136 |
| - obj.hide(); |
137 |
| - }, 200); |
138 |
| - |
139 |
| - obj.tooltip() |
140 |
| - .on('mouseover' + '.' + pluginName, function() { |
141 |
| - obj.mode = 'tooltipHover'; |
142 |
| - }) |
143 |
| - .on('mouseout' + '.' + pluginName, function() { |
144 |
| - obj.mode = 'show'; |
145 |
| - clearTimeout(waitForHover); |
146 |
| - waitForHover = setTimeout(function(){ |
147 |
| - obj.hide(); |
148 |
| - }, 200); |
149 |
| - }) |
150 |
| - ; |
151 |
| - }); |
152 |
| - } else { |
153 |
| - $e.on('mouseover' + '.' + pluginName, function() { |
154 |
| - obj.show(); |
155 |
| - }); |
156 |
| - $e.on('mouseout' + '.' + pluginName, function() { |
157 |
| - obj.hide(); |
158 |
| - }); |
159 |
| - } |
| 144 | + $e.on('mouseover' + '.' + pluginName, function() { |
| 145 | + obj.show(); |
| 146 | + }); |
| 147 | + $e.on('mouseout' + '.' + pluginName, function() { |
| 148 | + obj.hide(); |
| 149 | + }); |
160 | 150 | }
|
161 | 151 | },
|
162 | 152 | tooltip: function() {
|
|
212 | 202 | tipso_bubble.find('.tipso_content').html(obj.content());
|
213 | 203 | tipso_bubble.find('.tipso_title').html(obj.titleContent());
|
214 | 204 | reposition(obj);
|
215 |
| - $win.resize(function tipsoResizeHandler () { |
| 205 | + |
| 206 | + $win.on('resize' + '.' + pluginName, function tipsoResizeHandler () { |
216 | 207 | obj.settings.position = obj.settings.preferedPosition;
|
217 | 208 | reposition(obj);
|
218 | 209 | });
|
219 | 210 |
|
| 211 | + window.clearTimeout(obj.timeout); |
| 212 | + obj.timeout = null; |
220 | 213 | obj.timeout = window.setTimeout(function() {
|
221 | 214 | if (obj.ieFade || obj.settings.animationIn === '' || obj.settings.animationOut === ''){
|
222 | 215 | tipso_bubble.appendTo('body').stop(true, true).fadeIn(obj.settings
|
|
240 | 233 | if ($.isFunction(obj.settings.onShow)) {
|
241 | 234 | obj.settings.onShow(this.element, this);
|
242 | 235 | }
|
243 |
| - $win.off('resize', null, 'tipsoResizeHandler'); |
| 236 | + $win.off('resize' + '.' + pluginName, null, 'tipsoResizeHandler'); |
244 | 237 | });
|
245 | 238 | }
|
246 | 239 | }, obj.settings.delay);
|
|
253 | 246 |
|
254 | 247 | window.clearTimeout(obj.timeout);
|
255 | 248 | obj.timeout = null;
|
256 |
| - if (obj.mode !== 'tooltipHover') { |
257 |
| - if (obj.ieFade || obj.settings.animationIn === '' || obj.settings.animationOut === ''){ |
258 |
| - tipso_bubble.stop(true, true).fadeOut(obj.settings.speed, |
259 |
| - function() { |
260 |
| - $(this).remove(); |
261 |
| - if ($.isFunction(obj.settings.onHide) && obj.mode === 'show') { |
262 |
| - obj.settings.onHide(this.element, this); |
263 |
| - } |
264 |
| - obj.mode = 'hide'; |
265 |
| - $win.off('resize', null, 'tipsoResizeHandler'); |
266 |
| - }); |
267 |
| - } else { |
268 |
| - tipso_bubble.stop(true, true) |
269 |
| - .removeClass('animated ' + obj.settings.animationIn) |
270 |
| - .addClass('noAnimation').removeClass('noAnimation') |
271 |
| - .addClass('animated ' + obj.settings.animationOut) |
272 |
| - .one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function(){ |
273 |
| - $(this).removeClass('animated ' + obj.settings.animationOut).remove(); |
274 |
| - if ($.isFunction(obj.settings.onHide) && obj.mode === 'show') { |
275 |
| - obj.settings.onHide(this.element, this); |
276 |
| - } |
277 |
| - obj.mode = 'hide'; |
278 |
| - $win.off('resize', null, 'tipsoResizeHandler'); |
279 |
| - }); |
| 249 | + obj.timeout = window.setTimeout(function() { |
| 250 | + if (obj.mode !== 'tooltipHover') { |
| 251 | + if (obj.ieFade || obj.settings.animationIn === '' || obj.settings.animationOut === ''){ |
| 252 | + tipso_bubble.stop(true, true).fadeOut(obj.settings.speed, |
| 253 | + function() { |
| 254 | + $(this).remove(); |
| 255 | + if ($.isFunction(obj.settings.onHide) && obj.mode === 'show') { |
| 256 | + obj.settings.onHide(this.element, this); |
| 257 | + } |
| 258 | + obj.mode = 'hide'; |
| 259 | + $win.off('resize' + '.' + pluginName, null, 'tipsoResizeHandler'); |
| 260 | + }); |
| 261 | + } else { |
| 262 | + tipso_bubble.stop(true, true) |
| 263 | + .removeClass('animated ' + obj.settings.animationIn) |
| 264 | + .addClass('noAnimation').removeClass('noAnimation') |
| 265 | + .addClass('animated ' + obj.settings.animationOut) |
| 266 | + .one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function(){ |
| 267 | + $(this).removeClass('animated ' + obj.settings.animationOut).remove(); |
| 268 | + if ($.isFunction(obj.settings.onHide) && obj.mode === 'show') { |
| 269 | + obj.settings.onHide(this.element, this); |
| 270 | + } |
| 271 | + obj.mode = 'hide'; |
| 272 | + $win.off('resize' + '.' + pluginName, null, 'tipsoResizeHandler'); |
| 273 | + }); |
| 274 | + } |
280 | 275 | }
|
281 |
| - } |
| 276 | + }, obj.settings.hideDelay); |
282 | 277 | },
|
283 | 278 | destroy: function() {
|
284 | 279 | var $e = this.element,
|
285 | 280 | $win = this.win,
|
286 | 281 | $doc = this.doc;
|
287 | 282 | $e.off('.' + pluginName);
|
288 |
| - $win.off('resize', null, 'tipsoResizeHandler'); |
289 |
| - if (isTouchSupported()) { |
290 |
| - $doc.off('click', null, 'closeTipso' ); |
291 |
| - } |
| 283 | + $win.off('resize' + '.' + pluginName, null, 'tipsoResizeHandler'); |
292 | 284 | $e.removeData(pluginName);
|
293 | 285 | $e.removeClass('tipso_style').attr('title', this._title);
|
294 | 286 | },
|
|
358 | 350 | }
|
359 | 351 | });
|
360 | 352 |
|
361 |
| - function isTouchSupported() { |
362 |
| - var msTouchEnabled = window.navigator.msMaxTouchPoints; |
363 |
| - var generalTouchEnabled = "ontouchstart" in document.createElement( |
364 |
| - "div"); |
365 |
| - if (msTouchEnabled || generalTouchEnabled) { |
366 |
| - return true; |
367 |
| - } |
368 |
| - return false; |
369 |
| - } |
370 |
| - |
371 | 353 | function realHeight(obj) {
|
372 | 354 | var clone = obj.clone();
|
373 | 355 | clone.css("visibility", "hidden");
|
|
0 commit comments