govuk_publishing_components 9.3.6 → 9.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (261) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +13 -0
  3. data/app/assets/stylesheets/component_guide/application.scss +10 -0
  4. data/app/assets/stylesheets/govuk_publishing_components/_all_components.scss +1 -0
  5. data/app/assets/stylesheets/govuk_publishing_components/admin_styles.scss +13 -0
  6. data/app/assets/stylesheets/govuk_publishing_components/components/_highlight-boxes.scss +66 -0
  7. data/app/assets/stylesheets/govuk_publishing_components/components/_layout-footer.scss +1 -0
  8. data/app/assets/stylesheets/govuk_publishing_components/components/_layout-for-admin.scss +1 -0
  9. data/app/models/govuk_publishing_components/component_doc.rb +12 -0
  10. data/app/views/govuk_publishing_components/component_guide/component_doc/_preview.html.erb +7 -5
  11. data/app/views/govuk_publishing_components/component_guide/show.html.erb +22 -0
  12. data/app/views/govuk_publishing_components/components/_highlight_boxes.html.erb +39 -0
  13. data/app/views/govuk_publishing_components/components/_layout_footer.html.erb +26 -0
  14. data/app/views/govuk_publishing_components/components/_layout_for_admin.html.erb +10 -0
  15. data/app/views/govuk_publishing_components/components/docs/highlight_boxes.yml +142 -0
  16. data/app/views/govuk_publishing_components/components/docs/layout_footer.yml +12 -0
  17. data/app/views/govuk_publishing_components/components/docs/layout_for_admin.yml +28 -0
  18. data/app/views/govuk_publishing_components/components/docs/metadata.yml +1 -0
  19. data/app/views/layouts/govuk_publishing_components/application.html.erb +5 -0
  20. data/config/initializers/assets.rb +12 -0
  21. data/lib/govuk_publishing_components.rb +1 -0
  22. data/lib/govuk_publishing_components/presenters/highlight_boxes_helper.rb +13 -0
  23. data/lib/govuk_publishing_components/presenters/meta_tags.rb +1 -0
  24. data/lib/govuk_publishing_components/version.rb +1 -1
  25. data/node_modules/govuk-frontend/README.md +96 -0
  26. data/node_modules/govuk-frontend/all-ie8.scss +6 -0
  27. data/node_modules/govuk-frontend/all.js +1720 -0
  28. data/node_modules/govuk-frontend/all.scss +11 -0
  29. data/node_modules/govuk-frontend/assets/fonts/bold-a2452cb66f-v1.woff2 +0 -0
  30. data/node_modules/govuk-frontend/assets/fonts/bold-f38c792ac2-v1.woff +0 -0
  31. data/node_modules/govuk-frontend/assets/fonts/bold-fb2676462a-v1.eot +0 -0
  32. data/node_modules/govuk-frontend/assets/fonts/bold-tabular-357fdfbcc3-v1.eot +0 -0
  33. data/node_modules/govuk-frontend/assets/fonts/bold-tabular-784c21afb8-v1.woff +0 -0
  34. data/node_modules/govuk-frontend/assets/fonts/bold-tabular-b89238d840-v1.woff2 +0 -0
  35. data/node_modules/govuk-frontend/assets/fonts/light-2c037cf7e1-v1.eot +0 -0
  36. data/node_modules/govuk-frontend/assets/fonts/light-458f8ea81c-v1.woff +0 -0
  37. data/node_modules/govuk-frontend/assets/fonts/light-f38ad40456-v1.woff2 +0 -0
  38. data/node_modules/govuk-frontend/assets/fonts/light-tabular-498ea8ffe2-v1.eot +0 -0
  39. data/node_modules/govuk-frontend/assets/fonts/light-tabular-62cc6f0a28-v1.woff +0 -0
  40. data/node_modules/govuk-frontend/assets/fonts/light-tabular-851b10ccdd-v1.woff2 +0 -0
  41. data/node_modules/govuk-frontend/assets/images/favicon.ico +0 -0
  42. data/node_modules/govuk-frontend/assets/images/govuk-apple-touch-icon-152x152.png +0 -0
  43. data/node_modules/govuk-frontend/assets/images/govuk-apple-touch-icon-167x167.png +0 -0
  44. data/node_modules/govuk-frontend/assets/images/govuk-apple-touch-icon-180x180.png +0 -0
  45. data/node_modules/govuk-frontend/assets/images/govuk-apple-touch-icon.png +0 -0
  46. data/node_modules/govuk-frontend/assets/images/govuk-crest-2x.png +0 -0
  47. data/node_modules/govuk-frontend/assets/images/govuk-crest.png +0 -0
  48. data/node_modules/govuk-frontend/assets/images/govuk-logotype-crown.png +0 -0
  49. data/node_modules/govuk-frontend/assets/images/govuk-mask-icon.svg +7 -0
  50. data/node_modules/govuk-frontend/assets/images/govuk-opengraph-image.png +0 -0
  51. data/node_modules/govuk-frontend/assets/images/icon-arrow-left.png +0 -0
  52. data/node_modules/govuk-frontend/assets/images/icon-important.png +0 -0
  53. data/node_modules/govuk-frontend/assets/images/icon-pointer-2x.png +0 -0
  54. data/node_modules/govuk-frontend/assets/images/icon-pointer.png +0 -0
  55. data/node_modules/govuk-frontend/common.js +39 -0
  56. data/node_modules/govuk-frontend/components/_all.scss +26 -0
  57. data/node_modules/govuk-frontend/components/back-link/README.md +142 -0
  58. data/node_modules/govuk-frontend/components/back-link/_back-link.scss +54 -0
  59. data/node_modules/govuk-frontend/components/back-link/back-link.njk +3 -0
  60. data/node_modules/govuk-frontend/components/back-link/macro.njk +3 -0
  61. data/node_modules/govuk-frontend/components/back-link/template.njk +2 -0
  62. data/node_modules/govuk-frontend/components/breadcrumbs/README.md +335 -0
  63. data/node_modules/govuk-frontend/components/breadcrumbs/_breadcrumbs.scss +119 -0
  64. data/node_modules/govuk-frontend/components/breadcrumbs/breadcrumbs.njk +14 -0
  65. data/node_modules/govuk-frontend/components/breadcrumbs/macro.njk +3 -0
  66. data/node_modules/govuk-frontend/components/breadcrumbs/template.njk +13 -0
  67. data/node_modules/govuk-frontend/components/button/README.md +319 -0
  68. data/node_modules/govuk-frontend/components/button/_button.scss +185 -0
  69. data/node_modules/govuk-frontend/components/button/button.js +548 -0
  70. data/node_modules/govuk-frontend/components/button/button.njk +3 -0
  71. data/node_modules/govuk-frontend/components/button/macro.njk +3 -0
  72. data/node_modules/govuk-frontend/components/button/template.njk +35 -0
  73. data/node_modules/govuk-frontend/components/checkboxes/README.md +782 -0
  74. data/node_modules/govuk-frontend/components/checkboxes/_checkboxes.scss +151 -0
  75. data/node_modules/govuk-frontend/components/checkboxes/checkboxes.js +730 -0
  76. data/node_modules/govuk-frontend/components/checkboxes/checkboxes.njk +27 -0
  77. data/node_modules/govuk-frontend/components/checkboxes/macro.njk +3 -0
  78. data/node_modules/govuk-frontend/components/checkboxes/template.njk +86 -0
  79. data/node_modules/govuk-frontend/components/date-input/README.md +640 -0
  80. data/node_modules/govuk-frontend/components/date-input/_date-input.scss +35 -0
  81. data/node_modules/govuk-frontend/components/date-input/date-input.njk +23 -0
  82. data/node_modules/govuk-frontend/components/date-input/macro.njk +3 -0
  83. data/node_modules/govuk-frontend/components/date-input/template.njk +76 -0
  84. data/node_modules/govuk-frontend/components/details/README.md +237 -0
  85. data/node_modules/govuk-frontend/components/details/_details.scss +86 -0
  86. data/node_modules/govuk-frontend/components/details/details.js +836 -0
  87. data/node_modules/govuk-frontend/components/details/details.njk +7 -0
  88. data/node_modules/govuk-frontend/components/details/implementation.md +43 -0
  89. data/node_modules/govuk-frontend/components/details/macro.njk +3 -0
  90. data/node_modules/govuk-frontend/components/details/template.njk +10 -0
  91. data/node_modules/govuk-frontend/components/error-message/README.md +143 -0
  92. data/node_modules/govuk-frontend/components/error-message/_error-message.scss +15 -0
  93. data/node_modules/govuk-frontend/components/error-message/error-message.njk +7 -0
  94. data/node_modules/govuk-frontend/components/error-message/macro.njk +3 -0
  95. data/node_modules/govuk-frontend/components/error-message/template.njk +3 -0
  96. data/node_modules/govuk-frontend/components/error-summary/README.md +215 -0
  97. data/node_modules/govuk-frontend/components/error-summary/_error-summary.scss +68 -0
  98. data/node_modules/govuk-frontend/components/error-summary/error-summary.js +520 -0
  99. data/node_modules/govuk-frontend/components/error-summary/error-summary.njk +17 -0
  100. data/node_modules/govuk-frontend/components/error-summary/macro.njk +3 -0
  101. data/node_modules/govuk-frontend/components/error-summary/template.njk +25 -0
  102. data/node_modules/govuk-frontend/components/fieldset/README.md +213 -0
  103. data/node_modules/govuk-frontend/components/fieldset/_fieldset.scss +58 -0
  104. data/node_modules/govuk-frontend/components/fieldset/fieldset.njk +13 -0
  105. data/node_modules/govuk-frontend/components/fieldset/macro.njk +3 -0
  106. data/node_modules/govuk-frontend/components/fieldset/template.njk +17 -0
  107. data/node_modules/govuk-frontend/components/file-upload/README.md +332 -0
  108. data/node_modules/govuk-frontend/components/file-upload/_file-upload.scss +19 -0
  109. data/node_modules/govuk-frontend/components/file-upload/file-upload.njk +9 -0
  110. data/node_modules/govuk-frontend/components/file-upload/macro.njk +3 -0
  111. data/node_modules/govuk-frontend/components/file-upload/template.njk +42 -0
  112. data/node_modules/govuk-frontend/components/footer/README.md +284 -0
  113. data/node_modules/govuk-frontend/components/footer/_footer.scss +216 -0
  114. data/node_modules/govuk-frontend/components/footer/footer.njk +3 -0
  115. data/node_modules/govuk-frontend/components/footer/macro.njk +3 -0
  116. data/node_modules/govuk-frontend/components/footer/template.njk +80 -0
  117. data/node_modules/govuk-frontend/components/header/README.md +524 -0
  118. data/node_modules/govuk-frontend/components/header/_header.scss +285 -0
  119. data/node_modules/govuk-frontend/components/header/header.js +717 -0
  120. data/node_modules/govuk-frontend/components/header/header.njk +3 -0
  121. data/node_modules/govuk-frontend/components/header/macro.njk +3 -0
  122. data/node_modules/govuk-frontend/components/header/template.njk +82 -0
  123. data/node_modules/govuk-frontend/components/hint/README.md +157 -0
  124. data/node_modules/govuk-frontend/components/hint/_hint.scss +29 -0
  125. data/node_modules/govuk-frontend/components/hint/hint.njk +7 -0
  126. data/node_modules/govuk-frontend/components/hint/macro.njk +3 -0
  127. data/node_modules/govuk-frontend/components/hint/template.njk +4 -0
  128. data/node_modules/govuk-frontend/components/input/README.md +416 -0
  129. data/node_modules/govuk-frontend/components/input/_input.scss +62 -0
  130. data/node_modules/govuk-frontend/components/input/input.njk +9 -0
  131. data/node_modules/govuk-frontend/components/input/macro.njk +3 -0
  132. data/node_modules/govuk-frontend/components/input/template.njk +42 -0
  133. data/node_modules/govuk-frontend/components/inset-text/README.md +157 -0
  134. data/node_modules/govuk-frontend/components/inset-text/_inset-text.scss +28 -0
  135. data/node_modules/govuk-frontend/components/inset-text/inset-text.njk +7 -0
  136. data/node_modules/govuk-frontend/components/inset-text/macro.njk +3 -0
  137. data/node_modules/govuk-frontend/components/inset-text/template.njk +4 -0
  138. data/node_modules/govuk-frontend/components/label/README.md +193 -0
  139. data/node_modules/govuk-frontend/components/label/_label.scss +45 -0
  140. data/node_modules/govuk-frontend/components/label/label.njk +6 -0
  141. data/node_modules/govuk-frontend/components/label/macro.njk +3 -0
  142. data/node_modules/govuk-frontend/components/label/template.njk +15 -0
  143. data/node_modules/govuk-frontend/components/panel/README.md +151 -0
  144. data/node_modules/govuk-frontend/components/panel/_panel.scss +42 -0
  145. data/node_modules/govuk-frontend/components/panel/macro.njk +3 -0
  146. data/node_modules/govuk-frontend/components/panel/panel.njk +7 -0
  147. data/node_modules/govuk-frontend/components/panel/template.njk +12 -0
  148. data/node_modules/govuk-frontend/components/phase-banner/README.md +152 -0
  149. data/node_modules/govuk-frontend/components/phase-banner/_phase-banner.scss +31 -0
  150. data/node_modules/govuk-frontend/components/phase-banner/macro.njk +3 -0
  151. data/node_modules/govuk-frontend/components/phase-banner/phase-banner.njk +7 -0
  152. data/node_modules/govuk-frontend/components/phase-banner/template.njk +17 -0
  153. data/node_modules/govuk-frontend/components/radios/README.md +686 -0
  154. data/node_modules/govuk-frontend/components/radios/_radios.scss +157 -0
  155. data/node_modules/govuk-frontend/components/radios/macro.njk +3 -0
  156. data/node_modules/govuk-frontend/components/radios/radios.js +730 -0
  157. data/node_modules/govuk-frontend/components/radios/radios.njk +27 -0
  158. data/node_modules/govuk-frontend/components/radios/template.njk +85 -0
  159. data/node_modules/govuk-frontend/components/select/README.md +387 -0
  160. data/node_modules/govuk-frontend/components/select/_select.scss +35 -0
  161. data/node_modules/govuk-frontend/components/select/macro.njk +3 -0
  162. data/node_modules/govuk-frontend/components/select/select.njk +24 -0
  163. data/node_modules/govuk-frontend/components/select/template.njk +44 -0
  164. data/node_modules/govuk-frontend/components/skip-link/README.md +142 -0
  165. data/node_modules/govuk-frontend/components/skip-link/_skip-link.scss +15 -0
  166. data/node_modules/govuk-frontend/components/skip-link/macro.njk +3 -0
  167. data/node_modules/govuk-frontend/components/skip-link/skip-link.njk +3 -0
  168. data/node_modules/govuk-frontend/components/skip-link/template.njk +3 -0
  169. data/node_modules/govuk-frontend/components/table/README.md +585 -0
  170. data/node_modules/govuk-frontend/components/table/_table.scss +50 -0
  171. data/node_modules/govuk-frontend/components/table/macro.njk +3 -0
  172. data/node_modules/govuk-frontend/components/table/table.njk +45 -0
  173. data/node_modules/govuk-frontend/components/table/template.njk +39 -0
  174. data/node_modules/govuk-frontend/components/tabs/README.md +375 -0
  175. data/node_modules/govuk-frontend/components/tabs/_tabs.scss +120 -0
  176. data/node_modules/govuk-frontend/components/tabs/macro.njk +3 -0
  177. data/node_modules/govuk-frontend/components/tabs/tabs.js +1302 -0
  178. data/node_modules/govuk-frontend/components/tabs/tabs.njk +3 -0
  179. data/node_modules/govuk-frontend/components/tabs/template.njk +29 -0
  180. data/node_modules/govuk-frontend/components/tag/README.md +150 -0
  181. data/node_modules/govuk-frontend/components/tag/_tag.scss +23 -0
  182. data/node_modules/govuk-frontend/components/tag/macro.njk +3 -0
  183. data/node_modules/govuk-frontend/components/tag/tag.njk +7 -0
  184. data/node_modules/govuk-frontend/components/tag/template.njk +3 -0
  185. data/node_modules/govuk-frontend/components/textarea/README.md +350 -0
  186. data/node_modules/govuk-frontend/components/textarea/_textarea.scss +31 -0
  187. data/node_modules/govuk-frontend/components/textarea/macro.njk +3 -0
  188. data/node_modules/govuk-frontend/components/textarea/template.njk +41 -0
  189. data/node_modules/govuk-frontend/components/textarea/textarea.njk +11 -0
  190. data/node_modules/govuk-frontend/components/warning-text/README.md +148 -0
  191. data/node_modules/govuk-frontend/components/warning-text/_warning-text.scss +50 -0
  192. data/node_modules/govuk-frontend/components/warning-text/macro.njk +3 -0
  193. data/node_modules/govuk-frontend/components/warning-text/template.njk +9 -0
  194. data/node_modules/govuk-frontend/components/warning-text/warning-text.njk +9 -0
  195. data/node_modules/govuk-frontend/core/_all.scss +6 -0
  196. data/node_modules/govuk-frontend/core/_global-styles.scss +19 -0
  197. data/node_modules/govuk-frontend/core/_links.scss +40 -0
  198. data/node_modules/govuk-frontend/core/_lists.scss +63 -0
  199. data/node_modules/govuk-frontend/core/_section-break.scss +56 -0
  200. data/node_modules/govuk-frontend/core/_template.scss +16 -0
  201. data/node_modules/govuk-frontend/core/_typography.scss +186 -0
  202. data/node_modules/govuk-frontend/helpers/_all.scss +12 -0
  203. data/node_modules/govuk-frontend/helpers/_clearfix.scss +15 -0
  204. data/node_modules/govuk-frontend/helpers/_colour.scss +51 -0
  205. data/node_modules/govuk-frontend/helpers/_device-pixels.scss +38 -0
  206. data/node_modules/govuk-frontend/helpers/_focusable.scss +34 -0
  207. data/node_modules/govuk-frontend/helpers/_font-faces.scss +67 -0
  208. data/node_modules/govuk-frontend/helpers/_grid.scss +100 -0
  209. data/node_modules/govuk-frontend/helpers/_links.scss +149 -0
  210. data/node_modules/govuk-frontend/helpers/_media-queries.scss +95 -0
  211. data/node_modules/govuk-frontend/helpers/_shape-arrow.scss +80 -0
  212. data/node_modules/govuk-frontend/helpers/_spacing.scss +152 -0
  213. data/node_modules/govuk-frontend/helpers/_typography.scss +153 -0
  214. data/node_modules/govuk-frontend/helpers/_visually-hidden.scss +76 -0
  215. data/node_modules/govuk-frontend/objects/_all.scss +4 -0
  216. data/node_modules/govuk-frontend/objects/_form-group.scss +21 -0
  217. data/node_modules/govuk-frontend/objects/_grid.scss +10 -0
  218. data/node_modules/govuk-frontend/objects/_main-wrapper.scss +37 -0
  219. data/node_modules/govuk-frontend/objects/_width-container.scss +28 -0
  220. data/node_modules/govuk-frontend/overrides/_all.scss +4 -0
  221. data/node_modules/govuk-frontend/overrides/_display.scss +14 -0
  222. data/node_modules/govuk-frontend/overrides/_spacing.scss +58 -0
  223. data/node_modules/govuk-frontend/overrides/_typography.scss +21 -0
  224. data/node_modules/govuk-frontend/overrides/_width.scss +41 -0
  225. data/node_modules/govuk-frontend/package.json +89 -0
  226. data/node_modules/govuk-frontend/settings/_all.scss +21 -0
  227. data/node_modules/govuk-frontend/settings/_assets.scss +82 -0
  228. data/node_modules/govuk-frontend/settings/_colours-applied.scss +130 -0
  229. data/node_modules/govuk-frontend/settings/_colours-organisations.scss +136 -0
  230. data/node_modules/govuk-frontend/settings/_colours-palette.scss +37 -0
  231. data/node_modules/govuk-frontend/settings/_compatibility.scss +51 -0
  232. data/node_modules/govuk-frontend/settings/_global-styles.scss +13 -0
  233. data/node_modules/govuk-frontend/settings/_ie8.scss +18 -0
  234. data/node_modules/govuk-frontend/settings/_measurements.scss +85 -0
  235. data/node_modules/govuk-frontend/settings/_media-queries.scss +23 -0
  236. data/node_modules/govuk-frontend/settings/_spacing.scss +80 -0
  237. data/node_modules/govuk-frontend/settings/_typography-font-families.scss +22 -0
  238. data/node_modules/govuk-frontend/settings/_typography-font.scss +48 -0
  239. data/node_modules/govuk-frontend/settings/_typography-responsive.scss +138 -0
  240. data/node_modules/govuk-frontend/template.njk +56 -0
  241. data/node_modules/govuk-frontend/tools/_all.scss +7 -0
  242. data/node_modules/govuk-frontend/tools/_compatibility.scss +36 -0
  243. data/node_modules/govuk-frontend/tools/_exports.scss +33 -0
  244. data/node_modules/govuk-frontend/tools/_font-url.scss +28 -0
  245. data/node_modules/govuk-frontend/tools/_ie8.scss +51 -0
  246. data/node_modules/govuk-frontend/tools/_iff.scss +15 -0
  247. data/node_modules/govuk-frontend/tools/_image-url.scss +28 -0
  248. data/node_modules/govuk-frontend/tools/_px-to-em.scss +20 -0
  249. data/node_modules/govuk-frontend/utilities/_all.scss +2 -0
  250. data/node_modules/govuk-frontend/utilities/_clearfix.scss +5 -0
  251. data/node_modules/govuk-frontend/utilities/_visually-hidden.scss +9 -0
  252. data/node_modules/govuk-frontend/vendor/_sass-mq.scss +351 -0
  253. data/node_modules/govuk-frontend/vendor/polyfills/DOMTokenList.js +272 -0
  254. data/node_modules/govuk-frontend/vendor/polyfills/Document.js +34 -0
  255. data/node_modules/govuk-frontend/vendor/polyfills/Element.js +147 -0
  256. data/node_modules/govuk-frontend/vendor/polyfills/Element/prototype/classList.js +449 -0
  257. data/node_modules/govuk-frontend/vendor/polyfills/Event.js +504 -0
  258. data/node_modules/govuk-frontend/vendor/polyfills/Function/prototype/bind.js +252 -0
  259. data/node_modules/govuk-frontend/vendor/polyfills/Object/defineProperty.js +94 -0
  260. data/node_modules/govuk-frontend/vendor/polyfills/Window.js +28 -0
  261. metadata +249 -2
