-
Notifications
You must be signed in to change notification settings - Fork 9
/
tools.tooltip.slide.js
82 lines (68 loc) · 1.96 KB
/
tools.tooltip.slide.js
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/**
* tools.tooltip "Slide Effect" 1.0.0
*
* Copyright (c) 2009 Tero Piirainen
* http://flowplayer.org/tools/tooltip.html#slide
*
* Dual licensed under MIT and GPL 2+ licenses
* http://www.opensource.org/licenses
*
* Since : September 2009
* Date: ${date}
* Revision: ${revision}
*/
(function($) {
// version number
var t = $.tools.tooltip;
t.effects = t.effects || {};
t.effects.slide = {version: '1.0.0'};
// extend global configuragion with effect specific defaults
$.extend(t.conf, {
direction: 'up', // down, left, right
bounce: false,
slideOffset: 10,
slideInSpeed: 200,
slideOutSpeed: 200,
slideFade: !$.browser.msie
});
// directions for slide effect
var dirs = {
up: ['-', 'top'],
down: ['+', 'top'],
left: ['-', 'left'],
right: ['+', 'left']
};
/* default effect: "slide" */
$.tools.tooltip.addEffect("slide",
// show effect
function(done) {
// variables
var conf = this.getConf(),
tip = this.getTip(),
params = conf.slideFade ? {opacity: conf.opacity} : {},
dir = dirs[conf.direction] || dirs.up;
// direction
params[dir[1]] = dir[0] +'='+ conf.slideOffset;
// perform animation
if (conf.slideFade) { tip.css({opacity:0}); }
tip.show().animate(params, conf.slideInSpeed, done);
},
// hide effect
function(done) {
// variables
var conf = this.getConf(),
offset = conf.slideOffset,
params = conf.slideFade ? {opacity: 0} : {},
dir = dirs[conf.direction] || dirs.up;
// direction
var sign = "" + dir[0];
if (conf.bounce) { sign = sign == '+' ? '-' : '+'; }
params[dir[1]] = sign +'='+ offset;
// perform animation
this.getTip().animate(params, conf.slideOutSpeed, function() {
$(this).hide();
done.call();
});
}
);
})(jQuery);