hof 20.0.0-beta.8 → 20.0.0-redis-beta.32-redis-beta

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. package/.github/workflows/automate-publish.yml +1 -1
  2. package/.github/workflows/automate-tag.yml +4 -4
  3. package/.nyc_output/cb764db8-e9f0-43bb-b3b1-7af57bb79bb5.json +1 -0
  4. package/.nyc_output/processinfo/cb764db8-e9f0-43bb-b3b1-7af57bb79bb5.json +1 -0
  5. package/.nyc_output/processinfo/index.json +1 -1
  6. package/README.md +329 -256
  7. package/components/index.js +2 -1
  8. package/components/notify/index.js +60 -0
  9. package/components/notify/notify.js +25 -0
  10. package/config/hof-defaults.js +2 -1
  11. package/controller/controller.js +14 -4
  12. package/frontend/template-mixins/mixins/template-mixins.js +7 -3
  13. package/frontend/template-mixins/partials/forms/checkbox-group.html +10 -1
  14. package/frontend/template-mixins/partials/forms/input-text-date.html +1 -1
  15. package/frontend/template-mixins/partials/forms/input-text-group.html +5 -3
  16. package/frontend/template-mixins/partials/forms/option-group.html +9 -0
  17. package/frontend/template-mixins/partials/forms/select.html +1 -1
  18. package/frontend/template-mixins/partials/forms/textarea-group.html +2 -2
  19. package/frontend/template-partials/views/layout.html +10 -3
  20. package/frontend/template-partials/views/partials/cookie-banner.html +1 -1
  21. package/frontend/template-partials/views/partials/form.html +2 -1
  22. package/frontend/template-partials/views/partials/warn.html +7 -0
  23. package/frontend/themes/gov-uk/client-js/index.js +3 -5
  24. package/frontend/themes/gov-uk/styles/govuk.scss +4 -0
  25. package/frontend/themes/gov-uk/styles/modules/_validation.scss +2 -2
  26. package/frontend/toolkit/assets/javascript/form-focus.js +10 -1
  27. package/frontend/toolkit/assets/javascript/progressive-reveal.js +3 -1
  28. package/frontend/toolkit/assets/javascript/validation.js +6 -1
  29. package/lib/health.js +1 -1
  30. package/lib/sessions.js +1 -1
  31. package/middleware/rate-limiter.js +3 -1
  32. package/package.json +4 -3
  33. package/sandbox/apps/sandbox/fields.js +1 -0
  34. package/sandbox/apps/sandbox/index.js +1 -5
  35. package/sandbox/apps/sandbox/translations/en/default.json +36 -15
  36. package/sandbox/assets/scss/app.scss +0 -52
  37. package/sandbox/package.json +2 -0
  38. package/sandbox/public/css/app.css +21 -6666
  39. package/sandbox/public/js/bundle.js +37 -2793
  40. package/sandbox/server.js +2 -1
  41. package/sandbox/yarn.lock +39 -564
  42. package/.nyc_output/e2fdc3eb-4fd2-47e0-a392-fe5f665776a4.json +0 -1
  43. package/.nyc_output/processinfo/e2fdc3eb-4fd2-47e0-a392-fe5f665776a4.json +0 -1
  44. package/.vscode/settings.json +0 -6
  45. package/frontend/govuk-template/govuk_template_generated.html +0 -104
  46. package/sandbox/.env +0 -1
@@ -36,7 +36,7 @@ function showCookieBannerSubmitted() {
36
36
  document.getElementById('cookie-banner-info').style.display = 'none';
37
37
  document.getElementById('cookie-banner-actions').style.display = 'none';
38
38
  var cookieBannerSubmitted = document.getElementById('cookie-banner-submitted');
39
- cookieBannerSubmitted.style.display = 'block';
39
+ cookieBannerSubmitted.style.display = 'flex';
40
40
  cookieBannerSubmitted.focus();
41
41
  }
42
42
 
@@ -146,130 +146,6 @@ module.exports = {
146
146
  };
147
147
 
