hof 22.0.0-timeout-warning-beta.1 → 22.0.0-timeout-warning-beta.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -299,6 +299,9 @@ helpers.documentReady(characterCount);
299
299
  helpers.documentReady(validation);
300
300
 
301
301
  },{"../../../toolkit":12,"./cookieSettings":1,"./govuk-cookies":2,"./session-timeout-dialog":4,"./skip-to-main":5,"govuk-frontend":13}],4:[function(require,module,exports){
302
+ /* eslint max-len: 0 */
303
+ 'use strict';
304
+
302
305
  const $ = require('jquery');
303
306
 
304
307
  // Modal dialog prototype
@@ -318,8 +321,8 @@ window.GOVUK.sessionDialog = {
318
321
  $timer: $('#js-modal-dialog .timer'),
319
322
  $accessibleTimer: $('#js-modal-dialog .at-timer'),
320
323
 
321
- secondsSessionTimeout: parseInt($('#js-modal-dialog').data('session-timeout') || 1800),
322
- secondsTimeoutWarning: parseInt($('#js-modal-dialog').data('session-timeout-warning') || 300),
324
+ secondsSessionTimeout: parseInt($('#js-modal-dialog').data('session-timeout'), 10 || 1800),
325
+ secondsTimeoutWarning: parseInt($('#js-modal-dialog').data('session-timeout-warning'), 10 || 300),
323
326
  timeoutRedirectUrl: $('#js-modal-dialog').data('url-redirect'),
324
327
  timeSessionRefreshed: new Date(),
325
328
 
@@ -327,18 +330,18 @@ window.GOVUK.sessionDialog = {
327
330
  window.GOVUK.sessionDialog.$closeButton.on('click', function (e) {
328
331
  e.preventDefault();
329
332
  window.GOVUK.sessionDialog.closeDialog();
330
- })
333
+ });
331
334
 
332
335
  // Close modal when ESC pressed
333
336
  $(document).keydown(function (e) {
334
337
  if (window.GOVUK.sessionDialog.isDialogOpen() && e.keyCode === 27) {
335
338
  window.GOVUK.sessionDialog.closeDialog();
336
339
  }
337
- })
340
+ });
338
341
  },
339
342
 
340
343
  isDialogOpen: function () {
341
- return window.GOVUK.sessionDialog.el['open'];
344
+ return window.GOVUK.sessionDialog.el.open;
342
345
  },
343
346
 
344
347
  isConfigured: function () {
@@ -382,7 +385,7 @@ window.GOVUK.sessionDialog = {
382
385
  if (window.GOVUK.sessionDialog.$lastFocusedEl) {
383
386
  window.setTimeout(function () {
384
387
  window.GOVUK.sessionDialog.$lastFocusedEl.focus();
385
- }, 0)
388
+ }, 0);
386
389
  }
387
390
  },
388
391
 
@@ -405,51 +408,46 @@ window.GOVUK.sessionDialog = {
405
408
  },
406
409
 
