forked from 2600hz/monster-ui-voip
-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.js
102 lines (82 loc) · 2.25 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
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
96
97
98
99
100
101
102
define(function(require){
var $ = require('jquery'),
_ = require('underscore'),
monster = require('monster');
require([
'./submodules/devices/devices',
'./submodules/groups/groups',
'./submodules/numbers/numbers',
'./submodules/strategy/strategy',
'./submodules/callLogs/callLogs',
'./submodules/users/users',
'./submodules/myOffice/myOffice',
'./submodules/featureCodes/featureCodes',
'./submodules/vmboxes/vmboxes'
]);
var app = {
name: 'voip',
css: [ 'app' ],
i18n: {
'en-US': { customCss: false },
'fr-FR': { customCss: false },
'ru-RU': { customCss: false },
'es-ES': { customCss: false }
},
requests: {},
subscribe: {},
subModules: ['devices', 'groups', 'numbers', 'strategy', 'callLogs', 'users', 'myOffice', 'featureCodes', 'vmboxes'],
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(container){
var self = this,
parent = container || $('#monster-content'),
template = $(monster.template(self, 'app'));
/* On first Load, load my office */
template.find('.category#myOffice').addClass('active');
monster.pub('voip.myOffice.render', { parent: template.find('.right-content') });
self.bindEvents(template);
parent
.empty()
.append(template);
},
formatData: function(data) {
var self = this;
},
bindEvents: function(parent) {
var self = this,
container = parent.find('.right-content');
parent.find('.left-menu').on('click', '.category:not(.loading)', function() {
// Get the ID of the submodule to render
var $this = $(this),
args = {
parent: container,
callback: function() {
parent.find('.category').removeClass('loading');
}
},
id = $this.attr('id');
// Display the category we clicked as active
parent
.find('.category')
.removeClass('active')
.addClass('loading');
$this.toggleClass('active');
// Empty the main container and then render the submodule content
container.empty();
monster.pub('voip.' + id + '.render', args);
});
}
};
return app;
});