@@ -0,0 +1,836 @@
1
+ (function (global, factory) {
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
3
+ typeof define === 'function' && define.amd ? define('GOVUKFrontend', factory) :
4
+ (global.GOVUKFrontend = 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://github.com/Financial-Times/polyfill-service/blob/master/packages/polyfill-library/polyfills/Window/detect.js
255
+ var detect = ('Window' in this);
256
+
257
+ if (detect) return
258
+
259
+ // Polyfill from https://cdn.polyfill.io/v2/polyfill.js?features=Window&flags=always
260
+ if ((typeof WorkerGlobalScope === "undefined") && (typeof importScripts !== "function")) {
261
+ (function (global) {
262
+ if (global.constructor) {
263
+ global.Window = global.constructor;
264
+ } else {
265
+ (global.Window = global.constructor = new Function('return function Window() {}')()).prototype = this;
266
+ }
267
+ }(this));
268
+ }
269
+
270
+ })
271
+ .call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
272
+
273
+ (function(undefined) {
274
+
275
+ // Detection from https://github.com/Financial-Times/polyfill-service/blob/master/packages/polyfill-library/polyfills/Document/detect.js
276
+ var detect = ("Document" in this);
277
+
278
+ if (detect) return
279
+
280
+ // Polyfill from https://cdn.polyfill.io/v2/polyfill.js?features=Document&flags=always
281
+ if ((typeof WorkerGlobalScope === "undefined") && (typeof importScripts !== "function")) {
282
+
283
+ if (this.HTMLDocument) { // IE8
284
+
285
+ // HTMLDocument is an extension of Document. If the browser has HTMLDocument but not Document, the former will suffice as an alias for the latter.
286
+ this.Document = this.HTMLDocument;
287
+
288
+ } else {
289
+
290
+ // 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.
291
+ this.Document = this.HTMLDocument = document.constructor = (new Function('return function Document() {}')());
292
+ this.Document.prototype = document;
293
+ }
294
+ }
295
+
296
+
297
+ })
298
+ .call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
299
+
300
+ (function(undefined) {
301
+
302
+ // Detection from https://github.com/Financial-Times/polyfill-service/blob/master/packages/polyfill-library/polyfills/Element/detect.js
303
+ var detect = ('Element' in this && 'HTMLElement' in this);
304
+
305
+ if (detect) return
306
+
307
+ // Polyfill from https://cdn.polyfill.io/v2/polyfill.js?features=Element&flags=always
308
+ (function () {
309
+
310
+ // IE8
311
+ if (window.Element && !window.HTMLElement) {
312
+ window.HTMLElement = window.Element;
313
+ return;
314
+ }
315
+
316
+ // create Element constructor
317
+ window.Element = window.HTMLElement = new Function('return function Element() {}')();
318
+
319
+ // generate sandboxed iframe
320
+ var vbody = document.appendChild(document.createElement('body'));
321
+ var frame = vbody.appendChild(document.createElement('iframe'));
322
+
323
+ // use sandboxed iframe to replicate Element functionality
324
+ var frameDocument = frame.contentWindow.document;
325
+ var prototype = Element.prototype = frameDocument.appendChild(frameDocument.createElement('*'));
326
+ var cache = {};
327
+
328
+ // polyfill Element.prototype on an element
329
+ var shiv = function (element, deep) {
330
+ var
331
+ childNodes = element.childNodes || [],
332
+ index = -1,
333
+ key, value, childNode;
334
+
335
+ if (element.nodeType === 1 && element.constructor !== Element) {
336
+ element.constructor = Element;
337
+
338
+ for (key in cache) {
339
+ value = cache[key];
340
+ element[key] = value;
341
+ }
342
+ }
343
+
344
+ while (childNode = deep && childNodes[++index]) {
345
+ shiv(childNode, deep);
346
+ }
347
+
348
+ return element;
349
+ };
350
+
351
+ var elements = document.getElementsByTagName('*');
352
+ var nativeCreateElement = document.createElement;
353
+ var interval;
354
+ var loopLimit = 100;
355
+
356
+ prototype.attachEvent('onpropertychange', function (event) {
357
+ var
358
+ propertyName = event.propertyName,
359
+ nonValue = !cache.hasOwnProperty(propertyName),
360
+ newValue = prototype[propertyName],
361
+ oldValue = cache[propertyName],
362
+ index = -1,
363
+ element;
364
+
365
+ while (element = elements[++index]) {
366
+ if (element.nodeType === 1) {
367
+ if (nonValue || element[propertyName] === oldValue) {
368
+ element[propertyName] = newValue;
369
+ }
370
+ }
371
+ }
372
+
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);
392
+ }
393
+ return false;
394
+ }
395
+ if (!bodyCheck()) {
396
+ document.onreadystatechange = bodyCheck;
397
+ interval = setInterval(bodyCheck, 25);
398
+ }
399
+
400
+ // Apply to any new elements created after load
401
+ document.createElement = function createElement(nodeName) {
402
+ var element = nativeCreateElement(String(nodeName).toLowerCase());
403
+ return shiv(element);
404
+ };
405
+
406
+ // remove sandboxed iframe
407
+ document.removeChild(vbody);
408
+ }());
409
+
410
+ })
411
+ .call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
412
+
413
+ (function(undefined) {
414
+
415
+ // Detection from https://github.com/Financial-Times/polyfill-service/blob/master/packages/polyfill-library/polyfills/Event/detect.js
416
+ var detect = (
417
+ (function(global) {
418
+
419
+ if (!('Event' in global)) return false;
420
+ if (typeof global.Event === 'function') return true;
421
+
422
+ try {
423
+
424
+ // In IE 9-11, the Event object exists but cannot be instantiated
425
+ new Event('click');
426
+ return true;
427
+ } catch(e) {
428
+ return false;
429
+ }
430
+ }(this))
431
+ );
432
+
433
+ if (detect) return
434
+
435
+ // Polyfill from https://cdn.polyfill.io/v2/polyfill.js?features=Event&flags=always
436
+ (function () {
437
+ var unlistenableWindowEvents = {
438
+ click: 1,
439
+ dblclick: 1,
440
+ keyup: 1,
441
+ keypress: 1,
442
+ keydown: 1,
443
+ mousedown: 1,
444
+ mouseup: 1,
445
+ mousemove: 1,
446
+ mouseover: 1,
447
+ mouseenter: 1,
448
+ mouseleave: 1,
449
+ mouseout: 1,
450
+ storage: 1,
451
+ storagecommit: 1,
452
+ textinput: 1
453
+ };
454
+
455
+ // This polyfill depends on availability of `document` so will not run in a worker
456
+ // However, we asssume there are no browsers with worker support that lack proper
457
+ // support for `Event` within the worker
458
+ if (typeof document === 'undefined' || typeof window === 'undefined') return;
459
+
460
+ function indexOf(array, element) {
461
+ var
462
+ index = -1,
463
+ length = array.length;
464
+
465
+ while (++index < length) {
466
+ if (index in array && array[index] === element) {
467
+ return index;
468
+ }
469
+ }
470
+
471
+ return -1;
472
+ }
473
+
474
+ var existingProto = (window.Event && window.Event.prototype) || null;
475
+ window.Event = Window.prototype.Event = function Event(type, eventInitDict) {
476
+ if (!type) {
477
+ throw new Error('Not enough arguments');
478
+ }
479
+
480
+ var event;
481
+ // Shortcut if browser supports createEvent
482
+ if ('createEvent' in document) {
483
+ event = document.createEvent('Event');
484
+ var bubbles = eventInitDict && eventInitDict.bubbles !== undefined ? eventInitDict.bubbles : false;
485
+ var cancelable = eventInitDict && eventInitDict.cancelable !== undefined ? eventInitDict.cancelable : false;
486
+
487
+ event.initEvent(type, bubbles, cancelable);
488
+
489
+ return event;
490
+ }
491
+
492
+ event = document.createEventObject();
493
+
494
+ event.type = type;
495
+ event.bubbles = eventInitDict && eventInitDict.bubbles !== undefined ? eventInitDict.bubbles : false;
496
+ event.cancelable = eventInitDict && eventInitDict.cancelable !== undefined ? eventInitDict.cancelable : false;
497
+
498
+ return event;
499
+ };
500
+ if (existingProto) {
501
+ Object.defineProperty(window.Event, 'prototype', {
502
+ configurable: false,
503
+ enumerable: false,
504
+ writable: true,
505
+ value: existingProto
506
+ });
507
+ }
508
+
509
+ if (!('createEvent' in document)) {
510
+ window.addEventListener = Window.prototype.addEventListener = Document.prototype.addEventListener = Element.prototype.addEventListener = function addEventListener() {
511
+ var
512
+ element = this,
513
+ type = arguments[0],
514
+ listener = arguments[1];
515
+
516
+ if (element === window && type in unlistenableWindowEvents) {
517
+ 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.');
518
+ }
519
+
520
+ if (!element._events) {
521
+ element._events = {};
522
+ }
523
+
524
+ if (!element._events[type]) {
525
+ element._events[type] = function (event) {
526
+ var
527
+ list = element._events[event.type].list,
528
+ events = list.slice(),
529
+ index = -1,
530
+ length = events.length,
531
+ eventElement;
532
+
533
+ event.preventDefault = function preventDefault() {
534
+ if (event.cancelable !== false) {
535
+ event.returnValue = false;
536
+ }
537
+ };
538
+
539
+ event.stopPropagation = function stopPropagation() {
540
+ event.cancelBubble = true;
541
+ };
542
+
543
+ event.stopImmediatePropagation = function stopImmediatePropagation() {
544
+ event.cancelBubble = true;
545
+ event.cancelImmediate = true;
546
+ };
547
+
548
+ event.currentTarget = element;
549
+ event.relatedTarget = event.fromElement || null;
550
+ event.target = event.target || event.srcElement || element;
551
+ event.timeStamp = new Date().getTime();
552
+
553
+ if (event.clientX) {
554
+ event.pageX = event.clientX + document.documentElement.scrollLeft;
555
+ event.pageY = event.clientY + document.documentElement.scrollTop;
556
+ }
557
+
558
+ while (++index < length && !event.cancelImmediate) {
559
+ if (index in events) {
560
+ eventElement = events[index];
561
+
562
+ if (indexOf(list, eventElement) !== -1 && typeof eventElement === 'function') {
563
+ eventElement.call(element, event);
564
+ }
565
+ }
566
+ }
567
+ };
568
+
569
+ element._events[type].list = [];
570
+
571
+ if (element.attachEvent) {
572
+ element.attachEvent('on' + type, element._events[type]);
573
+ }
574
+ }
575
+
576
+ element._events[type].list.push(listener);
577
+ };
578
+
579
+ window.removeEventListener = Window.prototype.removeEventListener = Document.prototype.removeEventListener = Element.prototype.removeEventListener = function removeEventListener() {
580
+ var
581
+ element = this,
582
+ type = arguments[0],
583
+ listener = arguments[1],
584
+ index;
585
+
586
+ if (element._events && element._events[type] && element._events[type].list) {
587
+ index = indexOf(element._events[type].list, listener);
588
+
589
+ if (index !== -1) {
590
+ element._events[type].list.splice(index, 1);
591
+
592
+ if (!element._events[type].list.length) {
593
+ if (element.detachEvent) {
594
+ element.detachEvent('on' + type, element._events[type]);
595
+ }
596
+ delete element._events[type];
597
+ }
598
+ }
599
+ }
600
+ };
601
+
602
+ window.dispatchEvent = Window.prototype.dispatchEvent = Document.prototype.dispatchEvent = Element.prototype.dispatchEvent = function dispatchEvent(event) {
603
+ if (!arguments.length) {
604
+ throw new Error('Not enough arguments');
605
+ }
606
+
607
+ if (!event || typeof event.type !== 'string') {
608
+ throw new Error('DOM Events Exception 0');
609
+ }
610
+
611
+ var element = this, type = event.type;
612
+
613
+ try {
614
+ if (!event.bubbles) {
615
+ event.cancelBubble = true;
616
+
617
+ var cancelBubbleEvent = function (event) {
618
+ event.cancelBubble = true;
619
+
620
+ (element || window).detachEvent('on' + type, cancelBubbleEvent);
621
+ };
622
+
623
+ this.attachEvent('on' + type, cancelBubbleEvent);
624
+ }
625
+
626
+ this.fireEvent('on' + type, event);
627
+ } catch (error) {
628
+ event.target = element;
629
+
630
+ do {
631
+ event.currentTarget = element;
632
+
633
+ if ('_events' in element && typeof element._events[type] === 'function') {
634
+ element._events[type].call(element, event);
635
+ }
636
+
637
+ if (typeof element['on' + type] === 'function') {
638
+ element['on' + type].call(element, event);
639
+ }
640
+
641
+ element = element.nodeType === 9 ? element.parentWindow : element.parentNode;
642
+ } while (element && !event.cancelBubble);
643
+ }
644
+
645
+ return true;
646
+ };
647
+
648
+ // Add the DOMContentLoaded Event
649
+ document.attachEvent('onreadystatechange', function() {
650
+ if (document.readyState === 'complete') {
651
+ document.dispatchEvent(new Event('DOMContentLoaded', {
652
+ bubbles: true
653
+ }));
654
+ }
655
+ });
656
+ }
657
+ }());
658
+
659
+ })
660
+ .call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
661
+
662
+ /**
663
+ * TODO: Ideally this would be a NodeList.prototype.forEach polyfill
664
+ * This seems to fail in IE8, requires more investigation.
665
+ * See: https://github.com/imagitama/nodelist-foreach-polyfill
666
+ */
667
+
668
+ // Used to generate a unique string, allows multiple instances of the component without
669
+ // Them conflicting with each other.
670
+ // https://stackoverflow.com/a/8809472
671
+ function generateUniqueID () {
672
+ var d = new Date().getTime();
673
+ if (typeof window.performance !== 'undefined' && typeof window.performance.now === 'function') {
674
+ d += window.performance.now(); // use high-precision timer if available
675
+ }
676
+ return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
677
+ var r = (d + Math.random() * 16) % 16 | 0;
678
+ d = Math.floor(d / 16);
679
+ return (c === 'x' ? r : (r & 0x3 | 0x8)).toString(16)
680
+ })
681
+ }
682
+
683
+ /**
684
+ * JavaScript 'polyfill' for HTML5's <details> and <summary> elements
685
+ * and 'shim' to add accessiblity enhancements for all browsers
686
+ *
687
+ * http://caniuse.com/#feat=details
688
+ *
689
+ * Usage instructions:
690
+ * the 'polyfill' will be automatically initialised
691
+ */
692
+
693
+ var KEY_ENTER = 13;
694
+ var KEY_SPACE = 32;
695
+
696
+ // Create a flag to know if the browser supports navtive details
697
+ var NATIVE_DETAILS = typeof document.createElement('details').open === 'boolean';
698
+
699
+ function Details ($module) {
700
+ this.$module = $module;
701
+ }
702
+
703
+ /**
704
+ * Handle cross-modal click events
705
+ * @param {object} node element
706
+ * @param {function} callback function
707
+ */
708
+ Details.prototype.handleInputs = function (node, callback) {
709
+ node.addEventListener('keypress', function (event) {
710
+ var target = event.target;
711
+ // When the key gets pressed - check if it is enter or space
712
+ if (event.keyCode === KEY_ENTER || event.keyCode === KEY_SPACE) {
713
+ if (target.nodeName.toLowerCase() === 'summary') {
714
+ // Prevent space from scrolling the page
715
+ // and enter from submitting a form
716
+ event.preventDefault();
717
+ // Click to let the click event do all the necessary action
718
+ if (target.click) {
719
+ target.click();
720
+ } else {
721
+ // except Safari 5.1 and under don't support .click() here
722
+ callback(event);
723
+ }
724
+ }
725
+ }
726
+ });
727
+
728
+ // Prevent keyup to prevent clicking twice in Firefox when using space key
729
+ node.addEventListener('keyup', function (event) {
730
+ var target = event.target;
731
+ if (event.keyCode === KEY_SPACE) {
732
+ if (target.nodeName.toLowerCase() === 'summary') {
733
+ event.preventDefault();
734
+ }
735
+ }
736
+ });
737
+
738
+ node.addEventListener('click', callback);
739
+ };
740
+
741
+ Details.prototype.init = function () {
742
+ var $module = this.$module;
743
+
744
+ if (!$module) {
745
+ return
746
+ }
747
+
748
+ // Save shortcuts to the inner summary and content elements
749
+ var $summary = this.$summary = $module.getElementsByTagName('summary').item(0);
750
+ var $content = this.$content = $module.getElementsByTagName('div').item(0);
751
+
752
+ // If <details> doesn't have a <summary> and a <div> representing the content
753
+ // it means the required HTML structure is not met so the script will stop
754
+ if (!$summary || !$content) {
755
+ return
756
+ }
757
+
758
+ // If the content doesn't have an ID, assign it one now
759
+ // which we'll need for the summary's aria-controls assignment
760
+ if (!$content.id) {
761
+ $content.id = 'details-content-' + generateUniqueID();
762
+ }
763
+
764
+ // Add ARIA role="group" to details
765
+ $module.setAttribute('role', 'group');
766
+
767
+ // Add role=button to summary
768
+ $summary.setAttribute('role', 'button');
769
+
770
+ // Add aria-controls
771
+ $summary.setAttribute('aria-controls', $content.id);
772
+
773
+ // Set tabIndex so the summary is keyboard accessible for non-native elements
774
+ // http://www.saliences.com/browserBugs/tabIndex.html
775
+ if (!NATIVE_DETAILS) {
776
+ $summary.tabIndex = 0;
777
+ }
778
+
779
+ // Detect initial open state
780
+ var openAttr = $module.getAttribute('open') !== null;
781
+ if (openAttr === true) {
782
+ $summary.setAttribute('aria-expanded', 'true');
783
+ $content.setAttribute('aria-hidden', 'false');
784
+ } else {
785
+ $summary.setAttribute('aria-expanded', 'false');
786
+ $content.setAttribute('aria-hidden', 'true');
787
+ if (!NATIVE_DETAILS) {
788
+ $content.style.display = 'none';
789
+ }
790
+ }
791
+
792
+ // Bind an event to handle summary elements
793
+ this.handleInputs($module, this.setAttributes.bind(this));
794
+ };
795
+
796
+ /**
797
+ * Define a statechange function that updates aria-expanded and style.display
798
+ * @param {object} summary element
799
+ */
800
+ Details.prototype.setAttributes = function () {
801
+ var $module = this.$module;
802
+ var $summary = this.$summary;
803
+ var $content = this.$content;
804
+
805
+ var expanded = $summary.getAttribute('aria-expanded') === 'true';
806
+ var hidden = $content.getAttribute('aria-hidden') === 'true';
807
+
808
+ $summary.setAttribute('aria-expanded', (expanded ? 'false' : 'true'));
809
+ $content.setAttribute('aria-hidden', (hidden ? 'false' : 'true'));
810
+
811
+ if (!NATIVE_DETAILS) {
812
+ $content.style.display = (expanded ? 'none' : '');
813
+
814
+ var hasOpenAttr = $module.getAttribute('open') !== null;
815
+ if (!hasOpenAttr) {
816
+ $module.setAttribute('open', 'open');
817
+ } else {
818
+ $module.removeAttribute('open');
819
+ }
820
+ }
821
+ return true
822
+ };
823
+
824
+ /**
825
+ * Remove the click event from the node element
826
+ * @param {object} node element
827
+ */
828
+ Details.prototype.destroy = function (node) {
829
+ node.removeEventListener('keypress');
830
+ node.removeEventListener('keyup');
831
+ node.removeEventListener('click');
832
+ };
833
+
834
+ return Details;
835
+
836
+ })));