@ons/design-system 61.0.0 → 61.0.2
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/access-code/_macro.njk +6 -8
- package/components/modal/modal.js +12 -6
- package/components/modal/modal.spec.js +0 -11
- package/components/summary/_macro.njk +2 -2
- package/components/summary/_summary.scss +3 -12
- package/components/timeout-modal/_macro.njk +19 -20
- package/components/timeout-modal/timeout-modal.spec.js +17 -13
- package/css/main.css +1 -1
- package/js/analytics.js +1 -5
- package/js/timeout.js +7 -0
- package/package.json +1 -1
- package/scripts/main.es5.js +1 -1
- package/scripts/main.js +1 -1
package/js/analytics.js
CHANGED
|
@@ -20,16 +20,12 @@ export const trackElement = el => {
|
|
|
20
20
|
});
|
|
21
21
|
};
|
|
22
22
|
|
|
23
|
-
const isVisible = el => {
|
|
24
|
-
return !!(el.offsetWidth || el.offsetHeight || el.getClientRects().length);
|
|
25
|
-
};
|
|
26
|
-
|
|
27
23
|
export default function initAnalytics() {
|
|
28
24
|
let trackVisibleElements = [...document.querySelectorAll('[data-ga=visible]')];
|
|
29
25
|
|
|
30
26
|
const interval = window.setInterval(() => {
|
|
31
27
|
trackVisibleElements = trackVisibleElements.filter(element => {
|
|
32
|
-
return
|
|
28
|
+
return element ? trackElement(element) && false : true;
|
|
33
29
|
});
|
|
34
30
|
if (trackVisibleElements.length === 0) {
|
|
35
31
|
window.clearInterval(interval);
|
package/js/timeout.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import initAnalytics from './analytics';
|
|
1
2
|
export default class Timeout {
|
|
2
3
|
constructor(context, sessionExpiryEndpoint, initialExpiryTime, enableTimeoutReset, startOnLoad) {
|
|
3
4
|
this.context = context;
|
|
@@ -8,6 +9,7 @@ export default class Timeout {
|
|
|
8
9
|
this.countdown = context.querySelector('.ons-js-timeout-timer');
|
|
9
10
|
this.accessibleCountdown = context.querySelector('.ons-js-timeout-timer-acc');
|
|
10
11
|
this.timeOutRedirectUrl = context.getAttribute('data-redirect-url');
|
|
12
|
+
this.setGAAttributes = context.getAttribute('data-enable-ga');
|
|
11
13
|
|
|
12
14
|
// Language dependent text strings
|
|
13
15
|
this.minutesTextSingular = context.getAttribute('data-minutes-text-singular');
|
|
@@ -79,6 +81,11 @@ export default class Timeout {
|
|
|
79
81
|
if (timerExpired) {
|
|
80
82
|
$this.countdown.innerHTML = '<span class="ons-u-fw-b">' + $this.countdownExpiredText + '</span>';
|
|
81
83
|
$this.accessibleCountdown.innerHTML = $this.countdownExpiredText;
|
|
84
|
+
if ($this.setGAAttributes && $this.context.classList.contains('ons-modal')) {
|
|
85
|
+
$this.context.setAttribute('data-ga-action', 'Modal closed by timed event');
|
|
86
|
+
$this.context.setAttribute('data-ga-label', `Timeout modal closed`);
|
|
87
|
+
initAnalytics();
|
|
88
|
+
}
|
|
82
89
|
setTimeout($this.redirect.bind($this), 2000);
|
|
83
90
|
} else {
|
|
84
91
|
seconds--;
|