govuk_publishing_components 41.1.1 → 42.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-core.js +0 -1
- data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-ecommerce-tracker.js +0 -1
- data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-event-tracker.js +0 -1
- data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-link-tracker.js +0 -1
- data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-specialist-link-tracker.js +0 -1
- data/app/assets/javascripts/govuk_publishing_components/components/layout-super-navigation-header.js +0 -2
- data/app/assets/javascripts/govuk_publishing_components/components/step-by-step-nav.js +0 -4
- data/app/assets/javascripts/govuk_publishing_components/lib/govspeak/magna-charta.js +0 -1
- data/app/assets/javascripts/govuk_publishing_components/lib/toggle-input-class-on-focus.js +0 -1
- data/app/assets/javascripts/govuk_publishing_components/lib.js +0 -1
- data/app/assets/stylesheets/component_guide/application.scss +6 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_accordion.scss +1 -1
- data/app/assets/stylesheets/govuk_publishing_components/components/_contextual-guidance.scss +1 -1
- data/app/assets/stylesheets/govuk_publishing_components/components/_inverse-header.scss +12 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_layout-footer.scss +8 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_layout-for-public.scss +1 -1
- data/app/assets/stylesheets/govuk_publishing_components/components/_layout-header.scss +22 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_layout-super-navigation-header.scss +12 -6
- data/app/assets/stylesheets/govuk_publishing_components/components/_metadata.scss +2 -2
- data/app/assets/stylesheets/govuk_publishing_components/components/_option-select.scss +1 -1
- data/app/assets/stylesheets/govuk_publishing_components/components/_print-link.scss +1 -1
- data/app/assets/stylesheets/govuk_publishing_components/components/_related-navigation.scss +2 -2
- data/app/assets/stylesheets/govuk_publishing_components/components/_reorderable-list.scss +1 -1
- data/app/assets/stylesheets/govuk_publishing_components/components/_search.scss +6 -6
- data/app/assets/stylesheets/govuk_publishing_components/components/_single-page-notification-button.scss +1 -1
- data/app/assets/stylesheets/govuk_publishing_components/components/_step-by-step-nav-header.scss +14 -1
- data/app/assets/stylesheets/govuk_publishing_components/components/_step-by-step-nav-related.scss +24 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_step-by-step-nav.scss +5 -5
- data/app/assets/stylesheets/govuk_publishing_components/components/_subscription-links.scss +3 -3
- data/app/assets/stylesheets/govuk_publishing_components/components/_table.scss +32 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_tabs.scss +34 -2
- data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_attachment.scss +25 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_button.scss +17 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_highlight-answer.scss +11 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_media-player.scss +6 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/mixins/_grid-helper.scss +1 -1
- data/app/views/govuk_publishing_components/components/_attachment.html.erb +2 -0
- data/app/views/govuk_publishing_components/components/_layout_for_admin.html.erb +6 -1
- data/app/views/govuk_publishing_components/components/_layout_for_public.html.erb +2 -5
- data/app/views/govuk_publishing_components/components/_layout_header.html.erb +4 -4
- data/app/views/govuk_publishing_components/components/_layout_super_navigation_header.html.erb +1 -1
- data/app/views/govuk_publishing_components/components/_table.html.erb +1 -1
- data/app/views/govuk_publishing_components/components/attachment/_thumbnail_external.html.erb +3 -0
- data/app/views/govuk_publishing_components/components/docs/layout_for_admin.yml +9 -0
- data/app/views/govuk_publishing_components/components/layout_header/_navigation_items.html.erb +1 -1
- data/app/views/govuk_publishing_components/components/layout_header/_search.html.erb +1 -1
- data/config/initializers/assets.rb +1 -8
- data/lib/govuk_publishing_components/presenters/attachment_helper.rb +4 -0
- data/lib/govuk_publishing_components/version.rb +1 -1
- metadata +4 -30
- data/app/assets/config/govuk_publishing_components_sassc-rails_manifest.js +0 -90
- data/app/assets/javascripts/govuk_publishing_components/ie.js +0 -2
- data/app/assets/javascripts/govuk_publishing_components/vendor/html5shiv-printshiv.js +0 -4
- data/app/assets/javascripts/govuk_publishing_components/vendor/json2.js +0 -487
- data/app/assets/javascripts/govuk_publishing_components/vendor/polyfills/all.js +0 -1
- data/app/assets/javascripts/govuk_publishing_components/vendor/polyfills/closest.js +0 -23
- data/app/assets/javascripts/govuk_publishing_components/vendor/polyfills/common.js +0 -8
- data/app/assets/javascripts/govuk_publishing_components/vendor/polyfills/indexOf.js +0 -9
- data/app/assets/javascripts/govuk_publishing_components/vendor/polyfills-govuk-frontend-v4/DOMTokenList.js +0 -273
- data/app/assets/javascripts/govuk_publishing_components/vendor/polyfills-govuk-frontend-v4/Date/now.js +0 -21
- data/app/assets/javascripts/govuk_publishing_components/vendor/polyfills-govuk-frontend-v4/Document.js +0 -34
- data/app/assets/javascripts/govuk_publishing_components/vendor/polyfills-govuk-frontend-v4/Element/prototype/classList.js +0 -592
- data/app/assets/javascripts/govuk_publishing_components/vendor/polyfills-govuk-frontend-v4/Element/prototype/closest.js +0 -57
- data/app/assets/javascripts/govuk_publishing_components/vendor/polyfills-govuk-frontend-v4/Element/prototype/dataset.js +0 -303
- data/app/assets/javascripts/govuk_publishing_components/vendor/polyfills-govuk-frontend-v4/Element/prototype/matches.js +0 -32
- data/app/assets/javascripts/govuk_publishing_components/vendor/polyfills-govuk-frontend-v4/Element/prototype/nextElementSibling.js +0 -257
- data/app/assets/javascripts/govuk_publishing_components/vendor/polyfills-govuk-frontend-v4/Element/prototype/previousElementSibling.js +0 -257
- data/app/assets/javascripts/govuk_publishing_components/vendor/polyfills-govuk-frontend-v4/Element.js +0 -148
- data/app/assets/javascripts/govuk_publishing_components/vendor/polyfills-govuk-frontend-v4/Event.js +0 -506
- data/app/assets/javascripts/govuk_publishing_components/vendor/polyfills-govuk-frontend-v4/Function/prototype/bind.js +0 -253
- data/app/assets/javascripts/govuk_publishing_components/vendor/polyfills-govuk-frontend-v4/Object/defineProperty.js +0 -94
- data/app/assets/javascripts/govuk_publishing_components/vendor/polyfills-govuk-frontend-v4/String/prototype/trim.js +0 -22
- data/app/assets/javascripts/govuk_publishing_components/vendor/polyfills-govuk-frontend-v4/Window.js +0 -28
data/app/assets/javascripts/govuk_publishing_components/vendor/polyfills-govuk-frontend-v4/Event.js
DELETED
@@ -1,506 +0,0 @@
|
|
1
|
-
(function (global, factory) {
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory() :
|
3
|
-
typeof define === 'function' && define.amd ? define('GOVUKFrontend', factory) :
|
4
|
-
(factory());
|
5
|
-
}(this, (function () { 'use strict';
|
6
|
-
|
7
|
-
// @ts-nocheck
|
8
|
-
(function (undefined) {
|
9
|
-
|
10
|
-
// Detection from https://github.com/Financial-Times/polyfill-service/blob/master/packages/polyfill-library/polyfills/Window/detect.js
|
11
|
-
var detect = ('Window' in this);
|
12
|
-
|
13
|
-
if (detect) return
|
14
|
-
|
15
|
-
if ((typeof WorkerGlobalScope === "undefined") && (typeof importScripts !== "function")) {
|
16
|
-
(function (global) {
|
17
|
-
if (global.constructor) {
|
18
|
-
global.Window = global.constructor;
|
19
|
-
} else {
|
20
|
-
(global.Window = global.constructor = new Function('return function Window() {}')()).prototype = this;
|
21
|
-
}
|
22
|
-
}(this));
|
23
|
-
}
|
24
|
-
|
25
|
-
})
|
26
|
-
.call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
|
27
|
-
|
28
|
-
// @ts-nocheck
|
29
|
-
(function (undefined) {
|
30
|
-
|
31
|
-
// Detection from https://github.com/Financial-Times/polyfill-service/blob/master/packages/polyfill-library/polyfills/Document/detect.js
|
32
|
-
var detect = ("Document" in this);
|
33
|
-
|
34
|
-
if (detect) return
|
35
|
-
|
36
|
-
if ((typeof WorkerGlobalScope === "undefined") && (typeof importScripts !== "function")) {
|
37
|
-
|
38
|
-
if (this.HTMLDocument) { // IE8
|
39
|
-
|
40
|
-
// HTMLDocument is an extension of Document. If the browser has HTMLDocument but not Document, the former will suffice as an alias for the latter.
|
41
|
-
this.Document = this.HTMLDocument;
|
42
|
-
|
43
|
-
} else {
|
44
|
-
|
45
|
-
// 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.
|
46
|
-
this.Document = this.HTMLDocument = document.constructor = (new Function('return function Document() {}')());
|
47
|
-
this.Document.prototype = document;
|
48
|
-
}
|
49
|
-
}
|
50
|
-
|
51
|
-
|
52
|
-
})
|
53
|
-
.call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
|
54
|
-
|
55
|
-
// @ts-nocheck
|
56
|
-
|
57
|
-
(function(undefined) {
|
58
|
-
|
59
|
-
// Detection from https://github.com/Financial-Times/polyfill-service/blob/master/packages/polyfill-library/polyfills/Element/detect.js
|
60
|
-
var detect = ('Element' in this && 'HTMLElement' in this);
|
61
|
-
|
62
|
-
if (detect) return
|
63
|
-
|
64
|
-
(function () {
|
65
|
-
|
66
|
-
// IE8
|
67
|
-
if (window.Element && !window.HTMLElement) {
|
68
|
-
window.HTMLElement = window.Element;
|
69
|
-
return;
|
70
|
-
}
|
71
|
-
|
72
|
-
// create Element constructor
|
73
|
-
window.Element = window.HTMLElement = new Function('return function Element() {}')();
|
74
|
-
|
75
|
-
// generate sandboxed iframe
|
76
|
-
var vbody = document.appendChild(document.createElement('body'));
|
77
|
-
var frame = vbody.appendChild(document.createElement('iframe'));
|
78
|
-
|
79
|
-
// use sandboxed iframe to replicate Element functionality
|
80
|
-
var frameDocument = frame.contentWindow.document;
|
81
|
-
var prototype = Element.prototype = frameDocument.appendChild(frameDocument.createElement('*'));
|
82
|
-
var cache = {};
|
83
|
-
|
84
|
-
// polyfill Element.prototype on an element
|
85
|
-
var shiv = function (element, deep) {
|
86
|
-
var
|
87
|
-
childNodes = element.childNodes || [],
|
88
|
-
index = -1,
|
89
|
-
key, value, childNode;
|
90
|
-
|
91
|
-
if (element.nodeType === 1 && element.constructor !== Element) {
|
92
|
-
element.constructor = Element;
|
93
|
-
|
94
|
-
for (key in cache) {
|
95
|
-
value = cache[key];
|
96
|
-
element[key] = value;
|
97
|
-
}
|
98
|
-
}
|
99
|
-
|
100
|
-
while (childNode = deep && childNodes[++index]) {
|
101
|
-
shiv(childNode, deep);
|
102
|
-
}
|
103
|
-
|
104
|
-
return element;
|
105
|
-
};
|
106
|
-
|
107
|
-
var elements = document.getElementsByTagName('*');
|
108
|
-
var nativeCreateElement = document.createElement;
|
109
|
-
var interval;
|
110
|
-
var loopLimit = 100;
|
111
|
-
|
112
|
-
prototype.attachEvent('onpropertychange', function (event) {
|
113
|
-
var
|
114
|
-
propertyName = event.propertyName,
|
115
|
-
nonValue = !cache.hasOwnProperty(propertyName),
|
116
|
-
newValue = prototype[propertyName],
|
117
|
-
oldValue = cache[propertyName],
|
118
|
-
index = -1,
|
119
|
-
element;
|
120
|
-
|
121
|
-
while (element = elements[++index]) {
|
122
|
-
if (element.nodeType === 1) {
|
123
|
-
if (nonValue || element[propertyName] === oldValue) {
|
124
|
-
element[propertyName] = newValue;
|
125
|
-
}
|
126
|
-
}
|
127
|
-
}
|
128
|
-
|
129
|
-
cache[propertyName] = newValue;
|
130
|
-
});
|
131
|
-
|
132
|
-
prototype.constructor = Element;
|
133
|
-
|
134
|
-
if (!prototype.hasAttribute) {
|
135
|
-
// <Element>.hasAttribute
|
136
|
-
prototype.hasAttribute = function hasAttribute(name) {
|
137
|
-
return this.getAttribute(name) !== null;
|
138
|
-
};
|
139
|
-
}
|
140
|
-
|
141
|
-
// Apply Element prototype to the pre-existing DOM as soon as the body element appears.
|
142
|
-
function bodyCheck() {
|
143
|
-
if (!(loopLimit--)) clearTimeout(interval);
|
144
|
-
if (document.body && !document.body.prototype && /(complete|interactive)/.test(document.readyState)) {
|
145
|
-
shiv(document, true);
|
146
|
-
if (interval && document.body.prototype) clearTimeout(interval);
|
147
|
-
return (!!document.body.prototype);
|
148
|
-
}
|
149
|
-
return false;
|
150
|
-
}
|
151
|
-
if (!bodyCheck()) {
|
152
|
-
document.onreadystatechange = bodyCheck;
|
153
|
-
interval = setInterval(bodyCheck, 25);
|
154
|
-
}
|
155
|
-
|
156
|
-
// Apply to any new elements created after load
|
157
|
-
document.createElement = function createElement(nodeName) {
|
158
|
-
var element = nativeCreateElement(String(nodeName).toLowerCase());
|
159
|
-
return shiv(element);
|
160
|
-
};
|
161
|
-
|
162
|
-
// remove sandboxed iframe
|
163
|
-
document.removeChild(vbody);
|
164
|
-
}());
|
165
|
-
|
166
|
-
})
|
167
|
-
.call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
|
168
|
-
|
169
|
-
// @ts-nocheck
|
170
|
-
(function (undefined) {
|
171
|
-
|
172
|
-
// Detection from https://github.com/Financial-Times/polyfill-service/blob/master/packages/polyfill-library/polyfills/Object/defineProperty/detect.js
|
173
|
-
var detect = (
|
174
|
-
// In IE8, defineProperty could only act on DOM elements, so full support
|
175
|
-
// for the feature requires the ability to set a property on an arbitrary object
|
176
|
-
'defineProperty' in Object && (function() {
|
177
|
-
try {
|
178
|
-
var a = {};
|
179
|
-
Object.defineProperty(a, 'test', {value:42});
|
180
|
-
return true;
|
181
|
-
} catch(e) {
|
182
|
-
return false
|
183
|
-
}
|
184
|
-
}())
|
185
|
-
);
|
186
|
-
|
187
|
-
if (detect) return
|
188
|
-
|
189
|
-
(function (nativeDefineProperty) {
|
190
|
-
|
191
|
-
var supportsAccessors = Object.prototype.hasOwnProperty('__defineGetter__');
|
192
|
-
var ERR_ACCESSORS_NOT_SUPPORTED = 'Getters & setters cannot be defined on this javascript engine';
|
193
|
-
var ERR_VALUE_ACCESSORS = 'A property cannot both have accessors and be writable or have a value';
|
194
|
-
|
195
|
-
Object.defineProperty = function defineProperty(object, property, descriptor) {
|
196
|
-
|
197
|
-
// Where native support exists, assume it
|
198
|
-
if (nativeDefineProperty && (object === window || object === document || object === Element.prototype || object instanceof Element)) {
|
199
|
-
return nativeDefineProperty(object, property, descriptor);
|
200
|
-
}
|
201
|
-
|
202
|
-
if (object === null || !(object instanceof Object || typeof object === 'object')) {
|
203
|
-
throw new TypeError('Object.defineProperty called on non-object');
|
204
|
-
}
|
205
|
-
|
206
|
-
if (!(descriptor instanceof Object)) {
|
207
|
-
throw new TypeError('Property description must be an object');
|
208
|
-
}
|
209
|
-
|
210
|
-
var propertyString = String(property);
|
211
|
-
var hasValueOrWritable = 'value' in descriptor || 'writable' in descriptor;
|
212
|
-
var getterType = 'get' in descriptor && typeof descriptor.get;
|
213
|
-
var setterType = 'set' in descriptor && typeof descriptor.set;
|
214
|
-
|
215
|
-
// handle descriptor.get
|
216
|
-
if (getterType) {
|
217
|
-
if (getterType !== 'function') {
|
218
|
-
throw new TypeError('Getter must be a function');
|
219
|
-
}
|
220
|
-
if (!supportsAccessors) {
|
221
|
-
throw new TypeError(ERR_ACCESSORS_NOT_SUPPORTED);
|
222
|
-
}
|
223
|
-
if (hasValueOrWritable) {
|
224
|
-
throw new TypeError(ERR_VALUE_ACCESSORS);
|
225
|
-
}
|
226
|
-
Object.__defineGetter__.call(object, propertyString, descriptor.get);
|
227
|
-
} else {
|
228
|
-
object[propertyString] = descriptor.value;
|
229
|
-
}
|
230
|
-
|
231
|
-
// handle descriptor.set
|
232
|
-
if (setterType) {
|
233
|
-
if (setterType !== 'function') {
|
234
|
-
throw new TypeError('Setter must be a function');
|
235
|
-
}
|
236
|
-
if (!supportsAccessors) {
|
237
|
-
throw new TypeError(ERR_ACCESSORS_NOT_SUPPORTED);
|
238
|
-
}
|
239
|
-
if (hasValueOrWritable) {
|
240
|
-
throw new TypeError(ERR_VALUE_ACCESSORS);
|
241
|
-
}
|
242
|
-
Object.__defineSetter__.call(object, propertyString, descriptor.set);
|
243
|
-
}
|
244
|
-
|
245
|
-
// OK to define value unconditionally - if a getter has been specified as well, an error would be thrown above
|
246
|
-
if ('value' in descriptor) {
|
247
|
-
object[propertyString] = descriptor.value;
|
248
|
-
}
|
249
|
-
|
250
|
-
return object;
|
251
|
-
};
|
252
|
-
}(Object.defineProperty));
|
253
|
-
})
|
254
|
-
.call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
|
255
|
-
|
256
|
-
// @ts-nocheck
|
257
|
-
|
258
|
-
(function(undefined) {
|
259
|
-
|
260
|
-
// Detection from https://github.com/Financial-Times/polyfill-service/blob/master/packages/polyfill-library/polyfills/Event/detect.js
|
261
|
-
var detect = (
|
262
|
-
(function(global) {
|
263
|
-
|
264
|
-
if (!('Event' in global)) return false;
|
265
|
-
if (typeof global.Event === 'function') return true;
|
266
|
-
|
267
|
-
try {
|
268
|
-
|
269
|
-
// In IE 9-11, the Event object exists but cannot be instantiated
|
270
|
-
new Event('click');
|
271
|
-
return true;
|
272
|
-
} catch(e) {
|
273
|
-
return false;
|
274
|
-
}
|
275
|
-
}(this))
|
276
|
-
);
|
277
|
-
|
278
|
-
if (detect) return
|
279
|
-
|
280
|
-
(function () {
|
281
|
-
var unlistenableWindowEvents = {
|
282
|
-
click: 1,
|
283
|
-
dblclick: 1,
|
284
|
-
keyup: 1,
|
285
|
-
keypress: 1,
|
286
|
-
keydown: 1,
|
287
|
-
mousedown: 1,
|
288
|
-
mouseup: 1,
|
289
|
-
mousemove: 1,
|
290
|
-
mouseover: 1,
|
291
|
-
mouseenter: 1,
|
292
|
-
mouseleave: 1,
|
293
|
-
mouseout: 1,
|
294
|
-
storage: 1,
|
295
|
-
storagecommit: 1,
|
296
|
-
textinput: 1
|
297
|
-
};
|
298
|
-
|
299
|
-
// This polyfill depends on availability of `document` so will not run in a worker
|
300
|
-
// However, we asssume there are no browsers with worker support that lack proper
|
301
|
-
// support for `Event` within the worker
|
302
|
-
if (typeof document === 'undefined' || typeof window === 'undefined') return;
|
303
|
-
|
304
|
-
function indexOf(array, element) {
|
305
|
-
var
|
306
|
-
index = -1,
|
307
|
-
length = array.length;
|
308
|
-
|
309
|
-
while (++index < length) {
|
310
|
-
if (index in array && array[index] === element) {
|
311
|
-
return index;
|
312
|
-
}
|
313
|
-
}
|
314
|
-
|
315
|
-
return -1;
|
316
|
-
}
|
317
|
-
|
318
|
-
var existingProto = (window.Event && window.Event.prototype) || null;
|
319
|
-
window.Event = Window.prototype.Event = function Event(type, eventInitDict) {
|
320
|
-
if (!type) {
|
321
|
-
throw new Error('Not enough arguments');
|
322
|
-
}
|
323
|
-
|
324
|
-
var event;
|
325
|
-
// Shortcut if browser supports createEvent
|
326
|
-
if ('createEvent' in document) {
|
327
|
-
event = document.createEvent('Event');
|
328
|
-
var bubbles = eventInitDict && eventInitDict.bubbles !== undefined ? eventInitDict.bubbles : false;
|
329
|
-
var cancelable = eventInitDict && eventInitDict.cancelable !== undefined ? eventInitDict.cancelable : false;
|
330
|
-
|
331
|
-
event.initEvent(type, bubbles, cancelable);
|
332
|
-
|
333
|
-
return event;
|
334
|
-
}
|
335
|
-
|
336
|
-
event = document.createEventObject();
|
337
|
-
|
338
|
-
event.type = type;
|
339
|
-
event.bubbles = eventInitDict && eventInitDict.bubbles !== undefined ? eventInitDict.bubbles : false;
|
340
|
-
event.cancelable = eventInitDict && eventInitDict.cancelable !== undefined ? eventInitDict.cancelable : false;
|
341
|
-
|
342
|
-
return event;
|
343
|
-
};
|
344
|
-
if (existingProto) {
|
345
|
-
Object.defineProperty(window.Event, 'prototype', {
|
346
|
-
configurable: false,
|
347
|
-
enumerable: false,
|
348
|
-
writable: true,
|
349
|
-
value: existingProto
|
350
|
-
});
|
351
|
-
}
|
352
|
-
|
353
|
-
if (!('createEvent' in document)) {
|
354
|
-
window.addEventListener = Window.prototype.addEventListener = Document.prototype.addEventListener = Element.prototype.addEventListener = function addEventListener() {
|
355
|
-
var
|
356
|
-
element = this,
|
357
|
-
type = arguments[0],
|
358
|
-
listener = arguments[1];
|
359
|
-
|
360
|
-
if (element === window && type in unlistenableWindowEvents) {
|
361
|
-
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.');
|
362
|
-
}
|
363
|
-
|
364
|
-
if (!element._events) {
|
365
|
-
element._events = {};
|
366
|
-
}
|
367
|
-
|
368
|
-
if (!element._events[type]) {
|
369
|
-
element._events[type] = function (event) {
|
370
|
-
var
|
371
|
-
list = element._events[event.type].list,
|
372
|
-
events = list.slice(),
|
373
|
-
index = -1,
|
374
|
-
length = events.length,
|
375
|
-
eventElement;
|
376
|
-
|
377
|
-
event.preventDefault = function preventDefault() {
|
378
|
-
if (event.cancelable !== false) {
|
379
|
-
event.returnValue = false;
|
380
|
-
}
|
381
|
-
};
|
382
|
-
|
383
|
-
event.stopPropagation = function stopPropagation() {
|
384
|
-
event.cancelBubble = true;
|
385
|
-
};
|
386
|
-
|
387
|
-
event.stopImmediatePropagation = function stopImmediatePropagation() {
|
388
|
-
event.cancelBubble = true;
|
389
|
-
event.cancelImmediate = true;
|
390
|
-
};
|
391
|
-
|
392
|
-
event.currentTarget = element;
|
393
|
-
event.relatedTarget = event.fromElement || null;
|
394
|
-
event.target = event.target || event.srcElement || element;
|
395
|
-
event.timeStamp = new Date().getTime();
|
396
|
-
|
397
|
-
if (event.clientX) {
|
398
|
-
event.pageX = event.clientX + document.documentElement.scrollLeft;
|
399
|
-
event.pageY = event.clientY + document.documentElement.scrollTop;
|
400
|
-
}
|
401
|
-
|
402
|
-
while (++index < length && !event.cancelImmediate) {
|
403
|
-
if (index in events) {
|
404
|
-
eventElement = events[index];
|
405
|
-
|
406
|
-
if (indexOf(list, eventElement) !== -1 && typeof eventElement === 'function') {
|
407
|
-
eventElement.call(element, event);
|
408
|
-
}
|
409
|
-
}
|
410
|
-
}
|
411
|
-
};
|
412
|
-
|
413
|
-
element._events[type].list = [];
|
414
|
-
|
415
|
-
if (element.attachEvent) {
|
416
|
-
element.attachEvent('on' + type, element._events[type]);
|
417
|
-
}
|
418
|
-
}
|
419
|
-
|
420
|
-
element._events[type].list.push(listener);
|
421
|
-
};
|
422
|
-
|
423
|
-
window.removeEventListener = Window.prototype.removeEventListener = Document.prototype.removeEventListener = Element.prototype.removeEventListener = function removeEventListener() {
|
424
|
-
var
|
425
|
-
element = this,
|
426
|
-
type = arguments[0],
|
427
|
-
listener = arguments[1],
|
428
|
-
index;
|
429
|
-
|
430
|
-
if (element._events && element._events[type] && element._events[type].list) {
|
431
|
-
index = indexOf(element._events[type].list, listener);
|
432
|
-
|
433
|
-
if (index !== -1) {
|
434
|
-
element._events[type].list.splice(index, 1);
|
435
|
-
|
436
|
-
if (!element._events[type].list.length) {
|
437
|
-
if (element.detachEvent) {
|
438
|
-
element.detachEvent('on' + type, element._events[type]);
|
439
|
-
}
|
440
|
-
delete element._events[type];
|
441
|
-
}
|
442
|
-
}
|
443
|
-
}
|
444
|
-
};
|
445
|
-
|
446
|
-
window.dispatchEvent = Window.prototype.dispatchEvent = Document.prototype.dispatchEvent = Element.prototype.dispatchEvent = function dispatchEvent(event) {
|
447
|
-
if (!arguments.length) {
|
448
|
-
throw new Error('Not enough arguments');
|
449
|
-
}
|
450
|
-
|
451
|
-
if (!event || typeof event.type !== 'string') {
|
452
|
-
throw new Error('DOM Events Exception 0');
|
453
|
-
}
|
454
|
-
|
455
|
-
var element = this, type = event.type;
|
456
|
-
|
457
|
-
try {
|
458
|
-
if (!event.bubbles) {
|
459
|
-
event.cancelBubble = true;
|
460
|
-
|
461
|
-
var cancelBubbleEvent = function (event) {
|
462
|
-
event.cancelBubble = true;
|
463
|
-
|
464
|
-
(element || window).detachEvent('on' + type, cancelBubbleEvent);
|
465
|
-
};
|
466
|
-
|
467
|
-
this.attachEvent('on' + type, cancelBubbleEvent);
|
468
|
-
}
|
469
|
-
|
470
|
-
this.fireEvent('on' + type, event);
|
471
|
-
} catch (error) {
|
472
|
-
event.target = element;
|
473
|
-
|
474
|
-
do {
|
475
|
-
event.currentTarget = element;
|
476
|
-
|
477
|
-
if ('_events' in element && typeof element._events[type] === 'function') {
|
478
|
-
element._events[type].call(element, event);
|
479
|
-
}
|
480
|
-
|
481
|
-
if (typeof element['on' + type] === 'function') {
|
482
|
-
element['on' + type].call(element, event);
|
483
|
-
}
|
484
|
-
|
485
|
-
element = element.nodeType === 9 ? element.parentWindow : element.parentNode;
|
486
|
-
} while (element && !event.cancelBubble);
|
487
|
-
}
|
488
|
-
|
489
|
-
return true;
|
490
|
-
};
|
491
|
-
|
492
|
-
// Add the DOMContentLoaded Event
|
493
|
-
document.attachEvent('onreadystatechange', function() {
|
494
|
-
if (document.readyState === 'complete') {
|
495
|
-
document.dispatchEvent(new Event('DOMContentLoaded', {
|
496
|
-
bubbles: true
|
497
|
-
}));
|
498
|
-
}
|
499
|
-
});
|
500
|
-
}
|
501
|
-
}());
|
502
|
-
|
503
|
-
})
|
504
|
-
.call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
|
505
|
-
|
506
|
-
})));
|