govuk_tech_docs 2.2.2 → 2.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.nvmrc +1 -1
- data/.travis.yml +2 -0
- data/CHANGELOG.md +24 -0
- data/example/config/tech-docs.yml +1 -0
- data/example/source/single-page-nav.html.md +13 -0
- data/govuk_tech_docs.gemspec +2 -1
- data/lib/assets/javascripts/_modules/collapsible-navigation.js +7 -7
- data/lib/assets/javascripts/_modules/in-page-navigation.js +2 -4
- data/lib/assets/stylesheets/_govuk_tech_docs.scss +9 -10
- data/lib/assets/stylesheets/modules/_search.scss +4 -25
- data/lib/assets/stylesheets/modules/_technical-documentation.scss +1 -1
- data/lib/assets/stylesheets/modules/_toc.scss +11 -11
- data/lib/govuk_tech_docs/table_of_contents/heading.rb +5 -1
- data/lib/govuk_tech_docs/table_of_contents/heading_tree_renderer.rb +2 -2
- data/lib/govuk_tech_docs/table_of_contents/helpers.rb +22 -11
- data/lib/govuk_tech_docs/tech_docs_html_renderer.rb +1 -1
- data/lib/govuk_tech_docs/version.rb +1 -1
- data/lib/source/layouts/_header.erb +1 -2
- data/lib/source/layouts/layout.erb +3 -1
- data/node_modules/govuk-frontend/govuk/_base.scss +3 -0
- data/node_modules/govuk-frontend/govuk/all.js +306 -94
- data/node_modules/govuk-frontend/govuk/all.scss +1 -3
- data/node_modules/govuk-frontend/govuk/components/_all.scss +33 -29
- data/node_modules/govuk-frontend/govuk/components/accordion/_accordion.scss +2 -208
- data/node_modules/govuk-frontend/govuk/components/accordion/_index.scss +197 -0
- data/node_modules/govuk-frontend/govuk/components/accordion/accordion.js +1 -1
- data/node_modules/govuk-frontend/govuk/components/back-link/_back-link.scss +2 -65
- data/node_modules/govuk-frontend/govuk/components/back-link/_index.scss +99 -0
- data/node_modules/govuk-frontend/govuk/components/breadcrumbs/_breadcrumbs.scss +2 -118
- data/node_modules/govuk-frontend/govuk/components/breadcrumbs/_index.scss +138 -0
- data/node_modules/govuk-frontend/govuk/components/button/_button.scss +2 -284
- data/node_modules/govuk-frontend/govuk/components/button/_index.scss +288 -0
- data/node_modules/govuk-frontend/govuk/components/character-count/_character-count.scss +2 -31
- data/node_modules/govuk-frontend/govuk/components/character-count/_index.scss +25 -0
- data/node_modules/govuk-frontend/govuk/components/character-count/character-count.js +17 -9
- data/node_modules/govuk-frontend/govuk/components/checkboxes/_checkboxes.scss +2 -308
- data/node_modules/govuk-frontend/govuk/components/checkboxes/_index.scss +320 -0
- data/node_modules/govuk-frontend/govuk/components/checkboxes/checkboxes.js +129 -24
- data/node_modules/govuk-frontend/govuk/components/cookie-banner/_cookie-banner.scss +2 -0
- data/node_modules/govuk-frontend/govuk/components/cookie-banner/_index.scss +51 -0
- data/node_modules/govuk-frontend/govuk/components/date-input/_date-input.scss +2 -30
- data/node_modules/govuk-frontend/govuk/components/date-input/_index.scss +26 -0
- data/node_modules/govuk-frontend/govuk/components/details/_details.scss +2 -88
- data/node_modules/govuk-frontend/govuk/components/details/_index.scss +87 -0
- data/node_modules/govuk-frontend/govuk/components/error-message/_error-message.scss +2 -15
- data/node_modules/govuk-frontend/govuk/components/error-message/_index.scss +11 -0
- data/node_modules/govuk-frontend/govuk/components/error-summary/_error-summary.scss +2 -59
- data/node_modules/govuk-frontend/govuk/components/error-summary/_index.scss +43 -0
- data/node_modules/govuk-frontend/govuk/components/fieldset/_fieldset.scss +2 -68
- data/node_modules/govuk-frontend/govuk/components/fieldset/_index.scss +64 -0
- data/node_modules/govuk-frontend/govuk/components/file-upload/_file-upload.scss +2 -81
- data/node_modules/govuk-frontend/govuk/components/file-upload/_index.scss +49 -0
- data/node_modules/govuk-frontend/govuk/components/footer/_footer.scss +2 -244
- data/node_modules/govuk-frontend/govuk/components/footer/_index.scss +241 -0
- data/node_modules/govuk-frontend/govuk/components/header/_header.scss +2 -318
- data/node_modules/govuk-frontend/govuk/components/header/_index.scss +331 -0
- data/node_modules/govuk-frontend/govuk/components/header/header.js +665 -316
- data/node_modules/govuk-frontend/govuk/components/hint/_hint.scss +2 -50
- data/node_modules/govuk-frontend/govuk/components/hint/_index.scss +44 -0
- data/node_modules/govuk-frontend/govuk/components/input/_index.scss +191 -0
- data/node_modules/govuk-frontend/govuk/components/input/_input.scss +2 -103
- data/node_modules/govuk-frontend/govuk/components/inset-text/_index.scss +24 -0
- data/node_modules/govuk-frontend/govuk/components/inset-text/_inset-text.scss +2 -28
- data/node_modules/govuk-frontend/govuk/components/label/_index.scss +41 -0
- data/node_modules/govuk-frontend/govuk/components/label/_label.scss +2 -45
- data/node_modules/govuk-frontend/govuk/components/notification-banner/_index.scss +89 -0
- data/node_modules/govuk-frontend/govuk/components/notification-banner/_notification-banner.scss +2 -0
- data/node_modules/govuk-frontend/govuk/components/notification-banner/notification-banner.js +61 -0
- data/node_modules/govuk-frontend/govuk/components/panel/_index.scss +44 -0
- data/node_modules/govuk-frontend/govuk/components/panel/_panel.scss +2 -44
- data/node_modules/govuk-frontend/govuk/components/phase-banner/_index.scss +27 -0
- data/node_modules/govuk-frontend/govuk/components/phase-banner/_phase-banner.scss +2 -31
- data/node_modules/govuk-frontend/govuk/components/radios/_index.scss +342 -0
- data/node_modules/govuk-frontend/govuk/components/radios/_radios.scss +2 -346
- data/node_modules/govuk-frontend/govuk/components/radios/radios.js +76 -28
- data/node_modules/govuk-frontend/govuk/components/select/_index.scss +49 -0
- data/node_modules/govuk-frontend/govuk/components/select/_select.scss +2 -57
- data/node_modules/govuk-frontend/govuk/components/skip-link/_index.scss +36 -0
- data/node_modules/govuk-frontend/govuk/components/skip-link/_skip-link.scss +2 -37
- data/node_modules/govuk-frontend/govuk/components/summary-list/_index.scss +145 -0
- data/node_modules/govuk-frontend/govuk/components/summary-list/_summary-list.scss +2 -157
- data/node_modules/govuk-frontend/govuk/components/table/_index.scss +71 -0
- data/node_modules/govuk-frontend/govuk/components/table/_table.scss +2 -54
- data/node_modules/govuk-frontend/govuk/components/tabs/_index.scss +130 -0
- data/node_modules/govuk-frontend/govuk/components/tabs/_tabs.scss +2 -142
- data/node_modules/govuk-frontend/govuk/components/tag/_index.scss +86 -0
- data/node_modules/govuk-frontend/govuk/components/tag/_tag.scss +2 -91
- data/node_modules/govuk-frontend/govuk/components/textarea/_index.scss +47 -0
- data/node_modules/govuk-frontend/govuk/components/textarea/_textarea.scss +2 -55
- data/node_modules/govuk-frontend/govuk/components/warning-text/_index.scss +66 -0
- data/node_modules/govuk-frontend/govuk/components/warning-text/_warning-text.scss +2 -60
- data/node_modules/govuk-frontend/govuk/core/_global-styles.scss +5 -3
- data/node_modules/govuk-frontend/govuk/core/_links.scss +13 -3
- data/node_modules/govuk-frontend/govuk/core/_lists.scss +17 -3
- data/node_modules/govuk-frontend/govuk/core/_section-break.scss +5 -3
- data/node_modules/govuk-frontend/govuk/core/_template.scss +5 -4
- data/node_modules/govuk-frontend/govuk/core/_typography.scss +5 -3
- data/node_modules/govuk-frontend/govuk/helpers/_clearfix.scss +1 -1
- data/node_modules/govuk-frontend/govuk/helpers/_colour.scss +1 -1
- data/node_modules/govuk-frontend/govuk/helpers/_device-pixels.scss +3 -3
- data/node_modules/govuk-frontend/govuk/helpers/_focused.scss +1 -1
- data/node_modules/govuk-frontend/govuk/helpers/_font-faces.scss +9 -11
- data/node_modules/govuk-frontend/govuk/helpers/_grid.scss +2 -1
- data/node_modules/govuk-frontend/govuk/helpers/_links.scss +246 -33
- data/node_modules/govuk-frontend/govuk/helpers/_media-queries.scss +2 -6
- data/node_modules/govuk-frontend/govuk/helpers/_shape-arrow.scss +1 -1
- data/node_modules/govuk-frontend/govuk/helpers/_spacing.scss +3 -2
- data/node_modules/govuk-frontend/govuk/helpers/_typography.scss +8 -7
- data/node_modules/govuk-frontend/govuk/helpers/_visually-hidden.scss +1 -1
- data/node_modules/govuk-frontend/govuk/objects/_all.scss +1 -0
- data/node_modules/govuk-frontend/govuk/objects/_button-group.scss +101 -0
- data/node_modules/govuk-frontend/govuk/objects/_form-group.scss +1 -4
- data/node_modules/govuk-frontend/govuk/objects/_grid.scss +3 -6
- data/node_modules/govuk-frontend/govuk/objects/_main-wrapper.scss +5 -4
- data/node_modules/govuk-frontend/govuk/objects/_width-container.scss +6 -4
- data/node_modules/govuk-frontend/govuk/overrides/_display.scss +6 -4
- data/node_modules/govuk-frontend/govuk/overrides/_spacing.scss +5 -3
- data/node_modules/govuk-frontend/govuk/overrides/_typography.scss +5 -3
- data/node_modules/govuk-frontend/govuk/overrides/_width.scss +6 -3
- data/node_modules/govuk-frontend/govuk/settings/_all.scss +2 -0
- data/node_modules/govuk-frontend/govuk/settings/_colours-applied.scss +11 -5
- data/node_modules/govuk-frontend/govuk/settings/_colours-organisations.scss +3 -0
- data/node_modules/govuk-frontend/govuk/settings/_colours-palette.scss +42 -35
- data/node_modules/govuk-frontend/govuk/settings/_compatibility.scss +0 -1
- data/node_modules/govuk-frontend/govuk/settings/_ie8.scss +1 -1
- data/node_modules/govuk-frontend/govuk/settings/_links.scss +62 -0
- data/node_modules/govuk-frontend/govuk/settings/_measurements.scss +4 -5
- data/node_modules/govuk-frontend/govuk/settings/_typography-font-families.scss +2 -2
- data/node_modules/govuk-frontend/govuk/settings/_typography-font.scss +14 -5
- data/node_modules/govuk-frontend/govuk/settings/_typography-responsive.scss +6 -2
- data/node_modules/govuk-frontend/govuk/tools/_compatibility.scss +1 -1
- data/node_modules/govuk-frontend/govuk/tools/_font-url.scss +1 -4
- data/node_modules/govuk-frontend/govuk/tools/_ie8.scss +1 -1
- data/node_modules/govuk-frontend/govuk/tools/_image-url.scss +1 -4
- data/node_modules/govuk-frontend/govuk/tools/_px-to-em.scss +1 -1
- data/node_modules/govuk-frontend/govuk/tools/_px-to-rem.scss +1 -1
- data/node_modules/govuk-frontend/govuk/utilities/_visually-hidden.scss +0 -1
- data/node_modules/govuk-frontend/govuk/vendor/_sass-mq.scss +0 -4
- data/package-lock.json +358 -288
- data/package.json +2 -2
- metadata +56 -4
|
@@ -6,251 +6,6 @@
|
|
|
6
6
|
|
|
7
7
|
(function(undefined) {
|
|
8
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
9
|
// Detection from https://github.com/Financial-Times/polyfill-service/blob/master/packages/polyfill-library/polyfills/Window/detect.js
|
|
255
10
|
var detect = ('Window' in this);
|
|
256
11
|
|
|
@@ -370,43 +125,130 @@ if (detect) return
|
|
|
370
125
|
}
|
|
371
126
|
}
|
|
372
127
|
|
|
373
|
-
cache[propertyName] = newValue;
|
|
374
|
-
});
|
|
375
|
-
|
|
376
|
-
prototype.constructor = Element;
|
|
377
|
-
|
|
378
|
-
if (!prototype.hasAttribute) {
|
|
379
|
-
// <Element>.hasAttribute
|
|
380
|
-
prototype.hasAttribute = function hasAttribute(name) {
|
|
381
|
-
return this.getAttribute(name) !== null;
|
|
382
|
-
};
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
// Apply Element prototype to the pre-existing DOM as soon as the body element appears.
|
|
386
|
-
function bodyCheck() {
|
|
387
|
-
if (!(loopLimit--)) clearTimeout(interval);
|
|
388
|
-
if (document.body && !document.body.prototype && /(complete|interactive)/.test(document.readyState)) {
|
|
389
|
-
shiv(document, true);
|
|
390
|
-
if (interval && document.body.prototype) clearTimeout(interval);
|
|
391
|
-
return (!!document.body.prototype);
|
|
128
|
+
cache[propertyName] = newValue;
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
prototype.constructor = Element;
|
|
132
|
+
|
|
133
|
+
if (!prototype.hasAttribute) {
|
|
134
|
+
// <Element>.hasAttribute
|
|
135
|
+
prototype.hasAttribute = function hasAttribute(name) {
|
|
136
|
+
return this.getAttribute(name) !== null;
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// Apply Element prototype to the pre-existing DOM as soon as the body element appears.
|
|
141
|
+
function bodyCheck() {
|
|
142
|
+
if (!(loopLimit--)) clearTimeout(interval);
|
|
143
|
+
if (document.body && !document.body.prototype && /(complete|interactive)/.test(document.readyState)) {
|
|
144
|
+
shiv(document, true);
|
|
145
|
+
if (interval && document.body.prototype) clearTimeout(interval);
|
|
146
|
+
return (!!document.body.prototype);
|
|
147
|
+
}
|
|
148
|
+
return false;
|
|
149
|
+
}
|
|
150
|
+
if (!bodyCheck()) {
|
|
151
|
+
document.onreadystatechange = bodyCheck;
|
|
152
|
+
interval = setInterval(bodyCheck, 25);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// Apply to any new elements created after load
|
|
156
|
+
document.createElement = function createElement(nodeName) {
|
|
157
|
+
var element = nativeCreateElement(String(nodeName).toLowerCase());
|
|
158
|
+
return shiv(element);
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
// remove sandboxed iframe
|
|
162
|
+
document.removeChild(vbody);
|
|
163
|
+
}());
|
|
164
|
+
|
|
165
|
+
})
|
|
166
|
+
.call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
|
|
167
|
+
|
|
168
|
+
(function(undefined) {
|
|
169
|
+
|
|
170
|
+
// Detection from https://github.com/Financial-Times/polyfill-service/blob/master/packages/polyfill-library/polyfills/Object/defineProperty/detect.js
|
|
171
|
+
var detect = (
|
|
172
|
+
// In IE8, defineProperty could only act on DOM elements, so full support
|
|
173
|
+
// for the feature requires the ability to set a property on an arbitrary object
|
|
174
|
+
'defineProperty' in Object && (function() {
|
|
175
|
+
try {
|
|
176
|
+
var a = {};
|
|
177
|
+
Object.defineProperty(a, 'test', {value:42});
|
|
178
|
+
return true;
|
|
179
|
+
} catch(e) {
|
|
180
|
+
return false
|
|
181
|
+
}
|
|
182
|
+
}())
|
|
183
|
+
);
|
|
184
|
+
|
|
185
|
+
if (detect) return
|
|
186
|
+
|
|
187
|
+
// Polyfill from https://cdn.polyfill.io/v2/polyfill.js?features=Object.defineProperty&flags=always
|
|
188
|
+
(function (nativeDefineProperty) {
|
|
189
|
+
|
|
190
|
+
var supportsAccessors = Object.prototype.hasOwnProperty('__defineGetter__');
|
|
191
|
+
var ERR_ACCESSORS_NOT_SUPPORTED = 'Getters & setters cannot be defined on this javascript engine';
|
|
192
|
+
var ERR_VALUE_ACCESSORS = 'A property cannot both have accessors and be writable or have a value';
|
|
193
|
+
|
|
194
|
+
Object.defineProperty = function defineProperty(object, property, descriptor) {
|
|
195
|
+
|
|
196
|
+
// Where native support exists, assume it
|
|
197
|
+
if (nativeDefineProperty && (object === window || object === document || object === Element.prototype || object instanceof Element)) {
|
|
198
|
+
return nativeDefineProperty(object, property, descriptor);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
if (object === null || !(object instanceof Object || typeof object === 'object')) {
|
|
202
|
+
throw new TypeError('Object.defineProperty called on non-object');
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
if (!(descriptor instanceof Object)) {
|
|
206
|
+
throw new TypeError('Property description must be an object');
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
var propertyString = String(property);
|
|
210
|
+
var hasValueOrWritable = 'value' in descriptor || 'writable' in descriptor;
|
|
211
|
+
var getterType = 'get' in descriptor && typeof descriptor.get;
|
|
212
|
+
var setterType = 'set' in descriptor && typeof descriptor.set;
|
|
213
|
+
|
|
214
|
+
// handle descriptor.get
|
|
215
|
+
if (getterType) {
|
|
216
|
+
if (getterType !== 'function') {
|
|
217
|
+
throw new TypeError('Getter must be a function');
|
|
218
|
+
}
|
|
219
|
+
if (!supportsAccessors) {
|
|
220
|
+
throw new TypeError(ERR_ACCESSORS_NOT_SUPPORTED);
|
|
221
|
+
}
|
|
222
|
+
if (hasValueOrWritable) {
|
|
223
|
+
throw new TypeError(ERR_VALUE_ACCESSORS);
|
|
224
|
+
}
|
|
225
|
+
Object.__defineGetter__.call(object, propertyString, descriptor.get);
|
|
226
|
+
} else {
|
|
227
|
+
object[propertyString] = descriptor.value;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
// handle descriptor.set
|
|
231
|
+
if (setterType) {
|
|
232
|
+
if (setterType !== 'function') {
|
|
233
|
+
throw new TypeError('Setter must be a function');
|
|
234
|
+
}
|
|
235
|
+
if (!supportsAccessors) {
|
|
236
|
+
throw new TypeError(ERR_ACCESSORS_NOT_SUPPORTED);
|
|
237
|
+
}
|
|
238
|
+
if (hasValueOrWritable) {
|
|
239
|
+
throw new TypeError(ERR_VALUE_ACCESSORS);
|
|
240
|
+
}
|
|
241
|
+
Object.__defineSetter__.call(object, propertyString, descriptor.set);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
// OK to define value unconditionally - if a getter has been specified as well, an error would be thrown above
|
|
245
|
+
if ('value' in descriptor) {
|
|
246
|
+
object[propertyString] = descriptor.value;
|
|
392
247
|
}
|
|
393
|
-
return false;
|
|
394
|
-
}
|
|
395
|
-
if (!bodyCheck()) {
|
|
396
|
-
document.onreadystatechange = bodyCheck;
|
|
397
|
-
interval = setInterval(bodyCheck, 25);
|
|
398
|
-
}
|
|
399
248
|
|
|
400
|
-
|
|
401
|
-
document.createElement = function createElement(nodeName) {
|
|
402
|
-
var element = nativeCreateElement(String(nodeName).toLowerCase());
|
|
403
|
-
return shiv(element);
|
|
249
|
+
return object;
|
|
404
250
|
};
|
|
405
|
-
|
|
406
|
-
// remove sandboxed iframe
|
|
407
|
-
document.removeChild(vbody);
|
|
408
|
-
}());
|
|
409
|
-
|
|
251
|
+
}(Object.defineProperty));
|
|
410
252
|
})
|
|
411
253
|
.call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
|
|
412
254
|
|
|
@@ -659,57 +501,564 @@ if (detect) return
|
|
|
659
501
|
})
|
|
660
502
|
.call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
|
|
661
503
|
|
|
504
|
+
(function(undefined) {
|
|
505
|
+
|
|
506
|
+
// Detection from https://raw.githubusercontent.com/Financial-Times/polyfill-service/master/packages/polyfill-library/polyfills/DOMTokenList/detect.js
|
|
507
|
+
var detect = (
|
|
508
|
+
'DOMTokenList' in this && (function (x) {
|
|
509
|
+
return 'classList' in x ? !x.classList.toggle('x', false) && !x.className : true;
|
|
510
|
+
})(document.createElement('x'))
|
|
511
|
+
);
|
|
512
|
+
|
|
513
|
+
if (detect) return
|
|
514
|
+
|
|
515
|
+
// Polyfill from https://raw.githubusercontent.com/Financial-Times/polyfill-service/master/packages/polyfill-library/polyfills/DOMTokenList/polyfill.js
|
|
516
|
+
(function (global) {
|
|
517
|
+
var nativeImpl = "DOMTokenList" in global && global.DOMTokenList;
|
|
518
|
+
|
|
519
|
+
if (
|
|
520
|
+
!nativeImpl ||
|
|
521
|
+
(
|
|
522
|
+
!!document.createElementNS &&
|
|
523
|
+
!!document.createElementNS('http://www.w3.org/2000/svg', 'svg') &&
|
|
524
|
+
!(document.createElementNS("http://www.w3.org/2000/svg", "svg").classList instanceof DOMTokenList)
|
|
525
|
+
)
|
|
526
|
+
) {
|
|
527
|
+
global.DOMTokenList = (function() { // eslint-disable-line no-unused-vars
|
|
528
|
+
var dpSupport = true;
|
|
529
|
+
var defineGetter = function (object, name, fn, configurable) {
|
|
530
|
+
if (Object.defineProperty)
|
|
531
|
+
Object.defineProperty(object, name, {
|
|
532
|
+
configurable: false === dpSupport ? true : !!configurable,
|
|
533
|
+
get: fn
|
|
534
|
+
});
|
|
535
|
+
|
|
536
|
+
else object.__defineGetter__(name, fn);
|
|
537
|
+
};
|
|
538
|
+
|
|
539
|
+
/** Ensure the browser allows Object.defineProperty to be used on native JavaScript objects. */
|
|
540
|
+
try {
|
|
541
|
+
defineGetter({}, "support");
|
|
542
|
+
}
|
|
543
|
+
catch (e) {
|
|
544
|
+
dpSupport = false;
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
|
|
548
|
+
var _DOMTokenList = function (el, prop) {
|
|
549
|
+
var that = this;
|
|
550
|
+
var tokens = [];
|
|
551
|
+
var tokenMap = {};
|
|
552
|
+
var length = 0;
|
|
553
|
+
var maxLength = 0;
|
|
554
|
+
var addIndexGetter = function (i) {
|
|
555
|
+
defineGetter(that, i, function () {
|
|
556
|
+
preop();
|
|
557
|
+
return tokens[i];
|
|
558
|
+
}, false);
|
|
559
|
+
|
|
560
|
+
};
|
|
561
|
+
var reindex = function () {
|
|
562
|
+
|
|
563
|
+
/** Define getter functions for array-like access to the tokenList's contents. */
|
|
564
|
+
if (length >= maxLength)
|
|
565
|
+
for (; maxLength < length; ++maxLength) {
|
|
566
|
+
addIndexGetter(maxLength);
|
|
567
|
+
}
|
|
568
|
+
};
|
|
569
|
+
|
|
570
|
+
/** Helper function called at the start of each class method. Internal use only. */
|
|
571
|
+
var preop = function () {
|
|
572
|
+
var error;
|
|
573
|
+
var i;
|
|
574
|
+
var args = arguments;
|
|
575
|
+
var rSpace = /\s+/;
|
|
576
|
+
|
|
577
|
+
/** Validate the token/s passed to an instance method, if any. */
|
|
578
|
+
if (args.length)
|
|
579
|
+
for (i = 0; i < args.length; ++i)
|
|
580
|
+
if (rSpace.test(args[i])) {
|
|
581
|
+
error = new SyntaxError('String "' + args[i] + '" ' + "contains" + ' an invalid character');
|
|
582
|
+
error.code = 5;
|
|
583
|
+
error.name = "InvalidCharacterError";
|
|
584
|
+
throw error;
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
|
|
588
|
+
/** Split the new value apart by whitespace*/
|
|
589
|
+
if (typeof el[prop] === "object") {
|
|
590
|
+
tokens = ("" + el[prop].baseVal).replace(/^\s+|\s+$/g, "").split(rSpace);
|
|
591
|
+
} else {
|
|
592
|
+
tokens = ("" + el[prop]).replace(/^\s+|\s+$/g, "").split(rSpace);
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
/** Avoid treating blank strings as single-item token lists */
|
|
596
|
+
if ("" === tokens[0]) tokens = [];
|
|
597
|
+
|
|
598
|
+
/** Repopulate the internal token lists */
|
|
599
|
+
tokenMap = {};
|
|
600
|
+
for (i = 0; i < tokens.length; ++i)
|
|
601
|
+
tokenMap[tokens[i]] = true;
|
|
602
|
+
length = tokens.length;
|
|
603
|
+
reindex();
|
|
604
|
+
};
|
|
605
|
+
|
|
606
|
+
/** Populate our internal token list if the targeted attribute of the subject element isn't empty. */
|
|
607
|
+
preop();
|
|
608
|
+
|
|
609
|
+
/** Return the number of tokens in the underlying string. Read-only. */
|
|
610
|
+
defineGetter(that, "length", function () {
|
|
611
|
+
preop();
|
|
612
|
+
return length;
|
|
613
|
+
});
|
|
614
|
+
|
|
615
|
+
/** Override the default toString/toLocaleString methods to return a space-delimited list of tokens when typecast. */
|
|
616
|
+
that.toLocaleString =
|
|
617
|
+
that.toString = function () {
|
|
618
|
+
preop();
|
|
619
|
+
return tokens.join(" ");
|
|
620
|
+
};
|
|
621
|
+
|
|
622
|
+
that.item = function (idx) {
|
|
623
|
+
preop();
|
|
624
|
+
return tokens[idx];
|
|
625
|
+
};
|
|
626
|
+
|
|
627
|
+
that.contains = function (token) {
|
|
628
|
+
preop();
|
|
629
|
+
return !!tokenMap[token];
|
|
630
|
+
};
|
|
631
|
+
|
|
632
|
+
that.add = function () {
|
|
633
|
+
preop.apply(that, args = arguments);
|
|
634
|
+
|
|
635
|
+
for (var args, token, i = 0, l = args.length; i < l; ++i) {
|
|
636
|
+
token = args[i];
|
|
637
|
+
if (!tokenMap[token]) {
|
|
638
|
+
tokens.push(token);
|
|
639
|
+
tokenMap[token] = true;
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
/** Update the targeted attribute of the attached element if the token list's changed. */
|
|
644
|
+
if (length !== tokens.length) {
|
|
645
|
+
length = tokens.length >>> 0;
|
|
646
|
+
if (typeof el[prop] === "object") {
|
|
647
|
+
el[prop].baseVal = tokens.join(" ");
|
|
648
|
+
} else {
|
|
649
|
+
el[prop] = tokens.join(" ");
|
|
650
|
+
}
|
|
651
|
+
reindex();
|
|
652
|
+
}
|
|
653
|
+
};
|
|
654
|
+
|
|
655
|
+
that.remove = function () {
|
|
656
|
+
preop.apply(that, args = arguments);
|
|
657
|
+
|
|
658
|
+
/** Build a hash of token names to compare against when recollecting our token list. */
|
|
659
|
+
for (var args, ignore = {}, i = 0, t = []; i < args.length; ++i) {
|
|
660
|
+
ignore[args[i]] = true;
|
|
661
|
+
delete tokenMap[args[i]];
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
/** Run through our tokens list and reassign only those that aren't defined in the hash declared above. */
|
|
665
|
+
for (i = 0; i < tokens.length; ++i)
|
|
666
|
+
if (!ignore[tokens[i]]) t.push(tokens[i]);
|
|
667
|
+
|
|
668
|
+
tokens = t;
|
|
669
|
+
length = t.length >>> 0;
|
|
670
|
+
|
|
671
|
+
/** Update the targeted attribute of the attached element. */
|
|
672
|
+
if (typeof el[prop] === "object") {
|
|
673
|
+
el[prop].baseVal = tokens.join(" ");
|
|
674
|
+
} else {
|
|
675
|
+
el[prop] = tokens.join(" ");
|
|
676
|
+
}
|
|
677
|
+
reindex();
|
|
678
|
+
};
|
|
679
|
+
|
|
680
|
+
that.toggle = function (token, force) {
|
|
681
|
+
preop.apply(that, [token]);
|
|
682
|
+
|
|
683
|
+
/** Token state's being forced. */
|
|
684
|
+
if (undefined !== force) {
|
|
685
|
+
if (force) {
|
|
686
|
+
that.add(token);
|
|
687
|
+
return true;
|
|
688
|
+
} else {
|
|
689
|
+
that.remove(token);
|
|
690
|
+
return false;
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
/** Token already exists in tokenList. Remove it, and return FALSE. */
|
|
695
|
+
if (tokenMap[token]) {
|
|
696
|
+
that.remove(token);
|
|
697
|
+
return false;
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
/** Otherwise, add the token and return TRUE. */
|
|
701
|
+
that.add(token);
|
|
702
|
+
return true;
|
|
703
|
+
};
|
|
704
|
+
|
|
705
|
+
return that;
|
|
706
|
+
};
|
|
707
|
+
|
|
708
|
+
return _DOMTokenList;
|
|
709
|
+
}());
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
// Add second argument to native DOMTokenList.toggle() if necessary
|
|
713
|
+
(function () {
|
|
714
|
+
var e = document.createElement('span');
|
|
715
|
+
if (!('classList' in e)) return;
|
|
716
|
+
e.classList.toggle('x', false);
|
|
717
|
+
if (!e.classList.contains('x')) return;
|
|
718
|
+
e.classList.constructor.prototype.toggle = function toggle(token /*, force*/) {
|
|
719
|
+
var force = arguments[1];
|
|
720
|
+
if (force === undefined) {
|
|
721
|
+
var add = !this.contains(token);
|
|
722
|
+
this[add ? 'add' : 'remove'](token);
|
|
723
|
+
return add;
|
|
724
|
+
}
|
|
725
|
+
force = !!force;
|
|
726
|
+
this[force ? 'add' : 'remove'](token);
|
|
727
|
+
return force;
|
|
728
|
+
};
|
|
729
|
+
}());
|
|
730
|
+
|
|
731
|
+
// Add multiple arguments to native DOMTokenList.add() if necessary
|
|
732
|
+
(function () {
|
|
733
|
+
var e = document.createElement('span');
|
|
734
|
+
if (!('classList' in e)) return;
|
|
735
|
+
e.classList.add('a', 'b');
|
|
736
|
+
if (e.classList.contains('b')) return;
|
|
737
|
+
var native = e.classList.constructor.prototype.add;
|
|
738
|
+
e.classList.constructor.prototype.add = function () {
|
|
739
|
+
var args = arguments;
|
|
740
|
+
var l = arguments.length;
|
|
741
|
+
for (var i = 0; i < l; i++) {
|
|
742
|
+
native.call(this, args[i]);
|
|
743
|
+
}
|
|
744
|
+
};
|
|
745
|
+
}());
|
|
746
|
+
|
|
747
|
+
// Add multiple arguments to native DOMTokenList.remove() if necessary
|
|
748
|
+
(function () {
|
|
749
|
+
var e = document.createElement('span');
|
|
750
|
+
if (!('classList' in e)) return;
|
|
751
|
+
e.classList.add('a');
|
|
752
|
+
e.classList.add('b');
|
|
753
|
+
e.classList.remove('a', 'b');
|
|
754
|
+
if (!e.classList.contains('b')) return;
|
|
755
|
+
var native = e.classList.constructor.prototype.remove;
|
|
756
|
+
e.classList.constructor.prototype.remove = function () {
|
|
757
|
+
var args = arguments;
|
|
758
|
+
var l = arguments.length;
|
|
759
|
+
for (var i = 0; i < l; i++) {
|
|
760
|
+
native.call(this, args[i]);
|
|
761
|
+
}
|
|
762
|
+
};
|
|
763
|
+
}());
|
|
764
|
+
|
|
765
|
+
}(this));
|
|
766
|
+
|
|
767
|
+
}).call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
|
|
768
|
+
|
|
769
|
+
(function(undefined) {
|
|
770
|
+
|
|
771
|
+
// Detection from https://raw.githubusercontent.com/Financial-Times/polyfill-service/8717a9e04ac7aff99b4980fbedead98036b0929a/packages/polyfill-library/polyfills/Element/prototype/classList/detect.js
|
|
772
|
+
var detect = (
|
|
773
|
+
'document' in this && "classList" in document.documentElement && 'Element' in this && 'classList' in Element.prototype && (function () {
|
|
774
|
+
var e = document.createElement('span');
|
|
775
|
+
e.classList.add('a', 'b');
|
|
776
|
+
return e.classList.contains('b');
|
|
777
|
+
}())
|
|
778
|
+
);
|
|
779
|
+
|
|
780
|
+
if (detect) return
|
|
781
|
+
|
|
782
|
+
// Polyfill from https://cdn.polyfill.io/v2/polyfill.js?features=Element.prototype.classList&flags=always
|
|
783
|
+
(function (global) {
|
|
784
|
+
var dpSupport = true;
|
|
785
|
+
var defineGetter = function (object, name, fn, configurable) {
|
|
786
|
+
if (Object.defineProperty)
|
|
787
|
+
Object.defineProperty(object, name, {
|
|
788
|
+
configurable: false === dpSupport ? true : !!configurable,
|
|
789
|
+
get: fn
|
|
790
|
+
});
|
|
791
|
+
|
|
792
|
+
else object.__defineGetter__(name, fn);
|
|
793
|
+
};
|
|
794
|
+
/** Ensure the browser allows Object.defineProperty to be used on native JavaScript objects. */
|
|
795
|
+
try {
|
|
796
|
+
defineGetter({}, "support");
|
|
797
|
+
}
|
|
798
|
+
catch (e) {
|
|
799
|
+
dpSupport = false;
|
|
800
|
+
}
|
|
801
|
+
/** Polyfills a property with a DOMTokenList */
|
|
802
|
+
var addProp = function (o, name, attr) {
|
|
803
|
+
|
|
804
|
+
defineGetter(o.prototype, name, function () {
|
|
805
|
+
var tokenList;
|
|
806
|
+
|
|
807
|
+
var THIS = this,
|
|
808
|
+
|
|
809
|
+
/** Prevent this from firing twice for some reason. What the hell, IE. */
|
|
810
|
+
gibberishProperty = "__defineGetter__" + "DEFINE_PROPERTY" + name;
|
|
811
|
+
if(THIS[gibberishProperty]) return tokenList;
|
|
812
|
+
THIS[gibberishProperty] = true;
|
|
813
|
+
|
|
814
|
+
/**
|
|
815
|
+
* IE8 can't define properties on native JavaScript objects, so we'll use a dumb hack instead.
|
|
816
|
+
*
|
|
817
|
+
* What this is doing is creating a dummy element ("reflection") inside a detached phantom node ("mirror")
|
|
818
|
+
* that serves as the target of Object.defineProperty instead. While we could simply use the subject HTML
|
|
819
|
+
* element instead, this would conflict with element types which use indexed properties (such as forms and
|
|
820
|
+
* select lists).
|
|
821
|
+
*/
|
|
822
|
+
if (false === dpSupport) {
|
|
823
|
+
|
|
824
|
+
var visage;
|
|
825
|
+
var mirror = addProp.mirror || document.createElement("div");
|
|
826
|
+
var reflections = mirror.childNodes;
|
|
827
|
+
var l = reflections.length;
|
|
828
|
+
|
|
829
|
+
for (var i = 0; i < l; ++i)
|
|
830
|
+
if (reflections[i]._R === THIS) {
|
|
831
|
+
visage = reflections[i];
|
|
832
|
+
break;
|
|
833
|
+
}
|
|
834
|
+
|
|
835
|
+
/** Couldn't find an element's reflection inside the mirror. Materialise one. */
|
|
836
|
+
visage || (visage = mirror.appendChild(document.createElement("div")));
|
|
837
|
+
|
|
838
|
+
tokenList = DOMTokenList.call(visage, THIS, attr);
|
|
839
|
+
} else tokenList = new DOMTokenList(THIS, attr);
|
|
840
|
+
|
|
841
|
+
defineGetter(THIS, name, function () {
|
|
842
|
+
return tokenList;
|
|
843
|
+
});
|
|
844
|
+
delete THIS[gibberishProperty];
|
|
845
|
+
|
|
846
|
+
return tokenList;
|
|
847
|
+
}, true);
|
|
848
|
+
};
|
|
849
|
+
|
|
850
|
+
addProp(global.Element, "classList", "className");
|
|
851
|
+
addProp(global.HTMLElement, "classList", "className");
|
|
852
|
+
addProp(global.HTMLLinkElement, "relList", "rel");
|
|
853
|
+
addProp(global.HTMLAnchorElement, "relList", "rel");
|
|
854
|
+
addProp(global.HTMLAreaElement, "relList", "rel");
|
|
855
|
+
}(this));
|
|
856
|
+
|
|
857
|
+
}).call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
|
|
858
|
+
|
|
859
|
+
(function(undefined) {
|
|
860
|
+
// Detection from https://github.com/Financial-Times/polyfill-service/blob/master/packages/polyfill-library/polyfills/Function/prototype/bind/detect.js
|
|
861
|
+
var detect = 'bind' in Function.prototype;
|
|
862
|
+
|
|
863
|
+
if (detect) return
|
|
864
|
+
|
|
865
|
+
// Polyfill from https://cdn.polyfill.io/v2/polyfill.js?features=Function.prototype.bind&flags=always
|
|
866
|
+
Object.defineProperty(Function.prototype, 'bind', {
|
|
867
|
+
value: function bind(that) { // .length is 1
|
|
868
|
+
// add necessary es5-shim utilities
|
|
869
|
+
var $Array = Array;
|
|
870
|
+
var $Object = Object;
|
|
871
|
+
var ObjectPrototype = $Object.prototype;
|
|
872
|
+
var ArrayPrototype = $Array.prototype;
|
|
873
|
+
var Empty = function Empty() {};
|
|
874
|
+
var to_string = ObjectPrototype.toString;
|
|
875
|
+
var hasToStringTag = typeof Symbol === 'function' && typeof Symbol.toStringTag === 'symbol';
|
|
876
|
+
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; };
|
|
877
|
+
var array_slice = ArrayPrototype.slice;
|
|
878
|
+
var array_concat = ArrayPrototype.concat;
|
|
879
|
+
var array_push = ArrayPrototype.push;
|
|
880
|
+
var max = Math.max;
|
|
881
|
+
// /add necessary es5-shim utilities
|
|
882
|
+
|
|
883
|
+
// 1. Let Target be the this value.
|
|
884
|
+
var target = this;
|
|
885
|
+
// 2. If IsCallable(Target) is false, throw a TypeError exception.
|
|
886
|
+
if (!isCallable(target)) {
|
|
887
|
+
throw new TypeError('Function.prototype.bind called on incompatible ' + target);
|
|
888
|
+
}
|
|
889
|
+
// 3. Let A be a new (possibly empty) internal list of all of the
|
|
890
|
+
// argument values provided after thisArg (arg1, arg2 etc), in order.
|
|
891
|
+
// XXX slicedArgs will stand in for "A" if used
|
|
892
|
+
var args = array_slice.call(arguments, 1); // for normal call
|
|
893
|
+
// 4. Let F be a new native ECMAScript object.
|
|
894
|
+
// 11. Set the [[Prototype]] internal property of F to the standard
|
|
895
|
+
// built-in Function prototype object as specified in 15.3.3.1.
|
|
896
|
+
// 12. Set the [[Call]] internal property of F as described in
|
|
897
|
+
// 15.3.4.5.1.
|
|
898
|
+
// 13. Set the [[Construct]] internal property of F as described in
|
|
899
|
+
// 15.3.4.5.2.
|
|
900
|
+
// 14. Set the [[HasInstance]] internal property of F as described in
|
|
901
|
+
// 15.3.4.5.3.
|
|
902
|
+
var bound;
|
|
903
|
+
var binder = function () {
|
|
904
|
+
|
|
905
|
+
if (this instanceof bound) {
|
|
906
|
+
// 15.3.4.5.2 [[Construct]]
|
|
907
|
+
// When the [[Construct]] internal method of a function object,
|
|
908
|
+
// F that was created using the bind function is called with a
|
|
909
|
+
// list of arguments ExtraArgs, the following steps are taken:
|
|
910
|
+
// 1. Let target be the value of F's [[TargetFunction]]
|
|
911
|
+
// internal property.
|
|
912
|
+
// 2. If target has no [[Construct]] internal method, a
|
|
913
|
+
// TypeError exception is thrown.
|
|
914
|
+
// 3. Let boundArgs be the value of F's [[BoundArgs]] internal
|
|
915
|
+
// property.
|
|
916
|
+
// 4. Let args be a new list containing the same values as the
|
|
917
|
+
// list boundArgs in the same order followed by the same
|
|
918
|
+
// values as the list ExtraArgs in the same order.
|
|
919
|
+
// 5. Return the result of calling the [[Construct]] internal
|
|
920
|
+
// method of target providing args as the arguments.
|
|
921
|
+
|
|
922
|
+
var result = target.apply(
|
|
923
|
+
this,
|
|
924
|
+
array_concat.call(args, array_slice.call(arguments))
|
|
925
|
+
);
|
|
926
|
+
if ($Object(result) === result) {
|
|
927
|
+
return result;
|
|
928
|
+
}
|
|
929
|
+
return this;
|
|
930
|
+
|
|
931
|
+
} else {
|
|
932
|
+
// 15.3.4.5.1 [[Call]]
|
|
933
|
+
// When the [[Call]] internal method of a function object, F,
|
|
934
|
+
// which was created using the bind function is called with a
|
|
935
|
+
// this value and a list of arguments ExtraArgs, the following
|
|
936
|
+
// steps are taken:
|
|
937
|
+
// 1. Let boundArgs be the value of F's [[BoundArgs]] internal
|
|
938
|
+
// property.
|
|
939
|
+
// 2. Let boundThis be the value of F's [[BoundThis]] internal
|
|
940
|
+
// property.
|
|
941
|
+
// 3. Let target be the value of F's [[TargetFunction]] internal
|
|
942
|
+
// property.
|
|
943
|
+
// 4. Let args be a new list containing the same values as the
|
|
944
|
+
// list boundArgs in the same order followed by the same
|
|
945
|
+
// values as the list ExtraArgs in the same order.
|
|
946
|
+
// 5. Return the result of calling the [[Call]] internal method
|
|
947
|
+
// of target providing boundThis as the this value and
|
|
948
|
+
// providing args as the arguments.
|
|
949
|
+
|
|
950
|
+
// equiv: target.call(this, ...boundArgs, ...args)
|
|
951
|
+
return target.apply(
|
|
952
|
+
that,
|
|
953
|
+
array_concat.call(args, array_slice.call(arguments))
|
|
954
|
+
);
|
|
955
|
+
|
|
956
|
+
}
|
|
957
|
+
|
|
958
|
+
};
|
|
959
|
+
|
|
960
|
+
// 15. If the [[Class]] internal property of Target is "Function", then
|
|
961
|
+
// a. Let L be the length property of Target minus the length of A.
|
|
962
|
+
// b. Set the length own property of F to either 0 or L, whichever is
|
|
963
|
+
// larger.
|
|
964
|
+
// 16. Else set the length own property of F to 0.
|
|
965
|
+
|
|
966
|
+
var boundLength = max(0, target.length - args.length);
|
|
967
|
+
|
|
968
|
+
// 17. Set the attributes of the length own property of F to the values
|
|
969
|
+
// specified in 15.3.5.1.
|
|
970
|
+
var boundArgs = [];
|
|
971
|
+
for (var i = 0; i < boundLength; i++) {
|
|
972
|
+
array_push.call(boundArgs, '$' + i);
|
|
973
|
+
}
|
|
974
|
+
|
|
975
|
+
// XXX Build a dynamic function with desired amount of arguments is the only
|
|
976
|
+
// way to set the length property of a function.
|
|
977
|
+
// In environments where Content Security Policies enabled (Chrome extensions,
|
|
978
|
+
// for ex.) all use of eval or Function costructor throws an exception.
|
|
979
|
+
// However in all of these environments Function.prototype.bind exists
|
|
980
|
+
// and so this code will never be executed.
|
|
981
|
+
bound = Function('binder', 'return function (' + boundArgs.join(',') + '){ return binder.apply(this, arguments); }')(binder);
|
|
982
|
+
|
|
983
|
+
if (target.prototype) {
|
|
984
|
+
Empty.prototype = target.prototype;
|
|
985
|
+
bound.prototype = new Empty();
|
|
986
|
+
// Clean up dangling references.
|
|
987
|
+
Empty.prototype = null;
|
|
988
|
+
}
|
|
989
|
+
|
|
990
|
+
// TODO
|
|
991
|
+
// 18. Set the [[Extensible]] internal property of F to true.
|
|
992
|
+
|
|
993
|
+
// TODO
|
|
994
|
+
// 19. Let thrower be the [[ThrowTypeError]] function Object (13.2.3).
|
|
995
|
+
// 20. Call the [[DefineOwnProperty]] internal method of F with
|
|
996
|
+
// arguments "caller", PropertyDescriptor {[[Get]]: thrower, [[Set]]:
|
|
997
|
+
// thrower, [[Enumerable]]: false, [[Configurable]]: false}, and
|
|
998
|
+
// false.
|
|
999
|
+
// 21. Call the [[DefineOwnProperty]] internal method of F with
|
|
1000
|
+
// arguments "arguments", PropertyDescriptor {[[Get]]: thrower,
|
|
1001
|
+
// [[Set]]: thrower, [[Enumerable]]: false, [[Configurable]]: false},
|
|
1002
|
+
// and false.
|
|
1003
|
+
|
|
1004
|
+
// TODO
|
|
1005
|
+
// NOTE Function objects created using Function.prototype.bind do not
|
|
1006
|
+
// have a prototype property or the [[Code]], [[FormalParameters]], and
|
|
1007
|
+
// [[Scope]] internal properties.
|
|
1008
|
+
// XXX can't delete prototype in pure-js.
|
|
1009
|
+
|
|
1010
|
+
// 22. Return F.
|
|
1011
|
+
return bound;
|
|
1012
|
+
}
|
|
1013
|
+
});
|
|
1014
|
+
})
|
|
1015
|
+
.call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
|
|
1016
|
+
|
|
662
1017
|
function Header ($module) {
|
|
663
1018
|
this.$module = $module;
|
|
1019
|
+
this.$menuButton = $module && $module.querySelector('.govuk-js-header-toggle');
|
|
1020
|
+
this.$menu = this.$menuButton && $module.querySelector(
|
|
1021
|
+
'#' + this.$menuButton.getAttribute('aria-controls')
|
|
1022
|
+
);
|
|
664
1023
|
}
|
|
665
1024
|
|
|
1025
|
+
/**
|
|
1026
|
+
* Initialise header
|
|
1027
|
+
*
|
|
1028
|
+
* Check for the presence of the header, menu and menu button – if any are
|
|
1029
|
+
* missing then there's nothing to do so return early.
|
|
1030
|
+
*/
|
|
666
1031
|
Header.prototype.init = function () {
|
|
667
|
-
|
|
668
|
-
var $module = this.$module;
|
|
669
|
-
if (!$module) {
|
|
670
|
-
return
|
|
671
|
-
}
|
|
672
|
-
|
|
673
|
-
// Check for button
|
|
674
|
-
var $toggleButton = $module.querySelector('.govuk-js-header-toggle');
|
|
675
|
-
if (!$toggleButton) {
|
|
1032
|
+
if (!this.$module || !this.$menuButton || !this.$menu) {
|
|
676
1033
|
return
|
|
677
1034
|
}
|
|
678
1035
|
|
|
679
|
-
|
|
680
|
-
|
|
1036
|
+
this.syncState(this.$menu.classList.contains('govuk-header__navigation--open'));
|
|
1037
|
+
this.$menuButton.addEventListener('click', this.handleMenuButtonClick.bind(this));
|
|
681
1038
|
};
|
|
682
1039
|
|
|
683
1040
|
/**
|
|
684
|
-
*
|
|
685
|
-
*
|
|
686
|
-
*
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
1041
|
+
* Sync menu state
|
|
1042
|
+
*
|
|
1043
|
+
* Sync the menu button class and the accessible state of the menu and the menu
|
|
1044
|
+
* button with the visible state of the menu
|
|
1045
|
+
*
|
|
1046
|
+
* @param {boolean} isVisible Whether the menu is currently visible
|
|
1047
|
+
*/
|
|
1048
|
+
Header.prototype.syncState = function (isVisible) {
|
|
1049
|
+
this.$menuButton.classList.toggle('govuk-header__menu-button--open', isVisible);
|
|
1050
|
+
this.$menuButton.setAttribute('aria-expanded', isVisible);
|
|
694
1051
|
};
|
|
695
1052
|
|
|
696
1053
|
/**
|
|
697
|
-
*
|
|
698
|
-
*
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
var
|
|
704
|
-
|
|
705
|
-
// If a button with aria-controls, handle click
|
|
706
|
-
if ($toggleButton && $target) {
|
|
707
|
-
this.toggleClass($target, 'govuk-header__navigation--open');
|
|
708
|
-
this.toggleClass($toggleButton, 'govuk-header__menu-button--open');
|
|
709
|
-
|
|
710
|
-
$toggleButton.setAttribute('aria-expanded', $toggleButton.getAttribute('aria-expanded') !== 'true');
|
|
711
|
-
$target.setAttribute('aria-hidden', $target.getAttribute('aria-hidden') === 'false');
|
|
712
|
-
}
|
|
1054
|
+
* Handle menu button click
|
|
1055
|
+
*
|
|
1056
|
+
* When the menu button is clicked, change the visibility of the menu and then
|
|
1057
|
+
* sync the accessibility state and menu button state
|
|
1058
|
+
*/
|
|
1059
|
+
Header.prototype.handleMenuButtonClick = function () {
|
|
1060
|
+
var isVisible = this.$menu.classList.toggle('govuk-header__navigation--open');
|
|
1061
|
+
this.syncState(isVisible);
|
|
713
1062
|
};
|
|
714
1063
|
|
|
715
1064
|
return Header;
|