govuk_tech_docs 3.0.1 → 3.1.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of govuk_tech_docs might be problematic. Click here for more details.

Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +9 -0
  3. data/lib/govuk_tech_docs/version.rb +1 -1
  4. data/lib/source/layouts/_header.erb +3 -3
  5. data/lib/source/layouts/core.erb +1 -1
  6. data/node_modules/govuk-frontend/govuk/all.js +272 -75
  7. data/node_modules/govuk-frontend/govuk/components/accordion/_index.scss +275 -98
  8. data/node_modules/govuk-frontend/govuk/components/accordion/accordion.js +169 -65
  9. data/node_modules/govuk-frontend/govuk/components/button/_index.scss +3 -4
  10. data/node_modules/govuk-frontend/govuk/components/button/button.js +2 -2
  11. data/node_modules/govuk-frontend/govuk/components/character-count/character-count.js +3 -3
  12. data/node_modules/govuk-frontend/govuk/components/checkboxes/_index.scss +14 -0
  13. data/node_modules/govuk-frontend/govuk/components/checkboxes/checkboxes.js +8 -10
  14. data/node_modules/govuk-frontend/govuk/components/cookie-banner/_index.scss +0 -2
  15. data/node_modules/govuk-frontend/govuk/components/details/_index.scss +2 -1
  16. data/node_modules/govuk-frontend/govuk/components/details/details.js +2 -2
  17. data/node_modules/govuk-frontend/govuk/components/error-message/_index.scss +1 -0
  18. data/node_modules/govuk-frontend/govuk/components/error-summary/error-summary.js +2 -2
  19. data/node_modules/govuk-frontend/govuk/components/file-upload/_index.scss +1 -0
  20. data/node_modules/govuk-frontend/govuk/components/footer/_index.scss +6 -37
  21. data/node_modules/govuk-frontend/govuk/components/header/_index.scss +10 -4
  22. data/node_modules/govuk-frontend/govuk/components/header/header.js +4 -4
  23. data/node_modules/govuk-frontend/govuk/components/hint/_index.scss +1 -3
  24. data/node_modules/govuk-frontend/govuk/components/input/_index.scss +1 -1
  25. data/node_modules/govuk-frontend/govuk/components/notification-banner/notification-banner.js +499 -2
  26. data/node_modules/govuk-frontend/govuk/components/panel/_index.scss +13 -1
  27. data/node_modules/govuk-frontend/govuk/components/radios/_index.scss +14 -0
  28. data/node_modules/govuk-frontend/govuk/components/radios/radios.js +4 -4
  29. data/node_modules/govuk-frontend/govuk/components/select/_index.scss +1 -1
  30. data/node_modules/govuk-frontend/govuk/components/skip-link/_index.scss +13 -0
  31. data/node_modules/govuk-frontend/govuk/components/skip-link/skip-link.js +1108 -0
  32. data/node_modules/govuk-frontend/govuk/components/summary-list/_index.scss +15 -23
  33. data/node_modules/govuk-frontend/govuk/components/tabs/_index.scss +2 -2
  34. data/node_modules/govuk-frontend/govuk/components/tabs/tabs.js +2 -2
  35. data/node_modules/govuk-frontend/govuk/components/tag/_index.scss +0 -5
  36. data/node_modules/govuk-frontend/govuk/components/textarea/_index.scss +1 -1
  37. data/node_modules/govuk-frontend/govuk/core/_all.scss +0 -1
  38. data/node_modules/govuk-frontend/govuk/core/_global-styles.scss +0 -6
  39. data/node_modules/govuk-frontend/govuk/core/_links.scss +0 -6
  40. data/node_modules/govuk-frontend/govuk/core/_lists.scss +0 -6
  41. data/node_modules/govuk-frontend/govuk/core/_section-break.scss +0 -6
  42. data/node_modules/govuk-frontend/govuk/core/_typography.scss +0 -6
  43. data/node_modules/govuk-frontend/govuk/helpers/_colour.scss +2 -2
  44. data/node_modules/govuk-frontend/govuk/helpers/_spacing.scss +22 -4
  45. data/node_modules/govuk-frontend/govuk/objects/_all.scss +1 -0
  46. data/node_modules/govuk-frontend/govuk/objects/_main-wrapper.scss +15 -30
  47. data/node_modules/govuk-frontend/govuk/{core → objects}/_template.scss +1 -5
  48. data/node_modules/govuk-frontend/govuk/overrides/_all.scss +1 -0
  49. data/node_modules/govuk-frontend/govuk/overrides/_display.scss +0 -6
  50. data/node_modules/govuk-frontend/govuk/overrides/_spacing.scss +0 -6
  51. data/node_modules/govuk-frontend/govuk/overrides/_text-align.scss +14 -0
  52. data/node_modules/govuk-frontend/govuk/overrides/_typography.scss +0 -6
  53. data/node_modules/govuk-frontend/govuk/overrides/_width.scss +0 -6
  54. data/node_modules/govuk-frontend/govuk/settings/_colours-organisations.scss +3 -0
  55. data/node_modules/govuk-frontend/govuk/settings/_measurements.scss +0 -10
  56. data/node_modules/govuk-frontend/govuk/tools/_all.scss +0 -1
  57. data/package-lock.json +3 -3
  58. data/package.json +1 -1
  59. metadata +5 -4
  60. data/node_modules/govuk-frontend/govuk/tools/_iff.scss +0 -17
