-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoverlay.js
42 lines (37 loc) · 924 Bytes
/
overlay.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
define(['view',
'class'],
function(View, clazz) {
function Overlay(el, options) {
options = options || {};
Overlay.super_.call(this, el, options);
this.closable = options.closable;
this._autoRemove = options.autoRemove !== undefined ? options.autoRemove : true;
var self = this;
if (this.closable) {
this.el.on('click', function() {
self.hide();
return false;
});
}
}
clazz.inherits(Overlay, View);
Overlay.prototype.show = function() {
this.emit('show');
this.el.appendTo(document.body);
this.el.removeClass('hide');
return this;
}
Overlay.prototype.hide = function() {
this.emit('hide');
this.el.addClass('hide');
if (this._autoRemove) {
var self = this;
setTimeout(function() {
self.remove();
self.dispose();
}, 10);
}
return this;
}
return Overlay;
});