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
/*tooltip 类*/
UM.ui.define('tooltip', {
tpl: '<div class="edui-tooltip" unselectable="on" onmousedown="return false">' +
'<div class="edui-tooltip-arrow" unselectable="on" onmousedown="return false"></div>' +
'<div class="edui-tooltip-inner" unselectable="on" onmousedown="return false"></div>' +
'</div>',
init: function (options) {
var me = this;
me.root($(UM.utils.render(me.tpl, options || {})));
},
content: function (e) {
var me = this,
title = $(e.currentTarget).attr("data-original-title");
me.root().find('.edui-tooltip-inner')['text'](title);
},
position: function (e) {
var me = this,
$obj = $(e.currentTarget);
me.root().css($.extend({display: 'block'}, $obj ? {
top: $obj.outerHeight(),
left: (($obj.outerWidth() - me.root().outerWidth()) / 2)
} : {}))
},
show: function (e) {
if ($(e.currentTarget).hasClass('edui-disabled')) return;
var me = this;
me.content(e);
me.root().appendTo($(e.currentTarget));
me.position(e);
me.root().css('display', 'block');
},
hide: function () {
var me = this;
me.root().css('display', 'none')
},
attachTo: function ($obj) {
var me = this;
function tmp($obj) {
var me = this;
if (!$.contains(document.body, me.root()[0])) {
me.root().appendTo($obj);
}
me.data('tooltip', me.root());
$obj.each(function () {
if ($(this).attr("data-original-title")) {
$(this).on('mouseenter', $.proxy(me.show, me))
.on('mouseleave click', $.proxy(me.hide, me))
}
});
}
if ($.type($obj) === "undefined") {
$("[data-original-title]").each(function (i, el) {
tmp.call(me, $(el));
})
} else {
if (!$obj.data('tooltip')) {
tmp.call(me, $obj);
}
}
}
});