forked from ethereum/meteor-package-elements
-
Notifications
You must be signed in to change notification settings - Fork 0
/
modalQuestion.js
95 lines (77 loc) · 2.09 KB
/
modalQuestion.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/**
Template Controllers
@module Templates
*/
/**
The modal question template. It can receive an ok and cancel function,
which will be execited if the ok or cancel button is pressed.
After any of the buttons is pressed the modal, will disappear.
The data context for this modal should look as follows:
{
text: 'Do you really want to do this?',
ok: function(){
// do something on ok
},
cancel: function(){
// do something on cancel
}
}
@class [template] dapp_modal_question
@constructor
*/
Template["dapp_modal_question"].helpers({
/**
Check if the `ok` property is present, without executing it yet.
@method (hasOk)
*/
hasOk: function() {
return this.ok;
},
/**
Check if the `cancel` property is present, without executing it yet.
@method (hasCancel)
*/
hasCancel: function() {
return this.cancel;
},
/**
Returns text for OK button. Can be either an argument, a i18n default text or a default value.
@method (okButtonText)
*/
okButtonText: function() {
return this.modalQuestionOkButtonText || TAPi18n.__("buttons.ok") || "OK";
},
/**
Returns text for Cancel button. Can be either an argument, a i18n default text or a default value.
@method (cancelButtonText)
*/
cancelButtonText: function() {
return (
this.modalQuestionCancelButtonText ||
TAPi18n.__("buttons.cancel") ||
"Cancel"
);
}
});
Template["dapp_modal_question"].events({
/**
When the confirm button is clicked, execute the given ok() function.
@event click .dapp-modal-buttons button.ok
*/
"click .dapp-modal-buttons button.ok": function(e) {
// hide the modal
EthElements.Modal.hide();
if (_.isFunction(this.ok)) {
this.ok();
}
},
/**
When the confirm button is clicked, execute the given cancel() function.
@event click .dapp-modal-buttons button.cancel
*/
"click .dapp-modal-buttons button.cancel": function(e) {
// hide the modal
EthElements.Modal.hide();
if (_.isFunction(this.cancel)) this.cancel();
}
});