hof 22.0.1 → 22.0.3-nodemailer-dependency-beta

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.
Files changed (39) hide show
  1. package/.nyc_output/269ca22b-40c0-48fe-8fde-8cd21f2c2174.json +1 -0
  2. package/.nyc_output/processinfo/269ca22b-40c0-48fe-8fde-8cd21f2c2174.json +1 -0
  3. package/.nyc_output/processinfo/index.json +1 -0
  4. package/CHANGELOG.md +0 -13
  5. package/README.md +27 -111
  6. package/components/emailer/transports/smtp.js +1 -1
  7. package/components/index.js +1 -2
  8. package/config/hof-defaults.js +1 -5
  9. package/controller/controller.js +0 -4
  10. package/frontend/govuk-template/govuk_template_generated.html +102 -0
  11. package/frontend/template-partials/views/confirmation.html +4 -17
  12. package/frontend/template-partials/views/partials/head.html +0 -3
  13. package/frontend/template-partials/views/partials/page.html +0 -1
  14. package/frontend/themes/gov-uk/client-js/index.js +0 -1
  15. package/frontend/themes/gov-uk/styles/govuk.scss +0 -1
  16. package/index.js +4 -11
  17. package/lib/router.js +0 -2
  18. package/package.json +3 -5
  19. package/sandbox/.env +3 -0
  20. package/sandbox/apps/sandbox/index.js +0 -4
  21. package/sandbox/apps/sandbox/translations/en/default.json +239 -0
  22. package/sandbox/apps/sandbox/translations/src/en/pages.json +1 -16
  23. package/sandbox/public/css/app.css +9552 -0
  24. package/sandbox/public/images/icons/icon-caret-left.png +0 -0
  25. package/sandbox/public/images/icons/icon-complete.png +0 -0
  26. package/sandbox/public/images/icons/icon-cross-remove-sign.png +0 -0
  27. package/sandbox/public/js/bundle.js +47603 -0
  28. package/sandbox/server.js +0 -5
  29. package/wizard/index.js +0 -2
  30. package/components/session-timeout-warning/index.js +0 -67
  31. package/frontend/template-partials/translations/src/en/exit.json +0 -5
  32. package/frontend/template-partials/translations/src/en/save-and-exit.json +0 -4
  33. package/frontend/template-partials/views/exit.html +0 -9
  34. package/frontend/template-partials/views/partials/session-timeout-warning.html +0 -38
  35. package/frontend/template-partials/views/save-and-exit.html +0 -17
  36. package/frontend/themes/gov-uk/client-js/session-timeout-dialog.js +0 -348
  37. package/frontend/themes/gov-uk/styles/_session-timeout-dialog.scss +0 -121
  38. package/sandbox/apps/sandbox/translations/src/en/exit.json +0 -4
  39. package/sandbox/apps/sandbox/views/save-and-exit.html +0 -19
package/sandbox/server.js CHANGED
@@ -8,16 +8,11 @@ bootstrap({
8
8
  routes: [
9
9
  require('./apps/sandbox')
10
10
  ],
11
- behaviours: [
12
- require('../').components.sessionTimeoutWarning
13
- ],
14
11
  rateLimits: {
15
12
  requests: {
16
13
  active: true
17
14
  }
18
15
  },
19
16
  getAccessibility: true,
20
- sessionTimeoutWarningContent: true,
21
- exitFormContent: true,
22
17
  "port": 8082
23
18
  });
