hof 20.1.2-redis-beta.0 → 20.1.2-redis-beta.1

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