forked from noirbizarre/ezwall-plugin
/
router.js
79 lines (65 loc) · 1.59 KB
/
router.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
define([
'backbone',
'views/menu',
'views/settings',
'views/dashboard',
'views/about',
'models/jenkins'
], function(Backbone, Menu, Settings, Dashboard, About, Jenkins){
var AppRouter = Backbone.Router.extend({
routes : {
'settings' : 'showSettings',
'about' : 'showAbout',
// Default
'' : 'showHome'
},
initialize : function() {
console.log('AppRouter: initiliaze');
// Initialize menu
this.menu = new Menu;
this.menu.render();
this.menu.on('menu:refresh', function() {
this.view.fetch();
}, this);
this.menu.on('menu:settings', function() {
this.navigate('settings', true);
}, this);
this.menu.on('menu:about', function() {
this.navigate('about', true);
}, this);
// Inialize the jenkins View
this.view = new Jenkins.View();
// Initialize Dashboard
this.dashboard = new Dashboard.View({
model : this.view
});
this.dashboard.render();
// Bootstrap ezWall config
Jenkins.config.set('url', '.');
Jenkins.config.fetch();
console.log('AppRouter: initiliazed');
},
showHome : function() {
console.log('AppRouter: home');
},
showSettings : function() {
console.log('AppRouter: settings');
var popup = new Settings.Popup({
model : Jenkins.config
});
popup.render();
popup.on(Settings.CLOSE, function() {
this.navigate('', true);
}, this);
},
showAbout : function() {
console.log('AppRouter: about');
var popup = new About.Popup;
popup.render();
popup.on(About.CLOSE, function() {
this.navigate('', true);
}, this);
}
});
return new AppRouter();
});