-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathui.alert.js
More file actions
62 lines (50 loc) · 1.28 KB
/
ui.alert.js
File metadata and controls
62 lines (50 loc) · 1.28 KB
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
/*
用于继承的类,会自动垂直居中
*/
define(['UILayer', getViewTemplatePath('ui/ui.alert')], function (UILayer, template) {
return _.inherit(UILayer, {
propertys: function ($super) {
$super();
//数据模型
this.datamodel = {
title: 'alert',
content: 'content',
btns: [
{ name: 'cancel', className: 'pop-box-btns-cancel' },
{ name: 'ok', className: 'pop-box-btns-ok' }
]
};
//html模板
this.template = template;
//事件机制
this.events = {
'click .pop-box-btns-ok': 'okAction',
'click .pop-box-btns-cancel': 'cancelAction'
};
},
initialize: function ($super, opts) {
$super(opts);
},
addEvent: function ($super) {
$super();
this.on('onCreate', function () {
this.$el.addClass('ct-ui-alert');
});
this.maskToHide = false;
},
okAction: function () {
this.hide();
},
cancelAction: function () {
this.hide();
},
setDatamodel: function (datamodel, okAction, cancelAction) {
if (!datamodel) datamodel = {};
_.extend(this.datamodel, datamodel);
this.okAction = okAction;
this.cancelAction = cancelAction;
this.refresh();
}
});
});