@ons/design-system 46.1.0 → 46.1.3
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/LICENSE +1 -1
- package/components/message-list/_message-list.scss +1 -1
- package/components/tabs/_tabs.scss +2 -1
- package/components/timeout-modal/timeout-modal.js +29 -4
- package/css/census.css +1 -1
- package/css/main.css +1 -1
- package/js/timeout.js +8 -32
- package/layout/_template.njk +2 -2
- package/package.json +5 -7
- package/scripts/main.es5.js +2 -2
- package/scripts/main.js +1 -1
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2018
|
|
3
|
+
Copyright (c) 2018 Crown Copyright (Office for National Statistics)
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
|
@@ -8,6 +8,9 @@ export default class TimeoutModal {
|
|
|
8
8
|
this.initialExpiryTime = initialExpiryTime;
|
|
9
9
|
this.continueButton = context.querySelector('.ons-js-modal-btn');
|
|
10
10
|
this.modalVisibleInMilliseconds = context.getAttribute('data-show-modal-time') * 1000;
|
|
11
|
+
this.expiryTime = '';
|
|
12
|
+
this.expiryTimeInMilliseconds = 0;
|
|
13
|
+
this.shouldRestartCheck = false;
|
|
11
14
|
|
|
12
15
|
// Create modal instance
|
|
13
16
|
this.modal = new Modal(this.context);
|
|
@@ -27,7 +30,8 @@ export default class TimeoutModal {
|
|
|
27
30
|
startTimeout() {
|
|
28
31
|
clearTimeout(this.showModalTimeout);
|
|
29
32
|
if (this.initialExpiryTime) {
|
|
30
|
-
this.
|
|
33
|
+
this.expiryTime = this.timeout.expiryTime;
|
|
34
|
+
this.expiryTimeInMilliseconds = this.timeout.convertTimeToMilliSeconds(this.expiryTime);
|
|
31
35
|
} else {
|
|
32
36
|
// For demo purposes
|
|
33
37
|
this.expiryTimeInMilliseconds = 60000;
|
|
@@ -39,18 +43,39 @@ export default class TimeoutModal {
|
|
|
39
43
|
}
|
|
40
44
|
|
|
41
45
|
async openModalAndStartCountdown() {
|
|
42
|
-
const modalWillOpen = await this.
|
|
46
|
+
const modalWillOpen = await this.hasExpiryTimeResetInAnotherTab();
|
|
43
47
|
if (modalWillOpen && !this.modal.isDialogOpen()) {
|
|
44
48
|
this.modal.openDialog();
|
|
45
49
|
this.timeout.startUiCountdown();
|
|
50
|
+
|
|
51
|
+
this.shouldRestartCheck = setInterval(async () => {
|
|
52
|
+
await this.hasExpiryTimeResetInAnotherTab();
|
|
53
|
+
}, 20000);
|
|
46
54
|
}
|
|
47
55
|
}
|
|
48
56
|
|
|
49
|
-
|
|
57
|
+
async hasExpiryTimeResetInAnotherTab() {
|
|
58
|
+
const checkExpiryTime = await this.timeout.getExpiryTime();
|
|
59
|
+
if (checkExpiryTime.substring(0, 19) != this.timeout.expiryTime.substring(0, 19)) {
|
|
60
|
+
// Substring is required as endpoint can at random return milliseconds with expiry time
|
|
61
|
+
this.expiryTime = checkExpiryTime;
|
|
62
|
+
this.expiryTimeInMilliseconds = this.timeout.convertTimeToMilliSeconds(checkExpiryTime);
|
|
63
|
+
this.closeModalAndRestartTimeout(this.expiryTimeInMilliseconds);
|
|
64
|
+
} else {
|
|
65
|
+
return true;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
async closeModalAndRestartTimeout(time) {
|
|
70
|
+
clearInterval(this.shouldRestartCheck);
|
|
71
|
+
|
|
72
|
+
if (typeof timeInMilliSeconds !== 'string') {
|
|
73
|
+
time = false;
|
|
74
|
+
}
|
|
50
75
|
if (this.modal.isDialogOpen()) {
|
|
51
76
|
this.modal.closeDialog();
|
|
52
77
|
}
|
|
53
|
-
this.timeout.restartTimeout();
|
|
78
|
+
await this.timeout.restartTimeout(time);
|
|
54
79
|
this.startTimeout();
|
|
55
80
|
}
|
|
56
81
|
|