forked from urueedi/monster-ui-phonebook
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
61 lines (61 loc) · 2.43 KB
/
app.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
define(["require", "jquery", "underscore", "monster"], function(e) {
var $ = e("jquery"),
_ = e("underscore"),
monster = e("monster"),
app = {
name: "phonebook",
css: ["app"],
i18n: {
"en-US": {customCss: !1},
"fr-FR": {customCss: !1},
"ro-RO": {customCss: !1},
"nl-NL": {customCss: !1},
"it-IT": {customCss: !1},
"de-DE": {customCss: !1},
"dk-DK": {customCss: !1},
"es-ES": {customCss: !1},
"pt-PT": {customCss: !1},
"ru-RU": {customCss: !1},
"zh-CN": {customCss: !1}
},
requests: {},
subscribe: {},
subModules: ["phonebook", "speeddial", "blacklist"],
load: function(callback) {
var self = this;
self.initApp(function() {
callback && callback(self)
})
},
initApp: function(callback) {
var self = this;
monster.pub("auth.initApp", {
app: self,
callback: callback
})
},
render: function(callback) {
var self = this,
content = callback || $("#monster-content"),
template = $(monster.template(self, "app"));
// accountid switch urs
_.accountId = monster.apps.auth.accountId;
template.find(".category#phonebook").addClass("active"), monster.pub("phonebook.phonebook.render", {
parent: template.find(".right-content")
}), self.bindEvents(template), content.empty().append(template)
},
bindEvents: function(callback) {
var self = this,
content = callback.find(".right-content");
callback.find(".category").on("click", function() {
var self = $(this),
option = {
parent: content
},
attribut = self.attr("id");
callback.find(".category").removeClass("active"), self.toggleClass("active"), content.empty(), monster.pub("phonebook." + attribut + ".render", option)
})
}
};
return app
});