-
Notifications
You must be signed in to change notification settings - Fork 22
/
app.js
80 lines (69 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
Ext.require('Ext.ux.app.RoutedApplication', function () {
App = Ext.create('Ext.ux.app.RoutedApplication', {
appFolder:'app',
name:'App',
controllers:[
'Base',
'Login',
'Dashboard',
'Base',
'Albums',
'Artists',
'Songs'
],
requires:[
'App.view.Viewport',
'App.view.FormWindow'
],
launch:function () {
var me = this;
// create Viewport instance
var viewport = Ext.create('App.view.Viewport', {
controller:this
});
// Get a reference to main TabPanel. This is where top-level controllers will render themselves.
// eg: this.render("workspace", this.getArtistsIndexView());
// Think of it as a "render target".
var workspace = viewport.down('container[region=center]');
this.addLayout('workspace', workspace);
// Create Window instance for rendering popup forms upon. Controllers could render a form upon this shared
// window instance via:
// this.render("window", this.getAlbumsCreateView());
var popup = Ext.create('App.view.FormWindow', {});
this.addLayout('window', popup);
Ext.defer(this.hideLoadingScreen, 250);
Ext.History.init(me.initDispatch, me);
Ext.History.on('change', me.historyChange, me);
// Start with dashboard
token = Ext.History.getToken();
if (token == null) {
Ext.History.add('dashboard', true);
// Ext.dispatch('dashboard');
}
},
initDispatch:function () {
var me = this,
token = Ext.History.getToken();
Ext.log('Init dispatch with token: ' + token);
me.historyChange(token);
},
historyChange:function (token) {
var me = this;
// and check if token is set
Ext.log('History changed to: ' + token);
if (token) {
Ext.dispatch(token);
// var route = Ext.Router.recognize(token);
// //me.dispatch(route);
// console.log(route);
}
},
hideLoadingScreen:function() {
Ext.get('loading').remove();
Ext.fly('loading-mask').animate({
opacity:0,
remove:true
});
}
})
});