@@ -0,0 +1,1108 @@
1
+ (function (global, factory) {
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
3
+ typeof define === 'function' && define.amd ? define('GOVUKFrontend.SkipLink', factory) :
4
+ (global.GOVUKFrontend = global.GOVUKFrontend || {}, global.GOVUKFrontend.SkipLink = factory());
5
+ }(this, (function () { 'use strict';
6
+
7
+ (function(undefined) {
8
+
9
+ // Detection from https://github.com/Financial-Times/polyfill-service/blob/master/packages/polyfill-library/polyfills/Object/defineProperty/detect.js
10
+ var detect = (
11
+ // In IE8, defineProperty could only act on DOM elements, so full support
12
+ // for the feature requires the ability to set a property on an arbitrary object
13
+ 'defineProperty' in Object && (function() {
14
+ try {
15
+ var a = {};
16
+ Object.defineProperty(a, 'test', {value:42});
17
+ return true;
18
+ } catch(e) {
19
+ return false
20
+ }
21
+ }())
22
+ );
23
+
24
+ if (detect) return
25
+
26
+ // Polyfill from https://cdn.polyfill.io/v2/polyfill.js?features=Object.defineProperty&flags=always
27
+ (function (nativeDefineProperty) {
28
+
29
+ var supportsAccessors = Object.prototype.hasOwnProperty('__defineGetter__');
30
+ var ERR_ACCESSORS_NOT_SUPPORTED = 'Getters & setters cannot be defined on this javascript engine';
31
+ var ERR_VALUE_ACCESSORS = 'A property cannot both have accessors and be writable or have a value';
32
+
33
+ Object.defineProperty = function defineProperty(object, property, descriptor) {
34
+
35
+ // Where native support exists, assume it
36
+ if (nativeDefineProperty && (object === window || object === document || object === Element.prototype || object instanceof Element)) {
37
+ return nativeDefineProperty(object, property, descriptor);
38
+ }
39
+
40
+ if (object === null || !(object instanceof Object || typeof object === 'object')) {
41
+ throw new TypeError('Object.defineProperty called on non-object');
42
+ }
43
+
44
+ if (!(descriptor instanceof Object)) {
45
+ throw new TypeError('Property description must be an object');
46
+ }
47
+
48
+ var propertyString = String(property);
49
+ var hasValueOrWritable = 'value' in descriptor || 'writable' in descriptor;
50
+ var getterType = 'get' in descriptor && typeof descriptor.get;
51
+ var setterType = 'set' in descriptor && typeof descriptor.set;
52
+
53
+ // handle descriptor.get
54
+ if (getterType) {
55
+ if (getterType !== 'function') {
56
+ throw new TypeError('Getter must be a function');
57
+ }
58
+ if (!supportsAccessors) {
59
+ throw new TypeError(ERR_ACCESSORS_NOT_SUPPORTED);
60
+ }
61
+ if (hasValueOrWritable) {
62
+ throw new TypeError(ERR_VALUE_ACCESSORS);
63
+ }
64
+ Object.__defineGetter__.call(object, propertyString, descriptor.get);
65
+ } else {
66
+ object[propertyString] = descriptor.value;
67
+ }
68
+
69
+ // handle descriptor.set
70
+ if (setterType) {
71
+ if (setterType !== 'function') {
72
+ throw new TypeError('Setter must be a function');
73
+ }
74
+ if (!supportsAccessors) {
75
+ throw new TypeError(ERR_ACCESSORS_NOT_SUPPORTED);
76
+ }
77
+ if (hasValueOrWritable) {
78
+ throw new TypeError(ERR_VALUE_ACCESSORS);
79
+ }
80
+ Object.__defineSetter__.call(object, propertyString, descriptor.set);
81
+ }
82
+
83
+ // OK to define value unconditionally - if a getter has been specified as well, an error would be thrown above
84
+ if ('value' in descriptor) {
85
+ object[propertyString] = descriptor.value;
86
+ }
87
+
88
+ return object;
89
+ };
90
+ }(Object.defineProperty));
91
+ })
92
+ .call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
93
+
94
+ (function(undefined) {
95
+ // Detection from https://github.com/Financial-Times/polyfill-service/blob/master/packages/polyfill-library/polyfills/Function/prototype/bind/detect.js
96
+ var detect = 'bind' in Function.prototype;
97
+
98
+ if (detect) return
99
+
100
+ // Polyfill from https://cdn.polyfill.io/v2/polyfill.js?features=Function.prototype.bind&flags=always
101
+ Object.defineProperty(Function.prototype, 'bind', {
102
+ value: function bind(that) { // .length is 1
103
+ // add necessary es5-shim utilities
104
+ var $Array = Array;
105
+ var $Object = Object;
106
+ var ObjectPrototype = $Object.prototype;
107
+ var ArrayPrototype = $Array.prototype;
108
+ var Empty = function Empty() {};
109
+ var to_string = ObjectPrototype.toString;
110
+ var hasToStringTag = typeof Symbol === 'function' && typeof Symbol.toStringTag === 'symbol';
111
+ 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; };
112
+ var array_slice = ArrayPrototype.slice;
113
+ var array_concat = ArrayPrototype.concat;
114
+ var array_push = ArrayPrototype.push;
115
+ var max = Math.max;
116
+ // /add necessary es5-shim utilities
117
+
118
+ // 1. Let Target be the this value.
119
+ var target = this;
120
+ // 2. If IsCallable(Target) is false, throw a TypeError exception.
121
+ if (!isCallable(target)) {
122
+ throw new TypeError('Function.prototype.bind called on incompatible ' + target);
123
+ }
124
+ // 3. Let A be a new (possibly empty) internal list of all of the
125
+ // argument values provided after thisArg (arg1, arg2 etc), in order.
126
+ // XXX slicedArgs will stand in for "A" if used
127
+ var args = array_slice.call(arguments, 1); // for normal call
128
+ // 4. Let F be a new native ECMAScript object.
129
+ // 11. Set the [[Prototype]] internal property of F to the standard
130
+ // built-in Function prototype object as specified in 15.3.3.1.
131
+ // 12. Set the [[Call]] internal property of F as described in
132
+ // 15.3.4.5.1.
133
+ // 13. Set the [[Construct]] internal property of F as described in
134
+ // 15.3.4.5.2.
135
+ // 14. Set the [[HasInstance]] internal property of F as described in
136
+ // 15.3.4.5.3.
137
+ var bound;
138
+ var binder = function () {
139
+
140
+ if (this instanceof bound) {
141
+ // 15.3.4.5.2 [[Construct]]
142
+ // When the [[Construct]] internal method of a function object,
143
+ // F that was created using the bind function is called with a
144
+ // list of arguments ExtraArgs, the following steps are taken:
145
+ // 1. Let target be the value of F's [[TargetFunction]]
146
+ // internal property.
147
+ // 2. If target has no [[Construct]] internal method, a
148
+ // TypeError exception is thrown.
149
+ // 3. Let boundArgs be the value of F's [[BoundArgs]] internal
150
+ // property.
151
+ // 4. Let args be a new list containing the same values as the
152
+ // list boundArgs in the same order followed by the same
153
+ // values as the list ExtraArgs in the same order.
154
+ // 5. Return the result of calling the [[Construct]] internal
155
+ // method of target providing args as the arguments.
156
+
157
+ var result = target.apply(
158
+ this,
159
+ array_concat.call(args, array_slice.call(arguments))
160
+ );
161
+ if ($Object(result) === result) {
162
+ return result;
163
+ }
164
+ return this;
165
+
166
+ } else {
167
+ // 15.3.4.5.1 [[Call]]
168
+ // When the [[Call]] internal method of a function object, F,
169
+ // which was created using the bind function is called with a
170
+ // this value and a list of arguments ExtraArgs, the following
171
+ // steps are taken:
172
+ // 1. Let boundArgs be the value of F's [[BoundArgs]] internal
173
+ // property.
174
+ // 2. Let boundThis be the value of F's [[BoundThis]] internal
175
+ // property.
176
+ // 3. Let target be the value of F's [[TargetFunction]] internal
177
+ // property.
178
+ // 4. Let args be a new list containing the same values as the
179
+ // list boundArgs in the same order followed by the same
180
+ // values as the list ExtraArgs in the same order.
181
+ // 5. Return the result of calling the [[Call]] internal method
182
+ // of target providing boundThis as the this value and
183
+ // providing args as the arguments.
184
+
185
+ // equiv: target.call(this, ...boundArgs, ...args)
186
+ return target.apply(
187
+ that,
188
+ array_concat.call(args, array_slice.call(arguments))
189
+ );
190
+
191
+ }
192
+
193
+ };
194
+
195
+ // 15. If the [[Class]] internal property of Target is "Function", then
196
+ // a. Let L be the length property of Target minus the length of A.
197
+ // b. Set the length own property of F to either 0 or L, whichever is
198
+ // larger.
199
+ // 16. Else set the length own property of F to 0.
200
+
201
+ var boundLength = max(0, target.length - args.length);
202
+
203
+ // 17. Set the attributes of the length own property of F to the values
204
+ // specified in 15.3.5.1.
205
+ var boundArgs = [];
206
+ for (var i = 0; i < boundLength; i++) {
207
+ array_push.call(boundArgs, '$' + i);
208
+ }
209
+
210
+ // XXX Build a dynamic function with desired amount of arguments is the only
211
+ // way to set the length property of a function.
212
+ // In environments where Content Security Policies enabled (Chrome extensions,
213
+ // for ex.) all use of eval or Function costructor throws an exception.
214
+ // However in all of these environments Function.prototype.bind exists
215
+ // and so this code will never be executed.
216
+ bound = Function('binder', 'return function (' + boundArgs.join(',') + '){ return binder.apply(this, arguments); }')(binder);
217
+
218
+ if (target.prototype) {
219
+ Empty.prototype = target.prototype;
220
+ bound.prototype = new Empty();
221
+ // Clean up dangling references.
222
+ Empty.prototype = null;
223
+ }
224
+
225
+ // TODO
226
+ // 18. Set the [[Extensible]] internal property of F to true.
227
+
228
+ // TODO
229
+ // 19. Let thrower be the [[ThrowTypeError]] function Object (13.2.3).
230
+ // 20. Call the [[DefineOwnProperty]] internal method of F with
231
+ // arguments "caller", PropertyDescriptor {[[Get]]: thrower, [[Set]]:
232
+ // thrower, [[Enumerable]]: false, [[Configurable]]: false}, and
233
+ // false.
234
+ // 21. Call the [[DefineOwnProperty]] internal method of F with
235
+ // arguments "arguments", PropertyDescriptor {[[Get]]: thrower,
236
+ // [[Set]]: thrower, [[Enumerable]]: false, [[Configurable]]: false},
237
+ // and false.
238
+
239
+ // TODO
240
+ // NOTE Function objects created using Function.prototype.bind do not
241
+ // have a prototype property or the [[Code]], [[FormalParameters]], and
242
+ // [[Scope]] internal properties.
243
+ // XXX can't delete prototype in pure-js.
244
+
245
+ // 22. Return F.
246
+ return bound;
247
+ }
248
+ });
249
+ })
250
+ .call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
251
+
252
+ (function(undefined) {
253
+
254
+ // Detection from https://raw.githubusercontent.com/Financial-Times/polyfill-service/master/packages/polyfill-library/polyfills/DOMTokenList/detect.js
255
+ var detect = (
256
+ 'DOMTokenList' in this && (function (x) {
257
+ return 'classList' in x ? !x.classList.toggle('x', false) && !x.className : true;
258
+ })(document.createElement('x'))
259
+ );
260
+
261
+ if (detect) return
262
+
263
+ // Polyfill from https://raw.githubusercontent.com/Financial-Times/polyfill-service/master/packages/polyfill-library/polyfills/DOMTokenList/polyfill.js
264
+ (function (global) {
265
+ var nativeImpl = "DOMTokenList" in global && global.DOMTokenList;
266
+
267
+ if (
268
+ !nativeImpl ||
269
+ (
270
+ !!document.createElementNS &&
271
+ !!document.createElementNS('http://www.w3.org/2000/svg', 'svg') &&
272
+ !(document.createElementNS("http://www.w3.org/2000/svg", "svg").classList instanceof DOMTokenList)
273
+ )
274
+ ) {
275
+ global.DOMTokenList = (function() { // eslint-disable-line no-unused-vars
276
+ var dpSupport = true;
277
+ var defineGetter = function (object, name, fn, configurable) {
278
+ if (Object.defineProperty)
279
+ Object.defineProperty(object, name, {
280
+ configurable: false === dpSupport ? true : !!configurable,
281
+ get: fn
282
+ });
283
+
284
+ else object.__defineGetter__(name, fn);
285
+ };
286
+
287
+ /** Ensure the browser allows Object.defineProperty to be used on native JavaScript objects. */
288
+ try {
289
+ defineGetter({}, "support");
290
+ }
291
+ catch (e) {
292
+ dpSupport = false;
293
+ }
294
+
295
+
296
+ var _DOMTokenList = function (el, prop) {
297
+ var that = this;
298
+ var tokens = [];
299
+ var tokenMap = {};
300
+ var length = 0;
301
+ var maxLength = 0;
302
+ var addIndexGetter = function (i) {
303
+ defineGetter(that, i, function () {
304
+ preop();
305
+ return tokens[i];
306
+ }, false);
307
+
308
+ };
309
+ var reindex = function () {
310
+
311
+ /** Define getter functions for array-like access to the tokenList's contents. */
312
+ if (length >= maxLength)
313
+ for (; maxLength < length; ++maxLength) {
314
+ addIndexGetter(maxLength);
315
+ }
316
+ };
317
+
318
+ /** Helper function called at the start of each class method. Internal use only. */
319
+ var preop = function () {
320
+ var error;
321
+ var i;
322
+ var args = arguments;
323
+ var rSpace = /\s+/;
324
+
325
+ /** Validate the token/s passed to an instance method, if any. */
326
+ if (args.length)
327
+ for (i = 0; i < args.length; ++i)
328
+ if (rSpace.test(args[i])) {
329
+ error = new SyntaxError('String "' + args[i] + '" ' + "contains" + ' an invalid character');
330
+ error.code = 5;
331
+ error.name = "InvalidCharacterError";
332
+ throw error;
333
+ }
334
+
335
+
336
+ /** Split the new value apart by whitespace*/
337
+ if (typeof el[prop] === "object") {
338
+ tokens = ("" + el[prop].baseVal).replace(/^\s+|\s+$/g, "").split(rSpace);
339
+ } else {
340
+ tokens = ("" + el[prop]).replace(/^\s+|\s+$/g, "").split(rSpace);
341
+ }
342
+
343
+ /** Avoid treating blank strings as single-item token lists */
344
+ if ("" === tokens[0]) tokens = [];
345
+
346
+ /** Repopulate the internal token lists */
347
+ tokenMap = {};
348
+ for (i = 0; i < tokens.length; ++i)
349
+ tokenMap[tokens[i]] = true;
350
+ length = tokens.length;
351
+ reindex();
352
+ };
353
+
354
+ /** Populate our internal token list if the targeted attribute of the subject element isn't empty. */
355
+ preop();
356
+
357
+ /** Return the number of tokens in the underlying string. Read-only. */
358
+ defineGetter(that, "length", function () {
359
+ preop();
360
+ return length;
361
+ });
362
+
363
+ /** Override the default toString/toLocaleString methods to return a space-delimited list of tokens when typecast. */
364
+ that.toLocaleString =
365
+ that.toString = function () {
366
+ preop();
367
+ return tokens.join(" ");
368
+ };
369
+
370
+ that.item = function (idx) {
371
+ preop();
372
+ return tokens[idx];
373
+ };
374
+
375
+ that.contains = function (token) {
376
+ preop();
377
+ return !!tokenMap[token];
378
+ };
379
+
380
+ that.add = function () {
381
+ preop.apply(that, args = arguments);
382
+
383
+ for (var args, token, i = 0, l = args.length; i < l; ++i) {
384
+ token = args[i];
385
+ if (!tokenMap[token]) {
386
+ tokens.push(token);
387
+ tokenMap[token] = true;
388
+ }
389
+ }
390
+
391
+ /** Update the targeted attribute of the attached element if the token list's changed. */
392
+ if (length !== tokens.length) {
393
+ length = tokens.length >>> 0;
394
+ if (typeof el[prop] === "object") {
395
+ el[prop].baseVal = tokens.join(" ");
396
+ } else {
397
+ el[prop] = tokens.join(" ");
398
+ }
399
+ reindex();
400
+ }
401
+ };
402
+
403
+ that.remove = function () {
404
+ preop.apply(that, args = arguments);
405
+
406
+ /** Build a hash of token names to compare against when recollecting our token list. */
407
+ for (var args, ignore = {}, i = 0, t = []; i < args.length; ++i) {
408
+ ignore[args[i]] = true;
409
+ delete tokenMap[args[i]];
410
+ }
411
+
412
+ /** Run through our tokens list and reassign only those that aren't defined in the hash declared above. */
413
+ for (i = 0; i < tokens.length; ++i)
414
+ if (!ignore[tokens[i]]) t.push(tokens[i]);
415
+
416
+ tokens = t;
417
+ length = t.length >>> 0;
418
+
419
+ /** Update the targeted attribute of the attached element. */
420
+ if (typeof el[prop] === "object") {
421
+ el[prop].baseVal = tokens.join(" ");
422
+ } else {
423
+ el[prop] = tokens.join(" ");
424
+ }
425
+ reindex();
426
+ };
427
+
428
+ that.toggle = function (token, force) {
429
+ preop.apply(that, [token]);
430
+
431
+ /** Token state's being forced. */
432
+ if (undefined !== force) {
433
+ if (force) {
434
+ that.add(token);
435
+ return true;
436
+ } else {
437
+ that.remove(token);
438
+ return false;
439
+ }
440
+ }
441
+
442
+ /** Token already exists in tokenList. Remove it, and return FALSE. */
443
+ if (tokenMap[token]) {
444
+ that.remove(token);
445
+ return false;
446
+ }
447
+
448
+ /** Otherwise, add the token and return TRUE. */
449
+ that.add(token);
450
+ return true;
451
+ };
452
+
453
+ return that;
454
+ };
455
+
456
+ return _DOMTokenList;
457
+ }());
458
+ }
459
+
460
+ // Add second argument to native DOMTokenList.toggle() if necessary
461
+ (function () {
462
+ var e = document.createElement('span');
463
+ if (!('classList' in e)) return;
464
+ e.classList.toggle('x', false);
465
+ if (!e.classList.contains('x')) return;
466
+ e.classList.constructor.prototype.toggle = function toggle(token /*, force*/) {
467
+ var force = arguments[1];
468
+ if (force === undefined) {
469
+ var add = !this.contains(token);
470
+ this[add ? 'add' : 'remove'](token);
471
+ return add;
472
+ }
473
+ force = !!force;
474
+ this[force ? 'add' : 'remove'](token);
475
+ return force;
476
+ };
477
+ }());
478
+
479
+ // Add multiple arguments to native DOMTokenList.add() if necessary
480
+ (function () {
481
+ var e = document.createElement('span');
482
+ if (!('classList' in e)) return;
483
+ e.classList.add('a', 'b');
484
+ if (e.classList.contains('b')) return;
485
+ var native = e.classList.constructor.prototype.add;
486
+ e.classList.constructor.prototype.add = function () {
487
+ var args = arguments;
488
+ var l = arguments.length;
489
+ for (var i = 0; i < l; i++) {
490
+ native.call(this, args[i]);
491
+ }
492
+ };
493
+ }());
494
+
495
+ // Add multiple arguments to native DOMTokenList.remove() if necessary
496
+ (function () {
497
+ var e = document.createElement('span');
498
+ if (!('classList' in e)) return;
499
+ e.classList.add('a');
500
+ e.classList.add('b');
501
+ e.classList.remove('a', 'b');
502
+ if (!e.classList.contains('b')) return;
503
+ var native = e.classList.constructor.prototype.remove;
504
+ e.classList.constructor.prototype.remove = function () {
505
+ var args = arguments;
506
+ var l = arguments.length;
507
+ for (var i = 0; i < l; i++) {
508
+ native.call(this, args[i]);
509
+ }
510
+ };
511
+ }());
512
+
513
+ }(this));
514
+
515
+ }).call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
516
+
517
+ (function(undefined) {
518
+
519
+ // Detection from https://github.com/Financial-Times/polyfill-service/blob/master/packages/polyfill-library/polyfills/Document/detect.js
520
+ var detect = ("Document" in this);
521
+
522
+ if (detect) return
523
+
524
+ // Polyfill from https://cdn.polyfill.io/v2/polyfill.js?features=Document&flags=always
525
+ if ((typeof WorkerGlobalScope === "undefined") && (typeof importScripts !== "function")) {
526
+
527
+ if (this.HTMLDocument) { // IE8
528
+
529
+ // HTMLDocument is an extension of Document. If the browser has HTMLDocument but not Document, the former will suffice as an alias for the latter.
530
+ this.Document = this.HTMLDocument;
531
+
532
+ } else {
533
+
534
+ // 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.
535
+ this.Document = this.HTMLDocument = document.constructor = (new Function('return function Document() {}')());
536
+ this.Document.prototype = document;
537
+ }
538
+ }
539
+
540
+
541
+ })
542
+ .call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
543
+
544
+ (function(undefined) {
545
+
546
+ // Detection from https://github.com/Financial-Times/polyfill-service/blob/master/packages/polyfill-library/polyfills/Element/detect.js
547
+ var detect = ('Element' in this && 'HTMLElement' in this);
548
+
549
+ if (detect) return
550
+
551
+ // Polyfill from https://cdn.polyfill.io/v2/polyfill.js?features=Element&flags=always
552
+ (function () {
553
+
554
+ // IE8
555
+ if (window.Element && !window.HTMLElement) {
556
+ window.HTMLElement = window.Element;
557
+ return;
558
+ }
559
+
560
+ // create Element constructor
561
+ window.Element = window.HTMLElement = new Function('return function Element() {}')();
562
+
563
+ // generate sandboxed iframe
564
+ var vbody = document.appendChild(document.createElement('body'));
565
+ var frame = vbody.appendChild(document.createElement('iframe'));
566
+
567
+ // use sandboxed iframe to replicate Element functionality
568
+ var frameDocument = frame.contentWindow.document;
569
+ var prototype = Element.prototype = frameDocument.appendChild(frameDocument.createElement('*'));
570
+ var cache = {};
571
+
572
+ // polyfill Element.prototype on an element
573
+ var shiv = function (element, deep) {
574
+ var
575
+ childNodes = element.childNodes || [],
576
+ index = -1,
577
+ key, value, childNode;
578
+
579
+ if (element.nodeType === 1 && element.constructor !== Element) {
580
+ element.constructor = Element;
581
+
582
+ for (key in cache) {
583
+ value = cache[key];
584
+ element[key] = value;
585
+ }
586
+ }
587
+
588
+ while (childNode = deep && childNodes[++index]) {
589
+ shiv(childNode, deep);
590
+ }
591
+
592
+ return element;
593
+ };
594
+
595
+ var elements = document.getElementsByTagName('*');
596
+ var nativeCreateElement = document.createElement;
597
+ var interval;
598
+ var loopLimit = 100;
599
+
600
+ prototype.attachEvent('onpropertychange', function (event) {
601
+ var
602
+ propertyName = event.propertyName,
603
+ nonValue = !cache.hasOwnProperty(propertyName),
604
+ newValue = prototype[propertyName],
605
+ oldValue = cache[propertyName],
606
+ index = -1,
607
+ element;
608
+
609
+ while (element = elements[++index]) {
610
+ if (element.nodeType === 1) {
611
+ if (nonValue || element[propertyName] === oldValue) {
612
+ element[propertyName] = newValue;
613
+ }
614
+ }
615
+ }
616
+
617
+ cache[propertyName] = newValue;
618
+ });
619
+
620
+ prototype.constructor = Element;
621
+
622
+ if (!prototype.hasAttribute) {
623
+ // <Element>.hasAttribute
624
+ prototype.hasAttribute = function hasAttribute(name) {
625
+ return this.getAttribute(name) !== null;
626
+ };
627
+ }
628
+
629
+ // Apply Element prototype to the pre-existing DOM as soon as the body element appears.
630
+ function bodyCheck() {
631
+ if (!(loopLimit--)) clearTimeout(interval);
632
+ if (document.body && !document.body.prototype && /(complete|interactive)/.test(document.readyState)) {
633
+ shiv(document, true);
634
+ if (interval && document.body.prototype) clearTimeout(interval);
635
+ return (!!document.body.prototype);
636
+ }
637
+ return false;
638
+ }
639
+ if (!bodyCheck()) {
640
+ document.onreadystatechange = bodyCheck;
641
+ interval = setInterval(bodyCheck, 25);
642
+ }
643
+
644
+ // Apply to any new elements created after load
645
+ document.createElement = function createElement(nodeName) {
646
+ var element = nativeCreateElement(String(nodeName).toLowerCase());
647
+ return shiv(element);
648
+ };
649
+
650
+ // remove sandboxed iframe
651
+ document.removeChild(vbody);
652
+ }());
653
+
654
+ })
655
+ .call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
656
+
657
+ (function(undefined) {
658
+
659
+ // Detection from https://raw.githubusercontent.com/Financial-Times/polyfill-service/8717a9e04ac7aff99b4980fbedead98036b0929a/packages/polyfill-library/polyfills/Element/prototype/classList/detect.js
660
+ var detect = (
661
+ 'document' in this && "classList" in document.documentElement && 'Element' in this && 'classList' in Element.prototype && (function () {
662
+ var e = document.createElement('span');
663
+ e.classList.add('a', 'b');
664
+ return e.classList.contains('b');
665
+ }())
666
+ );
667
+
668
+ if (detect) return
669
+
670
+ // Polyfill from https://cdn.polyfill.io/v2/polyfill.js?features=Element.prototype.classList&flags=always
671
+ (function (global) {
672
+ var dpSupport = true;
673
+ var defineGetter = function (object, name, fn, configurable) {
674
+ if (Object.defineProperty)
675
+ Object.defineProperty(object, name, {
676
+ configurable: false === dpSupport ? true : !!configurable,
677
+ get: fn
678
+ });
679
+
680
+ else object.__defineGetter__(name, fn);
681
+ };
682
+ /** Ensure the browser allows Object.defineProperty to be used on native JavaScript objects. */
683
+ try {
684
+ defineGetter({}, "support");
685
+ }
686
+ catch (e) {
687
+ dpSupport = false;
688
+ }
689
+ /** Polyfills a property with a DOMTokenList */
690
+ var addProp = function (o, name, attr) {
691
+
692
+ defineGetter(o.prototype, name, function () {
693
+ var tokenList;
694
+
695
+ var THIS = this,
696
+
697
+ /** Prevent this from firing twice for some reason. What the hell, IE. */
698
+ gibberishProperty = "__defineGetter__" + "DEFINE_PROPERTY" + name;
699
+ if(THIS[gibberishProperty]) return tokenList;
700
+ THIS[gibberishProperty] = true;
701
+
702
+ /**
703
+ * IE8 can't define properties on native JavaScript objects, so we'll use a dumb hack instead.
704
+ *
705
+ * What this is doing is creating a dummy element ("reflection") inside a detached phantom node ("mirror")
706
+ * that serves as the target of Object.defineProperty instead. While we could simply use the subject HTML
707
+ * element instead, this would conflict with element types which use indexed properties (such as forms and
708
+ * select lists).
709
+ */
710
+ if (false === dpSupport) {
711
+
712
+ var visage;
713
+ var mirror = addProp.mirror || document.createElement("div");
714
+ var reflections = mirror.childNodes;
715
+ var l = reflections.length;
716
+
717
+ for (var i = 0; i < l; ++i)
718
+ if (reflections[i]._R === THIS) {
719
+ visage = reflections[i];
720
+ break;
721
+ }
722
+
723
+ /** Couldn't find an element's reflection inside the mirror. Materialise one. */
724
+ visage || (visage = mirror.appendChild(document.createElement("div")));
725
+
726
+ tokenList = DOMTokenList.call(visage, THIS, attr);
727
+ } else tokenList = new DOMTokenList(THIS, attr);
728
+
729
+ defineGetter(THIS, name, function () {
730
+ return tokenList;
731
+ });
732
+ delete THIS[gibberishProperty];
733
+
734
+ return tokenList;
735
+ }, true);
736
+ };
737
+
738
+ addProp(global.Element, "classList", "className");
739
+ addProp(global.HTMLElement, "classList", "className");
740
+ addProp(global.HTMLLinkElement, "relList", "rel");
741
+ addProp(global.HTMLAnchorElement, "relList", "rel");
742
+ addProp(global.HTMLAreaElement, "relList", "rel");
743
+ }(this));
744
+
745
+ }).call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
746
+
747
+ (function(undefined) {
748
+
749
+ // Detection from https://github.com/Financial-Times/polyfill-service/blob/master/packages/polyfill-library/polyfills/Window/detect.js
750
+ var detect = ('Window' in this);
751
+
752
+ if (detect) return
753
+
754
+ // Polyfill from https://cdn.polyfill.io/v2/polyfill.js?features=Window&flags=always
755
+ if ((typeof WorkerGlobalScope === "undefined") && (typeof importScripts !== "function")) {
756
+ (function (global) {
757
+ if (global.constructor) {
758
+ global.Window = global.constructor;
759
+ } else {
760
+ (global.Window = global.constructor = new Function('return function Window() {}')()).prototype = this;
761
+ }
762
+ }(this));
763
+ }
764
+
765
+ })
766
+ .call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
767
+
768
+ (function(undefined) {
769
+
770
+ // Detection from https://github.com/Financial-Times/polyfill-service/blob/master/packages/polyfill-library/polyfills/Event/detect.js
771
+ var detect = (
772
+ (function(global) {
773
+
774
+ if (!('Event' in global)) return false;
775
+ if (typeof global.Event === 'function') return true;
776
+
777
+ try {
778
+
779
+ // In IE 9-11, the Event object exists but cannot be instantiated
780
+ new Event('click');
781
+ return true;
782
+ } catch(e) {
783
+ return false;
784
+ }
785
+ }(this))
786
+ );
787
+
788
+ if (detect) return
789
+
790
+ // Polyfill from https://cdn.polyfill.io/v2/polyfill.js?features=Event&flags=always
791
+ (function () {
792
+ var unlistenableWindowEvents = {
793
+ click: 1,
794
+ dblclick: 1,
795
+ keyup: 1,
796
+ keypress: 1,
797
+ keydown: 1,
798
+ mousedown: 1,
799
+ mouseup: 1,
800
+ mousemove: 1,
801
+ mouseover: 1,
802
+ mouseenter: 1,
803
+ mouseleave: 1,
804
+ mouseout: 1,
805
+ storage: 1,
806
+ storagecommit: 1,
807
+ textinput: 1
808
+ };
809
+
810
+ // This polyfill depends on availability of `document` so will not run in a worker
811
+ // However, we asssume there are no browsers with worker support that lack proper
812
+ // support for `Event` within the worker
813
+ if (typeof document === 'undefined' || typeof window === 'undefined') return;
814
+
815
+ function indexOf(array, element) {
816
+ var
817
+ index = -1,
818
+ length = array.length;
819
+
820
+ while (++index < length) {
821
+ if (index in array && array[index] === element) {
822
+ return index;
823
+ }
824
+ }
825
+
826
+ return -1;
827
+ }
828
+
829
+ var existingProto = (window.Event && window.Event.prototype) || null;
830
+ window.Event = Window.prototype.Event = function Event(type, eventInitDict) {
831
+ if (!type) {
832
+ throw new Error('Not enough arguments');
833
+ }
834
+
835
+ var event;
836
+ // Shortcut if browser supports createEvent
837
+ if ('createEvent' in document) {
838
+ event = document.createEvent('Event');
839
+ var bubbles = eventInitDict && eventInitDict.bubbles !== undefined ? eventInitDict.bubbles : false;
840
+ var cancelable = eventInitDict && eventInitDict.cancelable !== undefined ? eventInitDict.cancelable : false;
841
+
842
+ event.initEvent(type, bubbles, cancelable);
843
+
844
+ return event;
845
+ }
846
+
847
+ event = document.createEventObject();
848
+
849
+ event.type = type;
850
+ event.bubbles = eventInitDict && eventInitDict.bubbles !== undefined ? eventInitDict.bubbles : false;
851
+ event.cancelable = eventInitDict && eventInitDict.cancelable !== undefined ? eventInitDict.cancelable : false;
852
+
853
+ return event;
854
+ };
855
+ if (existingProto) {
856
+ Object.defineProperty(window.Event, 'prototype', {
857
+ configurable: false,
858
+ enumerable: false,
859
+ writable: true,
860
+ value: existingProto
861
+ });
862
+ }
863
+
864
+ if (!('createEvent' in document)) {
865
+ window.addEventListener = Window.prototype.addEventListener = Document.prototype.addEventListener = Element.prototype.addEventListener = function addEventListener() {
866
+ var
867
+ element = this,
868
+ type = arguments[0],
869
+ listener = arguments[1];
870
+
871
+ if (element === window && type in unlistenableWindowEvents) {
872
+ 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.');
873
+ }
874
+
875
+ if (!element._events) {
876
+ element._events = {};
877
+ }
878
+
879
+ if (!element._events[type]) {
880
+ element._events[type] = function (event) {
881
+ var
882
+ list = element._events[event.type].list,
883
+ events = list.slice(),
884
+ index = -1,
885
+ length = events.length,
886
+ eventElement;
887
+
888
+ event.preventDefault = function preventDefault() {
889
+ if (event.cancelable !== false) {
890
+ event.returnValue = false;
891
+ }
892
+ };
893
+
894
+ event.stopPropagation = function stopPropagation() {
895
+ event.cancelBubble = true;
896
+ };
897
+
898
+ event.stopImmediatePropagation = function stopImmediatePropagation() {
899
+ event.cancelBubble = true;
900
+ event.cancelImmediate = true;
901
+ };
902
+
903
+ event.currentTarget = element;
904
+ event.relatedTarget = event.fromElement || null;
905
+ event.target = event.target || event.srcElement || element;
906
+ event.timeStamp = new Date().getTime();
907
+
908
+ if (event.clientX) {
909
+ event.pageX = event.clientX + document.documentElement.scrollLeft;
910
+ event.pageY = event.clientY + document.documentElement.scrollTop;
911
+ }
912
+
913
+ while (++index < length && !event.cancelImmediate) {
914
+ if (index in events) {
915
+ eventElement = events[index];
916
+
917
+ if (indexOf(list, eventElement) !== -1 && typeof eventElement === 'function') {
918
+ eventElement.call(element, event);
919
+ }
920
+ }
921
+ }
922
+ };
923
+
924
+ element._events[type].list = [];
925
+
926
+ if (element.attachEvent) {
927
+ element.attachEvent('on' + type, element._events[type]);
928
+ }
929
+ }
930
+
931
+ element._events[type].list.push(listener);
932
+ };
933
+
934
+ window.removeEventListener = Window.prototype.removeEventListener = Document.prototype.removeEventListener = Element.prototype.removeEventListener = function removeEventListener() {
935
+ var
936
+ element = this,
937
+ type = arguments[0],
938
+ listener = arguments[1],
939
+ index;
940
+
941
+ if (element._events && element._events[type] && element._events[type].list) {
942
+ index = indexOf(element._events[type].list, listener);
943
+
944
+ if (index !== -1) {
945
+ element._events[type].list.splice(index, 1);
946
+
947
+ if (!element._events[type].list.length) {
948
+ if (element.detachEvent) {
949
+ element.detachEvent('on' + type, element._events[type]);
950
+ }
951
+ delete element._events[type];
952
+ }
953
+ }
954
+ }
955
+ };
956
+
957
+ window.dispatchEvent = Window.prototype.dispatchEvent = Document.prototype.dispatchEvent = Element.prototype.dispatchEvent = function dispatchEvent(event) {
958
+ if (!arguments.length) {
959
+ throw new Error('Not enough arguments');
960
+ }
961
+
962
+ if (!event || typeof event.type !== 'string') {
963
+ throw new Error('DOM Events Exception 0');
964
+ }
965
+
966
+ var element = this, type = event.type;
967
+
968
+ try {
969
+ if (!event.bubbles) {
970
+ event.cancelBubble = true;
971
+
972
+ var cancelBubbleEvent = function (event) {
973
+ event.cancelBubble = true;
974
+
975
+ (element || window).detachEvent('on' + type, cancelBubbleEvent);
976
+ };
977
+
978
+ this.attachEvent('on' + type, cancelBubbleEvent);
979
+ }
980
+
981
+ this.fireEvent('on' + type, event);
982
+ } catch (error) {
983
+ event.target = element;
984
+
985
+ do {
986
+ event.currentTarget = element;
987
+
988
+ if ('_events' in element && typeof element._events[type] === 'function') {
989
+ element._events[type].call(element, event);
990
+ }
991
+
992
+ if (typeof element['on' + type] === 'function') {
993
+ element['on' + type].call(element, event);
994
+ }
995
+
996
+ element = element.nodeType === 9 ? element.parentWindow : element.parentNode;
997
+ } while (element && !event.cancelBubble);
998
+ }
999
+
1000
+ return true;
1001
+ };
1002
+
1003
+ // Add the DOMContentLoaded Event
1004
+ document.attachEvent('onreadystatechange', function() {
1005
+ if (document.readyState === 'complete') {
1006
+ document.dispatchEvent(new Event('DOMContentLoaded', {
1007
+ bubbles: true
1008
+ }));
1009
+ }
1010
+ });
1011
+ }
1012
+ }());
1013
+
1014
+ })
1015
+ .call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
1016
+
1017
+ function SkipLink ($module) {
1018
+ this.$module = $module;
1019
+ this.$linkedElement = null;
1020
+ this.linkedElementListener = false;
1021
+ }
1022
+
1023
+ /**
1024
+ * Initialise the component
1025
+ */
1026
+ SkipLink.prototype.init = function () {
1027
+ // Check for module
1028
+ if (!this.$module) {
1029
+ return
1030
+ }
1031
+
1032
+ // Check for linked element
1033
+ this.$linkedElement = this.getLinkedElement();
1034
+ if (!this.$linkedElement) {
1035
+ return
1036
+ }
1037
+
1038
+ this.$module.addEventListener('click', this.focusLinkedElement.bind(this));
1039
+ };
1040
+
1041
+ /**
1042
+ * Get linked element
1043
+ *
1044
+ * @returns {HTMLElement} $linkedElement - DOM element linked to from the skip link
1045
+ */
1046
+ SkipLink.prototype.getLinkedElement = function () {
1047
+ var linkedElementId = this.getFragmentFromUrl();
1048
+
1049
+ if (!linkedElementId) {
1050
+ return false
1051
+ }
1052
+
1053
+ return document.getElementById(linkedElementId)
1054
+ };
1055
+
1056
+ /**
1057
+ * Focus the linked element
1058
+ *
1059
+ * Set tabindex and helper CSS class. Set listener to remove them on blur.
1060
+ */
1061
+ SkipLink.prototype.focusLinkedElement = function () {
1062
+ var $linkedElement = this.$linkedElement;
1063
+
1064
+ if (!$linkedElement.getAttribute('tabindex')) {
1065
+ // Set the element tabindex to -1 so it can be focused with JavaScript.
1066
+ $linkedElement.setAttribute('tabindex', '-1');
1067
+ $linkedElement.classList.add('govuk-skip-link-focused-element');
1068
+
1069
+ // Add listener for blur on the focused element (unless the listener has previously been added)
1070
+ if (!this.linkedElementListener) {
1071
+ this.$linkedElement.addEventListener('blur', this.removeFocusProperties.bind(this));
1072
+ this.linkedElementListener = true;
1073
+ }
1074
+ }
1075
+ $linkedElement.focus();
1076
+ };
1077
+
1078
+ /**
1079
+ * Remove the tabindex that makes the linked element focusable because the element only needs to be
1080
+ * focusable until it has received programmatic focus and a screen reader has announced it.
1081
+ *
1082
+ * Remove the CSS class that removes the native focus styles.
1083
+ */
1084
+ SkipLink.prototype.removeFocusProperties = function () {
1085
+ this.$linkedElement.removeAttribute('tabindex');
1086
+ this.$linkedElement.classList.remove('govuk-skip-link-focused-element');
1087
+ };
1088
+
1089
+ /**
1090
+ * Get fragment from URL
1091
+ *
1092
+ * Extract the fragment (everything after the hash symbol) from a URL, but not including
1093
+ * the symbol.
1094
+ *
1095
+ * @returns {string} Fragment from URL, without the hash symbol
1096
+ */
1097
+ SkipLink.prototype.getFragmentFromUrl = function () {
1098
+ // Bail if the anchor link doesn't have a hash
1099
+ if (!this.$module.hash) {
1100
+ return false
1101
+ }
1102
+
1103
+ return this.$module.hash.split('#').pop()
1104
+ };
1105
+
1106
+ return SkipLink;
1107
+
1108
+ })));