package/wizard/index.js CHANGED
@@ -67,8 +67,6 @@ const Wizard = (steps, fields, setts) => {
67
67
  options.route = route;
68
68
  options.appConfig = settings.appConfig;
69
69
  options.confirmStep = settings.confirmStep;
70
- options.exitStep = settings.exitStep;
71
- options.saveAndExitStep = settings.saveAndExitStep;
72
70
  options.clearSession = options.clearSession || false;
73
71
  options.fieldsConfig = _.cloneDeep(fields);
74
72
  options.sanitiseInputs = settings.sanitiseInputs;
@@ -1,67 +0,0 @@
1
- /**
2
- *
3
- * @fileOverview
4
- * Provides custom behavior for handling session timeout warnings and exit actions. This includes
5
- * - Resetting the session if the user exits due to a session timeout.
6
- * - Customizing the session timeout warning dialog content.
7
- * - Setting custom content and titles on the exit page.
8
- *
9
- * @module SessionTimeoutWarningBehavior
10
- * @requires ../../config/hof-defaults
11
- * @param {Class} superclass - The class to be extended.
12
- * @returns {Class} - The extended class with session timeout handling functionality.
13
- */
14
-
15
- 'use strict';
16
- const config = require('../../config/hof-defaults');
17
- const logger = require('../../lib/logger')(config);
18
-
19
- module.exports = superclass => class extends superclass {
20
- configure(req, res, next) {
21
- try {
22
- // Reset the session if the user chooses to exit on session timeout warning
23
- if (req.form.options.route === '/exit') {
24
- req.sessionModel.reset();
25
- logger.log('info', 'Session has been reset on exit');
26
- }
27
- return super.configure(req, res, next);
28
- } catch (error) {
29
- logger.error('Error during session reset:', error);
30
- return next(error); // Pass the error to the next middleware for centralised handling
31
- }
32
- }
33
-
34
- locals(req, res) {
35
- // set the custom session dialog message
36
- const superLocals = super.locals(req, res);
37
- if (res.locals.sessionTimeoutWarningContent === true) {
38
- superLocals.dialogTitle = true;
39
- superLocals.dialogText = true;
40
- superLocals.timeoutContinueButton = true;
41
- superLocals.dialogExitLink = true;
42
- }
43
-
44
- // set the content on /exit page
45
- if (req.form.options.route === '/exit' && config.exitFormContent === true) {
46
- superLocals.exitFormContent = true;
47
- return superLocals;
48
- } else if (req.form.options.route === '/exit' && config.exitFormContent === false) {
49
- superLocals.header = req.translate('exit.header');
50
- superLocals.title = req.translate('exit.title');
51
- superLocals.message = req.translate('exit.message');
52
- return superLocals;
53
- }
54
-
55
- // set the content on /save-and-exit page
56
- if (req.form.options.route === '/save-and-exit' && config.saveExitFormContent === true) {
57
- superLocals.saveExitFormContent = true;
58
- return superLocals;
59
- } else if (req.form.options.route === '/save-and-exit' && config.saveExitFormContent === false) {
60
- superLocals.header = req.translate('save-and-exit.header');
61
- superLocals.title = req.translate('save-and-exit.title');
62
- superLocals.message = req.translate('save-and-exit.message');
63
- return superLocals;
64
- }
65
- return superLocals;
66
- }
67
- };
@@ -1,5 +0,0 @@
1
- {
2
- "header": "You have left this form",
3
- "title": "You have left this form",
4
- "message": "We have cleared your information to keep it secure. Your information has not been saved."
5
- }
@@ -1,4 +0,0 @@
1
- {
2
- "header": "You have been signed out",
3
- "message": "Any answers you saved have not been affected. You can sign back in to your application by returning to the <a href='/' class='govuk-link'>start page</a>."
4
- }
@@ -1,9 +0,0 @@
1
- {{<layout}}
2
- {{$header}}
3
- {{header}}
4
- {{/header}}
5
- {{$content}}
6
- <h2 class="govuk-heading-m">{{#exitFormContent}}{{#t}}pages.exit.message{{/t}}{{/exitFormContent}}{{^exitFormContent}}{{#t}}{{message}}{{/t}}{{/exitFormContent}}</h2>
7
- <a href="/" class="govuk-button" role="button">{{#t}}buttons.start-again{{/t}}</a>
8
- {{/content}}
9
- {{/layout}}
@@ -1,38 +0,0 @@
1
- <div class="govuk-timeout-warning-fallback">
2
- <p>We will reset your application if you do not complete the page and press continue
3
- in 5 minutes.</p>
4
- <p>We do this to keep your information secure.</p>
5
- </div>
6
-
7
- <dialog id="js-modal-dialog" data-session-timeout="{{sessionTimeOut}}" data-session-timeout-warning="{{sessionTimeOutWarning}}"
8
- data-url-redirect="/session-timeout" class="modal-dialog dialog" role="dialog"
9
- aria-live="polite" aria-labelledby="dialog-title" aria-describedby="at-timer">
10
- <div class="modal-dialog__inner">
11
- {{^showSaveAndExit}}
12
- <h2 id="dialog-title" class="govuk-heading-l">
13
- {{#dialogTitle}}{{#t}}pages.session-timeout-warning.dialog-title{{/t}}{{/dialogTitle}}{{^dialogTitle}}Your page will time out soon{{/dialogTitle}}
14
- </h2>
15
- <div class="govuk-body">
16
- <div id="timer" class="timer" aria-hidden="true" aria-relevant="additions"></div>
17
- <div id="at-timer" class="at-timer govuk-visually-hidden" role="status"></div>
18
- <p class="dialog-text-prefix visually-hidden">To protect your information, this page will time out in </p>
19
- <p class="dialog-text visually-hidden">{{#dialogText}}{{#t}}pages.session-timeout-warning.dialog-text{{/t}}{{/dialogText}}{{^dialogText}}If that happens, your progress will not be saved.{{/dialogText}}</p>
20
- </div>
21
- <button class="govuk-button dialog-button js-dialog-close" id="timeout-continue-button" data-module="govuk-button">{{#timeoutContinueButton}}{{#t}}pages.session-timeout-warning.timeout-continue-button{{/t}}{{/timeoutContinueButton}}{{^timeoutContinueButton}}Stay on this page{{/timeoutContinueButton}}</button>
22
- <a href="{{baseUrl}}{{exitStep}}" class="govuk-link dialog-exit-link" role="button">{{#dialogExitLink}}{{#t}}pages.session-timeout-warning.dialog-exit-link{{/t}}{{/dialogExitLink}}{{^dialogExitLink}}Exit this form{{/dialogExitLink}}</a>
23
- {{/showSaveAndExit}}
24
- {{#showSaveAndExit}}
25
- <h2 id="dialog-title" class="govuk-heading-l">
26
- {{#dialogTitle}}{{#t}}pages.session-timeout-warning.dialog-title{{/t}}{{/dialogTitle}}{{^dialogTitle}}You will be signed out soon{{/dialogTitle}}
27
- </h2>
28
- <div class="govuk-body">
29
- <div id="timer" class="timer" aria-hidden="true" aria-relevant="additions"></div>
30
- <div id="at-timer" class="at-timer govuk-visually-hidden" role="status"></div>
31
- <p class="dialog-text-prefix visually-hidden">To protect your information, you will be signed out in </p>
32
- <p class="dialog-text visually-hidden">{{#dialogText}}{{#t}}pages.session-timeout-warning.dialog-text{{/t}}{{/dialogText}}{{^dialogText}}Any answers you have saved will not be affected, but your progress on this page will not be saved.{{/dialogText}}</p>
33
- </div>
34
- <button class="govuk-button dialog-button js-dialog-close" id="timeout-continue-button" data-module="govuk-button">{{#timeoutContinueButton}}{{#t}}pages.session-timeout-warning.timeout-continue-button{{/t}}{{/timeoutContinueButton}}{{^timeoutContinueButton}}Stay signed in{{/timeoutContinueButton}}</button>
35
- <a href="{{baseUrl}}{{saveAndExitStep}}" class="govuk-link dialog-exit-link" role="button">{{#dialogExitLink}}{{#t}}pages.session-timeout-warning.dialog-exit-link{{/t}}{{/dialogExitLink}}{{^dialogExitLink}}Sign out{{/dialogExitLink}}</a>
36
- {{/showSaveAndExit}}
37
- </div>
38
- </dialog>
@@ -1,17 +0,0 @@
1
- {{<layout}}
2
- {{$journeyHeader}}
3
- {{#t}}journey.header{{/t}}
4
- {{/journeyHeader}}
5
-
6
- {{$propositionHeader}}
7
- {{> partials-navigation}}
8
- {{/propositionHeader}}
9
-
10
- {{$header}}
11
- {{header}}
12
- {{/header}}
13
-
14
- {{$content}}
15
- <p>{{#saveExitFormContent}}{{#t}}pages.save-and-exit.message{{/t}}{{/saveExitFormContent}}{{^saveExitFormContent}}{{{message}}}{{/saveExitFormContent}}</p>
16
- {{/content}}
17
- {{/layout}}
@@ -1,348 +0,0 @@
1
- /* eslint max-len: 0 */
2
- 'use strict';
3
-
4
- const $ = require('jquery');
5
- window.dialogPolyfill = require('dialog-polyfill');
6
-
7
- // Modal dialog prototype
8
- window.GOVUK.sessionDialog = {
9
- el: document.getElementById('js-modal-dialog'),
10
- $el: $('#js-modal-dialog'),
11
- $lastFocusedEl: null,
12
- $closeButton: $('.modal-dialog .js-dialog-close'),
13
- $fallBackElement: $('.govuk-timeout-warning-fallback'),
14
- dialogIsOpenClass: 'dialog-is-open',
15
- timers: [],
16
- warningTextPrefix: $('.dialog-text-prefix').text(),
17
- warningTextSuffix: '.',
18
- warningText: $('.dialog-text').text(),
19
- warningTextExtra: '',
20
-
21
- // Timer specific markup. If these are not present, timeout and redirection are disabled
22
- $timer: $('#js-modal-dialog .timer'),
23
- $accessibleTimer: $('#js-modal-dialog .at-timer'),
24
-
25
- secondsSessionTimeout: parseInt($('#js-modal-dialog').data('session-timeout'), 10 || 1800),
26
- secondsTimeoutWarning: parseInt($('#js-modal-dialog').data('session-timeout-warning'), 10 || 300),
27
- timeoutRedirectUrl: $('#js-modal-dialog').data('url-redirect'),
28
- timeSessionRefreshed: new Date(),
29
-
30
- bindUIElements: function () {
31
- window.GOVUK.sessionDialog.$closeButton.on('click', function (e) {
32
- e.preventDefault();
33
- window.GOVUK.sessionDialog.closeDialog();
34
- });
35
-
36
- // Close modal when ESC pressed
37
- $(document).keydown(function (e) {
38
- if (window.GOVUK.sessionDialog.isDialogOpen() && e.keyCode === 27) {
39
- window.GOVUK.sessionDialog.closeDialog();
40
- }
41
- });
42
- },
43
-
44
- isDialogOpen: function () {
45
- return window.GOVUK.sessionDialog.el && window.GOVUK.sessionDialog.el.open;
46
- },
47
-
48
- isConfigured: function () {
49
- return window.GOVUK.sessionDialog.$timer.length > 0 &&
50
- window.GOVUK.sessionDialog.$accessibleTimer.length > 0 &&
51
- window.GOVUK.sessionDialog.secondsSessionTimeout &&
52
- window.GOVUK.sessionDialog.secondsTimeoutWarning &&
53
- window.GOVUK.sessionDialog.timeoutRedirectUrl;
54
- },
55
-
56
- openDialog: function () {
57
- if (!window.GOVUK.sessionDialog.isDialogOpen()) {
58
- $('html, body').addClass(window.GOVUK.sessionDialog.dialogIsOpenClass);
59
- window.GOVUK.sessionDialog.saveLastFocusedEl();
60
- window.GOVUK.sessionDialog.makePageContentInert();
61
- window.GOVUK.sessionDialog.el.showModal();
62
- window.GOVUK.sessionDialog.el.open = true;
63
- }
64
- },
65
-
66
- closeDialog: function () {
67
- if (window.GOVUK.sessionDialog.isDialogOpen()) {
68
- $('html, body').removeClass(window.GOVUK.sessionDialog.dialogIsOpenClass);
69
- window.GOVUK.sessionDialog.el.close();
70
- window.GOVUK.sessionDialog.el.open = false;
71
- window.GOVUK.sessionDialog.setFocusOnLastFocusedEl();
72
- window.GOVUK.sessionDialog.removeInertFromPageContent();
73
- window.GOVUK.sessionDialog.refreshSession();
74
- }
75
- },
76
-
77
- saveLastFocusedEl: function () {
78
- window.GOVUK.sessionDialog.$lastFocusedEl = document.activeElement;
79
- if (!window.GOVUK.sessionDialog.$lastFocusedEl || window.GOVUK.sessionDialog.$lastFocusedEl === document.body) {
80
- window.GOVUK.sessionDialog.$lastFocusedEl = null;
81
- } else if (document.querySelector) {
82
- window.GOVUK.sessionDialog.$lastFocusedEl = document.querySelector(':focus');
83
- }
84
- },
85
-
86
- // Set focus back on last focused el when modal closed
87
- setFocusOnLastFocusedEl: function () {
88
- if (window.GOVUK.sessionDialog.$lastFocusedEl) {
89
- window.setTimeout(function () {
90
- window.GOVUK.sessionDialog.$lastFocusedEl.focus();
91
- }, 0);
92
- }
93
- },
94
-
95
- // Set page content to inert to indicate to screenreaders it's inactive
96
- // NB: This will look for #content for toggling inert state
97
- makePageContentInert: function () {
98
- if (document.querySelector('#content')) {
99
- document.querySelector('#content').inert = true;
100
- document.querySelector('#content').setAttribute('aria-hidden', 'true');
101
- }
102
- },
103
-
104
- // Make page content active when modal is not open
105
- // NB: This will look for #content for toggling inert state
106
- removeInertFromPageContent: function () {
107
- if (document.querySelector('#content')) {
108
- document.querySelector('#content').inert = false;
109
- document.querySelector('#content').setAttribute('aria-hidden', 'false');
110
- }
111
- },
112
-
113
- numberToWords: function (n) {
114
- const string = n.toString();
115
- let start;
116
- let end;
117
- let chunk;
118
- let ints;
119
- let i;
120
- let words = 'and';
121
-
122
- if (parseInt(string, 10) === 0) {
123
- return 'zero';
124
- }
125
-
126
- /* Array of units as words */
127
- const units = ['', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen'];
128
-
129
- /* Array of tens as words */
130
- const tens = ['', '', 'twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety'];
131
-
132
- /* Array of scales as words */
133
- const scales = ['', 'thousand', 'million', 'billion', 'trillion', 'quadrillion', 'quintillion', 'sextillion', 'septillion', 'octillion', 'nonillion', 'decillion', 'undecillion', 'duodecillion', 'tredecillion', 'quatttuor-decillion', 'quindecillion', 'sexdecillion', 'septen-decillion', 'octodecillion', 'novemdecillion', 'vigintillion', 'centillion'];
134
-
135
- /* Split user argument into 3 digit chunks from right to left */
136
- start = string.length;
137
- const chunks = [];
138
- while (start > 0) {
139
- end = start;
140
- chunks.push(string.slice((start = Math.max(0, start - 3)), end));
141
- }
142
-
143
- /* Check if function has enough scale words to be able to stringify the user argument */
144
- const chunksLen = chunks.length;
145
- if (chunksLen > scales.length) {
146
- return '';
147
- }
148
-
149
- /* Stringify each integer in each chunk */
150
- words = [];
151
- for (i = 0; i < chunksLen; i++) {
152
- chunk = parseInt(chunks[i], 10);
153
-
154
- if (chunk) {
155
- /* Split chunk into array of individual integers */
156
- ints = chunks[i].split('').reverse().map(parseFloat);
157
-
158
- /* If tens integer is 1, i.e. 10, then add 10 to units integer */
159
- if (ints[1] === 1) {
160
- ints[0] += 10;
161
- }
162
-
163
- /* Add scale word if chunk array item exists */
164
- if (scales[i]) {
165
- words.push(scales[i]);
166
- }
167
-
168
- /* Add unit word if array item exists */
169
- if (units[ints[0]]) {
170
- words.push(units[ints[0]]);
171
- }
172
-
173
- /* Add tens word if array item exists */
174
- if (tens[ints[1]]) {
175
- words.push(tens[ints[1]]);
176
- }
177
-
178
- /* Add hundreds word if array item exists */
179
- if (units[ints[2]]) {
180
- words.push(units[ints[2]] + ' hundred');
181
- }
182
- }
183
- }
184
- return words.reverse().join(' ');
185
- },
186
-
187
- // Attempt to convert numerics into text as OS VoiceOver
188
- // occasionally stalled when encountering numbers
189
- timeToWords: function (t, unit) {
190
- let words;
191
- if (t > 0) {
192
- try {
193
- words = window.GOVUK.sessionDialog.numberToWords(t);
194
- } catch (e) {
195
- words = t;
196
- }
197
- words = words + ' ' + window.GOVUK.sessionDialog.pluralise(t, unit);
198
- } else {
199
- words = '';
200
- }
201
- return words;
202
- },
203
-
204
- pluralise: function (n, unit) {
205
- return n === 1 ? unit : unit + 's';
206
- },
207
-
208
- numericSpan: function (n, unit) {
209
- return '<span class="tabular-numbers">' + n + '</span> ' + window.GOVUK.sessionDialog.pluralise(n, unit);
210
- },
211
-
212
- countdownText: function (minutes, seconds) {
213
- const minutesText = window.GOVUK.sessionDialog.numericSpan(minutes, 'minute');
214
- const secondsText = window.GOVUK.sessionDialog.numericSpan(seconds, 'second');
215
- return minutes > 0 ? minutesText : secondsText;
216
- },
217
-
218
- countdownAtText: function (minutes, seconds) {
219
- const minutesText = window.GOVUK.sessionDialog.timeToWords(minutes, 'minute');
220
- const secondsText = window.GOVUK.sessionDialog.timeToWords(seconds, 'second');
221
- return minutes > 0 ? minutesText : secondsText;
222
- },
223
-
224
- startCountdown: function () {
225
- const $timer = window.GOVUK.sessionDialog.$timer;
226
- const $accessibleTimer = window.GOVUK.sessionDialog.$accessibleTimer;
227
- let timerRunOnce = false;
228
- const iOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
229
-
230
- const seconds = window.GOVUK.sessionDialog.secondsUntilSessionTimeout();
231
- const minutes = seconds / 60;
232
-
233
- $timer.text(minutes + ' minute' + (minutes > 1 ? 's' : ''));
234
-
235
- (function countdown() {
236
- const secondsUntilSessionTimeout = window.GOVUK.sessionDialog.secondsUntilSessionTimeout();
237
- const timerExpired = secondsUntilSessionTimeout <= 0;
238
-
239
- if (!timerExpired) {
240
- const minutesLeft = parseInt(secondsUntilSessionTimeout / 60, 10);
241
- const secondsLeft = parseInt(secondsUntilSessionTimeout % 60, 10);
242
-
243
- // Below string will get read out by screen readers every time
244
- // the timeout refreshes.
245
- // Add additional information in extraText which will get announced to AT the
246
- // first time the time out opens
247
- const countdownText = window.GOVUK.sessionDialog.countdownText(minutesLeft, secondsLeft);
248
- const text = window.GOVUK.sessionDialog.warningTextPrefix + '<strong>' + countdownText + '</strong>' + window.GOVUK.sessionDialog.warningTextSuffix + '<p>' + window.GOVUK.sessionDialog.warningText + '</p>';
249
- const countdownAtText = window.GOVUK.sessionDialog.countdownAtText(minutesLeft, secondsLeft);
250
- const atText = window.GOVUK.sessionDialog.warningTextPrefix + countdownAtText + window.GOVUK.sessionDialog.warningTextSuffix + ' ' + window.GOVUK.sessionDialog.warningText;
251
- const extraText = '\n' + window.GOVUK.sessionDialog.warningTextExtra;
252
-
253
- $timer.html(text + ' ' + extraText);
254
-
255
- // Update screen reader friendly content every 20 secs
256
- if (secondsLeft % 20 === 0) {
257
- // Read out the extra content only once.
258
- // Don't read out on iOS VoiceOver which stalls on the longer text
259
- if (!timerRunOnce && !iOS) {
260
- $accessibleTimer.text(atText + extraText);
261
- timerRunOnce = true;
262
- } else {
263
- $accessibleTimer.text(atText);
264
- }
265
- }
266
-
267
- window.GOVUK.sessionDialog.addTimer(countdown, 20);
268
- }
269
- })();
270
- },
271
-
272
- // Clears all timers
273
- clearTimers: function () {
274
- for (let i = 0; i < window.GOVUK.sessionDialog.timers.length; i++) {
275
- clearInterval(window.GOVUK.sessionDialog.timers[i]);
276
- }
277
- },
278
-
279
- refreshSession: function () {
280
- $.get('');
281
- window.GOVUK.sessionDialog.timeSessionRefreshed = new Date();
282
- window.GOVUK.sessionDialog.controller();
283
- },
284
-
285
- redirect: function () {
286
- window.location = window.GOVUK.sessionDialog.timeoutRedirectUrl;
287
- },
288
-
289
- // JS doesn't allow resetting timers globally so timers need
290
- // to be retained for resetting.
291
- addTimer: function (f, seconds) {
292
- window.GOVUK.sessionDialog.timers.push(setInterval(f, seconds * 1000));
293
- },
294
-
295
- secondsSinceRefresh: function () {
296
- return Math.round(Math.abs((window.GOVUK.sessionDialog.timeSessionRefreshed - new Date()) / 1000));
297
- },
298
-
299
- secondsUntilSessionTimeout: function () {
300
- return window.GOVUK.sessionDialog.secondsSessionTimeout - window.GOVUK.sessionDialog.secondsSinceRefresh();
301
- },
302
-
303
- secondsUntilTimeoutWarning: function () {
304
- return window.GOVUK.sessionDialog.secondsUntilSessionTimeout() - window.GOVUK.sessionDialog.secondsTimeoutWarning;
305
- },
306
-
307
- // countdown controller logic
308
- controller: function () {
309
- window.GOVUK.sessionDialog.clearTimers();
310
-
311
- const secondsUntilSessionTimeout = window.GOVUK.sessionDialog.secondsUntilSessionTimeout();
312
-
313
- if (secondsUntilSessionTimeout <= 0) {
314
- // timed out - redirect
315
- window.GOVUK.sessionDialog.redirect();
316
- } else if (secondsUntilSessionTimeout <= window.GOVUK.sessionDialog.secondsTimeoutWarning) {
317
- // timeout warning - show countdown and schedule redirect
318
- window.GOVUK.sessionDialog.openDialog();
319
- window.GOVUK.sessionDialog.startCountdown();
320
- window.GOVUK.sessionDialog.addTimer(window.GOVUK.sessionDialog.controller, window.GOVUK.sessionDialog.secondsUntilSessionTimeout());
321
- } else {
322
- // wait for warning
323
- window.GOVUK.sessionDialog.addTimer(window.GOVUK.sessionDialog.controller, window.GOVUK.sessionDialog.secondsUntilTimeoutWarning());
324
- }
325
- },
326
-
327
- init: function (options) {
328
- $.extend(window.GOVUK.sessionDialog, options);
329
- if (window.GOVUK.sessionDialog.el && window.GOVUK.sessionDialog.isConfigured()) {
330
- // Native dialog is not supported by some browsers so use polyfill
331
- if (typeof HTMLDialogElement !== 'function') {
332
- try {
333
- window.dialogPolyfill.registerDialog(window.GOVUK.sessionDialog.el);
334
- return true;
335
- } catch (error) {
336
- // Doesn't support polyfill (IE8) - display fallback element
337
- window.GOVUK.sessionDialog.$fallBackElement.classList.add('govuk-!-display-block');
338
- return false;
339
- }
340
- }
341
- window.GOVUK.sessionDialog.bindUIElements();
342
- window.GOVUK.sessionDialog.controller();
343
- return true;
344
- }
345
- return false;
346
- }
347
- };
348
- window.GOVUK.sessionDialog.init();
@@ -1,121 +0,0 @@
1
- .modal-dialog {
2
- display: none;
3
- }
4
-
5
- .modal-dialog--no-js-persistent {
6
- display: inline-block;
7
- }
8
-
9
- .js-enabled {
10
- .modal-dialog--no-js-persistent {
11
- display: none;
12
-
13
- &[open], .dialog-button {
14
- display: inline-block;
15
- }
16
- }
17
-
18
- .modal-dialog[open] {
19
- display: inline-block;
20
- }
21
- }
22
-
23
- .modal-dialog[open] {
24
- overflow-x: hidden;
25
- overflow-y: auto;
26
- max-height: 90vh;
27
- padding: 0;
28
- margin-bottom: 0;
29
- margin-top: 0;
30
- position: fixed;
31
- top: 50% !important;
32
- -webkit-transform: translate(0, -50%);
33
- -ms-transform: translate(0, -50%);
34
- transform: translate(0, -50%);
35
- }
36
-
37
- @media (min-width: 641px) {
38
- .modal-dialog[open] {
39
- padding: 0;
40
- }
41
- }
42
-
43
- .modal-dialog__inner {
44
- padding: 20px;
45
- }
46
-
47
- .modal-dialog #dialog-title {
48
- margin-top: 0;
49
- }
50
-
51
- .dialog-is-open {
52
- overflow: hidden;
53
- }
54
-
55
- dialog {
56
- left: 0;
57
- right: 0;
58
- width: -moz-fit-content;
59
- width: -webkit-fit-content;
60
- width: fit-content;
61
- height: -moz-fit-content;
62
- height: -webkit-fit-content;
63
- height: fit-content;
64
- margin: auto;
65
- border: solid;
66
- padding: 1em;
67
- background: white;
68
- color: black;
69
- display: none;
70
- border: 5px solid black;
71
-
72
- + .backdrop {
73
- position: fixed;
74
- top: 0;
75
- right: 0;
76
- bottom: 0;
77
- left: 0;
78
- background: rgba(0, 0, 0, 0.8);
79
- }
80
-
81
- &[open] {
82
- display: block;
83
- box-sizing: border-box;
84
- margin: 0 auto;
85
- padding: 15px;
86
- width: 90%;
87
-
88
- + .backdrop, &::backdrop {
89
- background: rgba(0, 0, 0, 0.8);
90
- }
91
- }
92
- }
93
-
94
- @media (min-width: 641px) {
95
- dialog[open] {
96
- padding: 30px;
97
- margin: 30px auto;
98
- max-width: 500px;
99
- }
100
- }
101
-
102
- .js-enabled .govuk-timeout-warning-fallback {
103
- display: none;
104
- }
105
-
106
- .tabular-numbers {
107
- font-family: "ntatabularnumbers", "nta", Arial, sans-serif;
108
- }
109
-
110
- .dialog-exit-link {
111
- @include govuk-font($size: 24);
112
- display: inline-block;
113
-
114
- @include govuk-media-query($from: tablet) {
115
- @include govuk-font($size: 19);
116
-
117
- position: relative;
118
- padding: 0.526315em 0.789473em 0.263157em;
119
- line-height: 1.5;
120
- }
121
- }
@@ -1,4 +0,0 @@
1
- {
2
- "header": "You have left this form",
3
- "title": "You have left this form"
4
- }
@@ -1,19 +0,0 @@
1
- {{<layout}}
2
- {{$journeyHeader}}
3
- {{#t}}journey.header{{/t}}
4
- {{/journeyHeader}}
5
-
6
- {{$propositionHeader}}
7
- {{> partials-navigation}}
8
- {{/propositionHeader}}
9
-
10
- {{$header}}
11
- {{header}}
12
- {{/header}}
13
-
14
- {{$content}}
15
- <p>{{#t}}pages.save-and-exit.paragraph-1{{/t}}</p>
16
- <p>{{#t}}pages.save-and-exit.paragraph-2{{/t}}</p>
17
- <p>{{#t}}pages.save-and-exit.paragraph-3{{/t}}</p>
18
- {{/content}}
19
- {{/layout}}