hof 21.0.18-axios-beta → 21.0.19-axios-beta

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