1
|
|
|
define([ |
2
|
|
|
'oroui/js/app/controllers/base/controller', |
3
|
|
|
'oroui/js/app/views/page-view', |
4
|
|
|
'oroui/js/tools', |
5
|
|
|
'underscore', |
6
|
|
|
'module' |
7
|
|
|
], function(BaseController, PageView, tools, _, module) { |
8
|
|
|
'use strict'; |
9
|
|
|
|
10
|
|
|
var config = module.config(); |
11
|
|
|
config = _.extend({ |
12
|
|
|
showLoadingMaskOnStartup: true, |
13
|
|
|
showLoadingBarOnStartup: false |
14
|
|
|
}, config); |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* Init PageView |
18
|
|
|
*/ |
19
|
|
|
BaseController.addToReuse('page', PageView, { |
20
|
|
|
el: 'body', |
21
|
|
|
keepElement: true, |
22
|
|
|
regions: { |
23
|
|
|
mainContainer: '#container', |
24
|
|
|
mainMenu: '#main-menu', |
25
|
|
|
userMenu: '#top-page .user-menu', |
26
|
|
|
breadcrumb: '#breadcrumb', |
27
|
|
|
leftPanel: '#left-panel', |
28
|
|
|
beforeContentAddition: '#before-content-addition', |
29
|
|
|
messages: '#flash-messages .flash-messages-holder' |
30
|
|
|
} |
31
|
|
|
}); |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* Init PageContentView |
35
|
|
|
*/ |
36
|
|
|
BaseController.loadBeforeAction([ |
37
|
|
|
'oroui/js/app/views/page/content-view' |
38
|
|
|
], function(PageContentView) { |
39
|
|
|
BaseController.addToReuse('content', PageContentView, { |
40
|
|
|
el: 'region:mainContainer' |
41
|
|
|
}); |
42
|
|
|
}); |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* Init PageBeforeContentAdditionView |
46
|
|
|
*/ |
47
|
|
|
BaseController.loadBeforeAction([ |
48
|
|
|
'oroui/js/app/views/page/before-content-addition-view' |
49
|
|
|
], function(PageBeforeContentAdditionView) { |
50
|
|
|
BaseController.addToReuse('beforeContentAddition', PageBeforeContentAdditionView, { |
51
|
|
|
el: 'region:beforeContentAddition' |
52
|
|
|
}); |
53
|
|
|
}); |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* Init PageMainMenuView and BreadcrumbView |
57
|
|
|
*/ |
58
|
|
|
BaseController.loadBeforeAction([ |
59
|
|
|
'oroui/js/app/views/page/main-menu-view', |
60
|
|
|
'oroui/js/app/views/page/breadcrumb-view' |
61
|
|
|
], function(PageMainMenuView, BreadcrumbView) { |
62
|
|
|
BaseController.addToReuse('breadcrumb', BreadcrumbView, { |
63
|
|
|
el: 'region:breadcrumb' |
64
|
|
|
}); |
65
|
|
|
BaseController.addToReuse('mainMenu', PageMainMenuView, { |
66
|
|
|
el: 'region:mainMenu' |
67
|
|
|
}); |
68
|
|
|
}); |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* Init PageUserMenuView |
72
|
|
|
*/ |
73
|
|
|
BaseController.loadBeforeAction([ |
74
|
|
|
'oroui/js/app/views/page/user-menu-view' |
75
|
|
|
], function(PageUserMenuView) { |
76
|
|
|
BaseController.addToReuse('userMenu', PageUserMenuView, { |
77
|
|
|
el: 'region:userMenu' |
78
|
|
|
}); |
79
|
|
|
}); |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* Init PageLoadingMaskView |
83
|
|
|
*/ |
84
|
|
|
BaseController.loadBeforeAction([ |
85
|
|
|
'oroui/js/mediator', |
86
|
|
|
'oroui/js/app/views/loading-mask-view' |
87
|
|
|
], function(mediator, LoadingMaskView) { |
88
|
|
|
BaseController.addToReuse('loadingMask', { |
89
|
|
|
compose: function() { |
90
|
|
|
this.view = new LoadingMaskView({ |
91
|
|
|
container: 'body', |
92
|
|
|
hideDelay: 25 |
93
|
|
|
}); |
94
|
|
|
mediator.setHandler('showLoading', this.view.show, this.view); |
95
|
|
|
mediator.setHandler('hideLoading', this.view.hide, this.view); |
96
|
|
|
mediator.on('page:beforeChange', this.view.show, this.view); |
97
|
|
|
mediator.on('page:afterChange', this.view.hide, this.view); |
98
|
|
|
if (config.showLoadingMaskOnStartup) { |
99
|
|
|
this.view.show(); |
100
|
|
|
} |
101
|
|
|
} |
102
|
|
|
}); |
103
|
|
|
}); |
104
|
|
|
|
105
|
|
|
/** |
106
|
|
|
* Init PageLoadingBarView |
107
|
|
|
*/ |
108
|
|
|
BaseController.loadBeforeAction([ |
109
|
|
|
'oroui/js/mediator', |
110
|
|
|
'oroui/js/app/views/loading-bar-view' |
111
|
|
|
], function(mediator, LoadingBarView) { |
112
|
|
|
BaseController.addToReuse('loadingBar', { |
113
|
|
|
compose: function() { |
114
|
|
|
this.view = new LoadingBarView({ |
115
|
|
|
container: '#oroplatform-header', |
116
|
|
|
ajaxLoading: true |
117
|
|
|
}); |
118
|
|
|
mediator.setHandler('showLoadingBar', this.view.showLoader, this.view); |
119
|
|
|
mediator.setHandler('hideLoadingBar', this.view.hideLoader, this.view); |
120
|
|
|
mediator.on('page:beforeChange', this.view.showLoader, this.view); |
121
|
|
|
mediator.on('page:afterChange', this.view.hideLoader, this.view); |
122
|
|
|
if (config.showLoadingBarOnStartup) { |
123
|
|
|
this.view.showLoader(); |
124
|
|
|
} |
125
|
|
|
} |
126
|
|
|
}); |
127
|
|
|
}); |
128
|
|
|
|
129
|
|
|
/** |
130
|
|
|
* Init PageMessagesView |
131
|
|
|
*/ |
132
|
|
|
BaseController.loadBeforeAction([ |
133
|
|
|
'oroui/js/app/views/page/messages-view' |
134
|
|
|
], function(PageMessagesView) { |
135
|
|
|
BaseController.addToReuse('messages', PageMessagesView, { |
136
|
|
|
el: 'region:messages' |
137
|
|
|
}); |
138
|
|
|
}); |
139
|
|
|
|
140
|
|
|
if (tools.debug) { |
141
|
|
|
/** |
142
|
|
|
* Init DebugToolbarView |
143
|
|
|
*/ |
144
|
|
|
BaseController.loadBeforeAction([ |
145
|
|
|
'oroui/js/mediator', |
146
|
|
|
'oroui/js/app/views/page/debug-toolbar-view' |
147
|
|
|
], function(mediator, DebugToolbarView) { |
148
|
|
|
BaseController.addToReuse('debugToolbar', { |
149
|
|
|
compose: function() { |
150
|
|
|
var view; |
151
|
|
|
if (!mediator.execute('retrieveOption', 'debug')) { |
152
|
|
|
return; |
153
|
|
|
} |
154
|
|
|
view = new DebugToolbarView({ |
155
|
|
|
el: 'body .sf-toolbar' |
156
|
|
|
}); |
157
|
|
|
mediator.setHandler('updateDebugToolbar', view.updateToolbar, view); |
158
|
|
|
this.view = view; |
159
|
|
|
} |
160
|
|
|
}); |
161
|
|
|
}); |
162
|
|
|
} else { |
163
|
|
|
// initialize updateDebugToolbar mediator handler |
164
|
|
|
BaseController.loadBeforeAction([ |
165
|
|
|
'oroui/js/mediator' |
166
|
|
|
], function(mediator) { |
167
|
|
|
mediator.setHandler('updateDebugToolbar', _.noop); |
168
|
|
|
}); |
169
|
|
|
} |
170
|
|
|
|
171
|
|
|
if (!tools.isMobile()) { |
172
|
|
|
/** |
173
|
|
|
* Init SidePanelView |
174
|
|
|
*/ |
175
|
|
|
BaseController.loadBeforeAction([ |
176
|
|
|
'oroui/js/app/views/side-panel-view' |
177
|
|
|
], function(SidePanelView) { |
178
|
|
|
BaseController.addToReuse('leftPanel', SidePanelView, { |
179
|
|
|
el: 'region:leftPanel' |
180
|
|
|
}); |
181
|
|
|
}); |
182
|
|
|
} |
183
|
|
|
}); |
184
|
|
|
|