-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
51 lines (45 loc) · 1.43 KB
/
index.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
var m = require("mithril");
module.exports = {
_attrs: null,
_component: null,
show: function(component, attrs) {
this._component = component;
this._attrs = attrs;
// If there is a callback argument we wrap it in a function that will hide the popup
if (typeof this._attrs.callback === "function") {
var callback = this._attrs.callback;
this._attrs.callback = function() {
callback.apply(null, arguments);
this.hide();
}.bind(this);
}
},
hide: function() {
this._attrs = null;
this._component = null;
},
view: function(ctrl) {
if (this._component === null) {
return m("");
}
return m(".modal-container", [
m(".modal-backdrop.fade.in"),
m(".modal.fade.in[style='display: block']", {onclick: this.hide.bind(this)},
m(".modal-dialog",
m(".modal-content", {
onclick: function(e){
m.redraw.strategy("none");
e.stopPropagation();
}
}, [
m(".modal-header", [
m("button[aria-hidden='true'][data-dismiss='modal'][class='close'][type='button']", {onclick: this.hide.bind(this)}, m("span[aria-hidden=true]", "×")),
m("h4.modal-title", this._component.title ? this._component.title(this._attrs) : "")
]),
m(".modal-body", m.component(this._component, this._attrs))
])
)
)
]);
}
};