@ons/design-system 46.0.0 → 46.1.0
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/components/modal/_macro.njk +1 -1
- package/components/panel/_macro.njk +5 -1
- package/components/panel/_panel.scss +4 -0
- package/components/timeout-modal/_macro.njk +3 -2
- package/components/timeout-modal/{timeout.dom.js → timeout-modal.dom.js} +2 -2
- package/components/timeout-modal/timeout-modal.js +62 -0
- package/components/timeout-panel/_macro.njk +26 -0
- package/components/timeout-panel/timeout-panel.dom.js +17 -0
- package/css/census.css +1 -1
- package/css/main.css +1 -1
- package/js/main.js +2 -1
- package/{components/timeout-modal → js}/timeout.js +42 -79
- package/package.json +1 -1
- package/scripts/main.es5.js +1 -1
- package/scripts/main.js +1 -1
|
@@ -29,6 +29,8 @@
|
|
|
29
29
|
{% if params is defined and params and params.type == "warn-branded" or params.type == "announcement" %}
|
|
30
30
|
<div class="{{containerClass}}">
|
|
31
31
|
<div class="ons-container">
|
|
32
|
+
{% elif params.type is defined and params.type == "warn" %}
|
|
33
|
+
<div class="ons-container">
|
|
32
34
|
{% endif %}
|
|
33
35
|
|
|
34
36
|
<div {% if params is defined and params and params.type == 'error' and params.title is defined and params.title %}aria-labelledby="error-summary-title" role="alert" tabindex="-1" {% if params.dsExample != true %}autofocus="autofocus" {% endif %}{% endif %}class="ons-panel{{ typeClass }}{{ iconClass }}{{ noTitleClass }}{{ spaciousClass }}{{ classes }}"{% if params is defined and params and params.attributes is defined and params.attributes %}{% for attribute, value in (params.attributes.items() if params is defined and params and params.attributes is mapping and params.attributes.items is defined and params.attributes.items else params.attributes) %}{{attribute}}="{{value}}" {% endfor %}{% endif %}{% if params is defined and params and params.id is defined and params.id %} id="{{params.id}}"{% endif %}>
|
|
@@ -86,7 +88,7 @@
|
|
|
86
88
|
{% endif %}
|
|
87
89
|
{% endif %}
|
|
88
90
|
|
|
89
|
-
<div class="ons-panel__body{% if params is defined and params and params.iconSize is defined and params.iconSize %} ons-svg-icon-margin--{{ params.iconSize }}{% endif %}"
|
|
91
|
+
<div class="ons-panel__body{% if params is defined and params and params.iconSize is defined and params.iconSize %} ons-svg-icon-margin--{{ params.iconSize }}{% endif %}">{{ (params.body if params else "") | safe }}
|
|
90
92
|
{{ caller() if caller }}
|
|
91
93
|
</div>
|
|
92
94
|
|
|
@@ -95,6 +97,8 @@
|
|
|
95
97
|
{% if params is defined and params and params.type == "warn-branded" or params.type == "announcement" %}
|
|
96
98
|
</div>
|
|
97
99
|
</div>
|
|
100
|
+
{% elif params.type is defined and params.type == "warn" %}
|
|
101
|
+
</div>
|
|
98
102
|
{% endif %}
|
|
99
103
|
|
|
100
104
|
{% endmacro %}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{% from "components/modal/_macro.njk" import onsModal %}
|
|
2
|
-
{% macro onsTimeoutModal(params) %}
|
|
2
|
+
{% macro onsTimeoutModal(params) %}
|
|
3
3
|
{% call onsModal({
|
|
4
4
|
"title": params.title,
|
|
5
5
|
"btnText": params.btnText,
|
|
@@ -10,11 +10,12 @@
|
|
|
10
10
|
"data-show-modal-time": params.showModalTimeInSeconds,
|
|
11
11
|
"data-server-session-expiry-endpoint": params.serverSessionExpiryEndpoint,
|
|
12
12
|
"data-countdown-text": params.countdownText,
|
|
13
|
-
"data-
|
|
13
|
+
"data-countdown-expired-text": params.countdownExpiredText,
|
|
14
14
|
"data-minutes-text-singular": params.minutesTextSingular,
|
|
15
15
|
"data-minutes-text-plural": params.minutesTextPlural,
|
|
16
16
|
"data-seconds-text-singular": params.secondsTextSingular,
|
|
17
17
|
"data-seconds-text-plural": params.secondsTextPlural,
|
|
18
|
+
"data-full-stop": params.endWithFullStop,
|
|
18
19
|
"aria-describedby": "timeout-time-remaining"
|
|
19
20
|
}
|
|
20
21
|
})
|
|
@@ -4,12 +4,12 @@ async function modals() {
|
|
|
4
4
|
const timeouts = [...document.querySelectorAll('.ons-js-timeout-modal')];
|
|
5
5
|
|
|
6
6
|
if (timeouts.length) {
|
|
7
|
-
const
|
|
7
|
+
const TimeoutModal = (await import('./timeout-modal')).default;
|
|
8
8
|
|
|
9
9
|
timeouts.forEach(context => {
|
|
10
10
|
let url = context.getAttribute('data-server-session-expiry-endpoint');
|
|
11
11
|
let time = context.getAttribute('data-server-session-expires-at');
|
|
12
|
-
new
|
|
12
|
+
new TimeoutModal(context, url, time);
|
|
13
13
|
});
|
|
14
14
|
}
|
|
15
15
|
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import Modal from '../modal/modal';
|
|
2
|
+
import Timeout from '../../js/timeout';
|
|
3
|
+
|
|
4
|
+
export default class TimeoutModal {
|
|
5
|
+
constructor(context, sessionExpiryEndpoint, initialExpiryTime) {
|
|
6
|
+
this.context = context;
|
|
7
|
+
this.sessionExpiryEndpoint = sessionExpiryEndpoint;
|
|
8
|
+
this.initialExpiryTime = initialExpiryTime;
|
|
9
|
+
this.continueButton = context.querySelector('.ons-js-modal-btn');
|
|
10
|
+
this.modalVisibleInMilliseconds = context.getAttribute('data-show-modal-time') * 1000;
|
|
11
|
+
|
|
12
|
+
// Create modal instance
|
|
13
|
+
this.modal = new Modal(this.context);
|
|
14
|
+
|
|
15
|
+
// Create timeout instance
|
|
16
|
+
this.timeout = new Timeout(this.context, this.sessionExpiryEndpoint, this.initialExpiryTime, true);
|
|
17
|
+
|
|
18
|
+
this.bindEventListeners();
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
bindEventListeners() {
|
|
22
|
+
window.onload = this.startTimeout();
|
|
23
|
+
window.addEventListener('keydown', this.escToClose.bind(this));
|
|
24
|
+
this.continueButton.addEventListener('click', this.closeModalAndRestartTimeout.bind(this));
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
startTimeout() {
|
|
28
|
+
clearTimeout(this.showModalTimeout);
|
|
29
|
+
if (this.initialExpiryTime) {
|
|
30
|
+
this.expiryTimeInMilliseconds = this.timeout.convertTimeToMilliSeconds(this.initialExpiryTime);
|
|
31
|
+
} else {
|
|
32
|
+
// For demo purposes
|
|
33
|
+
this.expiryTimeInMilliseconds = 60000;
|
|
34
|
+
}
|
|
35
|
+
this.showModalTimeout = setTimeout(
|
|
36
|
+
this.openModalAndStartCountdown.bind(this),
|
|
37
|
+
this.expiryTimeInMilliseconds - this.modalVisibleInMilliseconds,
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
async openModalAndStartCountdown() {
|
|
42
|
+
const modalWillOpen = await this.timeout.hasExpiryTimeResetInAnotherTab();
|
|
43
|
+
if (modalWillOpen && !this.modal.isDialogOpen()) {
|
|
44
|
+
this.modal.openDialog();
|
|
45
|
+
this.timeout.startUiCountdown();
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
closeModalAndRestartTimeout() {
|
|
50
|
+
if (this.modal.isDialogOpen()) {
|
|
51
|
+
this.modal.closeDialog();
|
|
52
|
+
}
|
|
53
|
+
this.timeout.restartTimeout();
|
|
54
|
+
this.startTimeout();
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
escToClose(event) {
|
|
58
|
+
if (this.modal.isDialogOpen() && event.keyCode === 27) {
|
|
59
|
+
this.closeModalAndRestartTimeout();
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{% from "components/panel/_macro.njk" import onsPanel %}
|
|
2
|
+
{% macro onsTimeoutPanel(params) %}
|
|
3
|
+
{% call onsPanel({
|
|
4
|
+
"id": params.id,
|
|
5
|
+
"classes": "ons-js-panel-with-countdown",
|
|
6
|
+
"type": "warn",
|
|
7
|
+
"attributes": {
|
|
8
|
+
"data-redirect-url": params.redirectUrl,
|
|
9
|
+
"data-server-session-expires-at": params.sessionExpiresAt,
|
|
10
|
+
"data-server-session-expiry-endpoint": params.serverSessionExpiryEndpoint,
|
|
11
|
+
"data-countdown-text": params.countdownText,
|
|
12
|
+
"data-countdown-expired-text": params.countdownExpiredText,
|
|
13
|
+
"data-minutes-text-singular": params.minutesTextSingular,
|
|
14
|
+
"data-minutes-text-plural": params.minutesTextPlural,
|
|
15
|
+
"data-seconds-text-singular": params.secondsTextSingular,
|
|
16
|
+
"data-seconds-text-plural": params.secondsTextPlural,
|
|
17
|
+
"data-full-stop": params.endWithFullStop,
|
|
18
|
+
"aria-describedby": "timeout-time-remaining"
|
|
19
|
+
}
|
|
20
|
+
})
|
|
21
|
+
%}
|
|
22
|
+
<noscript><p class="ons-js-nojs-text">{{ params.nojsText }}</p></noscript>
|
|
23
|
+
<p class="ons-js-timeout-timer" aria-hidden="true" aria-relevant="additions"></p>
|
|
24
|
+
<p class="ons-js-timeout-timer-acc ons-u-vh" role="status" id="timeout-time-remaining"></p>
|
|
25
|
+
{% endcall %}
|
|
26
|
+
{% endmacro %}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import domready from '../../js/domready';
|
|
2
|
+
|
|
3
|
+
async function timeoutPanels() {
|
|
4
|
+
const panels = [...document.querySelectorAll('.ons-js-panel-with-countdown')];
|
|
5
|
+
|
|
6
|
+
if (panels.length) {
|
|
7
|
+
const Timeout = (await import('../../js/timeout')).default;
|
|
8
|
+
|
|
9
|
+
panels.forEach(context => {
|
|
10
|
+
let url = context.getAttribute('data-server-session-expiry-endpoint');
|
|
11
|
+
let time = context.getAttribute('data-server-session-expires-at');
|
|
12
|
+
new Timeout(context, url, time, false, true);
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
domready(timeoutPanels);
|