148
148
  },{}],2:[function(require,module,exports){
149
- (function () {
150
- "use strict"
151
- var root = this;
152
- if(typeof root.GOVUK === 'undefined') { root.GOVUK = {}; }
153
-
154
- /*
155
- Cookie methods
156
- ==============
157
-
158
- Usage:
159
-
160
- Setting a cookie:
161
- GOVUK.cookie('hobnob', 'tasty', { days: 30 });
162
-
163
- Reading a cookie:
164
- GOVUK.cookie('hobnob');
165
-
166
- Deleting a cookie:
167
- GOVUK.cookie('hobnob', null);
168
- */
169
- GOVUK.cookie = function (name, value, options) {
170
- if(typeof value !== 'undefined'){
171
- if(value === false || value === null) {
172
- return GOVUK.setCookie(name, '', { days: -1 });
173
- } else {
174
- return GOVUK.setCookie(name, value, options);
175
- }
176
- } else {
177
- return GOVUK.getCookie(name);
178
- }
179
- };
180
- GOVUK.setCookie = function (name, value, options) {
181
- if(typeof options === 'undefined') {
182
- options = {};
183
- }
184
- var cookieString = name + "=" + value + "; path=/";
185
- if (options.days) {
186
- var date = new Date();
187
- date.setTime(date.getTime() + (options.days * 24 * 60 * 60 * 1000));
188
- cookieString = cookieString + "; expires=" + date.toGMTString();
189
- }
190
- if (document.location.protocol == 'https:'){
191
- cookieString = cookieString + "; Secure";
192
- }
193
- document.cookie = cookieString;
194
- };
195
- GOVUK.getCookie = function (name) {
196
- var nameEQ = name + "=";
197
- var cookies = document.cookie.split(';');
198
- for(var i = 0, len = cookies.length; i < len; i++) {
199
- var cookie = cookies[i];
200
- while (cookie.charAt(0) == ' ') {
201
- cookie = cookie.substring(1, cookie.length);
202
- }
203
- if (cookie.indexOf(nameEQ) === 0) {
204
- return decodeURIComponent(cookie.substring(nameEQ.length));
205
- }
206
- }
207
- return null;
208
- };
209
- }).call(this);
210
- (function () {
211
- 'use strict'
212
- var root = this
213
- if (typeof root.GOVUK === 'undefined') { root.GOVUK = {} }
214
-
215
- GOVUK.addCookieMessage = function () {
216
- var message = document.getElementById('global-cookie-message')
217
-
218
- var hasCookieMessage = (message && GOVUK.cookie('seen_cookie_message') === null)
219
-
220
- if (hasCookieMessage) {
221
- message.style.display = 'block'
222
- GOVUK.cookie('seen_cookie_message', 'yes', { days: 28 })
223
-
224
- document.addEventListener('DOMContentLoaded', function (event) {
225
- if (GOVUK.analytics && typeof GOVUK.analytics.trackEvent === 'function') {
226
- GOVUK.analytics.trackEvent('cookieBanner', 'Cookie banner shown', {
227
- value: 1,
228
- nonInteraction: true
229
- })
230
- }
231
- })
232
- };
233
- }
234
- }).call(this)
235
- ;
236
- (function() {
237
- "use strict"
238
-
239
- // add cookie message
240
- if (window.GOVUK && GOVUK.addCookieMessage) {
241
- GOVUK.addCookieMessage();
242
- }
243
-
244
- // header navigation toggle
245
- if (document.querySelectorAll && document.addEventListener){
246
- var els = document.querySelectorAll('.js-header-toggle'),
247
- i, _i;
248
- for(i=0,_i=els.length; i<_i; i++){
249
- els[i].addEventListener('click', function(e){
250
- e.preventDefault();
251
- var target = document.getElementById(this.getAttribute('href').substr(1)),
252
- targetClass = target.getAttribute('class') || '',
253
- sourceClass = this.getAttribute('class') || '';
254
-
255
- if(targetClass.indexOf('js-visible') !== -1){
256
- target.setAttribute('class', targetClass.replace(/(^|\s)js-visible(\s|$)/, ''));
257
- } else {
258
- target.setAttribute('class', targetClass + " js-visible");
259
- }
260
- if(sourceClass.indexOf('js-visible') !== -1){
261
- this.setAttribute('class', sourceClass.replace(/(^|\s)js-visible(\s|$)/, ''));
262
- } else {
263
- this.setAttribute('class', sourceClass + " js-visible");
264
- }
265
- this.setAttribute('aria-expanded', this.getAttribute('aria-expanded') !== "true");
266
- target.setAttribute('aria-hidden', target.getAttribute('aria-hidden') === "false");
267
- });
268
- }
269
- }
270
- }).call(this);
271
-
272
- },{}],3:[function(require,module,exports){
273
149
  /* eslint-disable no-var */
274
150
  'use strict';
275
151
 
@@ -280,11 +156,6 @@ var formFocus = toolkit.formFocus;
280
156
  var characterCount = toolkit.characterCount;
281
157
  var validation = toolkit.validation;
282
158
 
283
- var GOVUK = require('govuk-frontend')
284
- GOVUK.initAll();
285
- window.GOVUK = GOVUK;
286
- var skipToMain = require('./skip-to-main');
287
- var cookie = require('./govuk-cookies');
288
159
  var cookieSettings = require('./cookieSettings');
289
160
 
290
161
  toolkit.detailsSummary();
@@ -297,27 +168,7 @@ helpers.documentReady(cookieSettings.onLoad);
297
168
  helpers.documentReady(characterCount);
298
169
  helpers.documentReady(validation);
299
170
 
300
- },{"../../../toolkit":11,"./cookieSettings":1,"./govuk-cookies":2,"./skip-to-main":4,"govuk-frontend":12}],4:[function(require,module,exports){
301
- const skipToMain = function () {
302
- const skipToMainLink = document.getElementById("skip-to-main");
303
- const firstControlId = skipToMainLink.hash.split('#')[1] ? skipToMainLink.hash.split('#')[1] : "main-content";
304
- if(firstControlId === "main-content"){
305
- skipToMainLink.setAttribute("href", "#main-content");
306
- }
307
- if(firstControlId) {
308
- skipToMainLink.onclick = function(e) {
309
- //here timeout added just to make this functionality asynchronous
310
- //to focus on form as well as non form contents
311
- setTimeout(() => {
312
- const firstControl = document.getElementById(firstControlId);
313
- firstControl.focus();
314
- }, 10);
315
- }
316
- }
317
- };
318
- skipToMain();
319
-
320
- },{}],5:[function(require,module,exports){
171
+ },{"../../../toolkit":9,"./cookieSettings":1}],3:[function(require,module,exports){
321
172
  /* eslint-disable max-len, no-var, no-use-before-define, no-param-reassign, vars-on-top, radix */
322
173
  'use strict';
323
174
 
@@ -350,12 +201,12 @@ CharacterCount.prototype.updateCount = function () {
350
201
  this.$maxlengthHint.innerHTML = 'You have ' + number + characterNoun + remainderSuffix;
351
202
 
352
203
  if (currentLength >= this.maxLength + 1) {
353
- helpers.removeClass(this.$maxlengthHint, 'govuk-hint');
354
- helpers.addClass(this.$maxlengthHint, 'govuk-error-message');
204
+ helpers.removeClass(this.$maxlengthHint, 'form-hint');
205
+ helpers.addClass(this.$maxlengthHint, 'error-message');
355
206
  helpers.addClass(this.$textarea, 'textarea-error');
356
207
  } else {
357
- helpers.addClass(this.$maxlengthHint, 'govuk-hint');
358
- helpers.removeClass(this.$maxlengthHint, 'govuk-error-message');
208
+ helpers.addClass(this.$maxlengthHint, 'form-hint');
209
+ helpers.removeClass(this.$maxlengthHint, 'error-message');
359
210
  helpers.removeClass(this.$textarea, 'textarea-error');
360
211
  }
361
212
  };
@@ -418,7 +269,7 @@ function characterCountAll() {
418
269
 
419
270
  module.exports = characterCountAll;
420
271
 
421
- },{"./helpers":7}],6:[function(require,module,exports){
272
+ },{"./helpers":5}],4:[function(require,module,exports){
422
273
  /* eslint-disable max-len, no-var, no-param-reassign, vars-on-top */
423
274
  /**
424
275
  * This module adds the yellow focus border to:
@@ -492,11 +343,20 @@ function formFocus() {
492
343
  var labels;
493
344
  var summaries;
494
345
 
495
- if (getElementFromSummaryLink && getEditPath === 'edit') {
346
+ var editMode = getElementFromSummaryLink && getEditPath === 'edit';
347
+
348
+ if (getElementFromSummaryLink && document.getElementById(getElementFromSummaryLink) && editMode) {
496
349
  document.getElementById(getElementFromSummaryLink).focus();
350
+ }
351
+
352
+ if (getElementFromSummaryLink && document.getElementById(getElementFromSummaryLink + '-group') && editMode) {
497
353
  document.getElementById(getElementFromSummaryLink + '-group').scrollIntoView();
498
354
  }
499
355
 
356
+ if (document.getElementById(getElementFromSummaryLink + '-day') && forms.length === 1 && editMode) {
357
+ document.getElementById(getElementFromSummaryLink + '-day').focus();
358
+ }
359
+
500
360
  if (forms.length > 0) {
501
361
  labels = document.getElementsByTagName('label');
502
362
  if (labels) {
@@ -512,7 +372,7 @@ function formFocus() {
512
372
 
513
373
  module.exports = formFocus;
514
374
 
515
- },{"./helpers":7,"lodash":13}],7:[function(require,module,exports){
375
+ },{"./helpers":5,"lodash":10}],5:[function(require,module,exports){
516
376
  /* eslint-disable max-len, no-var, no-param-reassign, vars-on-top, no-extend-native */
517
377
  'use strict';
518
378
 
@@ -691,7 +551,7 @@ helpers.pagehide = function (func) {
691
551
 
692
552
  module.exports = helpers;
693
553
 
694
- },{"lodash":13}],8:[function(require,module,exports){
554
+ },{"lodash":10}],6:[function(require,module,exports){
695
555
  /* eslint-disable max-len, no-var, no-param-reassign, vars-on-top */
696
556
  'use strict';
697
557
 
@@ -763,7 +623,7 @@ function progressiveReveal() {
763
623
 
764
624
  module.exports = progressiveReveal;
765
625
 
766
- },{"./helpers":7,"lodash":13}],9:[function(require,module,exports){
626
+ },{"./helpers":5,"lodash":10}],7:[function(require,module,exports){
767
627
  /* eslint-disable max-len, no-var, no-shadow, vars-on-top */
768
628
  var each = require('lodash').forEach;
769
629
 
@@ -790,7 +650,12 @@ function clicked(e) {
790
650
  }
791
651
 
792
652
  if (inputs) {
793
- inputs[0].focus();
653
+ if (inputs[0].getAttribute('type') === 'hidden') {
654
+ var getVisibleElements = group.querySelectorAll('input[type=text]');
655
+ getVisibleElements[0].focus();
656
+ } else {
657
+ inputs[0].focus();
658
+ }
794
659
  }
795
660
  }
796
661
  }
@@ -827,7 +692,7 @@ function validation() {
827
692
 
828
693
  module.exports = validation;
829
694
 
830
- },{"./helpers":7,"lodash":13}],10:[function(require,module,exports){
695
+ },{"./helpers":5,"lodash":10}],8:[function(require,module,exports){
831
696
  /* eslint-disable max-len, no-var, no-cond-assign, no-param-reassign, vars-on-top */
832
697
  // <details> polyfill
833
698
  // http://caniuse.com/#feat=details
@@ -1018,7 +883,7 @@ module.exports = validation;
1018
883
  addEvent(window, 'load', addDetailsPolyfill);
1019
884
  })();
1020
885
 
1021
- },{}],11:[function(require,module,exports){
886
+ },{}],9:[function(require,module,exports){
1022
887
  module.exports = {
1023
888
  helpers: require('./assets/javascript/helpers'),
1024
889
  formFocus: require('./assets/javascript/form-focus'),
@@ -1030,2627 +895,7 @@ module.exports = {
1030
895
  characterCount: require('./assets/javascript/character-count')
1031
896
  };
1032
897
 
1033
- },{"./assets/javascript/character-count":5,"./assets/javascript/form-focus":6,"./assets/javascript/helpers":7,"./assets/javascript/progressive-reveal":8,"./assets/javascript/validation":9,"./assets/javascript/vendor/details.polyfill":10}],12:[function(require,module,exports){
1034
- (function (global){(function (){
1035
- (function (global, factory) {
1036
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
1037
- typeof define === 'function' && define.amd ? define('GOVUKFrontend', ['exports'], factory) :
1038
- (factory((global.GOVUKFrontend = {})));
1039
- }(this, (function (exports) { 'use strict';
1040
-
1041
- /**
1042
- * TODO: Ideally this would be a NodeList.prototype.forEach polyfill
1043
- * This seems to fail in IE8, requires more investigation.
1044
- * See: https://github.com/imagitama/nodelist-foreach-polyfill
1045
- */
1046
- function nodeListForEach (nodes, callback) {
1047
- if (window.NodeList.prototype.forEach) {
1048
- return nodes.forEach(callback)
1049
- }
1050
- for (var i = 0; i < nodes.length; i++) {
1051
- callback.call(window, nodes[i], i, nodes);
1052
- }
1053
- }
1054
-
1055
- // Used to generate a unique string, allows multiple instances of the component without
1056
- // Them conflicting with each other.
1057
- // https://stackoverflow.com/a/8809472
1058
- function generateUniqueID () {
1059
- var d = new Date().getTime();
1060
- if (typeof window.performance !== 'undefined' && typeof window.performance.now === 'function') {
1061
- d += window.performance.now(); // use high-precision timer if available
1062
- }
1063
- return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
1064
- var r = (d + Math.random() * 16) % 16 | 0;
1065
- d = Math.floor(d / 16);
1066
- return (c === 'x' ? r : (r & 0x3 | 0x8)).toString(16)
1067
- })
1068
- }
1069
-
1070
- (function(undefined) {
1071
-
1072
- // Detection from https://github.com/Financial-Times/polyfill-service/blob/master/packages/polyfill-library/polyfills/Object/defineProperty/detect.js
1073
- var detect = (
1074
- // In IE8, defineProperty could only act on DOM elements, so full support
1075
- // for the feature requires the ability to set a property on an arbitrary object
1076
- 'defineProperty' in Object && (function() {
1077
- try {
1078
- var a = {};
1079
- Object.defineProperty(a, 'test', {value:42});
1080
- return true;
1081
- } catch(e) {
1082
- return false
1083
- }
1084
- }())
1085
- );
1086
-
1087
- if (detect) return
1088
-
1089
- // Polyfill from https://cdn.polyfill.io/v2/polyfill.js?features=Object.defineProperty&flags=always
1090
- (function (nativeDefineProperty) {
1091
-
1092
- var supportsAccessors = Object.prototype.hasOwnProperty('__defineGetter__');
1093
- var ERR_ACCESSORS_NOT_SUPPORTED = 'Getters & setters cannot be defined on this javascript engine';
1094
- var ERR_VALUE_ACCESSORS = 'A property cannot both have accessors and be writable or have a value';
1095
-
1096
- Object.defineProperty = function defineProperty(object, property, descriptor) {
1097
-
1098
- // Where native support exists, assume it
1099
- if (nativeDefineProperty && (object === window || object === document || object === Element.prototype || object instanceof Element)) {
1100
- return nativeDefineProperty(object, property, descriptor);
1101
- }
1102
-
1103
- if (object === null || !(object instanceof Object || typeof object === 'object')) {
1104
- throw new TypeError('Object.defineProperty called on non-object');
1105
- }
1106
-
1107
- if (!(descriptor instanceof Object)) {
1108
- throw new TypeError('Property description must be an object');
1109
- }
1110
-
1111
- var propertyString = String(property);
1112
- var hasValueOrWritable = 'value' in descriptor || 'writable' in descriptor;
1113
- var getterType = 'get' in descriptor && typeof descriptor.get;
1114
- var setterType = 'set' in descriptor && typeof descriptor.set;
1115
-
1116
- // handle descriptor.get
1117
- if (getterType) {
1118
- if (getterType !== 'function') {
1119
- throw new TypeError('Getter must be a function');
1120
- }
1121
- if (!supportsAccessors) {
1122
- throw new TypeError(ERR_ACCESSORS_NOT_SUPPORTED);
1123
- }
1124
- if (hasValueOrWritable) {
1125
- throw new TypeError(ERR_VALUE_ACCESSORS);
1126
- }
1127
- Object.__defineGetter__.call(object, propertyString, descriptor.get);
1128
- } else {
1129
- object[propertyString] = descriptor.value;
1130
- }
1131
-
1132
- // handle descriptor.set
1133
- if (setterType) {
1134
- if (setterType !== 'function') {
1135
- throw new TypeError('Setter must be a function');
1136
- }
1137
- if (!supportsAccessors) {
1138
- throw new TypeError(ERR_ACCESSORS_NOT_SUPPORTED);
1139
- }
1140
- if (hasValueOrWritable) {
1141
- throw new TypeError(ERR_VALUE_ACCESSORS);
1142
- }
1143
- Object.__defineSetter__.call(object, propertyString, descriptor.set);
1144
- }
1145
-
1146
- // OK to define value unconditionally - if a getter has been specified as well, an error would be thrown above
1147
- if ('value' in descriptor) {
1148
- object[propertyString] = descriptor.value;
1149
- }
1150
-
1151
- return object;
1152
- };
1153
- }(Object.defineProperty));
1154
- })
1155
- .call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
1156
-
1157
- (function(undefined) {
1158
- // Detection from https://github.com/Financial-Times/polyfill-service/blob/master/packages/polyfill-library/polyfills/Function/prototype/bind/detect.js
1159
- var detect = 'bind' in Function.prototype;
1160
-
1161
- if (detect) return
1162
-
1163
- // Polyfill from https://cdn.polyfill.io/v2/polyfill.js?features=Function.prototype.bind&flags=always
1164
- Object.defineProperty(Function.prototype, 'bind', {
1165
- value: function bind(that) { // .length is 1
1166
- // add necessary es5-shim utilities
1167
- var $Array = Array;
1168
- var $Object = Object;
1169
- var ObjectPrototype = $Object.prototype;
1170
- var ArrayPrototype = $Array.prototype;
1171
- var Empty = function Empty() {};
1172
- var to_string = ObjectPrototype.toString;
1173
- var hasToStringTag = typeof Symbol === 'function' && typeof Symbol.toStringTag === 'symbol';
1174
- var isCallable; /* inlined from https://npmjs.com/is-callable */ var fnToStr = Function.prototype.toString, tryFunctionObject = function tryFunctionObject(value) { try { fnToStr.call(value); return true; } catch (e) { return false; } }, fnClass = '[object Function]', genClass = '[object GeneratorFunction]'; isCallable = function isCallable(value) { if (typeof value !== 'function') { return false; } if (hasToStringTag) { return tryFunctionObject(value); } var strClass = to_string.call(value); return strClass === fnClass || strClass === genClass; };
1175
- var array_slice = ArrayPrototype.slice;
1176
- var array_concat = ArrayPrototype.concat;
1177
- var array_push = ArrayPrototype.push;
1178
- var max = Math.max;
1179
- // /add necessary es5-shim utilities
1180
-
1181
- // 1. Let Target be the this value.
1182
- var target = this;
1183
- // 2. If IsCallable(Target) is false, throw a TypeError exception.
1184
- if (!isCallable(target)) {
1185
- throw new TypeError('Function.prototype.bind called on incompatible ' + target);
1186
- }
1187
- // 3. Let A be a new (possibly empty) internal list of all of the
1188
- // argument values provided after thisArg (arg1, arg2 etc), in order.
1189
- // XXX slicedArgs will stand in for "A" if used
1190
- var args = array_slice.call(arguments, 1); // for normal call
1191
- // 4. Let F be a new native ECMAScript object.
1192
- // 11. Set the [[Prototype]] internal property of F to the standard
1193
- // built-in Function prototype object as specified in 15.3.3.1.
1194
- // 12. Set the [[Call]] internal property of F as described in
1195
- // 15.3.4.5.1.
1196
- // 13. Set the [[Construct]] internal property of F as described in
1197
- // 15.3.4.5.2.
1198
- // 14. Set the [[HasInstance]] internal property of F as described in
1199
- // 15.3.4.5.3.
1200
- var bound;
1201
- var binder = function () {
1202
-
1203
- if (this instanceof bound) {
1204
- // 15.3.4.5.2 [[Construct]]
1205
- // When the [[Construct]] internal method of a function object,
1206
- // F that was created using the bind function is called with a
1207
- // list of arguments ExtraArgs, the following steps are taken:
1208
- // 1. Let target be the value of F's [[TargetFunction]]
1209
- // internal property.
1210
- // 2. If target has no [[Construct]] internal method, a
1211
- // TypeError exception is thrown.
1212
- // 3. Let boundArgs be the value of F's [[BoundArgs]] internal
1213
- // property.
1214
- // 4. Let args be a new list containing the same values as the
1215
- // list boundArgs in the same order followed by the same
1216
- // values as the list ExtraArgs in the same order.
1217
- // 5. Return the result of calling the [[Construct]] internal
1218
- // method of target providing args as the arguments.
1219
-
1220
- var result = target.apply(
1221
- this,
1222
- array_concat.call(args, array_slice.call(arguments))
1223
- );
1224
- if ($Object(result) === result) {
1225
- return result;
1226
- }
1227
- return this;
1228
-
1229
- } else {
1230
- // 15.3.4.5.1 [[Call]]
1231
- // When the [[Call]] internal method of a function object, F,
1232
- // which was created using the bind function is called with a
1233
- // this value and a list of arguments ExtraArgs, the following
1234
- // steps are taken:
1235
- // 1. Let boundArgs be the value of F's [[BoundArgs]] internal
1236
- // property.
1237
- // 2. Let boundThis be the value of F's [[BoundThis]] internal
1238
- // property.
1239
- // 3. Let target be the value of F's [[TargetFunction]] internal
1240
- // property.
1241
- // 4. Let args be a new list containing the same values as the
1242
- // list boundArgs in the same order followed by the same
1243
- // values as the list ExtraArgs in the same order.
1244
- // 5. Return the result of calling the [[Call]] internal method
1245
- // of target providing boundThis as the this value and
1246
- // providing args as the arguments.
1247
-
1248
- // equiv: target.call(this, ...boundArgs, ...args)
1249
- return target.apply(
1250
- that,
1251
- array_concat.call(args, array_slice.call(arguments))
1252
- );
1253
-
1254
- }
1255
-
1256
- };
1257
-
1258
- // 15. If the [[Class]] internal property of Target is "Function", then
1259
- // a. Let L be the length property of Target minus the length of A.
1260
- // b. Set the length own property of F to either 0 or L, whichever is
1261
- // larger.
1262
- // 16. Else set the length own property of F to 0.
1263
-
1264
- var boundLength = max(0, target.length - args.length);
1265
-
1266
- // 17. Set the attributes of the length own property of F to the values
1267
- // specified in 15.3.5.1.
1268
- var boundArgs = [];
1269
- for (var i = 0; i < boundLength; i++) {
1270
- array_push.call(boundArgs, '$' + i);
1271
- }
1272
-
1273
- // XXX Build a dynamic function with desired amount of arguments is the only
1274
- // way to set the length property of a function.
1275
- // In environments where Content Security Policies enabled (Chrome extensions,
1276
- // for ex.) all use of eval or Function costructor throws an exception.
1277
- // However in all of these environments Function.prototype.bind exists
1278
- // and so this code will never be executed.
1279
- bound = Function('binder', 'return function (' + boundArgs.join(',') + '){ return binder.apply(this, arguments); }')(binder);
1280
-
1281
- if (target.prototype) {
1282
- Empty.prototype = target.prototype;
1283
- bound.prototype = new Empty();
1284
- // Clean up dangling references.
1285
- Empty.prototype = null;
1286
- }
1287
-
1288
- // TODO
1289
- // 18. Set the [[Extensible]] internal property of F to true.
1290
-
1291
- // TODO
1292
- // 19. Let thrower be the [[ThrowTypeError]] function Object (13.2.3).
1293
- // 20. Call the [[DefineOwnProperty]] internal method of F with
1294
- // arguments "caller", PropertyDescriptor {[[Get]]: thrower, [[Set]]:
1295
- // thrower, [[Enumerable]]: false, [[Configurable]]: false}, and
1296
- // false.
1297
- // 21. Call the [[DefineOwnProperty]] internal method of F with
1298
- // arguments "arguments", PropertyDescriptor {[[Get]]: thrower,
1299
- // [[Set]]: thrower, [[Enumerable]]: false, [[Configurable]]: false},
1300
- // and false.
1301
-
1302
- // TODO
1303
- // NOTE Function objects created using Function.prototype.bind do not
1304
- // have a prototype property or the [[Code]], [[FormalParameters]], and
1305
- // [[Scope]] internal properties.
1306
- // XXX can't delete prototype in pure-js.
1307
-
1308
- // 22. Return F.
1309
- return bound;
1310
- }
1311
- });
1312
- })
1313
- .call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
1314
-
1315
- (function(undefined) {
1316
-
1317
- // Detection from https://raw.githubusercontent.com/Financial-Times/polyfill-service/master/packages/polyfill-library/polyfills/DOMTokenList/detect.js
1318
- var detect = (
1319
- 'DOMTokenList' in this && (function (x) {
1320
- return 'classList' in x ? !x.classList.toggle('x', false) && !x.className : true;
1321
- })(document.createElement('x'))
1322
- );
1323
-
1324
- if (detect) return
1325
-
1326
- // Polyfill from https://raw.githubusercontent.com/Financial-Times/polyfill-service/master/packages/polyfill-library/polyfills/DOMTokenList/polyfill.js
1327
- (function (global) {
1328
- var nativeImpl = "DOMTokenList" in global && global.DOMTokenList;
1329
-
1330
- if (
1331
- !nativeImpl ||
1332
- (
1333
- !!document.createElementNS &&
1334
- !!document.createElementNS('http://www.w3.org/2000/svg', 'svg') &&
1335
- !(document.createElementNS("http://www.w3.org/2000/svg", "svg").classList instanceof DOMTokenList)
1336
- )
1337
- ) {
1338
- global.DOMTokenList = (function() { // eslint-disable-line no-unused-vars
1339
- var dpSupport = true;
1340
- var defineGetter = function (object, name, fn, configurable) {
1341
- if (Object.defineProperty)
1342
- Object.defineProperty(object, name, {
1343
- configurable: false === dpSupport ? true : !!configurable,
1344
- get: fn
1345
- });
1346
-
1347
- else object.__defineGetter__(name, fn);
1348
- };
1349
-
1350
- /** Ensure the browser allows Object.defineProperty to be used on native JavaScript objects. */
1351
- try {
1352
- defineGetter({}, "support");
1353
- }
1354
- catch (e) {
1355
- dpSupport = false;
1356
- }
1357
-
1358
-
1359
- var _DOMTokenList = function (el, prop) {
1360
- var that = this;
1361
- var tokens = [];
1362
- var tokenMap = {};
1363
- var length = 0;
1364
- var maxLength = 0;
1365
- var addIndexGetter = function (i) {
1366
- defineGetter(that, i, function () {
1367
- preop();
1368
- return tokens[i];
1369
- }, false);
1370
-
1371
- };
1372
- var reindex = function () {
1373
-
1374
- /** Define getter functions for array-like access to the tokenList's contents. */
1375
- if (length >= maxLength)
1376
- for (; maxLength < length; ++maxLength) {
1377
- addIndexGetter(maxLength);
1378
- }
1379
- };
1380
-
1381
- /** Helper function called at the start of each class method. Internal use only. */
1382
- var preop = function () {
1383
- var error;
1384
- var i;
1385
- var args = arguments;
1386
- var rSpace = /\s+/;
1387
-
1388
- /** Validate the token/s passed to an instance method, if any. */
1389
- if (args.length)
1390
- for (i = 0; i < args.length; ++i)
1391
- if (rSpace.test(args[i])) {
1392
- error = new SyntaxError('String "' + args[i] + '" ' + "contains" + ' an invalid character');
1393
- error.code = 5;
1394
- error.name = "InvalidCharacterError";
1395
- throw error;
1396
- }
1397
-
1398
-
1399
- /** Split the new value apart by whitespace*/
1400
- if (typeof el[prop] === "object") {
1401
- tokens = ("" + el[prop].baseVal).replace(/^\s+|\s+$/g, "").split(rSpace);
1402
- } else {
1403
- tokens = ("" + el[prop]).replace(/^\s+|\s+$/g, "").split(rSpace);
1404
- }
1405
-
1406
- /** Avoid treating blank strings as single-item token lists */
1407
- if ("" === tokens[0]) tokens = [];
1408
-
1409
- /** Repopulate the internal token lists */
1410
- tokenMap = {};
1411
- for (i = 0; i < tokens.length; ++i)
1412
- tokenMap[tokens[i]] = true;
1413
- length = tokens.length;
1414
- reindex();
1415
- };
1416
-
1417
- /** Populate our internal token list if the targeted attribute of the subject element isn't empty. */
1418
- preop();
1419
-
1420
- /** Return the number of tokens in the underlying string. Read-only. */
1421
- defineGetter(that, "length", function () {
1422
- preop();
1423
- return length;
1424
- });
1425
-
1426
- /** Override the default toString/toLocaleString methods to return a space-delimited list of tokens when typecast. */
1427
- that.toLocaleString =
1428
- that.toString = function () {
1429
- preop();
1430
- return tokens.join(" ");
1431
- };
1432
-
1433
- that.item = function (idx) {
1434
- preop();
1435
- return tokens[idx];
1436
- };
1437
-
1438
- that.contains = function (token) {
1439
- preop();
1440
- return !!tokenMap[token];
1441
- };
1442
-
1443
- that.add = function () {
1444
- preop.apply(that, args = arguments);
1445
-
1446
- for (var args, token, i = 0, l = args.length; i < l; ++i) {
1447
- token = args[i];
1448
- if (!tokenMap[token]) {
1449
- tokens.push(token);
1450
- tokenMap[token] = true;
1451
- }
1452
- }
1453
-
1454
- /** Update the targeted attribute of the attached element if the token list's changed. */
1455
- if (length !== tokens.length) {
1456
- length = tokens.length >>> 0;
1457
- if (typeof el[prop] === "object") {
1458
- el[prop].baseVal = tokens.join(" ");
1459
- } else {
1460
- el[prop] = tokens.join(" ");
1461
- }
1462
- reindex();
1463
- }
1464
- };
1465
-
1466
- that.remove = function () {
1467
- preop.apply(that, args = arguments);
1468
-
1469
- /** Build a hash of token names to compare against when recollecting our token list. */
1470
- for (var args, ignore = {}, i = 0, t = []; i < args.length; ++i) {
1471
- ignore[args[i]] = true;
1472
- delete tokenMap[args[i]];
1473
- }
1474
-
1475
- /** Run through our tokens list and reassign only those that aren't defined in the hash declared above. */
1476
- for (i = 0; i < tokens.length; ++i)
1477
- if (!ignore[tokens[i]]) t.push(tokens[i]);
1478
-
1479
- tokens = t;
1480
- length = t.length >>> 0;
1481
-
1482
- /** Update the targeted attribute of the attached element. */
1483
- if (typeof el[prop] === "object") {
1484
- el[prop].baseVal = tokens.join(" ");
1485
- } else {
1486
- el[prop] = tokens.join(" ");
1487
- }
1488
- reindex();
1489
- };
1490
-
1491
- that.toggle = function (token, force) {
1492
- preop.apply(that, [token]);
1493
-
1494
- /** Token state's being forced. */
1495
- if (undefined !== force) {
1496
- if (force) {
1497
- that.add(token);
1498
- return true;
1499
- } else {
1500
- that.remove(token);
1501
- return false;
1502
- }
1503
- }
1504
-
1505
- /** Token already exists in tokenList. Remove it, and return FALSE. */
1506
- if (tokenMap[token]) {
1507
- that.remove(token);
1508
- return false;
1509
- }
1510
-
1511
- /** Otherwise, add the token and return TRUE. */
1512
- that.add(token);
1513
- return true;
1514
- };
1515
-
1516
- return that;
1517
- };
1518
-
1519
- return _DOMTokenList;
1520
- }());
1521
- }
1522
-
1523
- // Add second argument to native DOMTokenList.toggle() if necessary
1524
- (function () {
1525
- var e = document.createElement('span');
1526
- if (!('classList' in e)) return;
1527
- e.classList.toggle('x', false);
1528
- if (!e.classList.contains('x')) return;
1529
- e.classList.constructor.prototype.toggle = function toggle(token /*, force*/) {
1530
- var force = arguments[1];
1531
- if (force === undefined) {
1532
- var add = !this.contains(token);
1533
- this[add ? 'add' : 'remove'](token);
1534
- return add;
1535
- }
1536
- force = !!force;
1537
- this[force ? 'add' : 'remove'](token);
1538
- return force;
1539
- };
1540
- }());
1541
-
1542
- // Add multiple arguments to native DOMTokenList.add() if necessary
1543
- (function () {
1544
- var e = document.createElement('span');
1545
- if (!('classList' in e)) return;
1546
- e.classList.add('a', 'b');
1547
- if (e.classList.contains('b')) return;
1548
- var native = e.classList.constructor.prototype.add;
1549
- e.classList.constructor.prototype.add = function () {
1550
- var args = arguments;
1551
- var l = arguments.length;
1552
- for (var i = 0; i < l; i++) {
1553
- native.call(this, args[i]);
1554
- }
1555
- };
1556
- }());
1557
-
1558
- // Add multiple arguments to native DOMTokenList.remove() if necessary
1559
- (function () {
1560
- var e = document.createElement('span');
1561
- if (!('classList' in e)) return;
1562
- e.classList.add('a');
1563
- e.classList.add('b');
1564
- e.classList.remove('a', 'b');
1565
- if (!e.classList.contains('b')) return;
1566
- var native = e.classList.constructor.prototype.remove;
1567
- e.classList.constructor.prototype.remove = function () {
1568
- var args = arguments;
1569
- var l = arguments.length;
1570
- for (var i = 0; i < l; i++) {
1571
- native.call(this, args[i]);
1572
- }
1573
- };
1574
- }());
1575
-
1576
- }(this));
1577
-
1578
- }).call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
1579
-
1580
- (function(undefined) {
1581
-
1582
- // Detection from https://github.com/Financial-Times/polyfill-service/blob/master/packages/polyfill-library/polyfills/Document/detect.js
1583
- var detect = ("Document" in this);
1584
-
1585
- if (detect) return
1586
-
1587
- // Polyfill from https://cdn.polyfill.io/v2/polyfill.js?features=Document&flags=always
1588
- if ((typeof WorkerGlobalScope === "undefined") && (typeof importScripts !== "function")) {
1589
-
1590
- if (this.HTMLDocument) { // IE8
1591
-
1592
- // HTMLDocument is an extension of Document. If the browser has HTMLDocument but not Document, the former will suffice as an alias for the latter.
1593
- this.Document = this.HTMLDocument;
1594
-
1595
- } else {
1596
-
1597
- // Create an empty function to act as the missing constructor for the document object, attach the document object as its prototype. The function needs to be anonymous else it is hoisted and causes the feature detect to prematurely pass, preventing the assignments below being made.
1598
- this.Document = this.HTMLDocument = document.constructor = (new Function('return function Document() {}')());
1599
- this.Document.prototype = document;
1600
- }
1601
- }
1602
-
1603
-
1604
- })
1605
- .call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
1606
-
1607
- (function(undefined) {
1608
-
1609
- // Detection from https://github.com/Financial-Times/polyfill-service/blob/master/packages/polyfill-library/polyfills/Element/detect.js
1610
- var detect = ('Element' in this && 'HTMLElement' in this);
1611
-
1612
- if (detect) return
1613
-
1614
- // Polyfill from https://cdn.polyfill.io/v2/polyfill.js?features=Element&flags=always
1615
- (function () {
1616
-
1617
- // IE8
1618
- if (window.Element && !window.HTMLElement) {
1619
- window.HTMLElement = window.Element;
1620
- return;
1621
- }
1622
-
1623
- // create Element constructor
1624
- window.Element = window.HTMLElement = new Function('return function Element() {}')();
1625
-
1626
- // generate sandboxed iframe
1627
- var vbody = document.appendChild(document.createElement('body'));
1628
- var frame = vbody.appendChild(document.createElement('iframe'));
1629
-
1630
- // use sandboxed iframe to replicate Element functionality
1631
- var frameDocument = frame.contentWindow.document;
1632
- var prototype = Element.prototype = frameDocument.appendChild(frameDocument.createElement('*'));
1633
- var cache = {};
1634
-
1635
- // polyfill Element.prototype on an element
1636
- var shiv = function (element, deep) {
1637
- var
1638
- childNodes = element.childNodes || [],
1639
- index = -1,
1640
- key, value, childNode;
1641
-
1642
- if (element.nodeType === 1 && element.constructor !== Element) {
1643
- element.constructor = Element;
1644
-
1645
- for (key in cache) {
1646
- value = cache[key];
1647
- element[key] = value;
1648
- }
1649
- }
1650
-
1651
- while (childNode = deep && childNodes[++index]) {
1652
- shiv(childNode, deep);
1653
- }
1654
-
1655
- return element;
1656
- };
1657
-
1658
- var elements = document.getElementsByTagName('*');
1659
- var nativeCreateElement = document.createElement;
1660
- var interval;
1661
- var loopLimit = 100;
1662
-
1663
- prototype.attachEvent('onpropertychange', function (event) {
1664
- var
1665
- propertyName = event.propertyName,
1666
- nonValue = !cache.hasOwnProperty(propertyName),
1667
- newValue = prototype[propertyName],
1668
- oldValue = cache[propertyName],
1669
- index = -1,
1670
- element;
1671
-
1672
- while (element = elements[++index]) {
1673
- if (element.nodeType === 1) {
1674
- if (nonValue || element[propertyName] === oldValue) {
1675
- element[propertyName] = newValue;
1676
- }
1677
- }
1678
- }
1679
-
1680
- cache[propertyName] = newValue;
1681
- });
1682
-
1683
- prototype.constructor = Element;
1684
-
1685
- if (!prototype.hasAttribute) {
1686
- // <Element>.hasAttribute
1687
- prototype.hasAttribute = function hasAttribute(name) {
1688
- return this.getAttribute(name) !== null;
1689
- };
1690
- }
1691
-
1692
- // Apply Element prototype to the pre-existing DOM as soon as the body element appears.
1693
- function bodyCheck() {
1694
- if (!(loopLimit--)) clearTimeout(interval);
1695
- if (document.body && !document.body.prototype && /(complete|interactive)/.test(document.readyState)) {
1696
- shiv(document, true);
1697
- if (interval && document.body.prototype) clearTimeout(interval);
1698
- return (!!document.body.prototype);
1699
- }
1700
- return false;
1701
- }
1702
- if (!bodyCheck()) {
1703
- document.onreadystatechange = bodyCheck;
1704
- interval = setInterval(bodyCheck, 25);
1705
- }
1706
-
1707
- // Apply to any new elements created after load
1708
- document.createElement = function createElement(nodeName) {
1709
- var element = nativeCreateElement(String(nodeName).toLowerCase());
1710
- return shiv(element);
1711
- };
1712
-
1713
- // remove sandboxed iframe
1714
- document.removeChild(vbody);
1715
- }());
1716
-
1717
- })
1718
- .call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
1719
-
1720
- (function(undefined) {
1721
-
1722
- // Detection from https://raw.githubusercontent.com/Financial-Times/polyfill-service/8717a9e04ac7aff99b4980fbedead98036b0929a/packages/polyfill-library/polyfills/Element/prototype/classList/detect.js
1723
- var detect = (
1724
- 'document' in this && "classList" in document.documentElement && 'Element' in this && 'classList' in Element.prototype && (function () {
1725
- var e = document.createElement('span');
1726
- e.classList.add('a', 'b');
1727
- return e.classList.contains('b');
1728
- }())
1729
- );
1730
-
1731
- if (detect) return
1732
-
1733
- // Polyfill from https://cdn.polyfill.io/v2/polyfill.js?features=Element.prototype.classList&flags=always
1734
- (function (global) {
1735
- var dpSupport = true;
1736
- var defineGetter = function (object, name, fn, configurable) {
1737
- if (Object.defineProperty)
1738
- Object.defineProperty(object, name, {
1739
- configurable: false === dpSupport ? true : !!configurable,
1740
- get: fn
1741
- });
1742
-
1743
- else object.__defineGetter__(name, fn);
1744
- };
1745
- /** Ensure the browser allows Object.defineProperty to be used on native JavaScript objects. */
1746
- try {
1747
- defineGetter({}, "support");
1748
- }
1749
- catch (e) {
1750
- dpSupport = false;
1751
- }
1752
- /** Polyfills a property with a DOMTokenList */
1753
- var addProp = function (o, name, attr) {
1754
-
1755
- defineGetter(o.prototype, name, function () {
1756
- var tokenList;
1757
-
1758
- var THIS = this,
1759
-
1760
- /** Prevent this from firing twice for some reason. What the hell, IE. */
1761
- gibberishProperty = "__defineGetter__" + "DEFINE_PROPERTY" + name;
1762
- if(THIS[gibberishProperty]) return tokenList;
1763
- THIS[gibberishProperty] = true;
1764
-
1765
- /**
1766
- * IE8 can't define properties on native JavaScript objects, so we'll use a dumb hack instead.
1767
- *
1768
- * What this is doing is creating a dummy element ("reflection") inside a detached phantom node ("mirror")
1769
- * that serves as the target of Object.defineProperty instead. While we could simply use the subject HTML
1770
- * element instead, this would conflict with element types which use indexed properties (such as forms and
1771
- * select lists).
1772
- */
1773
- if (false === dpSupport) {
1774
-
1775
- var visage;
1776
- var mirror = addProp.mirror || document.createElement("div");
1777
- var reflections = mirror.childNodes;
1778
- var l = reflections.length;
1779
-
1780
- for (var i = 0; i < l; ++i)
1781
- if (reflections[i]._R === THIS) {
1782
- visage = reflections[i];
1783
- break;
1784
- }
1785
-
1786
- /** Couldn't find an element's reflection inside the mirror. Materialise one. */
1787
- visage || (visage = mirror.appendChild(document.createElement("div")));
1788
-
1789
- tokenList = DOMTokenList.call(visage, THIS, attr);
1790
- } else tokenList = new DOMTokenList(THIS, attr);
1791
-
1792
- defineGetter(THIS, name, function () {
1793
- return tokenList;
1794
- });
1795
- delete THIS[gibberishProperty];
1796
-
1797
- return tokenList;
1798
- }, true);
1799
- };
1800
-
1801
- addProp(global.Element, "classList", "className");
1802
- addProp(global.HTMLElement, "classList", "className");
1803
- addProp(global.HTMLLinkElement, "relList", "rel");
1804
- addProp(global.HTMLAnchorElement, "relList", "rel");
1805
- addProp(global.HTMLAreaElement, "relList", "rel");
1806
- }(this));
1807
-
1808
- }).call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
1809
-
1810
- function Accordion ($module) {
1811
- this.$module = $module;
1812
- this.moduleId = $module.getAttribute('id');
1813
- this.$sections = $module.querySelectorAll('.govuk-accordion__section');
1814
- this.$openAllButton = '';
1815
- this.browserSupportsSessionStorage = helper.checkForSessionStorage();
1816
-
1817
- this.controlsClass = 'govuk-accordion__controls';
1818
- this.openAllClass = 'govuk-accordion__open-all';
1819
- this.iconClass = 'govuk-accordion__icon';
1820
-
1821
- this.sectionHeaderClass = 'govuk-accordion__section-header';
1822
- this.sectionHeaderFocusedClass = 'govuk-accordion__section-header--focused';
1823
- this.sectionHeadingClass = 'govuk-accordion__section-heading';
1824
- this.sectionSummaryClass = 'govuk-accordion__section-summary';
1825
- this.sectionButtonClass = 'govuk-accordion__section-button';
1826
- this.sectionExpandedClass = 'govuk-accordion__section--expanded';
1827
- }
1828
-
1829
- // Initialize component
1830
- Accordion.prototype.init = function () {
1831
- // Check for module
1832
- if (!this.$module) {
1833
- return
1834
- }
1835
-
1836
- this.initControls();
1837
-
1838
- this.initSectionHeaders();
1839
-
1840
- // See if "Open all" button text should be updated
1841
- var areAllSectionsOpen = this.checkIfAllSectionsOpen();
1842
- this.updateOpenAllButton(areAllSectionsOpen);
1843
- };
1844
-
1845
- // Initialise controls and set attributes
1846
- Accordion.prototype.initControls = function () {
1847
- // Create "Open all" button and set attributes
1848
- this.$openAllButton = document.createElement('button');
1849
- this.$openAllButton.setAttribute('type', 'button');
1850
- this.$openAllButton.innerHTML = 'Open all <span class="govuk-visually-hidden">sections</span>';
1851
- this.$openAllButton.setAttribute('class', this.openAllClass);
1852
- this.$openAllButton.setAttribute('aria-expanded', 'false');
1853
- this.$openAllButton.setAttribute('type', 'button');
1854
-
1855
- // Create control wrapper and add controls to it
1856
- var accordionControls = document.createElement('div');
1857
- accordionControls.setAttribute('class', this.controlsClass);
1858
- accordionControls.appendChild(this.$openAllButton);
1859
- this.$module.insertBefore(accordionControls, this.$module.firstChild);
1860
-
1861
- // Handle events for the controls
1862
- this.$openAllButton.addEventListener('click', this.onOpenOrCloseAllToggle.bind(this));
1863
- };
1864
-
1865
- // Initialise section headers
1866
- Accordion.prototype.initSectionHeaders = function () {
1867
- // Loop through section headers
1868
- nodeListForEach(this.$sections, function ($section, i) {
1869
- // Set header attributes
1870
- var header = $section.querySelector('.' + this.sectionHeaderClass);
1871
- this.initHeaderAttributes(header, i);
1872
-
1873
- this.setExpanded(this.isExpanded($section), $section);
1874
-
1875
- // Handle events
1876
- header.addEventListener('click', this.onSectionToggle.bind(this, $section));
1877
-
1878
- // See if there is any state stored in sessionStorage and set the sections to
1879
- // open or closed.
1880
- this.setInitialState($section);
1881
- }.bind(this));
1882
- };
1883
-
1884
- // Set individual header attributes
1885
- Accordion.prototype.initHeaderAttributes = function ($headerWrapper, index) {
1886
- var $module = this;
1887
- var $span = $headerWrapper.querySelector('.' + this.sectionButtonClass);
1888
- var $heading = $headerWrapper.querySelector('.' + this.sectionHeadingClass);
1889
- var $summary = $headerWrapper.querySelector('.' + this.sectionSummaryClass);
1890
-
1891
- // Copy existing span element to an actual button element, for improved accessibility.
1892
- var $button = document.createElement('button');
1893
- $button.setAttribute('type', 'button');
1894
- $button.setAttribute('id', this.moduleId + '-heading-' + (index + 1));
1895
- $button.setAttribute('aria-controls', this.moduleId + '-content-' + (index + 1));
1896
-
1897
- // Copy all attributes (https://developer.mozilla.org/en-US/docs/Web/API/Element/attributes) from $span to $button
1898
- for (var i = 0; i < $span.attributes.length; i++) {
1899
- var attr = $span.attributes.item(i);
1900
- $button.setAttribute(attr.nodeName, attr.nodeValue);
1901
- }
1902
-
1903
- $button.addEventListener('focusin', function (e) {
1904
- if (!$headerWrapper.classList.contains($module.sectionHeaderFocusedClass)) {
1905
- $headerWrapper.className += ' ' + $module.sectionHeaderFocusedClass;
1906
- }
1907
- });
1908
-
1909
- $button.addEventListener('blur', function (e) {
1910
- $headerWrapper.classList.remove($module.sectionHeaderFocusedClass);
1911
- });
1912
-
1913
- if (typeof ($summary) !== 'undefined' && $summary !== null) {
1914
- $button.setAttribute('aria-describedby', this.moduleId + '-summary-' + (index + 1));
1915
- }
1916
-
1917
- // $span could contain HTML elements (see https://www.w3.org/TR/2011/WD-html5-20110525/content-models.html#phrasing-content)
1918
- $button.innerHTML = $span.innerHTML;
1919
-
1920
- $heading.removeChild($span);
1921
- $heading.appendChild($button);
1922
-
1923
- // Add "+/-" icon
1924
- var icon = document.createElement('span');
1925
- icon.className = this.iconClass;
1926
- icon.setAttribute('aria-hidden', 'true');
1927
-
1928
- $button.appendChild(icon);
1929
- };
1930
-
1931
- // When section toggled, set and store state
1932
- Accordion.prototype.onSectionToggle = function ($section) {
1933
- var expanded = this.isExpanded($section);
1934
- this.setExpanded(!expanded, $section);
1935
-
1936
- // Store the state in sessionStorage when a change is triggered
1937
- this.storeState($section);
1938
- };
1939
-
1940
- // When Open/Close All toggled, set and store state
1941
- Accordion.prototype.onOpenOrCloseAllToggle = function () {
1942
- var $module = this;
1943
- var $sections = this.$sections;
1944
-
1945
- var nowExpanded = !this.checkIfAllSectionsOpen();
1946
-
1947
- nodeListForEach($sections, function ($section) {
1948
- $module.setExpanded(nowExpanded, $section);
1949
- // Store the state in sessionStorage when a change is triggered
1950
- $module.storeState($section);
1951
- });
1952
-
1953
- $module.updateOpenAllButton(nowExpanded);
1954
- };
1955
-
1956
- // Set section attributes when opened/closed
1957
- Accordion.prototype.setExpanded = function (expanded, $section) {
1958
- var $button = $section.querySelector('.' + this.sectionButtonClass);
1959
- $button.setAttribute('aria-expanded', expanded);
1960
-
1961
- if (expanded) {
1962
- $section.classList.add(this.sectionExpandedClass);
1963
- } else {
1964
- $section.classList.remove(this.sectionExpandedClass);
1965
- }
1966
-
1967
- // See if "Open all" button text should be updated
1968
- var areAllSectionsOpen = this.checkIfAllSectionsOpen();
1969
- this.updateOpenAllButton(areAllSectionsOpen);
1970
- };
1971
-
1972
- // Get state of section
1973
- Accordion.prototype.isExpanded = function ($section) {
1974
- return $section.classList.contains(this.sectionExpandedClass)
1975
- };
1976
-
1977
- // Check if all sections are open
1978
- Accordion.prototype.checkIfAllSectionsOpen = function () {
1979
- // Get a count of all the Accordion sections
1980
- var sectionsCount = this.$sections.length;
1981
- // Get a count of all Accordion sections that are expanded
1982
- var expandedSectionCount = this.$module.querySelectorAll('.' + this.sectionExpandedClass).length;
1983
- var areAllSectionsOpen = sectionsCount === expandedSectionCount;
1984
-
1985
- return areAllSectionsOpen
1986
- };
1987
-
1988
- // Update "Open all" button
1989
- Accordion.prototype.updateOpenAllButton = function (expanded) {
1990
- var newButtonText = expanded ? 'Close all' : 'Open all';
1991
- newButtonText += '<span class="govuk-visually-hidden"> sections</span>';
1992
- this.$openAllButton.setAttribute('aria-expanded', expanded);
1993
- this.$openAllButton.innerHTML = newButtonText;
1994
- };
1995
-
1996
- // Check for `window.sessionStorage`, and that it actually works.
1997
- var helper = {
1998
- checkForSessionStorage: function () {
1999
- var testString = 'this is the test string';
2000
- var result;
2001
- try {
2002
- window.sessionStorage.setItem(testString, testString);
2003
- result = window.sessionStorage.getItem(testString) === testString.toString();
2004
- window.sessionStorage.removeItem(testString);
2005
- return result
2006
- } catch (exception) {
2007
- if ((typeof console === 'undefined' || typeof console.log === 'undefined')) {
2008
- console.log('Notice: sessionStorage not available.');
2009
- }
2010
- }
2011
- }
2012
- };
2013
-
2014
- // Set the state of the accordions in sessionStorage
2015
- Accordion.prototype.storeState = function ($section) {
2016
- if (this.browserSupportsSessionStorage) {
2017
- // We need a unique way of identifying each content in the accordion. Since
2018
- // an `#id` should be unique and an `id` is required for `aria-` attributes
2019
- // `id` can be safely used.
2020
- var $button = $section.querySelector('.' + this.sectionButtonClass);
2021
-
2022
- if ($button) {
2023
- var contentId = $button.getAttribute('aria-controls');
2024
- var contentState = $button.getAttribute('aria-expanded');
2025
-
2026
- if (typeof contentId === 'undefined' && (typeof console === 'undefined' || typeof console.log === 'undefined')) {
2027
- console.error(new Error('No aria controls present in accordion section heading.'));
2028
- }
2029
-
2030
- if (typeof contentState === 'undefined' && (typeof console === 'undefined' || typeof console.log === 'undefined')) {
2031
- console.error(new Error('No aria expanded present in accordion section heading.'));
2032
- }
2033
-
2034
- // Only set the state when both `contentId` and `contentState` are taken from the DOM.
2035
- if (contentId && contentState) {
2036
- window.sessionStorage.setItem(contentId, contentState);
2037
- }
2038
- }
2039
- }
2040
- };
2041
-
2042
- // Read the state of the accordions from sessionStorage
2043
- Accordion.prototype.setInitialState = function ($section) {
2044
- if (this.browserSupportsSessionStorage) {
2045
- var $button = $section.querySelector('.' + this.sectionButtonClass);
2046
-
2047
- if ($button) {
2048
- var contentId = $button.getAttribute('aria-controls');
2049
- var contentState = contentId ? window.sessionStorage.getItem(contentId) : null;
2050
-
2051
- if (contentState !== null) {
2052
- this.setExpanded(contentState === 'true', $section);
2053
- }
2054
- }
2055
- }
2056
- };
2057
-
2058
- (function(undefined) {
2059
-
2060
- // Detection from https://github.com/Financial-Times/polyfill-service/blob/master/packages/polyfill-library/polyfills/Window/detect.js
2061
- var detect = ('Window' in this);
2062
-
2063
- if (detect) return
2064
-
2065
- // Polyfill from https://cdn.polyfill.io/v2/polyfill.js?features=Window&flags=always
2066
- if ((typeof WorkerGlobalScope === "undefined") && (typeof importScripts !== "function")) {
2067
- (function (global) {
2068
- if (global.constructor) {
2069
- global.Window = global.constructor;
2070
- } else {
2071
- (global.Window = global.constructor = new Function('return function Window() {}')()).prototype = this;
2072
- }
2073
- }(this));
2074
- }
2075
-
2076
- })
2077
- .call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
2078
-
2079
- (function(undefined) {
2080
-
2081
- // Detection from https://github.com/Financial-Times/polyfill-service/blob/master/packages/polyfill-library/polyfills/Event/detect.js
2082
- var detect = (
2083
- (function(global) {
2084
-
2085
- if (!('Event' in global)) return false;
2086
- if (typeof global.Event === 'function') return true;
2087
-
2088
- try {
2089
-
2090
- // In IE 9-11, the Event object exists but cannot be instantiated
2091
- new Event('click');
2092
- return true;
2093
- } catch(e) {
2094
- return false;
2095
- }
2096
- }(this))
2097
- );
2098
-
2099
- if (detect) return
2100
-
2101
- // Polyfill from https://cdn.polyfill.io/v2/polyfill.js?features=Event&flags=always
2102
- (function () {
2103
- var unlistenableWindowEvents = {
2104
- click: 1,
2105
- dblclick: 1,
2106
- keyup: 1,
2107
- keypress: 1,
2108
- keydown: 1,
2109
- mousedown: 1,
2110
- mouseup: 1,
2111
- mousemove: 1,
2112
- mouseover: 1,
2113
- mouseenter: 1,
2114
- mouseleave: 1,
2115
- mouseout: 1,
2116
- storage: 1,
2117
- storagecommit: 1,
2118
- textinput: 1
2119
- };
2120
-
2121
- // This polyfill depends on availability of `document` so will not run in a worker
2122
- // However, we asssume there are no browsers with worker support that lack proper
2123
- // support for `Event` within the worker
2124
- if (typeof document === 'undefined' || typeof window === 'undefined') return;
2125
-
2126
- function indexOf(array, element) {
2127
- var
2128
- index = -1,
2129
- length = array.length;
2130
-
2131
- while (++index < length) {
2132
- if (index in array && array[index] === element) {
2133
- return index;
2134
- }
2135
- }
2136
-
2137
- return -1;
2138
- }
2139
-
2140
- var existingProto = (window.Event && window.Event.prototype) || null;
2141
- window.Event = Window.prototype.Event = function Event(type, eventInitDict) {
2142
- if (!type) {
2143
- throw new Error('Not enough arguments');
2144
- }
2145
-
2146
- var event;
2147
- // Shortcut if browser supports createEvent
2148
- if ('createEvent' in document) {
2149
- event = document.createEvent('Event');
2150
- var bubbles = eventInitDict && eventInitDict.bubbles !== undefined ? eventInitDict.bubbles : false;
2151
- var cancelable = eventInitDict && eventInitDict.cancelable !== undefined ? eventInitDict.cancelable : false;
2152
-
2153
- event.initEvent(type, bubbles, cancelable);
2154
-
2155
- return event;
2156
- }
2157
-
2158
- event = document.createEventObject();
2159
-
2160
- event.type = type;
2161
- event.bubbles = eventInitDict && eventInitDict.bubbles !== undefined ? eventInitDict.bubbles : false;
2162
- event.cancelable = eventInitDict && eventInitDict.cancelable !== undefined ? eventInitDict.cancelable : false;
2163
-
2164
- return event;
2165
- };
2166
- if (existingProto) {
2167
- Object.defineProperty(window.Event, 'prototype', {
2168
- configurable: false,
2169
- enumerable: false,
2170
- writable: true,
2171
- value: existingProto
2172
- });
2173
- }
2174
-
2175
- if (!('createEvent' in document)) {
2176
- window.addEventListener = Window.prototype.addEventListener = Document.prototype.addEventListener = Element.prototype.addEventListener = function addEventListener() {
2177
- var
2178
- element = this,
2179
- type = arguments[0],
2180
- listener = arguments[1];
2181
-
2182
- if (element === window && type in unlistenableWindowEvents) {
2183
- throw new Error('In IE8 the event: ' + type + ' is not available on the window object. Please see https://github.com/Financial-Times/polyfill-service/issues/317 for more information.');
2184
- }
2185
-
2186
- if (!element._events) {
2187
- element._events = {};
2188
- }
2189
-
2190
- if (!element._events[type]) {
2191
- element._events[type] = function (event) {
2192
- var
2193
- list = element._events[event.type].list,
2194
- events = list.slice(),
2195
- index = -1,
2196
- length = events.length,
2197
- eventElement;
2198
-
2199
- event.preventDefault = function preventDefault() {
2200
- if (event.cancelable !== false) {
2201
- event.returnValue = false;
2202
- }
2203
- };
2204
-
2205
- event.stopPropagation = function stopPropagation() {
2206
- event.cancelBubble = true;
2207
- };
2208
-
2209
- event.stopImmediatePropagation = function stopImmediatePropagation() {
2210
- event.cancelBubble = true;
2211
- event.cancelImmediate = true;
2212
- };
2213
-
2214
- event.currentTarget = element;
2215
- event.relatedTarget = event.fromElement || null;
2216
- event.target = event.target || event.srcElement || element;
2217
- event.timeStamp = new Date().getTime();
2218
-
2219
- if (event.clientX) {
2220
- event.pageX = event.clientX + document.documentElement.scrollLeft;
2221
- event.pageY = event.clientY + document.documentElement.scrollTop;
2222
- }
2223
-
2224
- while (++index < length && !event.cancelImmediate) {
2225
- if (index in events) {
2226
- eventElement = events[index];
2227
-
2228
- if (indexOf(list, eventElement) !== -1 && typeof eventElement === 'function') {
2229
- eventElement.call(element, event);
2230
- }
2231
- }
2232
- }
2233
- };
2234
-
2235
- element._events[type].list = [];
2236
-
2237
- if (element.attachEvent) {
2238
- element.attachEvent('on' + type, element._events[type]);
2239
- }
2240
- }
2241
-
2242
- element._events[type].list.push(listener);
2243
- };
2244
-
2245
- window.removeEventListener = Window.prototype.removeEventListener = Document.prototype.removeEventListener = Element.prototype.removeEventListener = function removeEventListener() {
2246
- var
2247
- element = this,
2248
- type = arguments[0],
2249
- listener = arguments[1],
2250
- index;
2251
-
2252
- if (element._events && element._events[type] && element._events[type].list) {
2253
- index = indexOf(element._events[type].list, listener);
2254
-
2255
- if (index !== -1) {
2256
- element._events[type].list.splice(index, 1);
2257
-
2258
- if (!element._events[type].list.length) {
2259
- if (element.detachEvent) {
2260
- element.detachEvent('on' + type, element._events[type]);
2261
- }
2262
- delete element._events[type];
2263
- }
2264
- }
2265
- }
2266
- };
2267
-
2268
- window.dispatchEvent = Window.prototype.dispatchEvent = Document.prototype.dispatchEvent = Element.prototype.dispatchEvent = function dispatchEvent(event) {
2269
- if (!arguments.length) {
2270
- throw new Error('Not enough arguments');
2271
- }
2272
-
2273
- if (!event || typeof event.type !== 'string') {
2274
- throw new Error('DOM Events Exception 0');
2275
- }
2276
-
2277
- var element = this, type = event.type;
2278
-
2279
- try {
2280
- if (!event.bubbles) {
2281
- event.cancelBubble = true;
2282
-
2283
- var cancelBubbleEvent = function (event) {
2284
- event.cancelBubble = true;
2285
-
2286
- (element || window).detachEvent('on' + type, cancelBubbleEvent);
2287
- };
2288
-
2289
- this.attachEvent('on' + type, cancelBubbleEvent);
2290
- }
2291
-
2292
- this.fireEvent('on' + type, event);
2293
- } catch (error) {
2294
- event.target = element;
2295
-
2296
- do {
2297
- event.currentTarget = element;
2298
-
2299
- if ('_events' in element && typeof element._events[type] === 'function') {
2300
- element._events[type].call(element, event);
2301
- }
2302
-
2303
- if (typeof element['on' + type] === 'function') {
2304
- element['on' + type].call(element, event);
2305
- }
2306
-
2307
- element = element.nodeType === 9 ? element.parentWindow : element.parentNode;
2308
- } while (element && !event.cancelBubble);
2309
- }
2310
-
2311
- return true;
2312
- };
2313
-
2314
- // Add the DOMContentLoaded Event
2315
- document.attachEvent('onreadystatechange', function() {
2316
- if (document.readyState === 'complete') {
2317
- document.dispatchEvent(new Event('DOMContentLoaded', {
2318
- bubbles: true
2319
- }));
2320
- }
2321
- });
2322
- }
2323
- }());
2324
-
2325
- })
2326
- .call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
2327
-
2328
- var KEY_SPACE = 32;
2329
- var DEBOUNCE_TIMEOUT_IN_SECONDS = 1;
2330
-
2331
- function Button ($module) {
2332
- this.$module = $module;
2333
- this.debounceFormSubmitTimer = null;
2334
- }
2335
-
2336
- /**
2337
- * JavaScript 'shim' to trigger the click event of element(s) when the space key is pressed.
2338
- *
2339
- * Created since some Assistive Technologies (for example some Screenreaders)
2340
- * will tell a user to press space on a 'button', so this functionality needs to be shimmed
2341
- * See https://github.com/alphagov/govuk_elements/pull/272#issuecomment-233028270
2342
- *
2343
- * @param {object} event event
2344
- */
2345
- Button.prototype.handleKeyDown = function (event) {
2346
- // get the target element
2347
- var target = event.target;
2348
- // if the element has a role='button' and the pressed key is a space, we'll simulate a click
2349
- if (target.getAttribute('role') === 'button' && event.keyCode === KEY_SPACE) {
2350
- event.preventDefault();
2351
- // trigger the target's click event
2352
- target.click();
2353
- }
2354
- };
2355
-
2356
- /**
2357
- * If the click quickly succeeds a previous click then nothing will happen.
2358
- * This stops people accidentally causing multiple form submissions by
2359
- * double clicking buttons.
2360
- */
2361
- Button.prototype.debounce = function (event) {
2362
- var target = event.target;
2363
- // Check the button that is clicked on has the preventDoubleClick feature enabled
2364
- if (target.getAttribute('data-prevent-double-click') !== 'true') {
2365
- return
2366
- }
2367
-
2368
- // If the timer is still running then we want to prevent the click from submitting the form
2369
- if (this.debounceFormSubmitTimer) {
2370
- event.preventDefault();
2371
- return false
2372
- }
2373
-
2374
- this.debounceFormSubmitTimer = setTimeout(function () {
2375
- this.debounceFormSubmitTimer = null;
2376
- }.bind(this), DEBOUNCE_TIMEOUT_IN_SECONDS * 1000);
2377
- };
2378
-
2379
- /**
2380
- * Initialise an event listener for keydown at document level
2381
- * this will help listening for later inserted elements with a role="button"
2382
- */
2383
- Button.prototype.init = function () {
2384
- this.$module.addEventListener('keydown', this.handleKeyDown);
2385
- this.$module.addEventListener('click', this.debounce);
2386
- };
2387
-
2388
- /**
2389
- * JavaScript 'polyfill' for HTML5's <details> and <summary> elements
2390
- * and 'shim' to add accessiblity enhancements for all browsers
2391
- *
2392
- * http://caniuse.com/#feat=details
2393
- */
2394
-
2395
- var KEY_ENTER = 13;
2396
- var KEY_SPACE$1 = 32;
2397
-
2398
- function Details ($module) {
2399
- this.$module = $module;
2400
- }
2401
-
2402
- Details.prototype.init = function () {
2403
- if (!this.$module) {
2404
- return
2405
- }
2406
-
2407
- // If there is native details support, we want to avoid running code to polyfill native behaviour.
2408
- var hasNativeDetails = typeof this.$module.open === 'boolean';
2409
-
2410
- if (hasNativeDetails) {
2411
- return
2412
- }
2413
-
2414
- this.polyfillDetails();
2415
- };
2416
-
2417
- Details.prototype.polyfillDetails = function () {
2418
- var $module = this.$module;
2419
-
2420
- // Save shortcuts to the inner summary and content elements
2421
- var $summary = this.$summary = $module.getElementsByTagName('summary').item(0);
2422
- var $content = this.$content = $module.getElementsByTagName('div').item(0);
2423
-
2424
- // If <details> doesn't have a <summary> and a <div> representing the content
2425
- // it means the required HTML structure is not met so the script will stop
2426
- if (!$summary || !$content) {
2427
- return
2428
- }
2429
-
2430
- // If the content doesn't have an ID, assign it one now
2431
- // which we'll need for the summary's aria-controls assignment
2432
- if (!$content.id) {
2433
- $content.id = 'details-content-' + generateUniqueID();
2434
- }
2435
-
2436
- // Add ARIA role="group" to details
2437
- $module.setAttribute('role', 'group');
2438
-
2439
- // Add role=button to summary
2440
- $summary.setAttribute('role', 'button');
2441
-
2442
- // Add aria-controls
2443
- $summary.setAttribute('aria-controls', $content.id);
2444
-
2445
- // Set tabIndex so the summary is keyboard accessible for non-native elements
2446
- //
2447
- // We have to use the camelcase `tabIndex` property as there is a bug in IE6/IE7 when we set the correct attribute lowercase:
2448
- // See http://web.archive.org/web/20170120194036/http://www.saliences.com/browserBugs/tabIndex.html for more information.
2449
- $summary.tabIndex = 0;
2450
-
2451
- // Detect initial open state
2452
- var openAttr = $module.getAttribute('open') !== null;
2453
- if (openAttr === true) {
2454
- $summary.setAttribute('aria-expanded', 'true');
2455
- $content.setAttribute('aria-hidden', 'false');
2456
- } else {
2457
- $summary.setAttribute('aria-expanded', 'false');
2458
- $content.setAttribute('aria-hidden', 'true');
2459
- $content.style.display = 'none';
2460
- }
2461
-
2462
- // Bind an event to handle summary elements
2463
- this.polyfillHandleInputs($summary, this.polyfillSetAttributes.bind(this));
2464
- };
2465
-
2466
- /**
2467
- * Define a statechange function that updates aria-expanded and style.display
2468
- * @param {object} summary element
2469
- */
2470
- Details.prototype.polyfillSetAttributes = function () {
2471
- var $module = this.$module;
2472
- var $summary = this.$summary;
2473
- var $content = this.$content;
2474
-
2475
- var expanded = $summary.getAttribute('aria-expanded') === 'true';
2476
- var hidden = $content.getAttribute('aria-hidden') === 'true';
2477
-
2478
- $summary.setAttribute('aria-expanded', (expanded ? 'false' : 'true'));
2479
- $content.setAttribute('aria-hidden', (hidden ? 'false' : 'true'));
2480
-
2481
- $content.style.display = (expanded ? 'none' : '');
2482
-
2483
- var hasOpenAttr = $module.getAttribute('open') !== null;
2484
- if (!hasOpenAttr) {
2485
- $module.setAttribute('open', 'open');
2486
- } else {
2487
- $module.removeAttribute('open');
2488
- }
2489
-
2490
- return true
2491
- };
2492
-
2493
- /**
2494
- * Handle cross-modal click events
2495
- * @param {object} node element
2496
- * @param {function} callback function
2497
- */
2498
- Details.prototype.polyfillHandleInputs = function (node, callback) {
2499
- node.addEventListener('keypress', function (event) {
2500
- var target = event.target;
2501
- // When the key gets pressed - check if it is enter or space
2502
- if (event.keyCode === KEY_ENTER || event.keyCode === KEY_SPACE$1) {
2503
- if (target.nodeName.toLowerCase() === 'summary') {
2504
- // Prevent space from scrolling the page
2505
- // and enter from submitting a form
2506
- event.preventDefault();
2507
- // Click to let the click event do all the necessary action
2508
- if (target.click) {
2509
- target.click();
2510
- } else {
2511
- // except Safari 5.1 and under don't support .click() here
2512
- callback(event);
2513
- }
2514
- }
2515
- }
2516
- });
2517
-
2518
- // Prevent keyup to prevent clicking twice in Firefox when using space key
2519
- node.addEventListener('keyup', function (event) {
2520
- var target = event.target;
2521
- if (event.keyCode === KEY_SPACE$1) {
2522
- if (target.nodeName.toLowerCase() === 'summary') {
2523
- event.preventDefault();
2524
- }
2525
- }
2526
- });
2527
-
2528
- node.addEventListener('click', callback);
2529
- };
2530
-
2531
- function CharacterCount ($module) {
2532
- this.$module = $module;
2533
- this.$textarea = $module.querySelector('.govuk-js-character-count');
2534
- if (this.$textarea) {
2535
- this.$countMessage = $module.querySelector('[id="' + this.$textarea.id + '-info"]');
2536
- }
2537
- }
2538
-
2539
- CharacterCount.prototype.defaults = {
2540
- characterCountAttribute: 'data-maxlength',
2541
- wordCountAttribute: 'data-maxwords'
2542
- };
2543
-
2544
- // Initialize component
2545
- CharacterCount.prototype.init = function () {
2546
- // Check for module
2547
- var $module = this.$module;
2548
- var $textarea = this.$textarea;
2549
- var $countMessage = this.$countMessage;
2550
-
2551
- if (!$textarea || !$countMessage) {
2552
- return
2553
- }
2554
-
2555
- // We move count message right after the field
2556
- // Kept for backwards compatibility
2557
- $textarea.insertAdjacentElement('afterend', $countMessage);
2558
-
2559
- // Read options set using dataset ('data-' values)
2560
- this.options = this.getDataset($module);
2561
-
2562
- // Determine the limit attribute (characters or words)
2563
- var countAttribute = this.defaults.characterCountAttribute;
2564
- if (this.options.maxwords) {
2565
- countAttribute = this.defaults.wordCountAttribute;
2566
- }
2567
-
2568
- // Save the element limit
2569
- this.maxLength = $module.getAttribute(countAttribute);
2570
-
2571
- // Check for limit
2572
- if (!this.maxLength) {
2573
- return
2574
- }
2575
-
2576
- // Remove hard limit if set
2577
- $module.removeAttribute('maxlength');
2578
-
2579
- // When the page is restored after navigating 'back' in some browsers the
2580
- // state of the character count is not restored until *after* the DOMContentLoaded
2581
- // event is fired, so we need to sync after the pageshow event in browsers
2582
- // that support it.
2583
- if ('onpageshow' in window) {
2584
- window.addEventListener('pageshow', this.sync.bind(this));
2585
- } else {
2586
- window.addEventListener('DOMContentLoaded', this.sync.bind(this));
2587
- }
2588
-
2589
- this.sync();
2590
- };
2591
-
2592
- CharacterCount.prototype.sync = function () {
2593
- this.bindChangeEvents();
2594
- this.updateCountMessage();
2595
- };
2596
-
2597
- // Read data attributes
2598
- CharacterCount.prototype.getDataset = function (element) {
2599
- var dataset = {};
2600
- var attributes = element.attributes;
2601
- if (attributes) {
2602
- for (var i = 0; i < attributes.length; i++) {
2603
- var attribute = attributes[i];
2604
- var match = attribute.name.match(/^data-(.+)/);
2605
- if (match) {
2606
- dataset[match[1]] = attribute.value;
2607
- }
2608
- }
2609
- }
2610
- return dataset
2611
- };
2612
-
2613
- // Counts characters or words in text
2614
- CharacterCount.prototype.count = function (text) {
2615
- var length;
2616
- if (this.options.maxwords) {
2617
- var tokens = text.match(/\S+/g) || []; // Matches consecutive non-whitespace chars
2618
- length = tokens.length;
2619
- } else {
2620
- length = text.length;
2621
- }
2622
- return length
2623
- };
2624
-
2625
- // Bind input propertychange to the elements and update based on the change
2626
- CharacterCount.prototype.bindChangeEvents = function () {
2627
- var $textarea = this.$textarea;
2628
- $textarea.addEventListener('keyup', this.checkIfValueChanged.bind(this));
2629
-
2630
- // Bind focus/blur events to start/stop polling
2631
- $textarea.addEventListener('focus', this.handleFocus.bind(this));
2632
- $textarea.addEventListener('blur', this.handleBlur.bind(this));
2633
- };
2634
-
2635
- // Speech recognition software such as Dragon NaturallySpeaking will modify the
2636
- // fields by directly changing its `value`. These changes don't trigger events
2637
- // in JavaScript, so we need to poll to handle when and if they occur.
2638
- CharacterCount.prototype.checkIfValueChanged = function () {
2639
- if (!this.$textarea.oldValue) this.$textarea.oldValue = '';
2640
- if (this.$textarea.value !== this.$textarea.oldValue) {
2641
- this.$textarea.oldValue = this.$textarea.value;
2642
- this.updateCountMessage();
2643
- }
2644
- };
2645
-
2646
- // Update message box
2647
- CharacterCount.prototype.updateCountMessage = function () {
2648
- var countElement = this.$textarea;
2649
- var options = this.options;
2650
- var countMessage = this.$countMessage;
2651
-
2652
- // Determine the remaining number of characters/words
2653
- var currentLength = this.count(countElement.value);
2654
- var maxLength = this.maxLength;
2655
- var remainingNumber = maxLength - currentLength;
2656
-
2657
- // Set threshold if presented in options
2658
- var thresholdPercent = options.threshold ? options.threshold : 0;
2659
- var thresholdValue = maxLength * thresholdPercent / 100;
2660
- if (thresholdValue > currentLength) {
2661
- countMessage.classList.add('govuk-character-count__message--disabled');
2662
- // Ensure threshold is hidden for users of assistive technologies
2663
- countMessage.setAttribute('aria-hidden', true);
2664
- } else {
2665
- countMessage.classList.remove('govuk-character-count__message--disabled');
2666
- // Ensure threshold is visible for users of assistive technologies
2667
- countMessage.removeAttribute('aria-hidden');
2668
- }
2669
-
2670
- // Update styles
2671
- if (remainingNumber < 0) {
2672
- countElement.classList.add('govuk-textarea--error');
2673
- countMessage.classList.remove('govuk-hint');
2674
- countMessage.classList.add('govuk-error-message');
2675
- } else {
2676
- countElement.classList.remove('govuk-textarea--error');
2677
- countMessage.classList.remove('govuk-error-message');
2678
- countMessage.classList.add('govuk-hint');
2679
- }
2680
-
2681
- // Update message
2682
- var charVerb = 'remaining';
2683
- var charNoun = 'character';
2684
- var displayNumber = remainingNumber;
2685
- if (options.maxwords) {
2686
- charNoun = 'word';
2687
- }
2688
- charNoun = charNoun + ((remainingNumber === -1 || remainingNumber === 1) ? '' : 's');
2689
-
2690
- charVerb = (remainingNumber < 0) ? 'too many' : 'remaining';
2691
- displayNumber = Math.abs(remainingNumber);
2692
-
2693
- countMessage.innerHTML = 'You have ' + displayNumber + ' ' + charNoun + ' ' + charVerb;
2694
- };
2695
-
2696
- CharacterCount.prototype.handleFocus = function () {
2697
- // Check if value changed on focus
2698
- this.valueChecker = setInterval(this.checkIfValueChanged.bind(this), 1000);
2699
- };
2700
-
2701
- CharacterCount.prototype.handleBlur = function () {
2702
- // Cancel value checking on blur
2703
- clearInterval(this.valueChecker);
2704
- };
2705
-
2706
- function Checkboxes ($module) {
2707
- this.$module = $module;
2708
- this.$inputs = $module.querySelectorAll('input[type="checkbox"]');
2709
- }
2710
-
2711
- /**
2712
- * Initialise Checkboxes
2713
- *
2714
- * Checkboxes can be associated with a 'conditionally revealed' content block –
2715
- * for example, a checkbox for 'Phone' could reveal an additional form field for
2716
- * the user to enter their phone number.
2717
- *
2718
- * These associations are made using a `data-aria-controls` attribute, which is
2719
- * promoted to an aria-controls attribute during initialisation.
2720
- *
2721
- * We also need to restore the state of any conditional reveals on the page (for
2722
- * example if the user has navigated back), and set up event handlers to keep
2723
- * the reveal in sync with the checkbox state.
2724
- */
2725
- Checkboxes.prototype.init = function () {
2726
- var $module = this.$module;
2727
- var $inputs = this.$inputs;
2728
-
2729
- nodeListForEach($inputs, function ($input) {
2730
- var target = $input.getAttribute('data-aria-controls');
2731
-
2732
- // Skip checkboxes without data-aria-controls attributes, or where the
2733
- // target element does not exist.
2734
- if (!target || !$module.querySelector('#' + target)) {
2735
- return
2736
- }
2737
-
2738
- // Promote the data-aria-controls attribute to a aria-controls attribute
2739
- // so that the relationship is exposed in the AOM
2740
- $input.setAttribute('aria-controls', target);
2741
- $input.removeAttribute('data-aria-controls');
2742
- });
2743
-
2744
- // When the page is restored after navigating 'back' in some browsers the
2745
- // state of form controls is not restored until *after* the DOMContentLoaded
2746
- // event is fired, so we need to sync after the pageshow event in browsers
2747
- // that support it.
2748
- if ('onpageshow' in window) {
2749
- window.addEventListener('pageshow', this.syncAllConditionalReveals.bind(this));
2750
- } else {
2751
- window.addEventListener('DOMContentLoaded', this.syncAllConditionalReveals.bind(this));
2752
- }
2753
-
2754
- // Although we've set up handlers to sync state on the pageshow or
2755
- // DOMContentLoaded event, init could be called after those events have fired,
2756
- // for example if they are added to the page dynamically, so sync now too.
2757
- this.syncAllConditionalReveals();
2758
-
2759
- $module.addEventListener('click', this.handleClick.bind(this));
2760
- };
2761
-
2762
- /**
2763
- * Sync the conditional reveal states for all inputs in this $module.
2764
- */
2765
- Checkboxes.prototype.syncAllConditionalReveals = function () {
2766
- nodeListForEach(this.$inputs, this.syncConditionalRevealWithInputState.bind(this));
2767
- };
2768
-
2769
- /**
2770
- * Sync conditional reveal with the input state
2771
- *
2772
- * Synchronise the visibility of the conditional reveal, and its accessible
2773
- * state, with the input's checked state.
2774
- *
2775
- * @param {HTMLInputElement} $input Checkbox input
2776
- */
2777
- Checkboxes.prototype.syncConditionalRevealWithInputState = function ($input) {
2778
- var $target = this.$module.querySelector('#' + $input.getAttribute('aria-controls'));
2779
-
2780
- if ($target && $target.classList.contains('govuk-checkboxes__conditional')) {
2781
- var inputIsChecked = $input.checked;
2782
-
2783
- $input.setAttribute('aria-expanded', inputIsChecked);
2784
- $target.classList.toggle('govuk-checkboxes__conditional--hidden', !inputIsChecked);
2785
- }
2786
- };
2787
-
2788
- /**
2789
- * Uncheck other checkboxes
2790
- *
2791
- * Find any other checkbox inputs with the same name value, and uncheck them.
2792
- * This is useful for when a “None of these" checkbox is checked.
2793
- */
2794
- Checkboxes.prototype.unCheckAllInputsExcept = function ($input) {
2795
- var allInputsWithSameName = document.querySelectorAll('input[type="checkbox"][name="' + $input.name + '"]');
2796
-
2797
- nodeListForEach(allInputsWithSameName, function ($inputWithSameName) {
2798
- var hasSameFormOwner = ($input.form === $inputWithSameName.form);
2799
- if (hasSameFormOwner && $inputWithSameName !== $input) {
2800
- $inputWithSameName.checked = false;
2801
- }
2802
- });
2803
-
2804
- this.syncAllConditionalReveals();
2805
- };
2806
-
2807
- /**
2808
- * Uncheck exclusive inputs
2809
- *
2810
- * Find any checkbox inputs with the same name value and the 'exclusive' behaviour,
2811
- * and uncheck them. This helps prevent someone checking both a regular checkbox and a
2812
- * "None of these" checkbox in the same fieldset.
2813
- */
2814
- Checkboxes.prototype.unCheckExclusiveInputs = function ($input) {
2815
- var allInputsWithSameNameAndExclusiveBehaviour = document.querySelectorAll(
2816
- 'input[data-behaviour="exclusive"][type="checkbox"][name="' + $input.name + '"]'
2817
- );
2818
-
2819
- nodeListForEach(allInputsWithSameNameAndExclusiveBehaviour, function ($exclusiveInput) {
2820
- var hasSameFormOwner = ($input.form === $exclusiveInput.form);
2821
- if (hasSameFormOwner) {
2822
- $exclusiveInput.checked = false;
2823
- }
2824
- });
2825
-
2826
- this.syncAllConditionalReveals();
2827
- };
2828
-
2829
- /**
2830
- * Click event handler
2831
- *
2832
- * Handle a click within the $module – if the click occurred on a checkbox, sync
2833
- * the state of any associated conditional reveal with the checkbox state.
2834
- *
2835
- * @param {MouseEvent} event Click event
2836
- */
2837
- Checkboxes.prototype.handleClick = function (event) {
2838
- var $target = event.target;
2839
-
2840
- // Ignore clicks on things that aren't checkbox inputs
2841
- if ($target.type !== 'checkbox') {
2842
- return
2843
- }
2844
-
2845
- // If the checkbox conditionally-reveals some content, sync the state
2846
- var hasAriaControls = $target.getAttribute('aria-controls');
2847
- if (hasAriaControls) {
2848
- this.syncConditionalRevealWithInputState($target);
2849
- }
2850
-
2851
- // No further behaviour needed for unchecking
2852
- if (!$target.checked) {
2853
- return
2854
- }
2855
-
2856
- // Handle 'exclusive' checkbox behaviour (ie "None of these")
2857
- var hasBehaviourExclusive = ($target.getAttribute('data-behaviour') === 'exclusive');
2858
- if (hasBehaviourExclusive) {
2859
- this.unCheckAllInputsExcept($target);
2860
- } else {
2861
- this.unCheckExclusiveInputs($target);
2862
- }
2863
- };
2864
-
2865
- (function(undefined) {
2866
-
2867
- // Detection from https://raw.githubusercontent.com/Financial-Times/polyfill-service/1f3c09b402f65bf6e393f933a15ba63f1b86ef1f/packages/polyfill-library/polyfills/Element/prototype/matches/detect.js
2868
- var detect = (
2869
- 'document' in this && "matches" in document.documentElement
2870
- );
2871
-
2872
- if (detect) return
2873
-
2874
- // Polyfill from https://raw.githubusercontent.com/Financial-Times/polyfill-service/1f3c09b402f65bf6e393f933a15ba63f1b86ef1f/packages/polyfill-library/polyfills/Element/prototype/matches/polyfill.js
2875
- Element.prototype.matches = Element.prototype.webkitMatchesSelector || Element.prototype.oMatchesSelector || Element.prototype.msMatchesSelector || Element.prototype.mozMatchesSelector || function matches(selector) {
2876
- var element = this;
2877
- var elements = (element.document || element.ownerDocument).querySelectorAll(selector);
2878
- var index = 0;
2879
-
2880
- while (elements[index] && elements[index] !== element) {
2881
- ++index;
2882
- }
2883
-
2884
- return !!elements[index];
2885
- };
2886
-
2887
- }).call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
2888
-
2889
- (function(undefined) {
2890
-
2891
- // Detection from https://raw.githubusercontent.com/Financial-Times/polyfill-service/1f3c09b402f65bf6e393f933a15ba63f1b86ef1f/packages/polyfill-library/polyfills/Element/prototype/closest/detect.js
2892
- var detect = (
2893
- 'document' in this && "closest" in document.documentElement
2894
- );
2895
-
2896
- if (detect) return
2897
-
2898
- // Polyfill from https://raw.githubusercontent.com/Financial-Times/polyfill-service/1f3c09b402f65bf6e393f933a15ba63f1b86ef1f/packages/polyfill-library/polyfills/Element/prototype/closest/polyfill.js
2899
- Element.prototype.closest = function closest(selector) {
2900
- var node = this;
2901
-
2902
- while (node) {
2903
- if (node.matches(selector)) return node;
2904
- else node = 'SVGElement' in window && node instanceof SVGElement ? node.parentNode : node.parentElement;
2905
- }
2906
-
2907
- return null;
2908
- };
2909
-
2910
- }).call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
2911
-
2912
- function ErrorSummary ($module) {
2913
- this.$module = $module;
2914
- }
2915
-
2916
- ErrorSummary.prototype.init = function () {
2917
- var $module = this.$module;
2918
- if (!$module) {
2919
- return
2920
- }
2921
- $module.focus();
2922
-
2923
- $module.addEventListener('click', this.handleClick.bind(this));
2924
- };
2925
-
2926
- /**
2927
- * Click event handler
2928
- *
2929
- * @param {MouseEvent} event - Click event
2930
- */
2931
- ErrorSummary.prototype.handleClick = function (event) {
2932
- var target = event.target;
2933
- if (this.focusTarget(target)) {
2934
- event.preventDefault();
2935
- }
2936
- };
2937
-
2938
- /**
2939
- * Focus the target element
2940
- *
2941
- * By default, the browser will scroll the target into view. Because our labels
2942
- * or legends appear above the input, this means the user will be presented with
2943
- * an input without any context, as the label or legend will be off the top of
2944
- * the screen.
2945
- *
2946
- * Manually handling the click event, scrolling the question into view and then
2947
- * focussing the element solves this.
2948
- *
2949
- * This also results in the label and/or legend being announced correctly in
2950
- * NVDA (as tested in 2018.3.2) - without this only the field type is announced
2951
- * (e.g. "Edit, has autocomplete").
2952
- *
2953
- * @param {HTMLElement} $target - Event target
2954
- * @returns {boolean} True if the target was able to be focussed
2955
- */
2956
- ErrorSummary.prototype.focusTarget = function ($target) {
2957
- // If the element that was clicked was not a link, return early
2958
- if ($target.tagName !== 'A' || $target.href === false) {
2959
- return false
2960
- }
2961
-
2962
- var inputId = this.getFragmentFromUrl($target.href);
2963
- var $input = document.getElementById(inputId);
2964
- if (!$input) {
2965
- return false
2966
- }
2967
-
2968
- var $legendOrLabel = this.getAssociatedLegendOrLabel($input);
2969
- if (!$legendOrLabel) {
2970
- return false
2971
- }
2972
-
2973
- // Scroll the legend or label into view *before* calling focus on the input to
2974
- // avoid extra scrolling in browsers that don't support `preventScroll` (which
2975
- // at time of writing is most of them...)
2976
- $legendOrLabel.scrollIntoView();
2977
- $input.focus({ preventScroll: true });
2978
-
2979
- return true
2980
- };
2981
-
2982
- /**
2983
- * Get fragment from URL
2984
- *
2985
- * Extract the fragment (everything after the hash) from a URL, but not including
2986
- * the hash.
2987
- *
2988
- * @param {string} url - URL
2989
- * @returns {string} Fragment from URL, without the hash
2990
- */
2991
- ErrorSummary.prototype.getFragmentFromUrl = function (url) {
2992
- if (url.indexOf('#') === -1) {
2993
- return false
2994
- }
2995
-
2996
- return url.split('#').pop()
2997
- };
2998
-
2999
- /**
3000
- * Get associated legend or label
3001
- *
3002
- * Returns the first element that exists from this list:
3003
- *
3004
- * - The `<legend>` associated with the closest `<fieldset>` ancestor, as long
3005
- * as the top of it is no more than half a viewport height away from the
3006
- * bottom of the input
3007
- * - The first `<label>` that is associated with the input using for="inputId"
3008
- * - The closest parent `<label>`
3009
- *
3010
- * @param {HTMLElement} $input - The input
3011
- * @returns {HTMLElement} Associated legend or label, or null if no associated
3012
- * legend or label can be found
3013
- */
3014
- ErrorSummary.prototype.getAssociatedLegendOrLabel = function ($input) {
3015
- var $fieldset = $input.closest('fieldset');
3016
-
3017
- if ($fieldset) {
3018
- var legends = $fieldset.getElementsByTagName('legend');
3019
-
3020
- if (legends.length) {
3021
- var $candidateLegend = legends[0];
3022
-
3023
- // If the input type is radio or checkbox, always use the legend if there
3024
- // is one.
3025
- if ($input.type === 'checkbox' || $input.type === 'radio') {
3026
- return $candidateLegend
3027
- }
3028
-
3029
- // For other input types, only scroll to the fieldset’s legend (instead of
3030
- // the label associated with the input) if the input would end up in the
3031
- // top half of the screen.
3032
- //
3033
- // This should avoid situations where the input either ends up off the
3034
- // screen, or obscured by a software keyboard.
3035
- var legendTop = $candidateLegend.getBoundingClientRect().top;
3036
- var inputRect = $input.getBoundingClientRect();
3037
-
3038
- // If the browser doesn't support Element.getBoundingClientRect().height
3039
- // or window.innerHeight (like IE8), bail and just link to the label.
3040
- if (inputRect.height && window.innerHeight) {
3041
- var inputBottom = inputRect.top + inputRect.height;
3042
-
3043
- if (inputBottom - legendTop < window.innerHeight / 2) {
3044
- return $candidateLegend
3045
- }
3046
- }
3047
- }
3048
- }
3049
-
3050
- return document.querySelector("label[for='" + $input.getAttribute('id') + "']") ||
3051
- $input.closest('label')
3052
- };
3053
-
3054
- function NotificationBanner ($module) {
3055
- this.$module = $module;
3056
- }
3057
-
3058
- /**
3059
- * Initialise the component
3060
- */
3061
- NotificationBanner.prototype.init = function () {
3062
- var $module = this.$module;
3063
- // Check for module
3064
- if (!$module) {
3065
- return
3066
- }
3067
-
3068
- this.setFocus();
3069
- };
3070
-
3071
- /**
3072
- * Focus the element
3073
- *
3074
- * If `role="alert"` is set, focus the element to help some assistive technologies
3075
- * prioritise announcing it.
3076
- *
3077
- * You can turn off the auto-focus functionality by setting `data-disable-auto-focus="true"` in the
3078
- * component HTML. You might wish to do this based on user research findings, or to avoid a clash
3079
- * with another element which should be focused when the page loads.
3080
- */
3081
- NotificationBanner.prototype.setFocus = function () {
3082
- var $module = this.$module;
3083
-
3084
- if ($module.getAttribute('data-disable-auto-focus') === 'true') {
3085
- return
3086
- }
3087
-
3088
- if ($module.getAttribute('role') !== 'alert') {
3089
- return
3090
- }
3091
-
3092
- // Set tabindex to -1 to make the element focusable with JavaScript.
3093
- // Remove the tabindex on blur as the component doesn't need to be focusable after the page has
3094
- // loaded.
3095
- if (!$module.getAttribute('tabindex')) {
3096
- $module.setAttribute('tabindex', '-1');
3097
-
3098
- $module.addEventListener('blur', function () {
3099
- $module.removeAttribute('tabindex');
3100
- });
3101
- }
3102
-
3103
- $module.focus();
3104
- };
3105
-
3106
- function Header ($module) {
3107
- this.$module = $module;
3108
- this.$menuButton = $module && $module.querySelector('.govuk-js-header-toggle');
3109
- this.$menu = this.$menuButton && $module.querySelector(
3110
- '#' + this.$menuButton.getAttribute('aria-controls')
3111
- );
3112
- }
3113
-
3114
- /**
3115
- * Initialise header
3116
- *
3117
- * Check for the presence of the header, menu and menu button – if any are
3118
- * missing then there's nothing to do so return early.
3119
- */
3120
- Header.prototype.init = function () {
3121
- if (!this.$module || !this.$menuButton || !this.$menu) {
3122
- return
3123
- }
3124
-
3125
- this.syncState(this.$menu.classList.contains('govuk-header__navigation--open'));
3126
- this.$menuButton.addEventListener('click', this.handleMenuButtonClick.bind(this));
3127
- };
3128
-
3129
- /**
3130
- * Sync menu state
3131
- *
3132
- * Sync the menu button class and the accessible state of the menu and the menu
3133
- * button with the visible state of the menu
3134
- *
3135
- * @param {boolean} isVisible Whether the menu is currently visible
3136
- */
3137
- Header.prototype.syncState = function (isVisible) {
3138
- this.$menuButton.classList.toggle('govuk-header__menu-button--open', isVisible);
3139
- this.$menuButton.setAttribute('aria-expanded', isVisible);
3140
- };
3141
-
3142
- /**
3143
- * Handle menu button click
3144
- *
3145
- * When the menu button is clicked, change the visibility of the menu and then
3146
- * sync the accessibility state and menu button state
3147
- */
3148
- Header.prototype.handleMenuButtonClick = function () {
3149
- var isVisible = this.$menu.classList.toggle('govuk-header__navigation--open');
3150
- this.syncState(isVisible);
3151
- };
3152
-
3153
- function Radios ($module) {
3154
- this.$module = $module;
3155
- this.$inputs = $module.querySelectorAll('input[type="radio"]');
3156
- }
3157
-
3158
- /**
3159
- * Initialise Radios
3160
- *
3161
- * Radios can be associated with a 'conditionally revealed' content block – for
3162
- * example, a radio for 'Phone' could reveal an additional form field for the
3163
- * user to enter their phone number.
3164
- *
3165
- * These associations are made using a `data-aria-controls` attribute, which is
3166
- * promoted to an aria-controls attribute during initialisation.
3167
- *
3168
- * We also need to restore the state of any conditional reveals on the page (for
3169
- * example if the user has navigated back), and set up event handlers to keep
3170
- * the reveal in sync with the radio state.
3171
- */
3172
- Radios.prototype.init = function () {
3173
- var $module = this.$module;
3174
- var $inputs = this.$inputs;
3175
-
3176
- nodeListForEach($inputs, function ($input) {
3177
- var target = $input.getAttribute('data-aria-controls');
3178
-
3179
- // Skip radios without data-aria-controls attributes, or where the
3180
- // target element does not exist.
3181
- if (!target || !$module.querySelector('#' + target)) {
3182
- return
3183
- }
3184
-
3185
- // Promote the data-aria-controls attribute to a aria-controls attribute
3186
- // so that the relationship is exposed in the AOM
3187
- $input.setAttribute('aria-controls', target);
3188
- $input.removeAttribute('data-aria-controls');
3189
- });
3190
-
3191
- // When the page is restored after navigating 'back' in some browsers the
3192
- // state of form controls is not restored until *after* the DOMContentLoaded
3193
- // event is fired, so we need to sync after the pageshow event in browsers
3194
- // that support it.
3195
- if ('onpageshow' in window) {
3196
- window.addEventListener('pageshow', this.syncAllConditionalReveals.bind(this));
3197
- } else {
3198
- window.addEventListener('DOMContentLoaded', this.syncAllConditionalReveals.bind(this));
3199
- }
3200
-
3201
- // Although we've set up handlers to sync state on the pageshow or
3202
- // DOMContentLoaded event, init could be called after those events have fired,
3203
- // for example if they are added to the page dynamically, so sync now too.
3204
- this.syncAllConditionalReveals();
3205
-
3206
- // Handle events
3207
- $module.addEventListener('click', this.handleClick.bind(this));
3208
- };
3209
-
3210
- /**
3211
- * Sync the conditional reveal states for all inputs in this $module.
3212
- */
3213
- Radios.prototype.syncAllConditionalReveals = function () {
3214
- nodeListForEach(this.$inputs, this.syncConditionalRevealWithInputState.bind(this));
3215
- };
3216
-
3217
- /**
3218
- * Sync conditional reveal with the input state
3219
- *
3220
- * Synchronise the visibility of the conditional reveal, and its accessible
3221
- * state, with the input's checked state.
3222
- *
3223
- * @param {HTMLInputElement} $input Radio input
3224
- */
3225
- Radios.prototype.syncConditionalRevealWithInputState = function ($input) {
3226
- var $target = document.querySelector('#' + $input.getAttribute('aria-controls'));
3227
-
3228
- if ($target && $target.classList.contains('govuk-radios__conditional')) {
3229
- var inputIsChecked = $input.checked;
3230
-
3231
- $input.setAttribute('aria-expanded', inputIsChecked);
3232
- $target.classList.toggle('govuk-radios__conditional--hidden', !inputIsChecked);
3233
- }
3234
- };
3235
-
3236
- /**
3237
- * Click event handler
3238
- *
3239
- * Handle a click within the $module – if the click occurred on a radio, sync
3240
- * the state of the conditional reveal for all radio buttons in the same form
3241
- * with the same name (because checking one radio could have un-checked a radio
3242
- * in another $module)
3243
- *
3244
- * @param {MouseEvent} event Click event
3245
- */
3246
- Radios.prototype.handleClick = function (event) {
3247
- var $clickedInput = event.target;
3248
-
3249
- // Ignore clicks on things that aren't radio buttons
3250
- if ($clickedInput.type !== 'radio') {
3251
- return
3252
- }
3253
-
3254
- // We only need to consider radios with conditional reveals, which will have
3255
- // aria-controls attributes.
3256
- var $allInputs = document.querySelectorAll('input[type="radio"][aria-controls]');
3257
-
3258
- nodeListForEach($allInputs, function ($input) {
3259
- var hasSameFormOwner = ($input.form === $clickedInput.form);
3260
- var hasSameName = ($input.name === $clickedInput.name);
3261
-
3262
- if (hasSameName && hasSameFormOwner) {
3263
- this.syncConditionalRevealWithInputState($input);
3264
- }
3265
- }.bind(this));
3266
- };
3267
-
3268
- (function(undefined) {
3269
-
3270
- // Detection from https://raw.githubusercontent.com/Financial-Times/polyfill-library/master/polyfills/Element/prototype/nextElementSibling/detect.js
3271
- var detect = (
3272
- 'document' in this && "nextElementSibling" in document.documentElement
3273
- );
3274
-
3275
- if (detect) return
3276
-
3277
- // Polyfill from https://raw.githubusercontent.com/Financial-Times/polyfill-library/master/polyfills/Element/prototype/nextElementSibling/polyfill.js
3278
- Object.defineProperty(Element.prototype, "nextElementSibling", {
3279
- get: function(){
3280
- var el = this.nextSibling;
3281
- while (el && el.nodeType !== 1) { el = el.nextSibling; }
3282
- return el;
3283
- }
3284
- });
3285
-
3286
- }).call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
3287
-
3288
- (function(undefined) {
3289
-
3290
- // Detection from https://raw.githubusercontent.com/Financial-Times/polyfill-library/master/polyfills/Element/prototype/previousElementSibling/detect.js
3291
- var detect = (
3292
- 'document' in this && "previousElementSibling" in document.documentElement
3293
- );
3294
-
3295
- if (detect) return
3296
-
3297
- // Polyfill from https://raw.githubusercontent.com/Financial-Times/polyfill-library/master/polyfills/Element/prototype/previousElementSibling/polyfill.js
3298
- Object.defineProperty(Element.prototype, 'previousElementSibling', {
3299
- get: function(){
3300
- var el = this.previousSibling;
3301
- while (el && el.nodeType !== 1) { el = el.previousSibling; }
3302
- return el;
3303
- }
3304
- });
3305
-
3306
- }).call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
3307
-
3308
- function Tabs ($module) {
3309
- this.$module = $module;
3310
- this.$tabs = $module.querySelectorAll('.govuk-tabs__tab');
3311
-
3312
- this.keys = { left: 37, right: 39, up: 38, down: 40 };
3313
- this.jsHiddenClass = 'govuk-tabs__panel--hidden';
3314
- }
3315
-
3316
- Tabs.prototype.init = function () {
3317
- if (typeof window.matchMedia === 'function') {
3318
- this.setupResponsiveChecks();
3319
- } else {
3320
- this.setup();
3321
- }
3322
- };
3323
-
3324
- Tabs.prototype.setupResponsiveChecks = function () {
3325
- this.mql = window.matchMedia('(min-width: 40.0625em)');
3326
- this.mql.addListener(this.checkMode.bind(this));
3327
- this.checkMode();
3328
- };
3329
-
3330
- Tabs.prototype.checkMode = function () {
3331
- if (this.mql.matches) {
3332
- this.setup();
3333
- } else {
3334
- this.teardown();
3335
- }
3336
- };
3337
-
3338
- Tabs.prototype.setup = function () {
3339
- var $module = this.$module;
3340
- var $tabs = this.$tabs;
3341
- var $tabList = $module.querySelector('.govuk-tabs__list');
3342
- var $tabListItems = $module.querySelectorAll('.govuk-tabs__list-item');
3343
-
3344
- if (!$tabs || !$tabList || !$tabListItems) {
3345
- return
3346
- }
3347
-
3348
- $tabList.setAttribute('role', 'tablist');
3349
-
3350
- nodeListForEach($tabListItems, function ($item) {
3351
- $item.setAttribute('role', 'presentation');
3352
- });
3353
-
3354
- nodeListForEach($tabs, function ($tab) {
3355
- // Set HTML attributes
3356
- this.setAttributes($tab);
3357
-
3358
- // Save bounded functions to use when removing event listeners during teardown
3359
- $tab.boundTabClick = this.onTabClick.bind(this);
3360
- $tab.boundTabKeydown = this.onTabKeydown.bind(this);
3361
-
3362
- // Handle events
3363
- $tab.addEventListener('click', $tab.boundTabClick, true);
3364
- $tab.addEventListener('keydown', $tab.boundTabKeydown, true);
3365
-
3366
- // Remove old active panels
3367
- this.hideTab($tab);
3368
- }.bind(this));
3369
-
3370
- // Show either the active tab according to the URL's hash or the first tab
3371
- var $activeTab = this.getTab(window.location.hash) || this.$tabs[0];
3372
- this.showTab($activeTab);
3373
-
3374
- // Handle hashchange events
3375
- $module.boundOnHashChange = this.onHashChange.bind(this);
3376
- window.addEventListener('hashchange', $module.boundOnHashChange, true);
3377
- };
3378
-
3379
- Tabs.prototype.teardown = function () {
3380
- var $module = this.$module;
3381
- var $tabs = this.$tabs;
3382
- var $tabList = $module.querySelector('.govuk-tabs__list');
3383
- var $tabListItems = $module.querySelectorAll('.govuk-tabs__list-item');
3384
-
3385
- if (!$tabs || !$tabList || !$tabListItems) {
3386
- return
3387
- }
3388
-
3389
- $tabList.removeAttribute('role');
3390
-
3391
- nodeListForEach($tabListItems, function ($item) {
3392
- $item.removeAttribute('role', 'presentation');
3393
- });
3394
-
3395
- nodeListForEach($tabs, function ($tab) {
3396
- // Remove events
3397
- $tab.removeEventListener('click', $tab.boundTabClick, true);
3398
- $tab.removeEventListener('keydown', $tab.boundTabKeydown, true);
3399
-
3400
- // Unset HTML attributes
3401
- this.unsetAttributes($tab);
3402
- }.bind(this));
3403
-
3404
- // Remove hashchange event handler
3405
- window.removeEventListener('hashchange', $module.boundOnHashChange, true);
3406
- };
3407
-
3408
- Tabs.prototype.onHashChange = function (e) {
3409
- var hash = window.location.hash;
3410
- var $tabWithHash = this.getTab(hash);
3411
- if (!$tabWithHash) {
3412
- return
3413
- }
3414
-
3415
- // Prevent changing the hash
3416
- if (this.changingHash) {
3417
- this.changingHash = false;
3418
- return
3419
- }
3420
-
3421
- // Show either the active tab according to the URL's hash or the first tab
3422
- var $previousTab = this.getCurrentTab();
3423
-
3424
- this.hideTab($previousTab);
3425
- this.showTab($tabWithHash);
3426
- $tabWithHash.focus();
3427
- };
3428
-
3429
- Tabs.prototype.hideTab = function ($tab) {
3430
- this.unhighlightTab($tab);
3431
- this.hidePanel($tab);
3432
- };
3433
-
3434
- Tabs.prototype.showTab = function ($tab) {
3435
- this.highlightTab($tab);
3436
- this.showPanel($tab);
3437
- };
3438
-
3439
- Tabs.prototype.getTab = function (hash) {
3440
- return this.$module.querySelector('.govuk-tabs__tab[href="' + hash + '"]')
3441
- };
3442
-
3443
- Tabs.prototype.setAttributes = function ($tab) {
3444
- // set tab attributes
3445
- var panelId = this.getHref($tab).slice(1);
3446
- $tab.setAttribute('id', 'tab_' + panelId);
3447
- $tab.setAttribute('role', 'tab');
3448
- $tab.setAttribute('aria-controls', panelId);
3449
- $tab.setAttribute('aria-selected', 'false');
3450
- $tab.setAttribute('tabindex', '-1');
3451
-
3452
- // set panel attributes
3453
- var $panel = this.getPanel($tab);
3454
- $panel.setAttribute('role', 'tabpanel');
3455
- $panel.setAttribute('aria-labelledby', $tab.id);
3456
- $panel.classList.add(this.jsHiddenClass);
3457
- };
3458
-
3459
- Tabs.prototype.unsetAttributes = function ($tab) {
3460
- // unset tab attributes
3461
- $tab.removeAttribute('id');
3462
- $tab.removeAttribute('role');
3463
- $tab.removeAttribute('aria-controls');
3464
- $tab.removeAttribute('aria-selected');
3465
- $tab.removeAttribute('tabindex');
3466
-
3467
- // unset panel attributes
3468
- var $panel = this.getPanel($tab);
3469
- $panel.removeAttribute('role');
3470
- $panel.removeAttribute('aria-labelledby');
3471
- $panel.classList.remove(this.jsHiddenClass);
3472
- };
3473
-
3474
- Tabs.prototype.onTabClick = function (e) {
3475
- if (!e.target.classList.contains('govuk-tabs__tab')) {
3476
- // Allow events on child DOM elements to bubble up to tab parent
3477
- return false
3478
- }
3479
- e.preventDefault();
3480
- var $newTab = e.target;
3481
- var $currentTab = this.getCurrentTab();
3482
- this.hideTab($currentTab);
3483
- this.showTab($newTab);
3484
- this.createHistoryEntry($newTab);
3485
- };
3486
-
3487
- Tabs.prototype.createHistoryEntry = function ($tab) {
3488
- var $panel = this.getPanel($tab);
3489
-
3490
- // Save and restore the id
3491
- // so the page doesn't jump when a user clicks a tab (which changes the hash)
3492
- var id = $panel.id;
3493
- $panel.id = '';
3494
- this.changingHash = true;
3495
- window.location.hash = this.getHref($tab).slice(1);
3496
- $panel.id = id;
3497
- };
3498
-
3499
- Tabs.prototype.onTabKeydown = function (e) {
3500
- switch (e.keyCode) {
3501
- case this.keys.left:
3502
- case this.keys.up:
3503
- this.activatePreviousTab();
3504
- e.preventDefault();
3505
- break
3506
- case this.keys.right:
3507
- case this.keys.down:
3508
- this.activateNextTab();
3509
- e.preventDefault();
3510
- break
3511
- }
3512
- };
3513
-
3514
- Tabs.prototype.activateNextTab = function () {
3515
- var currentTab = this.getCurrentTab();
3516
- var nextTabListItem = currentTab.parentNode.nextElementSibling;
3517
- if (nextTabListItem) {
3518
- var nextTab = nextTabListItem.querySelector('.govuk-tabs__tab');
3519
- }
3520
- if (nextTab) {
3521
- this.hideTab(currentTab);
3522
- this.showTab(nextTab);
3523
- nextTab.focus();
3524
- this.createHistoryEntry(nextTab);
3525
- }
3526
- };
3527
-
3528
- Tabs.prototype.activatePreviousTab = function () {
3529
- var currentTab = this.getCurrentTab();
3530
- var previousTabListItem = currentTab.parentNode.previousElementSibling;
3531
- if (previousTabListItem) {
3532
- var previousTab = previousTabListItem.querySelector('.govuk-tabs__tab');
3533
- }
3534
- if (previousTab) {
3535
- this.hideTab(currentTab);
3536
- this.showTab(previousTab);
3537
- previousTab.focus();
3538
- this.createHistoryEntry(previousTab);
3539
- }
3540
- };
3541
-
3542
- Tabs.prototype.getPanel = function ($tab) {
3543
- var $panel = this.$module.querySelector(this.getHref($tab));
3544
- return $panel
3545
- };
3546
-
3547
- Tabs.prototype.showPanel = function ($tab) {
3548
- var $panel = this.getPanel($tab);
3549
- $panel.classList.remove(this.jsHiddenClass);
3550
- };
3551
-
3552
- Tabs.prototype.hidePanel = function (tab) {
3553
- var $panel = this.getPanel(tab);
3554
- $panel.classList.add(this.jsHiddenClass);
3555
- };
3556
-
3557
- Tabs.prototype.unhighlightTab = function ($tab) {
3558
- $tab.setAttribute('aria-selected', 'false');
3559
- $tab.parentNode.classList.remove('govuk-tabs__list-item--selected');
3560
- $tab.setAttribute('tabindex', '-1');
3561
- };
3562
-
3563
- Tabs.prototype.highlightTab = function ($tab) {
3564
- $tab.setAttribute('aria-selected', 'true');
3565
- $tab.parentNode.classList.add('govuk-tabs__list-item--selected');
3566
- $tab.setAttribute('tabindex', '0');
3567
- };
3568
-
3569
- Tabs.prototype.getCurrentTab = function () {
3570
- return this.$module.querySelector('.govuk-tabs__list-item--selected .govuk-tabs__tab')
3571
- };
3572
-
3573
- // this is because IE doesn't always return the actual value but a relative full path
3574
- // should be a utility function most prob
3575
- // http://labs.thesedays.com/blog/2010/01/08/getting-the-href-value-with-jquery-in-ie/
3576
- Tabs.prototype.getHref = function ($tab) {
3577
- var href = $tab.getAttribute('href');
3578
- var hash = href.slice(href.indexOf('#'), href.length);
3579
- return hash
3580
- };
3581
-
3582
- function initAll (options) {
3583
- // Set the options to an empty object by default if no options are passed.
3584
- options = typeof options !== 'undefined' ? options : {};
3585
-
3586
- // Allow the user to initialise GOV.UK Frontend in only certain sections of the page
3587
- // Defaults to the entire document if nothing is set.
3588
- var scope = typeof options.scope !== 'undefined' ? options.scope : document;
3589
-
3590
- var $buttons = scope.querySelectorAll('[data-module="govuk-button"]');
3591
- nodeListForEach($buttons, function ($button) {
3592
- new Button($button).init();
3593
- });
3594
-
3595
- var $accordions = scope.querySelectorAll('[data-module="govuk-accordion"]');
3596
- nodeListForEach($accordions, function ($accordion) {
3597
- new Accordion($accordion).init();
3598
- });
3599
-
3600
- var $details = scope.querySelectorAll('[data-module="govuk-details"]');
3601
- nodeListForEach($details, function ($detail) {
3602
- new Details($detail).init();
3603
- });
3604
-
3605
- var $characterCounts = scope.querySelectorAll('[data-module="govuk-character-count"]');
3606
- nodeListForEach($characterCounts, function ($characterCount) {
3607
- new CharacterCount($characterCount).init();
3608
- });
3609
-
3610
- var $checkboxes = scope.querySelectorAll('[data-module="govuk-checkboxes"]');
3611
- nodeListForEach($checkboxes, function ($checkbox) {
3612
- new Checkboxes($checkbox).init();
3613
- });
3614
-
3615
- // Find first error summary module to enhance.
3616
- var $errorSummary = scope.querySelector('[data-module="govuk-error-summary"]');
3617
- new ErrorSummary($errorSummary).init();
3618
-
3619
- // Find first header module to enhance.
3620
- var $toggleButton = scope.querySelector('[data-module="govuk-header"]');
3621
- new Header($toggleButton).init();
3622
-
3623
- var $notificationBanners = scope.querySelectorAll('[data-module="govuk-notification-banner"]');
3624
- nodeListForEach($notificationBanners, function ($notificationBanner) {
3625
- new NotificationBanner($notificationBanner).init();
3626
- });
3627
-
3628
- var $radios = scope.querySelectorAll('[data-module="govuk-radios"]');
3629
- nodeListForEach($radios, function ($radio) {
3630
- new Radios($radio).init();
3631
- });
3632
-
3633
- var $tabs = scope.querySelectorAll('[data-module="govuk-tabs"]');
3634
- nodeListForEach($tabs, function ($tabs) {
3635
- new Tabs($tabs).init();
3636
- });
3637
- }
3638
-
3639
- exports.initAll = initAll;
3640
- exports.Accordion = Accordion;
3641
- exports.Button = Button;
3642
- exports.Details = Details;
3643
- exports.CharacterCount = CharacterCount;
3644
- exports.Checkboxes = Checkboxes;
3645
- exports.ErrorSummary = ErrorSummary;
3646
- exports.Header = Header;
3647
- exports.Radios = Radios;
3648
- exports.Tabs = Tabs;
3649
-
3650
- })));
3651
-
3652
- }).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
3653
- },{}],13:[function(require,module,exports){
898
+ },{"./assets/javascript/character-count":3,"./assets/javascript/form-focus":4,"./assets/javascript/helpers":5,"./assets/javascript/progressive-reveal":6,"./assets/javascript/validation":7,"./assets/javascript/vendor/details.polyfill":8}],10:[function(require,module,exports){
3654
899
  (function (global){(function (){
3655
900
  /**
3656
901
  * @license
@@ -20863,7 +18108,7 @@ exports.Tabs = Tabs;
20863
18108
  }.call(this));
20864
18109
 
20865
18110
  }).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
20866
- },{}],14:[function(require,module,exports){
18111
+ },{}],11:[function(require,module,exports){
20867
18112
  // shim for using process in browser
20868
18113
  var process = module.exports = {};
20869
18114
 
@@ -21049,7 +18294,7 @@ process.chdir = function (dir) {
21049
18294
  };
21050
18295
  process.umask = function() { return 0; };
21051
18296
 
21052
- },{}],15:[function(require,module,exports){
18297
+ },{}],12:[function(require,module,exports){
21053
18298
  (function (setImmediate,clearImmediate){(function (){
21054
18299
  var nextTick = require('process/browser.js').nextTick;
21055
18300
  var apply = Function.prototype.apply;
@@ -21128,7 +18373,7 @@ exports.clearImmediate = typeof clearImmediate === "function" ? clearImmediate :
21128
18373
  delete immediateIds[id];
21129
18374
  };
21130
18375
  }).call(this)}).call(this,require("timers").setImmediate,require("timers").clearImmediate)
21131
- },{"process/browser.js":14,"timers":15}],16:[function(require,module,exports){
18376
+ },{"process/browser.js":11,"timers":12}],13:[function(require,module,exports){
21132
18377
  /* eslint-disable */
21133
18378
  'use strict'
21134
18379
 
@@ -21199,8 +18444,7 @@ $('.typeahead').each(function applyTypeahead() {
21199
18444
  limit: 100
21200
18445
  });
21201
18446
  });
21202
-
21203
- },{"../../../frontend/themes/gov-uk/client-js":3,"jquery":17,"typeahead-aria":20}],17:[function(require,module,exports){
18447
+ },{"../../../frontend/themes/gov-uk/client-js":2,"jquery":14,"typeahead-aria":17}],14:[function(require,module,exports){
21204
18448
  /*!
21205
18449
  * jQuery JavaScript Library v3.6.0
21206
18450
  * https://jquery.com/
@@ -32083,7 +29327,7 @@ if ( typeof noGlobal === "undefined" ) {
32083
29327
  return jQuery;
32084
29328
  } );
32085
29329
 
32086
- },{}],18:[function(require,module,exports){
29330
+ },{}],15:[function(require,module,exports){
32087
29331
  /*!
32088
29332
  * typeahead.js 1.0.4
32089
29333
  * https://github.com/twitter/typeahead.js
@@ -33036,7 +30280,7 @@ return jQuery;
33036
30280
  }();
33037
30281
  return Bloodhound;
33038
30282
  });
33039
- },{"jquery":17}],19:[function(require,module,exports){
30283
+ },{"jquery":14}],16:[function(require,module,exports){
33040
30284
  (function (setImmediate){(function (){
33041
30285
  /*!
33042
30286
  * typeahead.js 1.0.4
@@ -35633,7 +32877,7 @@ return jQuery;
35633
32877
  })();
35634
32878
  });
35635
32879
  }).call(this)}).call(this,require("timers").setImmediate)
35636
- },{"jquery":17,"timers":15}],20:[function(require,module,exports){
32880
+ },{"jquery":14,"timers":12}],17:[function(require,module,exports){
35637
32881
  'use strict';
35638
32882
 
35639
32883
  module.exports = {
@@ -35641,4 +32885,4 @@ module.exports = {
35641
32885
  "loadjQueryPlugin": function() {require("./dist/typeahead.bundle.js");}
35642
32886
  };
35643
32887
 
35644
- },{"./dist/bloodhound.js":18,"./dist/typeahead.bundle.js":19}]},{},[16]);
32888
+ },{"./dist/bloodhound.js":15,"./dist/typeahead.bundle.js":16}]},{},[13]);