-
Notifications
You must be signed in to change notification settings - Fork 62
/
appclass.js
59 lines (53 loc) · 1.42 KB
/
appclass.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
F2.Apps['com_openf2_examples_javascript_helloworld'] = (function () {
var App_Class = function (appConfig, appContent, root) {
this.appConfig = appConfig;
this.appContent = appContent;
this.$root = $(root);
};
App_Class.prototype.init = function () {
this.$root
.on(
'click',
'a.testAlert',
$.proxy(function () {
alert('Hello World!');
F2.log('callback fired!');
}, this)
)
.on(
'click',
'a.testConfirm',
$.proxy(function () {
let r = confirm('Hello World!');
if (r == true) {
F2.log('ok callback fired!');
} else {
F2.log('cancel callback fired!');
}
}, this)
);
// bind symbol change event
F2.Events.on(
F2.Constants.Events.CONTAINER_SYMBOL_CHANGE,
$.proxy(this._handleSymbolChange, this)
);
};
App_Class.prototype._handleSymbolChange = function (data) {
var symbolAlert = $('div.symbolAlert', this.$root);
symbolAlert = symbolAlert.length ? symbolAlert : this._renderSymbolAlert();
$('span:first', symbolAlert).text(
'The symbol has been changed to ' + data.symbol
);
};
App_Class.prototype._renderSymbolAlert = function () {
return $(
[
'<div class="alert alert-success symbolAlert">',
'<button type="button" class="close" data-dismiss="alert">×</button>',
'<span></span>',
'</div>'
].join('')
).prependTo($('.' + F2.Constants.Css.APP_CONTAINER, this.$root));
};
return App_Class;
})();