|
1
|
|
|
|
|
2
|
|
|
import _ from '_'; |
|
3
|
|
|
import $ from '$'; |
|
4
|
|
|
import ko from 'ko'; |
|
5
|
|
|
import hasher from 'hasher'; |
|
6
|
|
|
import crossroads from 'crossroads'; |
|
7
|
|
|
|
|
8
|
|
|
import {runHook} from 'Common/Plugins'; |
|
9
|
|
|
import {$html, aViewModels as VIEW_MODELS, popupVisibilityNames} from 'Common/Globals'; |
|
10
|
|
|
|
|
11
|
|
|
import { |
|
12
|
|
|
isArray, isUnd, pString, log, |
|
|
|
|
|
|
13
|
|
|
createCommand, delegateRun, isNonEmptyArray |
|
|
|
|
|
|
14
|
|
|
} from 'Common/Utils'; |
|
15
|
|
|
|
|
16
|
|
|
let |
|
17
|
|
|
currentScreen = null, |
|
|
|
|
|
|
18
|
|
|
defaultScreenName = ''; |
|
|
|
|
|
|
19
|
|
|
|
|
20
|
|
|
const SCREENS = {}; |
|
|
|
|
|
|
21
|
|
|
|
|
22
|
|
|
export const ViewType = { |
|
|
|
|
|
|
23
|
|
|
Popup: 'Popups', |
|
24
|
|
|
Left: 'Left', |
|
25
|
|
|
Right: 'Right', |
|
26
|
|
|
Center: 'Center' |
|
27
|
|
|
}; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* @returns {void} |
|
31
|
|
|
*/ |
|
32
|
|
|
export function hideLoading() |
|
33
|
|
|
{ |
|
34
|
|
|
$('#rl-content').addClass('rl-content-show'); |
|
35
|
|
|
$('#rl-loading').hide().remove(); |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* @param {Function} SettingsViewModelClass |
|
40
|
|
|
* @param {string} template |
|
41
|
|
|
* @param {string} labelName |
|
42
|
|
|
* @param {string} route |
|
43
|
|
|
* @param {boolean=} isDefault = false |
|
44
|
|
|
* @returns {void} |
|
45
|
|
|
*/ |
|
46
|
|
|
export function addSettingsViewModel(SettingsViewModelClass, template, labelName, route, isDefault = false) |
|
|
|
|
|
|
47
|
|
|
{ |
|
48
|
|
|
SettingsViewModelClass.__rlSettingsData = { |
|
49
|
|
|
Label: labelName, |
|
50
|
|
|
Template: template, |
|
51
|
|
|
Route: route, |
|
52
|
|
|
IsDefault: !!isDefault |
|
53
|
|
|
}; |
|
54
|
|
|
|
|
55
|
|
|
VIEW_MODELS.settings.push(SettingsViewModelClass); |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
/** |
|
59
|
|
|
* @param {Function} SettingsViewModelClass |
|
60
|
|
|
* @returns {void} |
|
61
|
|
|
*/ |
|
62
|
|
|
export function removeSettingsViewModel(SettingsViewModelClass) |
|
|
|
|
|
|
63
|
|
|
{ |
|
64
|
|
|
VIEW_MODELS['settings-removed'].push(SettingsViewModelClass); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
/** |
|
68
|
|
|
* @param {Function} SettingsViewModelClass |
|
69
|
|
|
* @returns {void} |
|
70
|
|
|
*/ |
|
71
|
|
|
export function disableSettingsViewModel(SettingsViewModelClass) |
|
|
|
|
|
|
72
|
|
|
{ |
|
73
|
|
|
VIEW_MODELS['settings-disabled'].push(SettingsViewModelClass); |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
/** |
|
77
|
|
|
* @returns {void} |
|
78
|
|
|
*/ |
|
79
|
|
|
export function routeOff() |
|
80
|
|
|
{ |
|
81
|
|
|
hasher.changed.active = false; |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
/** |
|
85
|
|
|
* @returns {void} |
|
86
|
|
|
*/ |
|
87
|
|
|
export function routeOn() |
|
88
|
|
|
{ |
|
89
|
|
|
hasher.changed.active = true; |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
/** |
|
93
|
|
|
* @param {string} screenName |
|
94
|
|
|
* @returns {?Object} |
|
95
|
|
|
*/ |
|
96
|
|
|
export function screen(screenName) |
|
|
|
|
|
|
97
|
|
|
{ |
|
98
|
|
|
return ('' !== screenName && !isUnd(SCREENS[screenName])) ? SCREENS[screenName] : null; |
|
99
|
|
|
} |
|
100
|
|
|
|
|
101
|
|
|
/** |
|
102
|
|
|
* @param {Function} ViewModelClassToHide |
|
103
|
|
|
* @returns {void} |
|
104
|
|
|
*/ |
|
105
|
|
|
export function hideScreenPopup(ViewModelClassToHide) |
|
|
|
|
|
|
106
|
|
|
{ |
|
107
|
|
|
if (ViewModelClassToHide && ViewModelClassToHide.__vm && ViewModelClassToHide.__dom) |
|
|
|
|
|
|
108
|
|
|
{ |
|
109
|
|
|
ViewModelClassToHide.__vm.modalVisibility(false); |
|
110
|
|
|
} |
|
111
|
|
|
} |
|
112
|
|
|
|
|
113
|
|
|
/** |
|
114
|
|
|
* @param {string} hookName |
|
115
|
|
|
* @param {Function} ViewModelClass |
|
116
|
|
|
* @param {mixed=} params = null |
|
117
|
|
|
*/ |
|
118
|
|
|
export function vmRunHook(hookName, ViewModelClass, params = null) |
|
|
|
|
|
|
119
|
|
|
{ |
|
120
|
|
|
_.each(ViewModelClass.__names, (name) => { |
|
121
|
|
|
runHook(hookName, [name, ViewModelClass.__vm, params]); |
|
122
|
|
|
}); |
|
123
|
|
|
} |
|
124
|
|
|
|
|
125
|
|
|
/** |
|
126
|
|
|
* @param {Function} ViewModelClass |
|
127
|
|
|
* @param {Object=} vmScreen |
|
128
|
|
|
* @returns {*} |
|
129
|
|
|
*/ |
|
130
|
|
|
export function buildViewModel(ViewModelClass, vmScreen) |
|
|
|
|
|
|
131
|
|
|
{ |
|
132
|
|
|
if (ViewModelClass && !ViewModelClass.__builded) |
|
|
|
|
|
|
133
|
|
|
{ |
|
134
|
|
|
let vmDom = null; |
|
|
|
|
|
|
135
|
|
|
const |
|
136
|
|
|
vm = new ViewModelClass(vmScreen), |
|
|
|
|
|
|
137
|
|
|
position = ViewModelClass.__type || '', |
|
|
|
|
|
|
138
|
|
|
vmPlace = position ? $('#rl-content #rl-' + position.toLowerCase()) : null; |
|
|
|
|
|
|
139
|
|
|
|
|
140
|
|
|
ViewModelClass.__builded = true; |
|
141
|
|
|
ViewModelClass.__vm = vm; |
|
142
|
|
|
|
|
143
|
|
|
vm.onShowTrigger = ko.observable(false); |
|
144
|
|
|
vm.onHideTrigger = ko.observable(false); |
|
145
|
|
|
|
|
146
|
|
|
vm.viewModelName = ViewModelClass.__name; |
|
147
|
|
|
vm.viewModelNames = ViewModelClass.__names; |
|
148
|
|
|
vm.viewModelTemplateID = ViewModelClass.__templateID; |
|
149
|
|
|
vm.viewModelPosition = ViewModelClass.__type; |
|
150
|
|
|
|
|
151
|
|
|
if (vmPlace && 1 === vmPlace.length) |
|
|
|
|
|
|
152
|
|
|
{ |
|
153
|
|
|
vmDom = $('<div></div>').addClass('rl-view-model').addClass('RL-' + vm.viewModelTemplateID).hide(); |
|
154
|
|
|
vmDom.appendTo(vmPlace); |
|
155
|
|
|
|
|
156
|
|
|
vm.viewModelDom = vmDom; |
|
157
|
|
|
ViewModelClass.__dom = vmDom; |
|
158
|
|
|
|
|
159
|
|
|
if (ViewType.Popup === position) |
|
160
|
|
|
{ |
|
161
|
|
|
vm.cancelCommand = vm.closeCommand = createCommand(() => { |
|
162
|
|
|
hideScreenPopup(ViewModelClass); |
|
163
|
|
|
}); |
|
164
|
|
|
|
|
165
|
|
|
vm.modalVisibility.subscribe((value) => { |
|
166
|
|
|
if (value) |
|
167
|
|
|
{ |
|
168
|
|
|
vm.viewModelDom.show(); |
|
169
|
|
|
vm.storeAndSetKeyScope(); |
|
170
|
|
|
|
|
171
|
|
|
popupVisibilityNames.push(vm.viewModelName); |
|
172
|
|
|
vm.viewModelDom.css('z-index', 3000 + popupVisibilityNames().length + 10); |
|
173
|
|
|
|
|
174
|
|
|
if (vm.onShowTrigger) |
|
175
|
|
|
{ |
|
176
|
|
|
vm.onShowTrigger(!vm.onShowTrigger()); |
|
177
|
|
|
} |
|
178
|
|
|
|
|
179
|
|
|
delegateRun(vm, 'onShowWithDelay', [], 500); |
|
180
|
|
|
} |
|
181
|
|
|
else |
|
182
|
|
|
{ |
|
183
|
|
|
delegateRun(vm, 'onHide'); |
|
184
|
|
|
delegateRun(vm, 'onHideWithDelay', [], 500); |
|
185
|
|
|
|
|
186
|
|
|
if (vm.onHideTrigger) |
|
187
|
|
|
{ |
|
188
|
|
|
vm.onHideTrigger(!vm.onHideTrigger()); |
|
189
|
|
|
} |
|
190
|
|
|
|
|
191
|
|
|
vm.restoreKeyScope(); |
|
192
|
|
|
|
|
193
|
|
|
vmRunHook('view-model-on-hide', ViewModelClass); |
|
194
|
|
|
|
|
195
|
|
|
popupVisibilityNames.remove(vm.viewModelName); |
|
196
|
|
|
vm.viewModelDom.css('z-index', 2000); |
|
197
|
|
|
|
|
198
|
|
|
_.delay(() => vm.viewModelDom.hide(), 300); |
|
199
|
|
|
} |
|
200
|
|
|
}); |
|
201
|
|
|
} |
|
202
|
|
|
|
|
203
|
|
|
vmRunHook('view-model-pre-build', ViewModelClass, vmDom); |
|
204
|
|
|
|
|
205
|
|
|
ko.applyBindingAccessorsToNode(vmDom[0], { |
|
206
|
|
|
translatorInit: true, |
|
207
|
|
|
template: () => ({name: vm.viewModelTemplateID}) |
|
208
|
|
|
}, vm); |
|
209
|
|
|
|
|
210
|
|
|
delegateRun(vm, 'onBuild', [vmDom]); |
|
211
|
|
|
if (vm && ViewType.Popup === position) |
|
|
|
|
|
|
212
|
|
|
{ |
|
213
|
|
|
vm.registerPopupKeyDown(); |
|
214
|
|
|
} |
|
215
|
|
|
|
|
216
|
|
|
vmRunHook('view-model-post-build', ViewModelClass, vmDom); |
|
217
|
|
|
} |
|
218
|
|
|
else |
|
219
|
|
|
{ |
|
220
|
|
|
log('Cannot find view model position: ' + position); |
|
221
|
|
|
} |
|
222
|
|
|
} |
|
223
|
|
|
|
|
224
|
|
|
return ViewModelClass ? ViewModelClass.__vm : null; |
|
|
|
|
|
|
225
|
|
|
} |
|
226
|
|
|
|
|
227
|
|
|
/** |
|
228
|
|
|
* @param {Function} ViewModelClassToShow |
|
229
|
|
|
* @param {Array=} params |
|
230
|
|
|
* @returns {void} |
|
231
|
|
|
*/ |
|
232
|
|
|
export function showScreenPopup(ViewModelClassToShow, params = []) |
|
|
|
|
|
|
233
|
|
|
{ |
|
234
|
|
|
if (ViewModelClassToShow) |
|
|
|
|
|
|
235
|
|
|
{ |
|
236
|
|
|
buildViewModel(ViewModelClassToShow); |
|
237
|
|
|
|
|
238
|
|
|
if (ViewModelClassToShow.__vm && ViewModelClassToShow.__dom) |
|
239
|
|
|
{ |
|
240
|
|
|
delegateRun(ViewModelClassToShow.__vm, 'onBeforeShow', params || []); |
|
|
|
|
|
|
241
|
|
|
|
|
242
|
|
|
ViewModelClassToShow.__vm.modalVisibility(true); |
|
243
|
|
|
|
|
244
|
|
|
delegateRun(ViewModelClassToShow.__vm, 'onShow', params || []); |
|
245
|
|
|
|
|
246
|
|
|
vmRunHook('view-model-on-show', ViewModelClassToShow, params || []); |
|
247
|
|
|
} |
|
248
|
|
|
} |
|
249
|
|
|
} |
|
250
|
|
|
|
|
251
|
|
|
/** |
|
252
|
|
|
* @param {Function} ViewModelClassToShow |
|
253
|
|
|
* @returns {void} |
|
254
|
|
|
*/ |
|
255
|
|
|
export function warmUpScreenPopup(ViewModelClassToShow) |
|
|
|
|
|
|
256
|
|
|
{ |
|
257
|
|
|
if (ViewModelClassToShow) |
|
|
|
|
|
|
258
|
|
|
{ |
|
259
|
|
|
buildViewModel(ViewModelClassToShow); |
|
260
|
|
|
|
|
261
|
|
|
if (ViewModelClassToShow.__vm && ViewModelClassToShow.__dom) |
|
262
|
|
|
{ |
|
263
|
|
|
delegateRun(ViewModelClassToShow.__vm, 'onWarmUp'); |
|
264
|
|
|
} |
|
265
|
|
|
} |
|
266
|
|
|
} |
|
267
|
|
|
|
|
268
|
|
|
/** |
|
269
|
|
|
* @param {Function} ViewModelClassToShow |
|
270
|
|
|
* @returns {boolean} |
|
271
|
|
|
*/ |
|
272
|
|
|
export function isPopupVisible(ViewModelClassToShow) |
|
|
|
|
|
|
273
|
|
|
{ |
|
274
|
|
|
return ViewModelClassToShow && ViewModelClassToShow.__vm ? ViewModelClassToShow.__vm.modalVisibility() : false; |
|
|
|
|
|
|
275
|
|
|
} |
|
276
|
|
|
|
|
277
|
|
|
/** |
|
278
|
|
|
* @param {string} screenName |
|
279
|
|
|
* @param {string} subPart |
|
280
|
|
|
* @returns {void} |
|
281
|
|
|
*/ |
|
282
|
|
|
export function screenOnRoute(screenName, subPart) |
|
|
|
|
|
|
283
|
|
|
{ |
|
284
|
|
|
let |
|
285
|
|
|
vmScreen = null, |
|
|
|
|
|
|
286
|
|
|
isSameScreen = false, |
|
|
|
|
|
|
287
|
|
|
cross = null; |
|
|
|
|
|
|
288
|
|
|
|
|
289
|
|
|
if ('' === pString(screenName)) |
|
290
|
|
|
{ |
|
291
|
|
|
screenName = defaultScreenName; |
|
|
|
|
|
|
292
|
|
|
} |
|
293
|
|
|
|
|
294
|
|
|
if ('' !== screenName) |
|
295
|
|
|
{ |
|
296
|
|
|
vmScreen = screen(screenName); |
|
297
|
|
|
if (!vmScreen) |
|
|
|
|
|
|
298
|
|
|
{ |
|
299
|
|
|
vmScreen = screen(defaultScreenName); |
|
300
|
|
|
if (vmScreen) |
|
301
|
|
|
{ |
|
302
|
|
|
subPart = screenName + '/' + subPart; |
|
|
|
|
|
|
303
|
|
|
screenName = defaultScreenName; |
|
304
|
|
|
} |
|
305
|
|
|
} |
|
306
|
|
|
|
|
307
|
|
|
if (vmScreen && vmScreen.__started) |
|
308
|
|
|
{ |
|
309
|
|
|
isSameScreen = currentScreen && vmScreen === currentScreen; |
|
|
|
|
|
|
310
|
|
|
|
|
311
|
|
|
if (!vmScreen.__builded) |
|
312
|
|
|
{ |
|
313
|
|
|
vmScreen.__builded = true; |
|
314
|
|
|
|
|
315
|
|
|
if (isNonEmptyArray(vmScreen.viewModels())) |
|
316
|
|
|
{ |
|
317
|
|
|
_.each(vmScreen.viewModels(), (ViewModelClass) => { |
|
318
|
|
|
buildViewModel(ViewModelClass, vmScreen); |
|
319
|
|
|
}); |
|
320
|
|
|
} |
|
321
|
|
|
|
|
322
|
|
|
delegateRun(vmScreen, 'onBuild'); |
|
323
|
|
|
} |
|
324
|
|
|
|
|
325
|
|
|
_.defer(() => { |
|
326
|
|
|
// hide screen |
|
327
|
|
|
if (currentScreen && !isSameScreen) |
|
|
|
|
|
|
328
|
|
|
{ |
|
329
|
|
|
delegateRun(currentScreen, 'onHide'); |
|
330
|
|
|
delegateRun(currentScreen, 'onHideWithDelay', [], 500); |
|
331
|
|
|
|
|
332
|
|
|
if (currentScreen.onHideTrigger) |
|
333
|
|
|
{ |
|
334
|
|
|
currentScreen.onHideTrigger(!currentScreen.onHideTrigger()); |
|
335
|
|
|
} |
|
336
|
|
|
|
|
337
|
|
|
if (isNonEmptyArray(currentScreen.viewModels())) |
|
338
|
|
|
{ |
|
339
|
|
|
_.each(currentScreen.viewModels(), (ViewModelClass) => { |
|
340
|
|
|
if (ViewModelClass.__vm && ViewModelClass.__dom && ViewType.Popup !== ViewModelClass.__vm.viewModelPosition) |
|
341
|
|
|
{ |
|
342
|
|
|
ViewModelClass.__dom.hide(); |
|
343
|
|
|
ViewModelClass.__vm.viewModelVisibility(false); |
|
344
|
|
|
|
|
345
|
|
|
delegateRun(ViewModelClass.__vm, 'onHide'); |
|
346
|
|
|
delegateRun(ViewModelClass.__vm, 'onHideWithDelay', [], 500); |
|
347
|
|
|
|
|
348
|
|
|
if (ViewModelClass.__vm.onHideTrigger) |
|
349
|
|
|
{ |
|
350
|
|
|
ViewModelClass.__vm.onHideTrigger(!ViewModelClass.__vm.onHideTrigger()); |
|
351
|
|
|
} |
|
352
|
|
|
} |
|
353
|
|
|
}); |
|
354
|
|
|
} |
|
355
|
|
|
} |
|
356
|
|
|
// -- |
|
357
|
|
|
|
|
358
|
|
|
currentScreen = vmScreen; |
|
|
|
|
|
|
359
|
|
|
|
|
360
|
|
|
// show screen |
|
361
|
|
|
if (currentScreen && !isSameScreen) |
|
|
|
|
|
|
362
|
|
|
{ |
|
363
|
|
|
delegateRun(currentScreen, 'onShow'); |
|
364
|
|
|
if (currentScreen.onShowTrigger) |
|
365
|
|
|
{ |
|
366
|
|
|
currentScreen.onShowTrigger(!currentScreen.onShowTrigger()); |
|
367
|
|
|
} |
|
368
|
|
|
|
|
369
|
|
|
runHook('screen-on-show', [currentScreen.screenName(), currentScreen]); |
|
370
|
|
|
|
|
371
|
|
|
if (isNonEmptyArray(currentScreen.viewModels())) |
|
372
|
|
|
{ |
|
373
|
|
|
_.each(currentScreen.viewModels(), (ViewModelClass) => { |
|
374
|
|
|
|
|
375
|
|
|
if (ViewModelClass.__vm && ViewModelClass.__dom && ViewType.Popup !== ViewModelClass.__vm.viewModelPosition) |
|
376
|
|
|
{ |
|
377
|
|
|
delegateRun(ViewModelClass.__vm, 'onBeforeShow'); |
|
378
|
|
|
|
|
379
|
|
|
ViewModelClass.__dom.show(); |
|
380
|
|
|
ViewModelClass.__vm.viewModelVisibility(true); |
|
381
|
|
|
|
|
382
|
|
|
delegateRun(ViewModelClass.__vm, 'onShow'); |
|
383
|
|
|
if (ViewModelClass.__vm.onShowTrigger) |
|
384
|
|
|
{ |
|
385
|
|
|
ViewModelClass.__vm.onShowTrigger(!ViewModelClass.__vm.onShowTrigger()); |
|
386
|
|
|
} |
|
387
|
|
|
|
|
388
|
|
|
delegateRun(ViewModelClass.__vm, 'onShowWithDelay', [], 200); |
|
389
|
|
|
vmRunHook('view-model-on-show', ViewModelClass); |
|
390
|
|
|
} |
|
391
|
|
|
|
|
392
|
|
|
}); |
|
393
|
|
|
} |
|
394
|
|
|
} |
|
395
|
|
|
// -- |
|
396
|
|
|
|
|
397
|
|
|
cross = vmScreen.__cross ? vmScreen.__cross() : null; |
|
|
|
|
|
|
398
|
|
|
if (cross) |
|
399
|
|
|
{ |
|
400
|
|
|
cross.parse(subPart); |
|
401
|
|
|
} |
|
402
|
|
|
}); |
|
403
|
|
|
} |
|
404
|
|
|
} |
|
405
|
|
|
} |
|
406
|
|
|
|
|
407
|
|
|
/** |
|
408
|
|
|
* @param {Array} screensClasses |
|
409
|
|
|
* @returns {void} |
|
410
|
|
|
*/ |
|
411
|
|
|
export function startScreens(screensClasses) |
|
|
|
|
|
|
412
|
|
|
{ |
|
413
|
|
|
_.each(screensClasses, (CScreen) => { |
|
414
|
|
|
if (CScreen) |
|
415
|
|
|
{ |
|
416
|
|
|
const |
|
417
|
|
|
vmScreen = new CScreen(), |
|
418
|
|
|
screenName = vmScreen ? vmScreen.screenName() : ''; |
|
419
|
|
|
|
|
420
|
|
|
if (vmScreen && '' !== screenName) |
|
421
|
|
|
{ |
|
422
|
|
|
if ('' === defaultScreenName) |
|
423
|
|
|
{ |
|
424
|
|
|
defaultScreenName = screenName; |
|
|
|
|
|
|
425
|
|
|
} |
|
426
|
|
|
|
|
427
|
|
|
SCREENS[screenName] = vmScreen; |
|
428
|
|
|
} |
|
429
|
|
|
} |
|
430
|
|
|
}); |
|
431
|
|
|
|
|
432
|
|
|
_.each(SCREENS, (vmScreen) => { |
|
433
|
|
|
if (vmScreen && !vmScreen.__started && vmScreen.__start) |
|
434
|
|
|
{ |
|
435
|
|
|
vmScreen.__started = true; |
|
436
|
|
|
vmScreen.__start(); |
|
437
|
|
|
|
|
438
|
|
|
runHook('screen-pre-start', [vmScreen.screenName(), vmScreen]); |
|
439
|
|
|
delegateRun(vmScreen, 'onStart'); |
|
440
|
|
|
runHook('screen-post-start', [vmScreen.screenName(), vmScreen]); |
|
441
|
|
|
} |
|
442
|
|
|
}); |
|
443
|
|
|
|
|
444
|
|
|
const cross = crossroads.create(); |
|
|
|
|
|
|
445
|
|
|
cross.addRoute(/^([a-zA-Z0-9\-]*)\/?(.*)$/, screenOnRoute); |
|
446
|
|
|
|
|
447
|
|
|
hasher.initialized.add(cross.parse, cross); |
|
448
|
|
|
hasher.changed.add(cross.parse, cross); |
|
449
|
|
|
hasher.init(); |
|
450
|
|
|
|
|
451
|
|
|
_.delay(() => $html.removeClass('rl-started-trigger').addClass('rl-started'), 100); |
|
452
|
|
|
_.delay(() => $html.addClass('rl-started-delay'), 200); |
|
453
|
|
|
} |
|
454
|
|
|
|
|
455
|
|
|
/** |
|
456
|
|
|
* @param {string} sHash |
|
|
|
|
|
|
457
|
|
|
* @param {boolean=} silence = false |
|
458
|
|
|
* @param {boolean=} replace = false |
|
459
|
|
|
* @returns {void} |
|
460
|
|
|
*/ |
|
461
|
|
|
export function setHash(hash, silence = false, replace = false) |
|
|
|
|
|
|
462
|
|
|
{ |
|
463
|
|
|
hash = '#' === hash.substr(0, 1) ? hash.substr(1) : hash; |
|
|
|
|
|
|
464
|
|
|
hash = '/' === hash.substr(0, 1) ? hash.substr(1) : hash; |
|
465
|
|
|
|
|
466
|
|
|
const cmd = replace ? 'replaceHash' : 'setHash'; |
|
|
|
|
|
|
467
|
|
|
|
|
468
|
|
|
if (silence) |
|
|
|
|
|
|
469
|
|
|
{ |
|
470
|
|
|
hasher.changed.active = false; |
|
471
|
|
|
hasher[cmd](hash); |
|
472
|
|
|
hasher.changed.active = true; |
|
473
|
|
|
} |
|
474
|
|
|
else |
|
475
|
|
|
{ |
|
476
|
|
|
hasher.changed.active = true; |
|
477
|
|
|
hasher[cmd](hash); |
|
478
|
|
|
hasher.setHash(hash); |
|
479
|
|
|
} |
|
480
|
|
|
} |
|
481
|
|
|
|
|
482
|
|
|
/** |
|
483
|
|
|
* @param {Object} params |
|
|
|
|
|
|
484
|
|
|
* @returns {void} |
|
485
|
|
|
*/ |
|
486
|
|
|
function viewDecorator({name, type, templateID}) |
|
487
|
|
|
{ |
|
488
|
|
|
return (target) => { |
|
489
|
|
|
if (target) |
|
490
|
|
|
{ |
|
491
|
|
|
if (name) |
|
492
|
|
|
{ |
|
493
|
|
|
if (isArray(name)) |
|
494
|
|
|
{ |
|
495
|
|
|
target.__names = name; |
|
496
|
|
|
} |
|
497
|
|
|
else |
|
498
|
|
|
{ |
|
499
|
|
|
target.__names = [name]; |
|
500
|
|
|
} |
|
501
|
|
|
|
|
502
|
|
|
target.__name = target.__names[0]; |
|
503
|
|
|
} |
|
504
|
|
|
|
|
505
|
|
|
if (type) |
|
506
|
|
|
{ |
|
507
|
|
|
target.__type = type; |
|
508
|
|
|
} |
|
509
|
|
|
|
|
510
|
|
|
if (templateID) |
|
511
|
|
|
{ |
|
512
|
|
|
target.__templateID = templateID; |
|
513
|
|
|
} |
|
514
|
|
|
} |
|
515
|
|
|
}; |
|
516
|
|
|
} |
|
517
|
|
|
|
|
518
|
|
|
export {viewDecorator, viewDecorator as view, viewDecorator as viewModel}; |
|
519
|
|
|
|