407
410
  numberToWords: function (n) {
408
- let string = n.toString()
409
- let units
410
- let tens
411
- let scales
412
- let start
413
- let end
414
- let chunks
415
- let chunksLen
416
- let chunk
417
- let ints
418
- let i
419
- let word
420
- let words = 'and'
421
-
422
- if (parseInt(string) === 0) {
411
+ const string = n.toString();
412
+ let start;
413
+ let end;
414
+ let chunk;
415
+ let ints;
416
+ let i;
417
+ let word;
418
+ let words = 'and';
419
+
420
+ if (parseInt(string, 10) === 0) {
423
421
  return 'zero';
424
422
  }
425
423
 
426
424
  /* Array of units as words */
427
- units = ['', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen'];
425
+ const units = ['', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen'];
428
426
 
429
427
  /* Array of tens as words */
430
- tens = ['', '', 'twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety'];
428
+ const tens = ['', '', 'twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety'];
431
429
 
432
430
  /* Array of scales as words */
433
- 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'];
431
+ 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'];
434
432
 
435
433
  /* Split user arguemnt into 3 digit chunks from right to left */
436
434
  start = string.length;
437
- chunks = [];
435
+ const chunks = [];
438
436
  while (start > 0) {
439
437
  end = start;
440
438
  chunks.push(string.slice((start = Math.max(0, start - 3)), end));
441
439
  }
442
440
 
443
441
  /* Check if function has enough scale words to be able to stringify the user argument */
444
- chunksLen = chunks.length
442
+ const chunksLen = chunks.length;
445
443
  if (chunksLen > scales.length) {
446
444
  return '';
447
445
  }
448
446
 
449
447
  /* Stringify each integer in each chunk */
450
- words = []
448
+ words = [];
451
449
  for (i = 0; i < chunksLen; i++) {
452
- chunk = parseInt(chunks[i]);
450
+ chunk = parseInt(chunks[i], 10);
453
451
 
454
452
  if (chunk) {
455
453
  /* Split chunk into array of individual integers */
@@ -461,22 +459,22 @@ window.GOVUK.sessionDialog = {
461
459
  }
462
460
 
463
461
  /* Add scale word if chunk is not zero and array item exists */
464
- if ((word = scales[i])) {
462
+ if ((word === scales[i])) {
465
463
  words.push(word);
466
464
  }
467
465
 
468
466
  /* Add unit word if array item exists */
469
- if ((word = units[ints[0]])) {
467
+ if ((word === units[ints[0]])) {
470
468
  words.push(word);
471
469
  }
472
470
 
473
471
  /* Add tens word if array item exists */
474
- if ((word = tens[ints[1]])) {
472
+ if ((word === tens[ints[1]])) {
475
473
  words.push(word);
476
474
  }
477
475
 
478
476
  /* Add hundreds word if array item exists */
479
- if ((word = units[ints[2]])) {
477
+ if ((word === units[ints[2]])) {
480
478
  words.push(word + ' hundred');
481
479
  }
482
480
  }
@@ -502,7 +500,7 @@ window.GOVUK.sessionDialog = {
502
500
  },
503
501
 
504
502
  pluralise: function (n, unit) {
505
- return n == 1 ? unit : unit + 's';
503
+ return n === 1 ? unit : unit + 's';
506
504
  },
507
505
 
508
506
  numericSpan: function (n, unit) {
@@ -518,7 +516,7 @@ window.GOVUK.sessionDialog = {
518
516
  countdownAtText: function (minutes, seconds) {
519
517
  const minutesText = window.GOVUK.sessionDialog.timeToWords(minutes, 'minute');
520
518
  const secondsText = window.GOVUK.sessionDialog.timeToWords(seconds, 'second');
521
- return minutes > 0 ? minutesText : secondsText;
519
+ return minutes > 0 ? minutesText : secondsText;
522
520
  },
523
521
 
524
522
  startCountdown: function () {
@@ -537,11 +535,8 @@ window.GOVUK.sessionDialog = {
537
535
  const timerExpired = secondsUntilSessionTimeout <= window.GOVUK.sessionDialog.secondsFinalWarning;
538
536
 
539
537
  if (!timerExpired) {
540
-
541
538
  const minutesLeft = parseInt(secondsUntilSessionTimeout / 60, 10);
542
539
  const secondsLeft = parseInt(secondsUntilSessionTimeout % 60, 10);
543
-
544
-
545
540
  const atMinutesText = window.GOVUK.sessionDialog.timeToWords(minutesLeft, 'minute');
546
541
  const atSecondsText = window.GOVUK.sessionDialog.timeToWords(secondsLeft, 'second');
547
542
 
@@ -552,14 +547,13 @@ window.GOVUK.sessionDialog = {
552
547
  const countdownText = window.GOVUK.sessionDialog.countdownText(minutesLeft, secondsLeft);
553
548
  const text = window.GOVUK.sessionDialog.warningTextPrefix + '<strong>' + countdownText + '</strong>' + window.GOVUK.sessionDialog.warningTextSuffix;
554
549
  const countdownAtText = window.GOVUK.sessionDialog.countdownAtText(atMinutesText, atSecondsText);
555
- const atText = window.GOVUK.sessionDialog.warningTextPrefix + countdownAtText + window.GOVUK.sessionDialog.warningTextSuffix + 'bgbhj ' + window.GOVUK.sessionDialog.warningText;
550
+ const atText = window.GOVUK.sessionDialog.warningTextPrefix + countdownAtText + window.GOVUK.sessionDialog.warningTextSuffix + 'bgbhj ' + window.GOVUK.sessionDialog.warningText;
556
551
  const extraText = '\n' + window.GOVUK.sessionDialog.warningTextExtra;
557
552
 
558
553
  $timer.html(text + ' ' + extraText);
559
554
 
560
555
  // Update screen reader friendly content every 20 secs
561
556
  if (secondsLeft % 20 === 0) {
562
-
563
557
  // Read out the extra content only once.
564
558
  // Don't read out on iOS VoiceOver which stalls on the longer text
565
559
  if (!timerRunOnce && !iOS) {
@@ -570,9 +564,9 @@ window.GOVUK.sessionDialog = {
570
564
  }
571
565
  }
572
566
 
573
- window.GOVUK.sessionDialog.addTimer(countdown,20);
567
+ window.GOVUK.sessionDialog.addTimer(countdown, 20);
574
568
  }
575
- })()
569
+ })();
576
570
  },
577
571
 
578
572
  // Clears all timers
@@ -583,7 +577,7 @@ window.GOVUK.sessionDialog = {
583
577
  },
584
578
 
585
579
  refreshSession: function () {
586
- $.get("");
580
+ $.get('');
587
581
  window.GOVUK.sessionDialog.timeSessionRefreshed = new Date();
588
582
  window.GOVUK.sessionDialog.controller();
589
583
  },
@@ -616,20 +610,16 @@ window.GOVUK.sessionDialog = {
616
610
 
617
611
  const secondsUntilSessionTimeout = window.GOVUK.sessionDialog.secondsUntilSessionTimeout();
618
612
 
619
- //timed out - redirect
620
613
  if (secondsUntilSessionTimeout <= 0) {
614
+ // timed out - redirect
621
615
  window.GOVUK.sessionDialog.redirect();
622
- }
623
-
624
- //timeout warning - show countdown and schedule redirect
625
- else if (secondsUntilSessionTimeout <= window.GOVUK.sessionDialog.secondsTimeoutWarning) {
616
+ } else if (secondsUntilSessionTimeout <= window.GOVUK.sessionDialog.secondsTimeoutWarning) {
617
+ // timeout warning - show countdown and schedule redirect
626
618
  window.GOVUK.sessionDialog.openDialog();
627
619
  window.GOVUK.sessionDialog.startCountdown();
628
- window.GOVUK.sessionDialog.addTimer(window.GOVUK.sessionDialog.controller,window.GOVUK.sessionDialog.secondsUntilSessionTimeout());
629
- }
630
-
631
- //wait for warning
632
- else {
620
+ window.GOVUK.sessionDialog.addTimer(window.GOVUK.sessionDialog.controller, window.GOVUK.sessionDialog.secondsUntilSessionTimeout());
621
+ } else {
622
+ // wait for warning
633
623
  window.GOVUK.sessionDialog.addTimer(window.GOVUK.sessionDialog.controller, window.GOVUK.sessionDialog.secondsUntilTimeoutWarning());
634
624
  }
635
625
  },
@@ -641,9 +631,7 @@ window.GOVUK.sessionDialog = {
641
631
  window.GOVUK.sessionDialog.controller();
642
632
  }
643
633
  }
644
- }
645
-
646
- window.GOVUK = GOVUK;
634
+ };
647
635
 
648
636
  },{"jquery":14}],5:[function(require,module,exports){
649
637
  const skipToMain = function () {