-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbootstrap-betterTooltip.js
More file actions
49 lines (45 loc) · 1.57 KB
/
Copy pathbootstrap-betterTooltip.js
File metadata and controls
49 lines (45 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/**
* Created by frank on 11/16/13.
*/
(function($) {
var mouseEnterTimer;
var mouseLeaveTimer;
var isFirstHover = true;
function betterTooltip(option) {
var _trigger;
var _show;
option = option || {};
_trigger = option.trigger || 'hover';
_show = (option.delay && option.delay.show) || 0;
if (_trigger === 'hover') {
option.trigger = 'manual';
if (_show) option.delay.show = 0;
return this.tooltip(option)
.mouseenter(function(e) {
var that = this;
window.clearTimeout(mouseLeaveTimer);
if (!isFirstHover) {
$(this).tooltip('show');
} else {
mouseEnterTimer = window.setTimeout(function() {
if (mouseEnterTimer) {
isFirstHover = false;
$(that).tooltip('show');
}
}, _show);
}
}).mouseleave(function(e) {
$(this).tooltip('hide');
window.clearTimeout(mouseEnterTimer);
mouseLeaveTimer = window.setTimeout(function() {
if (mouseLeaveTimer) {
isFirstHover = true;
}
}, 200);
});
} else {
return this.tooltip(option);
}
}
$.fn.betterTooltip = betterTooltip;
})(jQuery);