-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpopover.js
58 lines (50 loc) · 1.48 KB
/
popover.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
define(['overlay',
'tip',
'class'],
function(Overlay, Tip, clazz) {
function Popover(el, options) {
options = options || {};
options.className = options.className || 'popover';
Popover.super_.call(this, el, options);
var self = this
, el = this.el;
el.find('.close').on('click', function(){
self.emit('close');
self.hide(0, true);
return false;
});
}
clazz.inherits(Popover, Tip);
Popover.prototype.overlay = function(options) {
options = options || {};
options.autoRemove = this._autoRemove;
var self = this
, template = options.template || 'overlay';
this._overlay = new Overlay(template, options);
this._overlay.on('hide', function() {
if (self._autoRemove) self._overlay = null;
self.hide();
return true;
});
return this;
};
Popover.prototype.show = function(el) {
if (this._overlay) this._overlay.show();
Popover.super_.prototype.show.call(this, el);
}
Popover.prototype.hide = function(ms, btn) {
if (btn) {
if (this._overlay) this._overlay.hide();
}
Popover.super_.prototype.hide.call(this, ms);
}
Popover.prototype.remove = function() {
if (this._overlay) this._overlay.remove();
return Popover.super_.prototype.remove.call(this);
};
Popover.prototype.dispose = function() {
if (this._overlay) this._overlay.dispose();
return Popover.super_.prototype.dispose.call(this);
};
return Popover;
});