inviton-powerduck 0.0.165 → 0.0.166
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/app/global-state.ts +28 -0
- package/app/powerduck-initializer.ts +10 -9
- package/app/powerduck-state.ts +3 -2
- package/common/ajax-xhr.ts +2 -1
- package/common/api-http.ts +6 -5
- package/common/base-component.tsx +2 -1
- package/common/dialog-utils.ts +2 -1
- package/common/external-barcode-scanner.ts +244 -242
- package/common/history-extended.ts +44 -6
- package/common/history-handler.ts +15 -15
- package/common/keyboard-open-tracker.ts +20 -6
- package/common/ladda-lite.ts +14 -1
- package/common/local-storage-shim.ts +66 -30
- package/common/resource-helper.ts +77 -71
- package/common/scroll-utils.ts +9 -4
- package/common/set-current-url.ts +8 -5
- package/common/utils/checkbox-utils.ts +6 -0
- package/common/utils/clipboard-provider.ts +37 -34
- package/common/utils/cookie.ts +9 -0
- package/common/utils/dropdown-utils.ts +5 -0
- package/common/utils/string-utils.ts +46 -40
- package/common/utils/upload-image-helper.ts +2 -1
- package/common/utils/utils.ts +34 -14
- package/components/app/navigation-guard.ts +5 -2
- package/components/app/root-dynamic-component-container.tsx +2 -1
- package/components/app/vue-plugin-jsxtransform.ts +3 -1
- package/components/chart-js/line-chart-flot.tsx +4 -3
- package/components/chart-js/line-chart.tsx +5 -0
- package/components/chart-js/pie-chart.tsx +4 -3
- package/components/collapse/index.tsx +9 -0
- package/components/container-with-breakpoints/ts/breakpoint-handler.ts +7 -6
- package/components/counter/index.tsx +2 -1
- package/components/counter/testall.tsx +12 -9
- package/components/datatable/datatable.tsx +2363 -2362
- package/components/dropdown/mobile/legacy_fdd.ts +10 -9
- package/components/dropdown/mobile/legacy_lvb.ts +3 -1
- package/components/file-downloader/index.tsx +6 -5
- package/components/google/maps.tsx +18 -8
- package/components/google/places-autocomplete.tsx +6 -1
- package/components/google/ts/google-maps-api.ts +3 -2
- package/components/image-crop/image-cropping-modal.tsx +11 -6
- package/components/image-crop/upload-and-crop.tsx +163 -162
- package/components/input/daterange-picker.tsx +9 -0
- package/components/input/datetime-picker.tsx +11 -2
- package/components/input/localized-url-input.tsx +2 -1
- package/components/input/ts/bootstrapInputSpinner.ts +7 -2
- package/components/input/ts/dateInputHelper.ts +8 -7
- package/components/memory-cache/index.ts +7 -5
- package/components/modal/modal-utils.ts +2 -1
- package/components/modal/modal.tsx +5 -4
- package/components/modal/ts/file-manager-dialog.ts +3 -2
- package/components/share/share-modal.tsx +13 -12
- package/components/share/share.tsx +13 -12
- package/package.json +1 -1
- package/common/cdn-webpack-shim.ts +0 -5
- package/components/input/plugins/daterangepicker/jquery.daterangepicker.min.js +0 -1910
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { globalState } from '../app/global-state';
|
|
2
|
+
|
|
1
3
|
export interface HistoryChangedData {
|
|
2
4
|
from: any;
|
|
3
5
|
to: any;
|
|
@@ -23,8 +25,8 @@ interface HistoryOnSteroids extends History {
|
|
|
23
25
|
removeHistoryChangedListener: (listener: HistoryChangedListener) => void;
|
|
24
26
|
}
|
|
25
27
|
|
|
26
|
-
const history: HistoryOnSteroids =
|
|
27
|
-
if (!history.__historyExtendedInitialized) {
|
|
28
|
+
const history: HistoryOnSteroids = globalState.history as any;
|
|
29
|
+
if (history != null && !history.__historyExtendedInitialized) {
|
|
28
30
|
history.__historyExtendedInitialized = true;
|
|
29
31
|
|
|
30
32
|
(function () {
|
|
@@ -44,9 +46,9 @@ if (!history.__historyExtendedInitialized) {
|
|
|
44
46
|
let silentMode = false; // Flag to suppress events
|
|
45
47
|
|
|
46
48
|
// Function to log state into history
|
|
47
|
-
|
|
49
|
+
const logState = (state: any, index: number) => {
|
|
48
50
|
stateHistory[index] = { ...state, __heindex: index };
|
|
49
|
-
}
|
|
51
|
+
};
|
|
50
52
|
|
|
51
53
|
// Override pushState
|
|
52
54
|
history.pushState = function (
|
|
@@ -102,7 +104,7 @@ if (!history.__historyExtendedInitialized) {
|
|
|
102
104
|
};
|
|
103
105
|
|
|
104
106
|
// Popstate listener to detect navigation direction
|
|
105
|
-
|
|
107
|
+
globalState.addEventListener('popstate', (event) => {
|
|
106
108
|
const previousIndex = currentIndex;
|
|
107
109
|
previousState = stateHistory[previousIndex] || null;
|
|
108
110
|
|
|
@@ -162,7 +164,7 @@ if (!history.__historyExtendedInitialized) {
|
|
|
162
164
|
});
|
|
163
165
|
|
|
164
166
|
// Preserve current state on load and add index
|
|
165
|
-
|
|
167
|
+
globalState.addEventListener('load', () => {
|
|
166
168
|
const initialState = history.state || {};
|
|
167
169
|
if (!initialState.__heindex) {
|
|
168
170
|
history.replaceState({ ...initialState, __heindex: currentIndex }, '');
|
|
@@ -212,18 +214,34 @@ if (!history.__historyExtendedInitialized) {
|
|
|
212
214
|
|
|
213
215
|
export default class HistoryExtended {
|
|
214
216
|
static addPopstateListener(handler: HistoryChangedListener) {
|
|
217
|
+
if (!history) {
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
|
|
215
221
|
history.addHistoryChangedListener(handler);
|
|
216
222
|
}
|
|
217
223
|
|
|
218
224
|
static removePopstateListener(handler: HistoryChangedListener) {
|
|
225
|
+
if (!history) {
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
|
|
219
229
|
history.removeHistoryChangedListener(handler);
|
|
220
230
|
}
|
|
221
231
|
|
|
222
232
|
static nextBackWillNavigateAway(): boolean {
|
|
233
|
+
if (!history) {
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
|
|
223
237
|
return history.nextBackWillNavigateAway();
|
|
224
238
|
}
|
|
225
239
|
|
|
226
240
|
static back(args?: { silent?: boolean }): void {
|
|
241
|
+
if (!history) {
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
|
|
227
245
|
if (args?.silent == true) {
|
|
228
246
|
history.silentBack();
|
|
229
247
|
} else {
|
|
@@ -232,10 +250,18 @@ export default class HistoryExtended {
|
|
|
232
250
|
}
|
|
233
251
|
|
|
234
252
|
static forward(): void {
|
|
253
|
+
if (!history) {
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
256
|
+
|
|
235
257
|
history.forward();
|
|
236
258
|
}
|
|
237
259
|
|
|
238
260
|
static go(delta?: number): void {
|
|
261
|
+
if (!history) {
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
|
|
239
265
|
history.go(delta);
|
|
240
266
|
}
|
|
241
267
|
|
|
@@ -244,6 +270,10 @@ export default class HistoryExtended {
|
|
|
244
270
|
unused: string,
|
|
245
271
|
url?: string | URL | null,
|
|
246
272
|
): void {
|
|
273
|
+
if (!history) {
|
|
274
|
+
return;
|
|
275
|
+
}
|
|
276
|
+
|
|
247
277
|
history.pushState(
|
|
248
278
|
data,
|
|
249
279
|
unused,
|
|
@@ -256,6 +286,10 @@ export default class HistoryExtended {
|
|
|
256
286
|
unused: string,
|
|
257
287
|
url?: string | URL | null,
|
|
258
288
|
): void {
|
|
289
|
+
if (!history) {
|
|
290
|
+
return;
|
|
291
|
+
}
|
|
292
|
+
|
|
259
293
|
history.replaceState(
|
|
260
294
|
data,
|
|
261
295
|
unused,
|
|
@@ -264,6 +298,10 @@ export default class HistoryExtended {
|
|
|
264
298
|
}
|
|
265
299
|
|
|
266
300
|
static clearForward() {
|
|
301
|
+
if (!history) {
|
|
302
|
+
return;
|
|
303
|
+
}
|
|
304
|
+
|
|
267
305
|
history.clearForward();
|
|
268
306
|
}
|
|
269
307
|
}
|
|
@@ -1,21 +1,29 @@
|
|
|
1
|
+
import { globalState } from '../app/global-state';
|
|
1
2
|
import { ModalUtils } from './../components/modal/modal-utils';
|
|
2
3
|
import HistoryExtended from './history-extended';
|
|
3
4
|
|
|
4
5
|
export const initHistory = () => {
|
|
6
|
+
if (globalState.windowExists) {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
|
|
5
10
|
const randomString = (length: number): string => {
|
|
6
11
|
let result = '';
|
|
7
12
|
const chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
|
8
|
-
for (let i = length; i > 0; --i) {
|
|
13
|
+
for (let i = length; i > 0; --i) {
|
|
14
|
+
result += chars[Math.floor(Math.random() * chars.length)];
|
|
15
|
+
}
|
|
16
|
+
|
|
9
17
|
return result;
|
|
10
18
|
};
|
|
11
19
|
|
|
12
20
|
const initializer = {
|
|
13
21
|
intializeModalListener() {
|
|
14
|
-
if (
|
|
22
|
+
if (globalState.__historyPowerduckInitialized == true) {
|
|
15
23
|
return;
|
|
16
24
|
}
|
|
17
25
|
|
|
18
|
-
|
|
26
|
+
globalState.__historyPowerduckInitialized = true;
|
|
19
27
|
$(document).on(
|
|
20
28
|
'show.bs.modal',
|
|
21
29
|
'.modal',
|
|
@@ -35,11 +43,7 @@ export const initHistory = () => {
|
|
|
35
43
|
},
|
|
36
44
|
);
|
|
37
45
|
|
|
38
|
-
$(document).on('fdd-show',
|
|
39
|
-
this: any,
|
|
40
|
-
e: any,
|
|
41
|
-
elem: HTMLElement,
|
|
42
|
-
) {
|
|
46
|
+
$(document).on('fdd-show', (e: any, elem: HTMLElement) => {
|
|
43
47
|
if (elem.getAttribute('data-preventhistory') == 'true') {
|
|
44
48
|
return;
|
|
45
49
|
}
|
|
@@ -78,11 +82,7 @@ export const initHistory = () => {
|
|
|
78
82
|
},
|
|
79
83
|
);
|
|
80
84
|
|
|
81
|
-
$(document).on('fdd-hide',
|
|
82
|
-
this: any,
|
|
83
|
-
e: any,
|
|
84
|
-
elem: HTMLElement,
|
|
85
|
-
) {
|
|
85
|
+
$(document).on('fdd-hide', (e: any, elem: HTMLElement) => {
|
|
86
86
|
if (elem.getAttribute('data-preventhistory') == 'true') {
|
|
87
87
|
return;
|
|
88
88
|
}
|
|
@@ -131,11 +131,11 @@ export const initHistory = () => {
|
|
|
131
131
|
});
|
|
132
132
|
},
|
|
133
133
|
initBackdropFix() {
|
|
134
|
-
if (
|
|
134
|
+
if (globalState.__backdropFixInitialized == true) {
|
|
135
135
|
return;
|
|
136
136
|
}
|
|
137
137
|
|
|
138
|
-
|
|
138
|
+
globalState.__backdropFixInitialized = true;
|
|
139
139
|
$(document).on(
|
|
140
140
|
'show.bs.modal',
|
|
141
141
|
'.modal',
|
|
@@ -1,23 +1,37 @@
|
|
|
1
|
+
import { globalState } from '../app/global-state';
|
|
2
|
+
|
|
1
3
|
export default class KeyboardOpenTracker {
|
|
2
4
|
static bind() {
|
|
3
|
-
if (
|
|
5
|
+
if (globalState._keyboardOpenTrackerBound == true) {
|
|
4
6
|
return;
|
|
5
7
|
}
|
|
6
8
|
|
|
7
|
-
|
|
9
|
+
globalState._keyboardOpenTrackerBound = true;
|
|
8
10
|
|
|
9
11
|
const getOrientation = () => {
|
|
10
|
-
|
|
12
|
+
if (!globalState.matchMedia) {
|
|
13
|
+
return 'portrait';
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return globalState.matchMedia('(orientation: portrait)').matches ? 'portrait' : 'landscape';
|
|
11
17
|
};
|
|
12
18
|
|
|
13
19
|
const getScreenHeight = () => {
|
|
14
|
-
|
|
20
|
+
if (!globalState.screen) {
|
|
21
|
+
return 0;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return globalState.screen.height; // Constant physical screen height
|
|
15
25
|
};
|
|
16
26
|
|
|
17
27
|
let lastOrientation = getOrientation();
|
|
18
28
|
const handleResize = () => {
|
|
29
|
+
if (!globalState.windowExists) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
|
|
19
33
|
const currentOrientation = getOrientation();
|
|
20
|
-
const currentInnerHeight =
|
|
34
|
+
const currentInnerHeight = globalState.visualViewport?.height ?? globalState.innerHeight;
|
|
21
35
|
const screenHeight = getScreenHeight();
|
|
22
36
|
|
|
23
37
|
// Different thresholds for portrait/landscape
|
|
@@ -38,7 +52,7 @@ export default class KeyboardOpenTracker {
|
|
|
38
52
|
document.body.classList.toggle('powerduck-keyboard-open', isKeyboardOpen);
|
|
39
53
|
};
|
|
40
54
|
|
|
41
|
-
|
|
55
|
+
globalState.addEventListener('resize', handleResize);
|
|
42
56
|
handleResize(); // Run initially
|
|
43
57
|
}
|
|
44
58
|
}
|
package/common/ladda-lite.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { globalState } from '../app/global-state';
|
|
1
2
|
import './css/ladda-themeless-zoomin.min.css';
|
|
2
3
|
|
|
3
4
|
/*! Ladda http://lab.hakim.se/ladda MIT licensed Copyright (C) 2016 Hakim El Hattab, http://hakim.se ....Lightweight adaptation for Inviton API needs */
|
|
@@ -316,7 +317,7 @@ namespace laddaLiteUtils {
|
|
|
316
317
|
function createSpinner(button: any) {
|
|
317
318
|
let height = button.offsetHeight;
|
|
318
319
|
if (height === 0) {
|
|
319
|
-
height = parseFloat(
|
|
320
|
+
height = parseFloat(globalState.getComputedStyle(button).height);
|
|
320
321
|
}
|
|
321
322
|
|
|
322
323
|
if (height > 32) {
|
|
@@ -354,6 +355,10 @@ namespace laddaLiteUtils {
|
|
|
354
355
|
}
|
|
355
356
|
|
|
356
357
|
export function createLaddaInstance(button: any) {
|
|
358
|
+
if (!globalState.windowExists) {
|
|
359
|
+
return;
|
|
360
|
+
}
|
|
361
|
+
|
|
357
362
|
const laddaLabel = document.createElement('span');
|
|
358
363
|
laddaLabel.setAttribute('class', 'ladda-label');
|
|
359
364
|
|
|
@@ -389,6 +394,10 @@ export class LaddaLite {
|
|
|
389
394
|
return;
|
|
390
395
|
}
|
|
391
396
|
|
|
397
|
+
if (!globalState.windowExists) {
|
|
398
|
+
return;
|
|
399
|
+
}
|
|
400
|
+
|
|
392
401
|
let laddaInstance;
|
|
393
402
|
const button = laddaLiteUtils.getTarget(target);
|
|
394
403
|
const instanceId = laddaLiteUtils.getInstanceId(button);
|
|
@@ -410,6 +419,10 @@ export class LaddaLite {
|
|
|
410
419
|
return;
|
|
411
420
|
}
|
|
412
421
|
|
|
422
|
+
if (!globalState.windowExists) {
|
|
423
|
+
return;
|
|
424
|
+
}
|
|
425
|
+
|
|
413
426
|
const button = laddaLiteUtils.getTarget(target);
|
|
414
427
|
const instanceId = laddaLiteUtils.getInstanceId(button);
|
|
415
428
|
const laddaInstance = laddaLiteUtils.instanceCache[instanceId];
|
|
@@ -1,52 +1,90 @@
|
|
|
1
|
-
|
|
2
|
-
delete (window as any).localStorage;
|
|
3
|
-
(window as any).localStorage = {};
|
|
1
|
+
import { globalState } from '../app/global-state';
|
|
4
2
|
|
|
5
|
-
|
|
3
|
+
// Shim for SSR
|
|
4
|
+
class LocalStorageInMemory {
|
|
5
|
+
private _storage: any = {};
|
|
6
6
|
get length(): number {
|
|
7
|
-
return
|
|
7
|
+
return this._storage.length;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
clear(): void {
|
|
11
|
-
|
|
11
|
+
this._storage = {};
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
getItem(key: string): string | null {
|
|
15
|
-
return
|
|
15
|
+
return this._storage[key];
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
key(index: number): string | null {
|
|
19
|
-
return
|
|
19
|
+
return Object.keys(this._storage)[index];
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
removeItem(key: string): void {
|
|
23
|
-
|
|
23
|
+
this._storage[key] = null;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
setItem(key: string, value: string): void {
|
|
27
|
-
|
|
27
|
+
this._storage[key] = value;
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
if (
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
31
|
+
const storage = globalState.localStorage ?? new LocalStorageInMemory();
|
|
32
|
+
if (!(storage as unknown as any).isPatched && globalState.localStorage != null) {
|
|
33
|
+
try {
|
|
34
|
+
delete (globalState as any).localStorage;
|
|
35
|
+
(globalState as any).localStorage = {};
|
|
36
|
+
|
|
37
|
+
class LocalStorageImpl {
|
|
38
|
+
isPatched = true;
|
|
39
|
+
|
|
40
|
+
get length(): number {
|
|
41
|
+
return storage.length;
|
|
39
42
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
43
|
+
|
|
44
|
+
clear(): void {
|
|
45
|
+
storage.clear();
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
getItem(key: string): string | null {
|
|
49
|
+
return storage.getItem(`public.${key.replace('public.', '')}`);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
key(index: number): string | null {
|
|
53
|
+
return storage.key(index);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
removeItem(key: string): void {
|
|
57
|
+
storage.removeItem(`public.${key}`);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
setItem(key: string, value: string): void {
|
|
61
|
+
storage.setItem(`public.${key}`, value);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
let newStorage = new LocalStorageImpl();
|
|
66
|
+
if (globalState.Proxy && globalState.Reflect) {
|
|
67
|
+
newStorage = new globalState.Proxy(newStorage, {
|
|
68
|
+
get(target, prop: any) {
|
|
69
|
+
if ((storage as any)[prop] != null) {
|
|
70
|
+
return globalState.Reflect.get(target, prop);
|
|
71
|
+
} else {
|
|
72
|
+
return storage.getItem(`public.${prop}`);
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
set(
|
|
76
|
+
target,
|
|
77
|
+
prop,
|
|
78
|
+
value,
|
|
79
|
+
) {
|
|
80
|
+
storage.setItem(`public.${prop as any}`, value);
|
|
81
|
+
return true;
|
|
82
|
+
},
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
(globalState as any).localStorage = newStorage;
|
|
87
|
+
} catch (error) { }
|
|
50
88
|
}
|
|
51
89
|
|
|
52
90
|
/**
|
|
@@ -132,5 +170,3 @@ export default class StorageProvider {
|
|
|
132
170
|
StorageProvider.setString(key, storeVal);
|
|
133
171
|
}
|
|
134
172
|
}
|
|
135
|
-
|
|
136
|
-
(window as any).localStorage = newStorage;
|
|
@@ -1,83 +1,89 @@
|
|
|
1
|
+
import { globalState } from "../app/global-state";
|
|
2
|
+
|
|
1
3
|
export default class ResourceHelper {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
4
|
+
static loadResourcesDynamically(files: { src: string; type: 'js' | 'css'; mode?: 'normal' | 'module' }[]): Promise<boolean> {
|
|
5
|
+
return new Promise((resolve) => {
|
|
6
|
+
const loadScript = (
|
|
7
|
+
src: string,
|
|
8
|
+
mode?: 'normal' | 'module',
|
|
9
|
+
retries = 3,
|
|
10
|
+
) => {
|
|
11
|
+
return new Promise((resolve, reject) => {
|
|
12
|
+
if (!globalState.windowExists) {
|
|
13
|
+
resolve('Not supported for SSR');
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const attemptLoad = (attempt) => {
|
|
17
|
+
const script = document.createElement('script');
|
|
18
|
+
script.src = src;
|
|
19
|
+
script.async = true;
|
|
14
20
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
21
|
+
if (mode == 'module') {
|
|
22
|
+
script.type = 'module';
|
|
23
|
+
}
|
|
18
24
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
script.onload = () => resolve(`Loaded: ${src}`);
|
|
26
|
+
script.onerror = () => {
|
|
27
|
+
if (attempt < retries) {
|
|
28
|
+
const delay = Math.floor(Math.random() * (1200 - 500 + 1)) + 500;
|
|
29
|
+
console.warn(`Retrying ${src} in ${delay}ms... (${attempt + 1}/${retries})`);
|
|
30
|
+
setTimeout(() => attemptLoad(attempt + 1), delay);
|
|
31
|
+
} else {
|
|
32
|
+
reject(new Error(`Failed to load: ${src}`));
|
|
33
|
+
}
|
|
34
|
+
};
|
|
29
35
|
|
|
30
|
-
|
|
31
|
-
|
|
36
|
+
document.head.appendChild(script);
|
|
37
|
+
};
|
|
32
38
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
39
|
+
attemptLoad(0);
|
|
40
|
+
});
|
|
41
|
+
};
|
|
36
42
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
+
const loadCSS = (href: string, retries = 3) => {
|
|
44
|
+
return new Promise((resolve, reject) => {
|
|
45
|
+
const attemptLoad = (attempt) => {
|
|
46
|
+
const link = document.createElement('link');
|
|
47
|
+
link.rel = 'stylesheet';
|
|
48
|
+
link.href = href;
|
|
43
49
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
50
|
+
link.onload = () => resolve(`Loaded: ${href}`);
|
|
51
|
+
link.onerror = () => {
|
|
52
|
+
if (attempt < retries) {
|
|
53
|
+
const delay = Math.floor(Math.random() * (1200 - 500 + 1)) + 500;
|
|
54
|
+
console.warn(`Retrying ${href} in ${delay}ms... (${attempt + 1}/${retries})`);
|
|
55
|
+
setTimeout(() => attemptLoad(attempt + 1), delay);
|
|
56
|
+
} else {
|
|
57
|
+
reject(new Error(`Failed to load: ${href}`));
|
|
58
|
+
}
|
|
59
|
+
};
|
|
54
60
|
|
|
55
|
-
|
|
56
|
-
|
|
61
|
+
document.head.appendChild(link);
|
|
62
|
+
};
|
|
57
63
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
64
|
+
attemptLoad(0);
|
|
65
|
+
});
|
|
66
|
+
};
|
|
61
67
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
68
|
+
Promise.all(files.map((file) => {
|
|
69
|
+
if (file.type == 'js') {
|
|
70
|
+
return loadScript(file.src, file.mode).then(result => ({ status: 'fulfilled', value: result }), error => ({ status: 'rejected', reason: error }));
|
|
71
|
+
} else if (file.type == 'css') {
|
|
72
|
+
return loadCSS(file.src).then(result => ({ status: 'fulfilled', value: result }), error => ({ status: 'rejected', reason: error }));
|
|
73
|
+
} else {
|
|
74
|
+
return Promise.resolve({ status: 'rejected', reason: new Error(`Unsupported file type: ${file}`) });
|
|
75
|
+
}
|
|
76
|
+
})).then((results) => {
|
|
77
|
+
let allOk = true;
|
|
78
|
+
results.forEach((result) => {
|
|
79
|
+
if (result.status != 'fulfilled') {
|
|
80
|
+
console.error((result as any).reason);
|
|
81
|
+
allOk = false;
|
|
82
|
+
}
|
|
83
|
+
});
|
|
78
84
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
85
|
+
resolve(allOk);
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
}
|
|
83
89
|
}
|
package/common/scroll-utils.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Vue } from 'vue-facing-decorator';
|
|
2
|
+
import { globalState } from '../app/global-state';
|
|
2
3
|
import PowerduckState from '../app/powerduck-state';
|
|
3
4
|
import TemporalUtils from './utils/temporal-utils';
|
|
4
5
|
|
|
@@ -36,7 +37,7 @@ export default class ScrollUtils {
|
|
|
36
37
|
animated?: boolean,
|
|
37
38
|
instant?: boolean,
|
|
38
39
|
): void {
|
|
39
|
-
if (elem == null) {
|
|
40
|
+
if (elem == null || !globalState.scrollTo) {
|
|
40
41
|
return;
|
|
41
42
|
}
|
|
42
43
|
|
|
@@ -46,7 +47,7 @@ export default class ScrollUtils {
|
|
|
46
47
|
otherHeaderHeight = $('header').height();
|
|
47
48
|
}
|
|
48
49
|
|
|
49
|
-
if (($(
|
|
50
|
+
if (($(globalState).width() as number < 768 && mobileOffset != false) || otherHeaderHeight > 0) {
|
|
50
51
|
if ((mobileOffset as number) > 1) {
|
|
51
52
|
offset = mobileOffset as number;
|
|
52
53
|
} else {
|
|
@@ -87,15 +88,19 @@ export default class ScrollUtils {
|
|
|
87
88
|
animated?: boolean,
|
|
88
89
|
instant?: boolean,
|
|
89
90
|
): void {
|
|
91
|
+
if (!globalState.scrollTo) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
|
|
90
95
|
if (instant != true) {
|
|
91
96
|
setTimeout(() => {
|
|
92
|
-
(context?.length > 0 ? context[0] :
|
|
97
|
+
(context?.length > 0 ? context[0] : globalState).scrollTo({
|
|
93
98
|
top: position,
|
|
94
99
|
behavior: (animated != false ? 'smooth' : 'instant') as any,
|
|
95
100
|
});
|
|
96
101
|
});
|
|
97
102
|
} else {
|
|
98
|
-
(context?.length > 0 ? context[0] :
|
|
103
|
+
(context?.length > 0 ? context[0] : globalState).scrollTo({
|
|
99
104
|
top: position,
|
|
100
105
|
behavior: (animated != false ? 'smooth' : 'instant') as any,
|
|
101
106
|
});
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { Vue } from 'vue-facing-decorator';
|
|
2
|
+
import { globalState } from '../app/global-state';
|
|
2
3
|
import PowerduckState from '../app/powerduck-state';
|
|
3
4
|
|
|
4
5
|
type VueType = typeof Vue.prototype;
|
|
5
|
-
export
|
|
6
|
-
const newUrl = new URL(url,
|
|
7
|
-
const currentUrl = new URL(
|
|
6
|
+
export const setCurrentUrl = (instance: VueType, url: string) => {
|
|
7
|
+
const newUrl = new URL(url, globalState.location.origin);
|
|
8
|
+
const currentUrl = new URL(globalState.location.href);
|
|
8
9
|
const router = PowerduckState.getRouter();
|
|
9
10
|
const route = PowerduckState.getCurrentRouteQuery();
|
|
10
11
|
|
|
@@ -14,7 +15,9 @@ export function setCurrentUrl(instance: VueType, url: string) {
|
|
|
14
15
|
|
|
15
16
|
let nextTick = instance?.$nextTick;
|
|
16
17
|
if (nextTick == null) {
|
|
17
|
-
nextTick = (cb) => {
|
|
18
|
+
nextTick = (cb) => {
|
|
19
|
+
cb();
|
|
20
|
+
};
|
|
18
21
|
}
|
|
19
22
|
|
|
20
23
|
if (currentUrl.href != newUrl.href) {
|
|
@@ -35,4 +38,4 @@ export function setCurrentUrl(instance: VueType, url: string) {
|
|
|
35
38
|
}
|
|
36
39
|
}, 500);
|
|
37
40
|
}
|
|
38
|
-
}
|
|
41
|
+
};
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { globalState } from "../../app/global-state";
|
|
2
|
+
|
|
1
3
|
export default class CheckboxUtils {
|
|
2
4
|
private static shiftClickBound: boolean = false;
|
|
3
5
|
|
|
@@ -5,6 +7,10 @@ export default class CheckboxUtils {
|
|
|
5
7
|
if (!CheckboxUtils.shiftClickBound) {
|
|
6
8
|
CheckboxUtils.shiftClickBound = true;
|
|
7
9
|
|
|
10
|
+
if (!globalState.windowExists) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
|
|
8
14
|
$(document).on(
|
|
9
15
|
'click',
|
|
10
16
|
'.dt-selection-checkbox .inv-chckb-clickable',
|