defra_ruby_template 3.13.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (479) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +8 -0
  3. data/Gemfile +6 -0
  4. data/Gemfile.lock +20 -0
  5. data/README.md +71 -0
  6. data/Rakefile +50 -0
  7. data/app/views/layouts/defra_ruby_template.html.erb +83 -0
  8. data/bin/console +14 -0
  9. data/bin/setup +8 -0
  10. data/defra_ruby_template.gemspec +24 -0
  11. data/lib/defra_ruby_template.rb +23 -0
  12. data/lib/defra_ruby_template/version.rb +3 -0
  13. data/node_modules/govuk-frontend/README.md +91 -0
  14. data/node_modules/govuk-frontend/govuk-prototype-kit.config.json +14 -0
  15. data/node_modules/govuk-frontend/govuk/_base.scss +3 -0
  16. data/node_modules/govuk-frontend/govuk/all-ie8.scss +6 -0
  17. data/node_modules/govuk-frontend/govuk/all.js +2616 -0
  18. data/node_modules/govuk-frontend/govuk/all.scss +9 -0
  19. data/node_modules/govuk-frontend/govuk/assets/fonts/bold-affa96571d-v2.woff +0 -0
  20. data/node_modules/govuk-frontend/govuk/assets/fonts/bold-b542beb274-v2.woff2 +0 -0
  21. data/node_modules/govuk-frontend/govuk/assets/fonts/light-94a07e06a1-v2.woff2 +0 -0
  22. data/node_modules/govuk-frontend/govuk/assets/fonts/light-f591b13f7d-v2.woff +0 -0
  23. data/node_modules/govuk-frontend/govuk/assets/images/favicon.ico +0 -0
  24. data/node_modules/govuk-frontend/govuk/assets/images/govuk-apple-touch-icon-152x152.png +0 -0
  25. data/node_modules/govuk-frontend/govuk/assets/images/govuk-apple-touch-icon-167x167.png +0 -0
  26. data/node_modules/govuk-frontend/govuk/assets/images/govuk-apple-touch-icon-180x180.png +0 -0
  27. data/node_modules/govuk-frontend/govuk/assets/images/govuk-apple-touch-icon.png +0 -0
  28. data/node_modules/govuk-frontend/govuk/assets/images/govuk-crest-2x.png +0 -0
  29. data/node_modules/govuk-frontend/govuk/assets/images/govuk-crest.png +0 -0
  30. data/node_modules/govuk-frontend/govuk/assets/images/govuk-logotype-crown.png +0 -0
  31. data/node_modules/govuk-frontend/govuk/assets/images/govuk-mask-icon.svg +7 -0
  32. data/node_modules/govuk-frontend/govuk/assets/images/govuk-opengraph-image.png +0 -0
  33. data/node_modules/govuk-frontend/govuk/common.js +39 -0
  34. data/node_modules/govuk-frontend/govuk/components/_all.scss +33 -0
  35. data/node_modules/govuk-frontend/govuk/components/accordion/README.md +15 -0
  36. data/node_modules/govuk-frontend/govuk/components/accordion/_accordion.scss +2 -0
  37. data/node_modules/govuk-frontend/govuk/components/accordion/_index.scss +197 -0
  38. data/node_modules/govuk-frontend/govuk/components/accordion/accordion.js +1011 -0
  39. data/node_modules/govuk-frontend/govuk/components/accordion/fixtures.json +250 -0
  40. data/node_modules/govuk-frontend/govuk/components/accordion/macro-options.json +76 -0
  41. data/node_modules/govuk-frontend/govuk/components/accordion/macro.njk +3 -0
  42. data/node_modules/govuk-frontend/govuk/components/accordion/template.njk +27 -0
  43. data/node_modules/govuk-frontend/govuk/components/back-link/README.md +15 -0
  44. data/node_modules/govuk-frontend/govuk/components/back-link/_back-link.scss +2 -0
  45. data/node_modules/govuk-frontend/govuk/components/back-link/_index.scss +99 -0
  46. data/node_modules/govuk-frontend/govuk/components/back-link/fixtures.json +62 -0
  47. data/node_modules/govuk-frontend/govuk/components/back-link/macro-options.json +32 -0
  48. data/node_modules/govuk-frontend/govuk/components/back-link/macro.njk +3 -0
  49. data/node_modules/govuk-frontend/govuk/components/back-link/template.njk +2 -0
  50. data/node_modules/govuk-frontend/govuk/components/breadcrumbs/README.md +15 -0
  51. data/node_modules/govuk-frontend/govuk/components/breadcrumbs/_breadcrumbs.scss +2 -0
  52. data/node_modules/govuk-frontend/govuk/components/breadcrumbs/_index.scss +138 -0
  53. data/node_modules/govuk-frontend/govuk/components/breadcrumbs/fixtures.json +193 -0
  54. data/node_modules/govuk-frontend/govuk/components/breadcrumbs/macro-options.json +52 -0
  55. data/node_modules/govuk-frontend/govuk/components/breadcrumbs/macro.njk +3 -0
  56. data/node_modules/govuk-frontend/govuk/components/breadcrumbs/template.njk +24 -0
  57. data/node_modules/govuk-frontend/govuk/components/button/README.md +15 -0
  58. data/node_modules/govuk-frontend/govuk/components/button/_button.scss +2 -0
  59. data/node_modules/govuk-frontend/govuk/components/button/_index.scss +288 -0
  60. data/node_modules/govuk-frontend/govuk/components/button/button.js +724 -0
  61. data/node_modules/govuk-frontend/govuk/components/button/fixtures.json +318 -0
  62. data/node_modules/govuk-frontend/govuk/components/button/macro-options.json +74 -0
  63. data/node_modules/govuk-frontend/govuk/components/button/macro.njk +3 -0
  64. data/node_modules/govuk-frontend/govuk/components/button/template.njk +60 -0
  65. data/node_modules/govuk-frontend/govuk/components/character-count/README.md +15 -0
  66. data/node_modules/govuk-frontend/govuk/components/character-count/_character-count.scss +2 -0
  67. data/node_modules/govuk-frontend/govuk/components/character-count/_index.scss +25 -0
  68. data/node_modules/govuk-frontend/govuk/components/character-count/character-count.js +1194 -0
  69. data/node_modules/govuk-frontend/govuk/components/character-count/fixtures.json +240 -0
  70. data/node_modules/govuk-frontend/govuk/components/character-count/macro-options.json +111 -0
  71. data/node_modules/govuk-frontend/govuk/components/character-count/macro.njk +3 -0
  72. data/node_modules/govuk-frontend/govuk/components/character-count/template.njk +37 -0
  73. data/node_modules/govuk-frontend/govuk/components/checkboxes/README.md +15 -0
  74. data/node_modules/govuk-frontend/govuk/components/checkboxes/_checkboxes.scss +2 -0
  75. data/node_modules/govuk-frontend/govuk/components/checkboxes/_index.scss +320 -0
  76. data/node_modules/govuk-frontend/govuk/components/checkboxes/checkboxes.js +1192 -0
  77. data/node_modules/govuk-frontend/govuk/components/checkboxes/fixtures.json +1189 -0
  78. data/node_modules/govuk-frontend/govuk/components/checkboxes/macro-options.json +161 -0
  79. data/node_modules/govuk-frontend/govuk/components/checkboxes/macro.njk +3 -0
  80. data/node_modules/govuk-frontend/govuk/components/checkboxes/template.njk +119 -0
  81. data/node_modules/govuk-frontend/govuk/components/cookie-banner/README.md +15 -0
  82. data/node_modules/govuk-frontend/govuk/components/cookie-banner/_cookie-banner.scss +2 -0
  83. data/node_modules/govuk-frontend/govuk/components/cookie-banner/_index.scss +51 -0
  84. data/node_modules/govuk-frontend/govuk/components/cookie-banner/fixtures.json +443 -0
  85. data/node_modules/govuk-frontend/govuk/components/cookie-banner/macro-options.json +132 -0
  86. data/node_modules/govuk-frontend/govuk/components/cookie-banner/macro.njk +3 -0
  87. data/node_modules/govuk-frontend/govuk/components/cookie-banner/template.njk +73 -0
  88. data/node_modules/govuk-frontend/govuk/components/date-input/README.md +15 -0
  89. data/node_modules/govuk-frontend/govuk/components/date-input/_date-input.scss +2 -0
  90. data/node_modules/govuk-frontend/govuk/components/date-input/_index.scss +26 -0
  91. data/node_modules/govuk-frontend/govuk/components/date-input/fixtures.json +549 -0
  92. data/node_modules/govuk-frontend/govuk/components/date-input/macro-options.json +117 -0
  93. data/node_modules/govuk-frontend/govuk/components/date-input/macro.njk +3 -0
  94. data/node_modules/govuk-frontend/govuk/components/date-input/template.njk +97 -0
  95. data/node_modules/govuk-frontend/govuk/components/details/README.md +15 -0
  96. data/node_modules/govuk-frontend/govuk/components/details/_details.scss +2 -0
  97. data/node_modules/govuk-frontend/govuk/components/details/_index.scss +87 -0
  98. data/node_modules/govuk-frontend/govuk/components/details/details.js +828 -0
  99. data/node_modules/govuk-frontend/govuk/components/details/fixtures.json +103 -0
  100. data/node_modules/govuk-frontend/govuk/components/details/implementation.md +43 -0
  101. data/node_modules/govuk-frontend/govuk/components/details/macro-options.json +50 -0
  102. data/node_modules/govuk-frontend/govuk/components/details/macro.njk +3 -0
  103. data/node_modules/govuk-frontend/govuk/components/details/template.njk +10 -0
  104. data/node_modules/govuk-frontend/govuk/components/error-message/README.md +15 -0
  105. data/node_modules/govuk-frontend/govuk/components/error-message/_error-message.scss +2 -0
  106. data/node_modules/govuk-frontend/govuk/components/error-message/_index.scss +11 -0
  107. data/node_modules/govuk-frontend/govuk/components/error-message/fixtures.json +77 -0
  108. data/node_modules/govuk-frontend/govuk/components/error-message/macro-options.json +38 -0
  109. data/node_modules/govuk-frontend/govuk/components/error-message/macro.njk +3 -0
  110. data/node_modules/govuk-frontend/govuk/components/error-message/template.njk +6 -0
  111. data/node_modules/govuk-frontend/govuk/components/error-summary/README.md +15 -0
  112. data/node_modules/govuk-frontend/govuk/components/error-summary/_error-summary.scss +2 -0
  113. data/node_modules/govuk-frontend/govuk/components/error-summary/_index.scss +43 -0
  114. data/node_modules/govuk-frontend/govuk/components/error-summary/error-summary.js +853 -0
  115. data/node_modules/govuk-frontend/govuk/components/error-summary/fixtures.json +242 -0
  116. data/node_modules/govuk-frontend/govuk/components/error-summary/macro-options.json +70 -0
  117. data/node_modules/govuk-frontend/govuk/components/error-summary/macro.njk +3 -0
  118. data/node_modules/govuk-frontend/govuk/components/error-summary/template.njk +25 -0
  119. data/node_modules/govuk-frontend/govuk/components/fieldset/README.md +15 -0
  120. data/node_modules/govuk-frontend/govuk/components/fieldset/_fieldset.scss +2 -0
  121. data/node_modules/govuk-frontend/govuk/components/fieldset/_index.scss +64 -0
  122. data/node_modules/govuk-frontend/govuk/components/fieldset/fixtures.json +103 -0
  123. data/node_modules/govuk-frontend/govuk/components/fieldset/macro-options.json +70 -0
  124. data/node_modules/govuk-frontend/govuk/components/fieldset/macro.njk +3 -0
  125. data/node_modules/govuk-frontend/govuk/components/fieldset/template.njk +22 -0
  126. data/node_modules/govuk-frontend/govuk/components/file-upload/README.md +15 -0
  127. data/node_modules/govuk-frontend/govuk/components/file-upload/_file-upload.scss +2 -0
  128. data/node_modules/govuk-frontend/govuk/components/file-upload/_index.scss +49 -0
  129. data/node_modules/govuk-frontend/govuk/components/file-upload/fixtures.json +198 -0
  130. data/node_modules/govuk-frontend/govuk/components/file-upload/macro-options.json +73 -0
  131. data/node_modules/govuk-frontend/govuk/components/file-upload/macro.njk +3 -0
  132. data/node_modules/govuk-frontend/govuk/components/file-upload/template.njk +44 -0
  133. data/node_modules/govuk-frontend/govuk/components/footer/README.md +15 -0
  134. data/node_modules/govuk-frontend/govuk/components/footer/_footer.scss +2 -0
  135. data/node_modules/govuk-frontend/govuk/components/footer/_index.scss +241 -0
  136. data/node_modules/govuk-frontend/govuk/components/footer/fixtures.json +501 -0
  137. data/node_modules/govuk-frontend/govuk/components/footer/macro-options.json +118 -0
  138. data/node_modules/govuk-frontend/govuk/components/footer/macro.njk +3 -0
  139. data/node_modules/govuk-frontend/govuk/components/footer/template.njk +87 -0
  140. data/node_modules/govuk-frontend/govuk/components/header/README.md +15 -0
  141. data/node_modules/govuk-frontend/govuk/components/header/_header.scss +2 -0
  142. data/node_modules/govuk-frontend/govuk/components/header/_index.scss +331 -0
  143. data/node_modules/govuk-frontend/govuk/components/header/fixtures.json +378 -0
  144. data/node_modules/govuk-frontend/govuk/components/header/header.js +1066 -0
  145. data/node_modules/govuk-frontend/govuk/components/header/macro-options.json +106 -0
  146. data/node_modules/govuk-frontend/govuk/components/header/macro.njk +3 -0
  147. data/node_modules/govuk-frontend/govuk/components/header/template.njk +79 -0
  148. data/node_modules/govuk-frontend/govuk/components/hint/README.md +15 -0
  149. data/node_modules/govuk-frontend/govuk/components/hint/_hint.scss +2 -0
  150. data/node_modules/govuk-frontend/govuk/components/hint/_index.scss +44 -0
  151. data/node_modules/govuk-frontend/govuk/components/hint/fixtures.json +59 -0
  152. data/node_modules/govuk-frontend/govuk/components/hint/macro-options.json +32 -0
  153. data/node_modules/govuk-frontend/govuk/components/hint/macro.njk +3 -0
  154. data/node_modules/govuk-frontend/govuk/components/hint/template.njk +4 -0
  155. data/node_modules/govuk-frontend/govuk/components/input/README.md +15 -0
  156. data/node_modules/govuk-frontend/govuk/components/input/_index.scss +191 -0
  157. data/node_modules/govuk-frontend/govuk/components/input/_input.scss +2 -0
  158. data/node_modules/govuk-frontend/govuk/components/input/fixtures.json +628 -0
  159. data/node_modules/govuk-frontend/govuk/components/input/macro-options.json +167 -0
  160. data/node_modules/govuk-frontend/govuk/components/input/macro.njk +3 -0
  161. data/node_modules/govuk-frontend/govuk/components/input/template.njk +65 -0
  162. data/node_modules/govuk-frontend/govuk/components/inset-text/README.md +15 -0
  163. data/node_modules/govuk-frontend/govuk/components/inset-text/_index.scss +24 -0
  164. data/node_modules/govuk-frontend/govuk/components/inset-text/_inset-text.scss +2 -0
  165. data/node_modules/govuk-frontend/govuk/components/inset-text/fixtures.json +58 -0
  166. data/node_modules/govuk-frontend/govuk/components/inset-text/macro-options.json +32 -0
  167. data/node_modules/govuk-frontend/govuk/components/inset-text/macro.njk +3 -0
  168. data/node_modules/govuk-frontend/govuk/components/inset-text/template.njk +4 -0
  169. data/node_modules/govuk-frontend/govuk/components/label/README.md +15 -0
  170. data/node_modules/govuk-frontend/govuk/components/label/_index.scss +41 -0
  171. data/node_modules/govuk-frontend/govuk/components/label/_label.scss +2 -0
  172. data/node_modules/govuk-frontend/govuk/components/label/fixtures.json +84 -0
  173. data/node_modules/govuk-frontend/govuk/components/label/macro-options.json +38 -0
  174. data/node_modules/govuk-frontend/govuk/components/label/macro.njk +3 -0
  175. data/node_modules/govuk-frontend/govuk/components/label/template.njk +15 -0
  176. data/node_modules/govuk-frontend/govuk/components/notification-banner/README.md +15 -0
  177. data/node_modules/govuk-frontend/govuk/components/notification-banner/_index.scss +89 -0
  178. data/node_modules/govuk-frontend/govuk/components/notification-banner/_notification-banner.scss +2 -0
  179. data/node_modules/govuk-frontend/govuk/components/notification-banner/fixtures.json +212 -0
  180. data/node_modules/govuk-frontend/govuk/components/notification-banner/macro-options.json +68 -0
  181. data/node_modules/govuk-frontend/govuk/components/notification-banner/macro.njk +3 -0
  182. data/node_modules/govuk-frontend/govuk/components/notification-banner/notification-banner.js +61 -0
  183. data/node_modules/govuk-frontend/govuk/components/notification-banner/template.njk +47 -0
  184. data/node_modules/govuk-frontend/govuk/components/panel/README.md +15 -0
  185. data/node_modules/govuk-frontend/govuk/components/panel/_index.scss +44 -0
  186. data/node_modules/govuk-frontend/govuk/components/panel/_panel.scss +2 -0
  187. data/node_modules/govuk-frontend/govuk/components/panel/fixtures.json +91 -0
  188. data/node_modules/govuk-frontend/govuk/components/panel/macro-options.json +44 -0
  189. data/node_modules/govuk-frontend/govuk/components/panel/macro.njk +3 -0
  190. data/node_modules/govuk-frontend/govuk/components/panel/template.njk +13 -0
  191. data/node_modules/govuk-frontend/govuk/components/phase-banner/README.md +15 -0
  192. data/node_modules/govuk-frontend/govuk/components/phase-banner/_index.scss +27 -0
  193. data/node_modules/govuk-frontend/govuk/components/phase-banner/_phase-banner.scss +2 -0
  194. data/node_modules/govuk-frontend/govuk/components/phase-banner/fixtures.json +76 -0
  195. data/node_modules/govuk-frontend/govuk/components/phase-banner/macro-options.json +33 -0
  196. data/node_modules/govuk-frontend/govuk/components/phase-banner/macro.njk +3 -0
  197. data/node_modules/govuk-frontend/govuk/components/phase-banner/template.njk +15 -0
  198. data/node_modules/govuk-frontend/govuk/components/radios/README.md +15 -0
  199. data/node_modules/govuk-frontend/govuk/components/radios/_index.scss +342 -0
  200. data/node_modules/govuk-frontend/govuk/components/radios/_radios.scss +2 -0
  201. data/node_modules/govuk-frontend/govuk/components/radios/fixtures.json +1183 -0
  202. data/node_modules/govuk-frontend/govuk/components/radios/macro-options.json +143 -0
  203. data/node_modules/govuk-frontend/govuk/components/radios/macro.njk +3 -0
  204. data/node_modules/govuk-frontend/govuk/components/radios/radios.js +1148 -0
  205. data/node_modules/govuk-frontend/govuk/components/radios/template.njk +116 -0
  206. data/node_modules/govuk-frontend/govuk/components/select/README.md +15 -0
  207. data/node_modules/govuk-frontend/govuk/components/select/_index.scss +49 -0
  208. data/node_modules/govuk-frontend/govuk/components/select/_select.scss +2 -0
  209. data/node_modules/govuk-frontend/govuk/components/select/fixtures.json +327 -0
  210. data/node_modules/govuk-frontend/govuk/components/select/macro-options.json +105 -0
  211. data/node_modules/govuk-frontend/govuk/components/select/macro.njk +3 -0
  212. data/node_modules/govuk-frontend/govuk/components/select/template.njk +51 -0
  213. data/node_modules/govuk-frontend/govuk/components/skip-link/README.md +15 -0
  214. data/node_modules/govuk-frontend/govuk/components/skip-link/_index.scss +36 -0
  215. data/node_modules/govuk-frontend/govuk/components/skip-link/_skip-link.scss +2 -0
  216. data/node_modules/govuk-frontend/govuk/components/skip-link/fixtures.json +84 -0
  217. data/node_modules/govuk-frontend/govuk/components/skip-link/macro-options.json +32 -0
  218. data/node_modules/govuk-frontend/govuk/components/skip-link/macro.njk +3 -0
  219. data/node_modules/govuk-frontend/govuk/components/skip-link/template.njk +3 -0
  220. data/node_modules/govuk-frontend/govuk/components/summary-list/README.md +15 -0
  221. data/node_modules/govuk-frontend/govuk/components/summary-list/_index.scss +145 -0
  222. data/node_modules/govuk-frontend/govuk/components/summary-list/_summary-list.scss +2 -0
  223. data/node_modules/govuk-frontend/govuk/components/summary-list/fixtures.json +1084 -0
  224. data/node_modules/govuk-frontend/govuk/components/summary-list/macro-options.json +113 -0
  225. data/node_modules/govuk-frontend/govuk/components/summary-list/macro.njk +3 -0
  226. data/node_modules/govuk-frontend/govuk/components/summary-list/template.njk +47 -0
  227. data/node_modules/govuk-frontend/govuk/components/table/README.md +15 -0
  228. data/node_modules/govuk-frontend/govuk/components/table/_index.scss +71 -0
  229. data/node_modules/govuk-frontend/govuk/components/table/_table.scss +2 -0
  230. data/node_modules/govuk-frontend/govuk/components/table/fixtures.json +538 -0
  231. data/node_modules/govuk-frontend/govuk/components/table/macro-options.json +132 -0
  232. data/node_modules/govuk-frontend/govuk/components/table/macro.njk +3 -0
  233. data/node_modules/govuk-frontend/govuk/components/table/template.njk +45 -0
  234. data/node_modules/govuk-frontend/govuk/components/tabs/README.md +15 -0
  235. data/node_modules/govuk-frontend/govuk/components/tabs/_index.scss +130 -0
  236. data/node_modules/govuk-frontend/govuk/components/tabs/_tabs.scss +2 -0
  237. data/node_modules/govuk-frontend/govuk/components/tabs/fixtures.json +286 -0
  238. data/node_modules/govuk-frontend/govuk/components/tabs/macro-options.json +84 -0
  239. data/node_modules/govuk-frontend/govuk/components/tabs/macro.njk +3 -0
  240. data/node_modules/govuk-frontend/govuk/components/tabs/tabs.js +1347 -0
  241. data/node_modules/govuk-frontend/govuk/components/tabs/template.njk +32 -0
  242. data/node_modules/govuk-frontend/govuk/components/tag/README.md +15 -0
  243. data/node_modules/govuk-frontend/govuk/components/tag/_index.scss +86 -0
  244. data/node_modules/govuk-frontend/govuk/components/tag/_tag.scss +2 -0
  245. data/node_modules/govuk-frontend/govuk/components/tag/fixtures.json +131 -0
  246. data/node_modules/govuk-frontend/govuk/components/tag/macro-options.json +26 -0
  247. data/node_modules/govuk-frontend/govuk/components/tag/macro.njk +3 -0
  248. data/node_modules/govuk-frontend/govuk/components/tag/template.njk +3 -0
  249. data/node_modules/govuk-frontend/govuk/components/textarea/README.md +15 -0
  250. data/node_modules/govuk-frontend/govuk/components/textarea/_index.scss +47 -0
  251. data/node_modules/govuk-frontend/govuk/components/textarea/_textarea.scss +2 -0
  252. data/node_modules/govuk-frontend/govuk/components/textarea/fixtures.json +250 -0
  253. data/node_modules/govuk-frontend/govuk/components/textarea/macro-options.json +91 -0
  254. data/node_modules/govuk-frontend/govuk/components/textarea/macro.njk +3 -0
  255. data/node_modules/govuk-frontend/govuk/components/textarea/template.njk +45 -0
  256. data/node_modules/govuk-frontend/govuk/components/warning-text/README.md +15 -0
  257. data/node_modules/govuk-frontend/govuk/components/warning-text/_index.scss +66 -0
  258. data/node_modules/govuk-frontend/govuk/components/warning-text/_warning-text.scss +2 -0
  259. data/node_modules/govuk-frontend/govuk/components/warning-text/fixtures.json +73 -0
  260. data/node_modules/govuk-frontend/govuk/components/warning-text/macro-options.json +32 -0
  261. data/node_modules/govuk-frontend/govuk/components/warning-text/macro.njk +3 -0
  262. data/node_modules/govuk-frontend/govuk/components/warning-text/template.njk +9 -0
  263. data/node_modules/govuk-frontend/govuk/core/_all.scss +6 -0
  264. data/node_modules/govuk-frontend/govuk/core/_global-styles.scss +25 -0
  265. data/node_modules/govuk-frontend/govuk/core/_links.scss +41 -0
  266. data/node_modules/govuk-frontend/govuk/core/_lists.scss +72 -0
  267. data/node_modules/govuk-frontend/govuk/core/_section-break.scss +62 -0
  268. data/node_modules/govuk-frontend/govuk/core/_template.scss +36 -0
  269. data/node_modules/govuk-frontend/govuk/core/_typography.scss +192 -0
  270. data/node_modules/govuk-frontend/govuk/helpers/_all.scss +12 -0
  271. data/node_modules/govuk-frontend/govuk/helpers/_clearfix.scss +15 -0
  272. data/node_modules/govuk-frontend/govuk/helpers/_colour.scss +95 -0
  273. data/node_modules/govuk-frontend/govuk/helpers/_device-pixels.scss +37 -0
  274. data/node_modules/govuk-frontend/govuk/helpers/_focused.scss +28 -0
  275. data/node_modules/govuk-frontend/govuk/helpers/_font-faces.scss +41 -0
  276. data/node_modules/govuk-frontend/govuk/helpers/_grid.scss +61 -0
  277. data/node_modules/govuk-frontend/govuk/helpers/_links.scss +427 -0
  278. data/node_modules/govuk-frontend/govuk/helpers/_media-queries.scss +91 -0
  279. data/node_modules/govuk-frontend/govuk/helpers/_shape-arrow.scss +80 -0
  280. data/node_modules/govuk-frontend/govuk/helpers/_spacing.scss +153 -0
  281. data/node_modules/govuk-frontend/govuk/helpers/_typography.scss +207 -0
  282. data/node_modules/govuk-frontend/govuk/helpers/_visually-hidden.scss +84 -0
  283. data/node_modules/govuk-frontend/govuk/objects/_all.scss +5 -0
  284. data/node_modules/govuk-frontend/govuk/objects/_button-group.scss +101 -0
  285. data/node_modules/govuk-frontend/govuk/objects/_form-group.scss +23 -0
  286. data/node_modules/govuk-frontend/govuk/objects/_grid.scss +24 -0
  287. data/node_modules/govuk-frontend/govuk/objects/_main-wrapper.scss +68 -0
  288. data/node_modules/govuk-frontend/govuk/objects/_width-container.scss +88 -0
  289. data/node_modules/govuk-frontend/govuk/overrides/_all.scss +4 -0
  290. data/node_modules/govuk-frontend/govuk/overrides/_display.scss +30 -0
  291. data/node_modules/govuk-frontend/govuk/overrides/_spacing.scss +64 -0
  292. data/node_modules/govuk-frontend/govuk/overrides/_typography.scss +27 -0
  293. data/node_modules/govuk-frontend/govuk/overrides/_width.scss +52 -0
  294. data/node_modules/govuk-frontend/govuk/settings/_all.scss +23 -0
  295. data/node_modules/govuk-frontend/govuk/settings/_assets.scss +82 -0
  296. data/node_modules/govuk-frontend/govuk/settings/_colours-applied.scss +155 -0
  297. data/node_modules/govuk-frontend/govuk/settings/_colours-organisations.scss +139 -0
  298. data/node_modules/govuk-frontend/govuk/settings/_colours-palette.scss +108 -0
  299. data/node_modules/govuk-frontend/govuk/settings/_compatibility.scss +74 -0
  300. data/node_modules/govuk-frontend/govuk/settings/_global-styles.scss +13 -0
  301. data/node_modules/govuk-frontend/govuk/settings/_ie8.scss +18 -0
  302. data/node_modules/govuk-frontend/govuk/settings/_links.scss +62 -0
  303. data/node_modules/govuk-frontend/govuk/settings/_measurements.scss +105 -0
  304. data/node_modules/govuk-frontend/govuk/settings/_media-queries.scss +23 -0
  305. data/node_modules/govuk-frontend/govuk/settings/_spacing.scss +80 -0
  306. data/node_modules/govuk-frontend/govuk/settings/_typography-font-families.scss +32 -0
  307. data/node_modules/govuk-frontend/govuk/settings/_typography-font.scss +89 -0
  308. data/node_modules/govuk-frontend/govuk/settings/_typography-responsive.scss +183 -0
  309. data/node_modules/govuk-frontend/govuk/template.njk +60 -0
  310. data/node_modules/govuk-frontend/govuk/tools/_all.scss +8 -0
  311. data/node_modules/govuk-frontend/govuk/tools/_compatibility.scss +36 -0
  312. data/node_modules/govuk-frontend/govuk/tools/_exports.scss +33 -0
  313. data/node_modules/govuk-frontend/govuk/tools/_font-url.scss +25 -0
  314. data/node_modules/govuk-frontend/govuk/tools/_ie8.scss +51 -0
  315. data/node_modules/govuk-frontend/govuk/tools/_iff.scss +17 -0
  316. data/node_modules/govuk-frontend/govuk/tools/_image-url.scss +25 -0
  317. data/node_modules/govuk-frontend/govuk/tools/_px-to-em.scss +20 -0
  318. data/node_modules/govuk-frontend/govuk/tools/_px-to-rem.scss +20 -0
  319. data/node_modules/govuk-frontend/govuk/utilities/_all.scss +2 -0
  320. data/node_modules/govuk-frontend/govuk/utilities/_clearfix.scss +5 -0
  321. data/node_modules/govuk-frontend/govuk/utilities/_visually-hidden.scss +9 -0
  322. data/node_modules/govuk-frontend/govuk/vendor/_sass-mq.scss +347 -0
  323. data/node_modules/govuk-frontend/govuk/vendor/polyfills/DOMTokenList.js +272 -0
  324. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Document.js +34 -0
  325. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element.js +147 -0
  326. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/classList.js +589 -0
  327. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/closest.js +54 -0
  328. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/matches.js +31 -0
  329. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/nextElementSibling.js +254 -0
  330. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/previousElementSibling.js +254 -0
  331. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Event.js +504 -0
  332. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Function/prototype/bind.js +252 -0
  333. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Object/defineProperty.js +94 -0
  334. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Window.js +28 -0
  335. data/node_modules/govuk-frontend/package.json +56 -0
  336. data/package-lock.json +13 -0
  337. data/package.json +29 -0
  338. data/vendor/assets/fonts/bold-affa96571d-v2.woff +0 -0
  339. data/vendor/assets/fonts/bold-b542beb274-v2.woff2 +0 -0
  340. data/vendor/assets/fonts/light-94a07e06a1-v2.woff2 +0 -0
  341. data/vendor/assets/fonts/light-f591b13f7d-v2.woff +0 -0
  342. data/vendor/assets/images/favicon.ico +0 -0
  343. data/vendor/assets/images/govuk-apple-touch-icon-152x152.png +0 -0
  344. data/vendor/assets/images/govuk-apple-touch-icon-167x167.png +0 -0
  345. data/vendor/assets/images/govuk-apple-touch-icon-180x180.png +0 -0
  346. data/vendor/assets/images/govuk-apple-touch-icon.png +0 -0
  347. data/vendor/assets/images/govuk-crest-2x.png +0 -0
  348. data/vendor/assets/images/govuk-crest.png +0 -0
  349. data/vendor/assets/images/govuk-logotype-crown.png +0 -0
  350. data/vendor/assets/images/govuk-mask-icon.svg +7 -0
  351. data/vendor/assets/images/govuk-opengraph-image.png +0 -0
  352. data/vendor/assets/javascripts/defra_ruby_template.js +2616 -0
  353. data/vendor/assets/stylesheets/_base.scss +3 -0
  354. data/vendor/assets/stylesheets/all-ie8.scss +6 -0
  355. data/vendor/assets/stylesheets/all.scss +9 -0
  356. data/vendor/assets/stylesheets/components/_all.scss +33 -0
  357. data/vendor/assets/stylesheets/components/accordion/_accordion.scss +2 -0
  358. data/vendor/assets/stylesheets/components/accordion/_index.scss +197 -0
  359. data/vendor/assets/stylesheets/components/back-link/_back-link.scss +2 -0
  360. data/vendor/assets/stylesheets/components/back-link/_index.scss +99 -0
  361. data/vendor/assets/stylesheets/components/breadcrumbs/_breadcrumbs.scss +2 -0
  362. data/vendor/assets/stylesheets/components/breadcrumbs/_index.scss +138 -0
  363. data/vendor/assets/stylesheets/components/button/_button.scss +2 -0
  364. data/vendor/assets/stylesheets/components/button/_index.scss +288 -0
  365. data/vendor/assets/stylesheets/components/character-count/_character-count.scss +2 -0
  366. data/vendor/assets/stylesheets/components/character-count/_index.scss +25 -0
  367. data/vendor/assets/stylesheets/components/checkboxes/_checkboxes.scss +2 -0
  368. data/vendor/assets/stylesheets/components/checkboxes/_index.scss +320 -0
  369. data/vendor/assets/stylesheets/components/cookie-banner/_cookie-banner.scss +2 -0
  370. data/vendor/assets/stylesheets/components/cookie-banner/_index.scss +51 -0
  371. data/vendor/assets/stylesheets/components/date-input/_date-input.scss +2 -0
  372. data/vendor/assets/stylesheets/components/date-input/_index.scss +26 -0
  373. data/vendor/assets/stylesheets/components/details/_details.scss +2 -0
  374. data/vendor/assets/stylesheets/components/details/_index.scss +87 -0
  375. data/vendor/assets/stylesheets/components/error-message/_error-message.scss +2 -0
  376. data/vendor/assets/stylesheets/components/error-message/_index.scss +11 -0
  377. data/vendor/assets/stylesheets/components/error-summary/_error-summary.scss +2 -0
  378. data/vendor/assets/stylesheets/components/error-summary/_index.scss +43 -0
  379. data/vendor/assets/stylesheets/components/fieldset/_fieldset.scss +2 -0
  380. data/vendor/assets/stylesheets/components/fieldset/_index.scss +64 -0
  381. data/vendor/assets/stylesheets/components/file-upload/_file-upload.scss +2 -0
  382. data/vendor/assets/stylesheets/components/file-upload/_index.scss +49 -0
  383. data/vendor/assets/stylesheets/components/footer/_footer.scss +2 -0
  384. data/vendor/assets/stylesheets/components/footer/_index.scss +241 -0
  385. data/vendor/assets/stylesheets/components/header/_header.scss +2 -0
  386. data/vendor/assets/stylesheets/components/header/_index.scss +331 -0
  387. data/vendor/assets/stylesheets/components/hint/_hint.scss +2 -0
  388. data/vendor/assets/stylesheets/components/hint/_index.scss +44 -0
  389. data/vendor/assets/stylesheets/components/input/_index.scss +191 -0
  390. data/vendor/assets/stylesheets/components/input/_input.scss +2 -0
  391. data/vendor/assets/stylesheets/components/inset-text/_index.scss +24 -0
  392. data/vendor/assets/stylesheets/components/inset-text/_inset-text.scss +2 -0
  393. data/vendor/assets/stylesheets/components/label/_index.scss +41 -0
  394. data/vendor/assets/stylesheets/components/label/_label.scss +2 -0
  395. data/vendor/assets/stylesheets/components/notification-banner/_index.scss +89 -0
  396. data/vendor/assets/stylesheets/components/notification-banner/_notification-banner.scss +2 -0
  397. data/vendor/assets/stylesheets/components/panel/_index.scss +44 -0
  398. data/vendor/assets/stylesheets/components/panel/_panel.scss +2 -0
  399. data/vendor/assets/stylesheets/components/phase-banner/_index.scss +27 -0
  400. data/vendor/assets/stylesheets/components/phase-banner/_phase-banner.scss +2 -0
  401. data/vendor/assets/stylesheets/components/radios/_index.scss +342 -0
  402. data/vendor/assets/stylesheets/components/radios/_radios.scss +2 -0
  403. data/vendor/assets/stylesheets/components/select/_index.scss +49 -0
  404. data/vendor/assets/stylesheets/components/select/_select.scss +2 -0
  405. data/vendor/assets/stylesheets/components/skip-link/_index.scss +36 -0
  406. data/vendor/assets/stylesheets/components/skip-link/_skip-link.scss +2 -0
  407. data/vendor/assets/stylesheets/components/summary-list/_index.scss +145 -0
  408. data/vendor/assets/stylesheets/components/summary-list/_summary-list.scss +2 -0
  409. data/vendor/assets/stylesheets/components/table/_index.scss +71 -0
  410. data/vendor/assets/stylesheets/components/table/_table.scss +2 -0
  411. data/vendor/assets/stylesheets/components/tabs/_index.scss +130 -0
  412. data/vendor/assets/stylesheets/components/tabs/_tabs.scss +2 -0
  413. data/vendor/assets/stylesheets/components/tag/_index.scss +86 -0
  414. data/vendor/assets/stylesheets/components/tag/_tag.scss +2 -0
  415. data/vendor/assets/stylesheets/components/textarea/_index.scss +47 -0
  416. data/vendor/assets/stylesheets/components/textarea/_textarea.scss +2 -0
  417. data/vendor/assets/stylesheets/components/warning-text/_index.scss +66 -0
  418. data/vendor/assets/stylesheets/components/warning-text/_warning-text.scss +2 -0
  419. data/vendor/assets/stylesheets/core/_all.scss +6 -0
  420. data/vendor/assets/stylesheets/core/_global-styles.scss +25 -0
  421. data/vendor/assets/stylesheets/core/_links.scss +41 -0
  422. data/vendor/assets/stylesheets/core/_lists.scss +72 -0
  423. data/vendor/assets/stylesheets/core/_section-break.scss +62 -0
  424. data/vendor/assets/stylesheets/core/_template.scss +36 -0
  425. data/vendor/assets/stylesheets/core/_typography.scss +192 -0
  426. data/vendor/assets/stylesheets/defra_ruby_template.scss +16 -0
  427. data/vendor/assets/stylesheets/helpers/_all.scss +12 -0
  428. data/vendor/assets/stylesheets/helpers/_clearfix.scss +15 -0
  429. data/vendor/assets/stylesheets/helpers/_colour.scss +95 -0
  430. data/vendor/assets/stylesheets/helpers/_device-pixels.scss +37 -0
  431. data/vendor/assets/stylesheets/helpers/_focused.scss +28 -0
  432. data/vendor/assets/stylesheets/helpers/_font-faces.scss +41 -0
  433. data/vendor/assets/stylesheets/helpers/_grid.scss +61 -0
  434. data/vendor/assets/stylesheets/helpers/_links.scss +427 -0
  435. data/vendor/assets/stylesheets/helpers/_media-queries.scss +91 -0
  436. data/vendor/assets/stylesheets/helpers/_shape-arrow.scss +80 -0
  437. data/vendor/assets/stylesheets/helpers/_spacing.scss +153 -0
  438. data/vendor/assets/stylesheets/helpers/_typography.scss +207 -0
  439. data/vendor/assets/stylesheets/helpers/_visually-hidden.scss +84 -0
  440. data/vendor/assets/stylesheets/objects/_all.scss +5 -0
  441. data/vendor/assets/stylesheets/objects/_button-group.scss +101 -0
  442. data/vendor/assets/stylesheets/objects/_form-group.scss +23 -0
  443. data/vendor/assets/stylesheets/objects/_grid.scss +24 -0
  444. data/vendor/assets/stylesheets/objects/_main-wrapper.scss +68 -0
  445. data/vendor/assets/stylesheets/objects/_width-container.scss +88 -0
  446. data/vendor/assets/stylesheets/overrides/_all.scss +4 -0
  447. data/vendor/assets/stylesheets/overrides/_display.scss +30 -0
  448. data/vendor/assets/stylesheets/overrides/_spacing.scss +64 -0
  449. data/vendor/assets/stylesheets/overrides/_typography.scss +27 -0
  450. data/vendor/assets/stylesheets/overrides/_width.scss +52 -0
  451. data/vendor/assets/stylesheets/settings/_all.scss +23 -0
  452. data/vendor/assets/stylesheets/settings/_assets.scss +82 -0
  453. data/vendor/assets/stylesheets/settings/_colours-applied.scss +155 -0
  454. data/vendor/assets/stylesheets/settings/_colours-organisations.scss +139 -0
  455. data/vendor/assets/stylesheets/settings/_colours-palette.scss +108 -0
  456. data/vendor/assets/stylesheets/settings/_compatibility.scss +74 -0
  457. data/vendor/assets/stylesheets/settings/_global-styles.scss +13 -0
  458. data/vendor/assets/stylesheets/settings/_ie8.scss +18 -0
  459. data/vendor/assets/stylesheets/settings/_links.scss +62 -0
  460. data/vendor/assets/stylesheets/settings/_measurements.scss +105 -0
  461. data/vendor/assets/stylesheets/settings/_media-queries.scss +23 -0
  462. data/vendor/assets/stylesheets/settings/_spacing.scss +80 -0
  463. data/vendor/assets/stylesheets/settings/_typography-font-families.scss +32 -0
  464. data/vendor/assets/stylesheets/settings/_typography-font.scss +89 -0
  465. data/vendor/assets/stylesheets/settings/_typography-responsive.scss +183 -0
  466. data/vendor/assets/stylesheets/tools/_all.scss +8 -0
  467. data/vendor/assets/stylesheets/tools/_compatibility.scss +36 -0
  468. data/vendor/assets/stylesheets/tools/_exports.scss +33 -0
  469. data/vendor/assets/stylesheets/tools/_font-url.scss +25 -0
  470. data/vendor/assets/stylesheets/tools/_ie8.scss +51 -0
  471. data/vendor/assets/stylesheets/tools/_iff.scss +17 -0
  472. data/vendor/assets/stylesheets/tools/_image-url.scss +25 -0
  473. data/vendor/assets/stylesheets/tools/_px-to-em.scss +20 -0
  474. data/vendor/assets/stylesheets/tools/_px-to-rem.scss +20 -0
  475. data/vendor/assets/stylesheets/utilities/_all.scss +2 -0
  476. data/vendor/assets/stylesheets/utilities/_clearfix.scss +5 -0
  477. data/vendor/assets/stylesheets/utilities/_visually-hidden.scss +9 -0
  478. data/vendor/assets/stylesheets/vendor/_sass-mq.scss +347 -0
  479. metadata +520 -0
@@ -0,0 +1,3 @@
1
+ @import "settings/all";
2
+ @import "tools/all";
3
+ @import "helpers/all";
@@ -0,0 +1,6 @@
1
+ // By setting $govuk-is-ie8 to true, we create a version of the stylesheet that
2
+ // targets IE8 – e.g. conditionally including or excluding styles, and
3
+ // rasterizing media queries.
4
+ $govuk-is-ie8: true;
5
+
6
+ @import "all";
@@ -0,0 +1,2616 @@
1
+ (function (global, factory) {
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
3
+ typeof define === 'function' && define.amd ? define('GOVUKFrontend', ['exports'], factory) :
4
+ (factory((global.GOVUKFrontend = {})));
5
+ }(this, (function (exports) { 'use strict';
6
+
7
+ /**
8
+ * TODO: Ideally this would be a NodeList.prototype.forEach polyfill
9
+ * This seems to fail in IE8, requires more investigation.
10
+ * See: https://github.com/imagitama/nodelist-foreach-polyfill
11
+ */
12
+ function nodeListForEach (nodes, callback) {
13
+ if (window.NodeList.prototype.forEach) {
14
+ return nodes.forEach(callback)
15
+ }
16
+ for (var i = 0; i < nodes.length; i++) {
17
+ callback.call(window, nodes[i], i, nodes);
18
+ }
19
+ }
20
+
21
+ // Used to generate a unique string, allows multiple instances of the component without
22
+ // Them conflicting with each other.
23
+ // https://stackoverflow.com/a/8809472
24
+ function generateUniqueID () {
25
+ var d = new Date().getTime();
26
+ if (typeof window.performance !== 'undefined' && typeof window.performance.now === 'function') {
27
+ d += window.performance.now(); // use high-precision timer if available
28
+ }
29
+ return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
30
+ var r = (d + Math.random() * 16) % 16 | 0;
31
+ d = Math.floor(d / 16);
32
+ return (c === 'x' ? r : (r & 0x3 | 0x8)).toString(16)
33
+ })
34
+ }
35
+
36
+ (function(undefined) {
37
+
38
+ // Detection from https://github.com/Financial-Times/polyfill-service/blob/master/packages/polyfill-library/polyfills/Object/defineProperty/detect.js
39
+ var detect = (
40
+ // In IE8, defineProperty could only act on DOM elements, so full support
41
+ // for the feature requires the ability to set a property on an arbitrary object
42
+ 'defineProperty' in Object && (function() {
43
+ try {
44
+ var a = {};
45
+ Object.defineProperty(a, 'test', {value:42});
46
+ return true;
47
+ } catch(e) {
48
+ return false
49
+ }
50
+ }())
51
+ );
52
+
53
+ if (detect) return
54
+
55
+ // Polyfill from https://cdn.polyfill.io/v2/polyfill.js?features=Object.defineProperty&flags=always
56
+ (function (nativeDefineProperty) {
57
+
58
+ var supportsAccessors = Object.prototype.hasOwnProperty('__defineGetter__');
59
+ var ERR_ACCESSORS_NOT_SUPPORTED = 'Getters & setters cannot be defined on this javascript engine';
60
+ var ERR_VALUE_ACCESSORS = 'A property cannot both have accessors and be writable or have a value';
61
+
62
+ Object.defineProperty = function defineProperty(object, property, descriptor) {
63
+
64
+ // Where native support exists, assume it
65
+ if (nativeDefineProperty && (object === window || object === document || object === Element.prototype || object instanceof Element)) {
66
+ return nativeDefineProperty(object, property, descriptor);
67
+ }
68
+
69
+ if (object === null || !(object instanceof Object || typeof object === 'object')) {
70
+ throw new TypeError('Object.defineProperty called on non-object');
71
+ }
72
+
73
+ if (!(descriptor instanceof Object)) {
74
+ throw new TypeError('Property description must be an object');
75
+ }
76
+
77
+ var propertyString = String(property);
78
+ var hasValueOrWritable = 'value' in descriptor || 'writable' in descriptor;
79
+ var getterType = 'get' in descriptor && typeof descriptor.get;
80
+ var setterType = 'set' in descriptor && typeof descriptor.set;
81
+
82
+ // handle descriptor.get
83
+ if (getterType) {
84
+ if (getterType !== 'function') {
85
+ throw new TypeError('Getter must be a function');
86
+ }
87
+ if (!supportsAccessors) {
88
+ throw new TypeError(ERR_ACCESSORS_NOT_SUPPORTED);
89
+ }
90
+ if (hasValueOrWritable) {
91
+ throw new TypeError(ERR_VALUE_ACCESSORS);
92
+ }
93
+ Object.__defineGetter__.call(object, propertyString, descriptor.get);
94
+ } else {
95
+ object[propertyString] = descriptor.value;
96
+ }
97
+
98
+ // handle descriptor.set
99
+ if (setterType) {
100
+ if (setterType !== 'function') {
101
+ throw new TypeError('Setter must be a function');
102
+ }
103
+ if (!supportsAccessors) {
104
+ throw new TypeError(ERR_ACCESSORS_NOT_SUPPORTED);
105
+ }
106
+ if (hasValueOrWritable) {
107
+ throw new TypeError(ERR_VALUE_ACCESSORS);
108
+ }
109
+ Object.__defineSetter__.call(object, propertyString, descriptor.set);
110
+ }
111
+
112
+ // OK to define value unconditionally - if a getter has been specified as well, an error would be thrown above
113
+ if ('value' in descriptor) {
114
+ object[propertyString] = descriptor.value;
115
+ }
116
+
117
+ return object;
118
+ };
119
+ }(Object.defineProperty));
120
+ })
121
+ .call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
122
+
123
+ (function(undefined) {
124
+ // Detection from https://github.com/Financial-Times/polyfill-service/blob/master/packages/polyfill-library/polyfills/Function/prototype/bind/detect.js
125
+ var detect = 'bind' in Function.prototype;
126
+
127
+ if (detect) return
128
+
129
+ // Polyfill from https://cdn.polyfill.io/v2/polyfill.js?features=Function.prototype.bind&flags=always
130
+ Object.defineProperty(Function.prototype, 'bind', {
131
+ value: function bind(that) { // .length is 1
132
+ // add necessary es5-shim utilities
133
+ var $Array = Array;
134
+ var $Object = Object;
135
+ var ObjectPrototype = $Object.prototype;
136
+ var ArrayPrototype = $Array.prototype;
137
+ var Empty = function Empty() {};
138
+ var to_string = ObjectPrototype.toString;
139
+ var hasToStringTag = typeof Symbol === 'function' && typeof Symbol.toStringTag === 'symbol';
140
+ 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; };
141
+ var array_slice = ArrayPrototype.slice;
142
+ var array_concat = ArrayPrototype.concat;
143
+ var array_push = ArrayPrototype.push;
144
+ var max = Math.max;
145
+ // /add necessary es5-shim utilities
146
+
147
+ // 1. Let Target be the this value.
148
+ var target = this;
149
+ // 2. If IsCallable(Target) is false, throw a TypeError exception.
150
+ if (!isCallable(target)) {
151
+ throw new TypeError('Function.prototype.bind called on incompatible ' + target);
152
+ }
153
+ // 3. Let A be a new (possibly empty) internal list of all of the
154
+ // argument values provided after thisArg (arg1, arg2 etc), in order.
155
+ // XXX slicedArgs will stand in for "A" if used
156
+ var args = array_slice.call(arguments, 1); // for normal call
157
+ // 4. Let F be a new native ECMAScript object.
158
+ // 11. Set the [[Prototype]] internal property of F to the standard
159
+ // built-in Function prototype object as specified in 15.3.3.1.
160
+ // 12. Set the [[Call]] internal property of F as described in
161
+ // 15.3.4.5.1.
162
+ // 13. Set the [[Construct]] internal property of F as described in
163
+ // 15.3.4.5.2.
164
+ // 14. Set the [[HasInstance]] internal property of F as described in
165
+ // 15.3.4.5.3.
166
+ var bound;
167
+ var binder = function () {
168
+
169
+ if (this instanceof bound) {
170
+ // 15.3.4.5.2 [[Construct]]
171
+ // When the [[Construct]] internal method of a function object,
172
+ // F that was created using the bind function is called with a
173
+ // list of arguments ExtraArgs, the following steps are taken:
174
+ // 1. Let target be the value of F's [[TargetFunction]]
175
+ // internal property.
176
+ // 2. If target has no [[Construct]] internal method, a
177
+ // TypeError exception is thrown.
178
+ // 3. Let boundArgs be the value of F's [[BoundArgs]] internal
179
+ // property.
180
+ // 4. Let args be a new list containing the same values as the
181
+ // list boundArgs in the same order followed by the same
182
+ // values as the list ExtraArgs in the same order.
183
+ // 5. Return the result of calling the [[Construct]] internal
184
+ // method of target providing args as the arguments.
185
+
186
+ var result = target.apply(
187
+ this,
188
+ array_concat.call(args, array_slice.call(arguments))
189
+ );
190
+ if ($Object(result) === result) {
191
+ return result;
192
+ }
193
+ return this;
194
+
195
+ } else {
196
+ // 15.3.4.5.1 [[Call]]
197
+ // When the [[Call]] internal method of a function object, F,
198
+ // which was created using the bind function is called with a
199
+ // this value and a list of arguments ExtraArgs, the following
200
+ // steps are taken:
201
+ // 1. Let boundArgs be the value of F's [[BoundArgs]] internal
202
+ // property.
203
+ // 2. Let boundThis be the value of F's [[BoundThis]] internal
204
+ // property.
205
+ // 3. Let target be the value of F's [[TargetFunction]] internal
206
+ // property.
207
+ // 4. Let args be a new list containing the same values as the
208
+ // list boundArgs in the same order followed by the same
209
+ // values as the list ExtraArgs in the same order.
210
+ // 5. Return the result of calling the [[Call]] internal method
211
+ // of target providing boundThis as the this value and
212
+ // providing args as the arguments.
213
+
214
+ // equiv: target.call(this, ...boundArgs, ...args)
215
+ return target.apply(
216
+ that,
217
+ array_concat.call(args, array_slice.call(arguments))
218
+ );
219
+
220
+ }
221
+
222
+ };
223
+
224
+ // 15. If the [[Class]] internal property of Target is "Function", then
225
+ // a. Let L be the length property of Target minus the length of A.
226
+ // b. Set the length own property of F to either 0 or L, whichever is
227
+ // larger.
228
+ // 16. Else set the length own property of F to 0.
229
+
230
+ var boundLength = max(0, target.length - args.length);
231
+
232
+ // 17. Set the attributes of the length own property of F to the values
233
+ // specified in 15.3.5.1.
234
+ var boundArgs = [];
235
+ for (var i = 0; i < boundLength; i++) {
236
+ array_push.call(boundArgs, '$' + i);
237
+ }
238
+
239
+ // XXX Build a dynamic function with desired amount of arguments is the only
240
+ // way to set the length property of a function.
241
+ // In environments where Content Security Policies enabled (Chrome extensions,
242
+ // for ex.) all use of eval or Function costructor throws an exception.
243
+ // However in all of these environments Function.prototype.bind exists
244
+ // and so this code will never be executed.
245
+ bound = Function('binder', 'return function (' + boundArgs.join(',') + '){ return binder.apply(this, arguments); }')(binder);
246
+
247
+ if (target.prototype) {
248
+ Empty.prototype = target.prototype;
249
+ bound.prototype = new Empty();
250
+ // Clean up dangling references.
251
+ Empty.prototype = null;
252
+ }
253
+
254
+ // TODO
255
+ // 18. Set the [[Extensible]] internal property of F to true.
256
+
257
+ // TODO
258
+ // 19. Let thrower be the [[ThrowTypeError]] function Object (13.2.3).
259
+ // 20. Call the [[DefineOwnProperty]] internal method of F with
260
+ // arguments "caller", PropertyDescriptor {[[Get]]: thrower, [[Set]]:
261
+ // thrower, [[Enumerable]]: false, [[Configurable]]: false}, and
262
+ // false.
263
+ // 21. Call the [[DefineOwnProperty]] internal method of F with
264
+ // arguments "arguments", PropertyDescriptor {[[Get]]: thrower,
265
+ // [[Set]]: thrower, [[Enumerable]]: false, [[Configurable]]: false},
266
+ // and false.
267
+
268
+ // TODO
269
+ // NOTE Function objects created using Function.prototype.bind do not
270
+ // have a prototype property or the [[Code]], [[FormalParameters]], and
271
+ // [[Scope]] internal properties.
272
+ // XXX can't delete prototype in pure-js.
273
+
274
+ // 22. Return F.
275
+ return bound;
276
+ }
277
+ });
278
+ })
279
+ .call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
280
+
281
+ (function(undefined) {
282
+
283
+ // Detection from https://raw.githubusercontent.com/Financial-Times/polyfill-service/master/packages/polyfill-library/polyfills/DOMTokenList/detect.js
284
+ var detect = (
285
+ 'DOMTokenList' in this && (function (x) {
286
+ return 'classList' in x ? !x.classList.toggle('x', false) && !x.className : true;
287
+ })(document.createElement('x'))
288
+ );
289
+
290
+ if (detect) return
291
+
292
+ // Polyfill from https://raw.githubusercontent.com/Financial-Times/polyfill-service/master/packages/polyfill-library/polyfills/DOMTokenList/polyfill.js
293
+ (function (global) {
294
+ var nativeImpl = "DOMTokenList" in global && global.DOMTokenList;
295
+
296
+ if (
297
+ !nativeImpl ||
298
+ (
299
+ !!document.createElementNS &&
300
+ !!document.createElementNS('http://www.w3.org/2000/svg', 'svg') &&
301
+ !(document.createElementNS("http://www.w3.org/2000/svg", "svg").classList instanceof DOMTokenList)
302
+ )
303
+ ) {
304
+ global.DOMTokenList = (function() { // eslint-disable-line no-unused-vars
305
+ var dpSupport = true;
306
+ var defineGetter = function (object, name, fn, configurable) {
307
+ if (Object.defineProperty)
308
+ Object.defineProperty(object, name, {
309
+ configurable: false === dpSupport ? true : !!configurable,
310
+ get: fn
311
+ });
312
+
313
+ else object.__defineGetter__(name, fn);
314
+ };
315
+
316
+ /** Ensure the browser allows Object.defineProperty to be used on native JavaScript objects. */
317
+ try {
318
+ defineGetter({}, "support");
319
+ }
320
+ catch (e) {
321
+ dpSupport = false;
322
+ }
323
+
324
+
325
+ var _DOMTokenList = function (el, prop) {
326
+ var that = this;
327
+ var tokens = [];
328
+ var tokenMap = {};
329
+ var length = 0;
330
+ var maxLength = 0;
331
+ var addIndexGetter = function (i) {
332
+ defineGetter(that, i, function () {
333
+ preop();
334
+ return tokens[i];
335
+ }, false);
336
+
337
+ };
338
+ var reindex = function () {
339
+
340
+ /** Define getter functions for array-like access to the tokenList's contents. */
341
+ if (length >= maxLength)
342
+ for (; maxLength < length; ++maxLength) {
343
+ addIndexGetter(maxLength);
344
+ }
345
+ };
346
+
347
+ /** Helper function called at the start of each class method. Internal use only. */
348
+ var preop = function () {
349
+ var error;
350
+ var i;
351
+ var args = arguments;
352
+ var rSpace = /\s+/;
353
+
354
+ /** Validate the token/s passed to an instance method, if any. */
355
+ if (args.length)
356
+ for (i = 0; i < args.length; ++i)
357
+ if (rSpace.test(args[i])) {
358
+ error = new SyntaxError('String "' + args[i] + '" ' + "contains" + ' an invalid character');
359
+ error.code = 5;
360
+ error.name = "InvalidCharacterError";
361
+ throw error;
362
+ }
363
+
364
+
365
+ /** Split the new value apart by whitespace*/
366
+ if (typeof el[prop] === "object") {
367
+ tokens = ("" + el[prop].baseVal).replace(/^\s+|\s+$/g, "").split(rSpace);
368
+ } else {
369
+ tokens = ("" + el[prop]).replace(/^\s+|\s+$/g, "").split(rSpace);
370
+ }
371
+
372
+ /** Avoid treating blank strings as single-item token lists */
373
+ if ("" === tokens[0]) tokens = [];
374
+
375
+ /** Repopulate the internal token lists */
376
+ tokenMap = {};
377
+ for (i = 0; i < tokens.length; ++i)
378
+ tokenMap[tokens[i]] = true;
379
+ length = tokens.length;
380
+ reindex();
381
+ };
382
+
383
+ /** Populate our internal token list if the targeted attribute of the subject element isn't empty. */
384
+ preop();
385
+
386
+ /** Return the number of tokens in the underlying string. Read-only. */
387
+ defineGetter(that, "length", function () {
388
+ preop();
389
+ return length;
390
+ });
391
+
392
+ /** Override the default toString/toLocaleString methods to return a space-delimited list of tokens when typecast. */
393
+ that.toLocaleString =
394
+ that.toString = function () {
395
+ preop();
396
+ return tokens.join(" ");
397
+ };
398
+
399
+ that.item = function (idx) {
400
+ preop();
401
+ return tokens[idx];
402
+ };
403
+
404
+ that.contains = function (token) {
405
+ preop();
406
+ return !!tokenMap[token];
407
+ };
408
+
409
+ that.add = function () {
410
+ preop.apply(that, args = arguments);
411
+
412
+ for (var args, token, i = 0, l = args.length; i < l; ++i) {
413
+ token = args[i];
414
+ if (!tokenMap[token]) {
415
+ tokens.push(token);
416
+ tokenMap[token] = true;
417
+ }
418
+ }
419
+
420
+ /** Update the targeted attribute of the attached element if the token list's changed. */
421
+ if (length !== tokens.length) {
422
+ length = tokens.length >>> 0;
423
+ if (typeof el[prop] === "object") {
424
+ el[prop].baseVal = tokens.join(" ");
425
+ } else {
426
+ el[prop] = tokens.join(" ");
427
+ }
428
+ reindex();
429
+ }
430
+ };
431
+
432
+ that.remove = function () {
433
+ preop.apply(that, args = arguments);
434
+
435
+ /** Build a hash of token names to compare against when recollecting our token list. */
436
+ for (var args, ignore = {}, i = 0, t = []; i < args.length; ++i) {
437
+ ignore[args[i]] = true;
438
+ delete tokenMap[args[i]];
439
+ }
440
+
441
+ /** Run through our tokens list and reassign only those that aren't defined in the hash declared above. */
442
+ for (i = 0; i < tokens.length; ++i)
443
+ if (!ignore[tokens[i]]) t.push(tokens[i]);
444
+
445
+ tokens = t;
446
+ length = t.length >>> 0;
447
+
448
+ /** Update the targeted attribute of the attached element. */
449
+ if (typeof el[prop] === "object") {
450
+ el[prop].baseVal = tokens.join(" ");
451
+ } else {
452
+ el[prop] = tokens.join(" ");
453
+ }
454
+ reindex();
455
+ };
456
+
457
+ that.toggle = function (token, force) {
458
+ preop.apply(that, [token]);
459
+
460
+ /** Token state's being forced. */
461
+ if (undefined !== force) {
462
+ if (force) {
463
+ that.add(token);
464
+ return true;
465
+ } else {
466
+ that.remove(token);
467
+ return false;
468
+ }
469
+ }
470
+
471
+ /** Token already exists in tokenList. Remove it, and return FALSE. */
472
+ if (tokenMap[token]) {
473
+ that.remove(token);
474
+ return false;
475
+ }
476
+
477
+ /** Otherwise, add the token and return TRUE. */
478
+ that.add(token);
479
+ return true;
480
+ };
481
+
482
+ return that;
483
+ };
484
+
485
+ return _DOMTokenList;
486
+ }());
487
+ }
488
+
489
+ // Add second argument to native DOMTokenList.toggle() if necessary
490
+ (function () {
491
+ var e = document.createElement('span');
492
+ if (!('classList' in e)) return;
493
+ e.classList.toggle('x', false);
494
+ if (!e.classList.contains('x')) return;
495
+ e.classList.constructor.prototype.toggle = function toggle(token /*, force*/) {
496
+ var force = arguments[1];
497
+ if (force === undefined) {
498
+ var add = !this.contains(token);
499
+ this[add ? 'add' : 'remove'](token);
500
+ return add;
501
+ }
502
+ force = !!force;
503
+ this[force ? 'add' : 'remove'](token);
504
+ return force;
505
+ };
506
+ }());
507
+
508
+ // Add multiple arguments to native DOMTokenList.add() if necessary
509
+ (function () {
510
+ var e = document.createElement('span');
511
+ if (!('classList' in e)) return;
512
+ e.classList.add('a', 'b');
513
+ if (e.classList.contains('b')) return;
514
+ var native = e.classList.constructor.prototype.add;
515
+ e.classList.constructor.prototype.add = function () {
516
+ var args = arguments;
517
+ var l = arguments.length;
518
+ for (var i = 0; i < l; i++) {
519
+ native.call(this, args[i]);
520
+ }
521
+ };
522
+ }());
523
+
524
+ // Add multiple arguments to native DOMTokenList.remove() if necessary
525
+ (function () {
526
+ var e = document.createElement('span');
527
+ if (!('classList' in e)) return;
528
+ e.classList.add('a');
529
+ e.classList.add('b');
530
+ e.classList.remove('a', 'b');
531
+ if (!e.classList.contains('b')) return;
532
+ var native = e.classList.constructor.prototype.remove;
533
+ e.classList.constructor.prototype.remove = function () {
534
+ var args = arguments;
535
+ var l = arguments.length;
536
+ for (var i = 0; i < l; i++) {
537
+ native.call(this, args[i]);
538
+ }
539
+ };
540
+ }());
541
+
542
+ }(this));
543
+
544
+ }).call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
545
+
546
+ (function(undefined) {
547
+
548
+ // Detection from https://github.com/Financial-Times/polyfill-service/blob/master/packages/polyfill-library/polyfills/Document/detect.js
549
+ var detect = ("Document" in this);
550
+
551
+ if (detect) return
552
+
553
+ // Polyfill from https://cdn.polyfill.io/v2/polyfill.js?features=Document&flags=always
554
+ if ((typeof WorkerGlobalScope === "undefined") && (typeof importScripts !== "function")) {
555
+
556
+ if (this.HTMLDocument) { // IE8
557
+
558
+ // HTMLDocument is an extension of Document. If the browser has HTMLDocument but not Document, the former will suffice as an alias for the latter.
559
+ this.Document = this.HTMLDocument;
560
+
561
+ } else {
562
+
563
+ // 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.
564
+ this.Document = this.HTMLDocument = document.constructor = (new Function('return function Document() {}')());
565
+ this.Document.prototype = document;
566
+ }
567
+ }
568
+
569
+
570
+ })
571
+ .call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
572
+
573
+ (function(undefined) {
574
+
575
+ // Detection from https://github.com/Financial-Times/polyfill-service/blob/master/packages/polyfill-library/polyfills/Element/detect.js
576
+ var detect = ('Element' in this && 'HTMLElement' in this);
577
+
578
+ if (detect) return
579
+
580
+ // Polyfill from https://cdn.polyfill.io/v2/polyfill.js?features=Element&flags=always
581
+ (function () {
582
+
583
+ // IE8
584
+ if (window.Element && !window.HTMLElement) {
585
+ window.HTMLElement = window.Element;
586
+ return;
587
+ }
588
+
589
+ // create Element constructor
590
+ window.Element = window.HTMLElement = new Function('return function Element() {}')();
591
+
592
+ // generate sandboxed iframe
593
+ var vbody = document.appendChild(document.createElement('body'));
594
+ var frame = vbody.appendChild(document.createElement('iframe'));
595
+
596
+ // use sandboxed iframe to replicate Element functionality
597
+ var frameDocument = frame.contentWindow.document;
598
+ var prototype = Element.prototype = frameDocument.appendChild(frameDocument.createElement('*'));
599
+ var cache = {};
600
+
601
+ // polyfill Element.prototype on an element
602
+ var shiv = function (element, deep) {
603
+ var
604
+ childNodes = element.childNodes || [],
605
+ index = -1,
606
+ key, value, childNode;
607
+
608
+ if (element.nodeType === 1 && element.constructor !== Element) {
609
+ element.constructor = Element;
610
+
611
+ for (key in cache) {
612
+ value = cache[key];
613
+ element[key] = value;
614
+ }
615
+ }
616
+
617
+ while (childNode = deep && childNodes[++index]) {
618
+ shiv(childNode, deep);
619
+ }
620
+
621
+ return element;
622
+ };
623
+
624
+ var elements = document.getElementsByTagName('*');
625
+ var nativeCreateElement = document.createElement;
626
+ var interval;
627
+ var loopLimit = 100;
628
+
629
+ prototype.attachEvent('onpropertychange', function (event) {
630
+ var
631
+ propertyName = event.propertyName,
632
+ nonValue = !cache.hasOwnProperty(propertyName),
633
+ newValue = prototype[propertyName],
634
+ oldValue = cache[propertyName],
635
+ index = -1,
636
+ element;
637
+
638
+ while (element = elements[++index]) {
639
+ if (element.nodeType === 1) {
640
+ if (nonValue || element[propertyName] === oldValue) {
641
+ element[propertyName] = newValue;
642
+ }
643
+ }
644
+ }
645
+
646
+ cache[propertyName] = newValue;
647
+ });
648
+
649
+ prototype.constructor = Element;
650
+
651
+ if (!prototype.hasAttribute) {
652
+ // <Element>.hasAttribute
653
+ prototype.hasAttribute = function hasAttribute(name) {
654
+ return this.getAttribute(name) !== null;
655
+ };
656
+ }
657
+
658
+ // Apply Element prototype to the pre-existing DOM as soon as the body element appears.
659
+ function bodyCheck() {
660
+ if (!(loopLimit--)) clearTimeout(interval);
661
+ if (document.body && !document.body.prototype && /(complete|interactive)/.test(document.readyState)) {
662
+ shiv(document, true);
663
+ if (interval && document.body.prototype) clearTimeout(interval);
664
+ return (!!document.body.prototype);
665
+ }
666
+ return false;
667
+ }
668
+ if (!bodyCheck()) {
669
+ document.onreadystatechange = bodyCheck;
670
+ interval = setInterval(bodyCheck, 25);
671
+ }
672
+
673
+ // Apply to any new elements created after load
674
+ document.createElement = function createElement(nodeName) {
675
+ var element = nativeCreateElement(String(nodeName).toLowerCase());
676
+ return shiv(element);
677
+ };
678
+
679
+ // remove sandboxed iframe
680
+ document.removeChild(vbody);
681
+ }());
682
+
683
+ })
684
+ .call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
685
+
686
+ (function(undefined) {
687
+
688
+ // Detection from https://raw.githubusercontent.com/Financial-Times/polyfill-service/8717a9e04ac7aff99b4980fbedead98036b0929a/packages/polyfill-library/polyfills/Element/prototype/classList/detect.js
689
+ var detect = (
690
+ 'document' in this && "classList" in document.documentElement && 'Element' in this && 'classList' in Element.prototype && (function () {
691
+ var e = document.createElement('span');
692
+ e.classList.add('a', 'b');
693
+ return e.classList.contains('b');
694
+ }())
695
+ );
696
+
697
+ if (detect) return
698
+
699
+ // Polyfill from https://cdn.polyfill.io/v2/polyfill.js?features=Element.prototype.classList&flags=always
700
+ (function (global) {
701
+ var dpSupport = true;
702
+ var defineGetter = function (object, name, fn, configurable) {
703
+ if (Object.defineProperty)
704
+ Object.defineProperty(object, name, {
705
+ configurable: false === dpSupport ? true : !!configurable,
706
+ get: fn
707
+ });
708
+
709
+ else object.__defineGetter__(name, fn);
710
+ };
711
+ /** Ensure the browser allows Object.defineProperty to be used on native JavaScript objects. */
712
+ try {
713
+ defineGetter({}, "support");
714
+ }
715
+ catch (e) {
716
+ dpSupport = false;
717
+ }
718
+ /** Polyfills a property with a DOMTokenList */
719
+ var addProp = function (o, name, attr) {
720
+
721
+ defineGetter(o.prototype, name, function () {
722
+ var tokenList;
723
+
724
+ var THIS = this,
725
+
726
+ /** Prevent this from firing twice for some reason. What the hell, IE. */
727
+ gibberishProperty = "__defineGetter__" + "DEFINE_PROPERTY" + name;
728
+ if(THIS[gibberishProperty]) return tokenList;
729
+ THIS[gibberishProperty] = true;
730
+
731
+ /**
732
+ * IE8 can't define properties on native JavaScript objects, so we'll use a dumb hack instead.
733
+ *
734
+ * What this is doing is creating a dummy element ("reflection") inside a detached phantom node ("mirror")
735
+ * that serves as the target of Object.defineProperty instead. While we could simply use the subject HTML
736
+ * element instead, this would conflict with element types which use indexed properties (such as forms and
737
+ * select lists).
738
+ */
739
+ if (false === dpSupport) {
740
+
741
+ var visage;
742
+ var mirror = addProp.mirror || document.createElement("div");
743
+ var reflections = mirror.childNodes;
744
+ var l = reflections.length;
745
+
746
+ for (var i = 0; i < l; ++i)
747
+ if (reflections[i]._R === THIS) {
748
+ visage = reflections[i];
749
+ break;
750
+ }
751
+
752
+ /** Couldn't find an element's reflection inside the mirror. Materialise one. */
753
+ visage || (visage = mirror.appendChild(document.createElement("div")));
754
+
755
+ tokenList = DOMTokenList.call(visage, THIS, attr);
756
+ } else tokenList = new DOMTokenList(THIS, attr);
757
+
758
+ defineGetter(THIS, name, function () {
759
+ return tokenList;
760
+ });
761
+ delete THIS[gibberishProperty];
762
+
763
+ return tokenList;
764
+ }, true);
765
+ };
766
+
767
+ addProp(global.Element, "classList", "className");
768
+ addProp(global.HTMLElement, "classList", "className");
769
+ addProp(global.HTMLLinkElement, "relList", "rel");
770
+ addProp(global.HTMLAnchorElement, "relList", "rel");
771
+ addProp(global.HTMLAreaElement, "relList", "rel");
772
+ }(this));
773
+
774
+ }).call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
775
+
776
+ function Accordion ($module) {
777
+ this.$module = $module;
778
+ this.moduleId = $module.getAttribute('id');
779
+ this.$sections = $module.querySelectorAll('.govuk-accordion__section');
780
+ this.$openAllButton = '';
781
+ this.browserSupportsSessionStorage = helper.checkForSessionStorage();
782
+
783
+ this.controlsClass = 'govuk-accordion__controls';
784
+ this.openAllClass = 'govuk-accordion__open-all';
785
+ this.iconClass = 'govuk-accordion__icon';
786
+
787
+ this.sectionHeaderClass = 'govuk-accordion__section-header';
788
+ this.sectionHeaderFocusedClass = 'govuk-accordion__section-header--focused';
789
+ this.sectionHeadingClass = 'govuk-accordion__section-heading';
790
+ this.sectionSummaryClass = 'govuk-accordion__section-summary';
791
+ this.sectionButtonClass = 'govuk-accordion__section-button';
792
+ this.sectionExpandedClass = 'govuk-accordion__section--expanded';
793
+ }
794
+
795
+ // Initialize component
796
+ Accordion.prototype.init = function () {
797
+ // Check for module
798
+ if (!this.$module) {
799
+ return
800
+ }
801
+
802
+ this.initControls();
803
+
804
+ this.initSectionHeaders();
805
+
806
+ // See if "Open all" button text should be updated
807
+ var areAllSectionsOpen = this.checkIfAllSectionsOpen();
808
+ this.updateOpenAllButton(areAllSectionsOpen);
809
+ };
810
+
811
+ // Initialise controls and set attributes
812
+ Accordion.prototype.initControls = function () {
813
+ // Create "Open all" button and set attributes
814
+ this.$openAllButton = document.createElement('button');
815
+ this.$openAllButton.setAttribute('type', 'button');
816
+ this.$openAllButton.innerHTML = 'Open all <span class="govuk-visually-hidden">sections</span>';
817
+ this.$openAllButton.setAttribute('class', this.openAllClass);
818
+ this.$openAllButton.setAttribute('aria-expanded', 'false');
819
+ this.$openAllButton.setAttribute('type', 'button');
820
+
821
+ // Create control wrapper and add controls to it
822
+ var accordionControls = document.createElement('div');
823
+ accordionControls.setAttribute('class', this.controlsClass);
824
+ accordionControls.appendChild(this.$openAllButton);
825
+ this.$module.insertBefore(accordionControls, this.$module.firstChild);
826
+
827
+ // Handle events for the controls
828
+ this.$openAllButton.addEventListener('click', this.onOpenOrCloseAllToggle.bind(this));
829
+ };
830
+
831
+ // Initialise section headers
832
+ Accordion.prototype.initSectionHeaders = function () {
833
+ // Loop through section headers
834
+ nodeListForEach(this.$sections, function ($section, i) {
835
+ // Set header attributes
836
+ var header = $section.querySelector('.' + this.sectionHeaderClass);
837
+ this.initHeaderAttributes(header, i);
838
+
839
+ this.setExpanded(this.isExpanded($section), $section);
840
+
841
+ // Handle events
842
+ header.addEventListener('click', this.onSectionToggle.bind(this, $section));
843
+
844
+ // See if there is any state stored in sessionStorage and set the sections to
845
+ // open or closed.
846
+ this.setInitialState($section);
847
+ }.bind(this));
848
+ };
849
+
850
+ // Set individual header attributes
851
+ Accordion.prototype.initHeaderAttributes = function ($headerWrapper, index) {
852
+ var $module = this;
853
+ var $span = $headerWrapper.querySelector('.' + this.sectionButtonClass);
854
+ var $heading = $headerWrapper.querySelector('.' + this.sectionHeadingClass);
855
+ var $summary = $headerWrapper.querySelector('.' + this.sectionSummaryClass);
856
+
857
+ // Copy existing span element to an actual button element, for improved accessibility.
858
+ var $button = document.createElement('button');
859
+ $button.setAttribute('type', 'button');
860
+ $button.setAttribute('id', this.moduleId + '-heading-' + (index + 1));
861
+ $button.setAttribute('aria-controls', this.moduleId + '-content-' + (index + 1));
862
+
863
+ // Copy all attributes (https://developer.mozilla.org/en-US/docs/Web/API/Element/attributes) from $span to $button
864
+ for (var i = 0; i < $span.attributes.length; i++) {
865
+ var attr = $span.attributes.item(i);
866
+ $button.setAttribute(attr.nodeName, attr.nodeValue);
867
+ }
868
+
869
+ $button.addEventListener('focusin', function (e) {
870
+ if (!$headerWrapper.classList.contains($module.sectionHeaderFocusedClass)) {
871
+ $headerWrapper.className += ' ' + $module.sectionHeaderFocusedClass;
872
+ }
873
+ });
874
+
875
+ $button.addEventListener('blur', function (e) {
876
+ $headerWrapper.classList.remove($module.sectionHeaderFocusedClass);
877
+ });
878
+
879
+ if (typeof ($summary) !== 'undefined' && $summary !== null) {
880
+ $button.setAttribute('aria-describedby', this.moduleId + '-summary-' + (index + 1));
881
+ }
882
+
883
+ // $span could contain HTML elements (see https://www.w3.org/TR/2011/WD-html5-20110525/content-models.html#phrasing-content)
884
+ $button.innerHTML = $span.innerHTML;
885
+
886
+ $heading.removeChild($span);
887
+ $heading.appendChild($button);
888
+
889
+ // Add "+/-" icon
890
+ var icon = document.createElement('span');
891
+ icon.className = this.iconClass;
892
+ icon.setAttribute('aria-hidden', 'true');
893
+
894
+ $button.appendChild(icon);
895
+ };
896
+
897
+ // When section toggled, set and store state
898
+ Accordion.prototype.onSectionToggle = function ($section) {
899
+ var expanded = this.isExpanded($section);
900
+ this.setExpanded(!expanded, $section);
901
+
902
+ // Store the state in sessionStorage when a change is triggered
903
+ this.storeState($section);
904
+ };
905
+
906
+ // When Open/Close All toggled, set and store state
907
+ Accordion.prototype.onOpenOrCloseAllToggle = function () {
908
+ var $module = this;
909
+ var $sections = this.$sections;
910
+
911
+ var nowExpanded = !this.checkIfAllSectionsOpen();
912
+
913
+ nodeListForEach($sections, function ($section) {
914
+ $module.setExpanded(nowExpanded, $section);
915
+ // Store the state in sessionStorage when a change is triggered
916
+ $module.storeState($section);
917
+ });
918
+
919
+ $module.updateOpenAllButton(nowExpanded);
920
+ };
921
+
922
+ // Set section attributes when opened/closed
923
+ Accordion.prototype.setExpanded = function (expanded, $section) {
924
+ var $button = $section.querySelector('.' + this.sectionButtonClass);
925
+ $button.setAttribute('aria-expanded', expanded);
926
+
927
+ if (expanded) {
928
+ $section.classList.add(this.sectionExpandedClass);
929
+ } else {
930
+ $section.classList.remove(this.sectionExpandedClass);
931
+ }
932
+
933
+ // See if "Open all" button text should be updated
934
+ var areAllSectionsOpen = this.checkIfAllSectionsOpen();
935
+ this.updateOpenAllButton(areAllSectionsOpen);
936
+ };
937
+
938
+ // Get state of section
939
+ Accordion.prototype.isExpanded = function ($section) {
940
+ return $section.classList.contains(this.sectionExpandedClass)
941
+ };
942
+
943
+ // Check if all sections are open
944
+ Accordion.prototype.checkIfAllSectionsOpen = function () {
945
+ // Get a count of all the Accordion sections
946
+ var sectionsCount = this.$sections.length;
947
+ // Get a count of all Accordion sections that are expanded
948
+ var expandedSectionCount = this.$module.querySelectorAll('.' + this.sectionExpandedClass).length;
949
+ var areAllSectionsOpen = sectionsCount === expandedSectionCount;
950
+
951
+ return areAllSectionsOpen
952
+ };
953
+
954
+ // Update "Open all" button
955
+ Accordion.prototype.updateOpenAllButton = function (expanded) {
956
+ var newButtonText = expanded ? 'Close all' : 'Open all';
957
+ newButtonText += '<span class="govuk-visually-hidden"> sections</span>';
958
+ this.$openAllButton.setAttribute('aria-expanded', expanded);
959
+ this.$openAllButton.innerHTML = newButtonText;
960
+ };
961
+
962
+ // Check for `window.sessionStorage`, and that it actually works.
963
+ var helper = {
964
+ checkForSessionStorage: function () {
965
+ var testString = 'this is the test string';
966
+ var result;
967
+ try {
968
+ window.sessionStorage.setItem(testString, testString);
969
+ result = window.sessionStorage.getItem(testString) === testString.toString();
970
+ window.sessionStorage.removeItem(testString);
971
+ return result
972
+ } catch (exception) {
973
+ if ((typeof console === 'undefined' || typeof console.log === 'undefined')) {
974
+ console.log('Notice: sessionStorage not available.');
975
+ }
976
+ }
977
+ }
978
+ };
979
+
980
+ // Set the state of the accordions in sessionStorage
981
+ Accordion.prototype.storeState = function ($section) {
982
+ if (this.browserSupportsSessionStorage) {
983
+ // We need a unique way of identifying each content in the accordion. Since
984
+ // an `#id` should be unique and an `id` is required for `aria-` attributes
985
+ // `id` can be safely used.
986
+ var $button = $section.querySelector('.' + this.sectionButtonClass);
987
+
988
+ if ($button) {
989
+ var contentId = $button.getAttribute('aria-controls');
990
+ var contentState = $button.getAttribute('aria-expanded');
991
+
992
+ if (typeof contentId === 'undefined' && (typeof console === 'undefined' || typeof console.log === 'undefined')) {
993
+ console.error(new Error('No aria controls present in accordion section heading.'));
994
+ }
995
+
996
+ if (typeof contentState === 'undefined' && (typeof console === 'undefined' || typeof console.log === 'undefined')) {
997
+ console.error(new Error('No aria expanded present in accordion section heading.'));
998
+ }
999
+
1000
+ // Only set the state when both `contentId` and `contentState` are taken from the DOM.
1001
+ if (contentId && contentState) {
1002
+ window.sessionStorage.setItem(contentId, contentState);
1003
+ }
1004
+ }
1005
+ }
1006
+ };
1007
+
1008
+ // Read the state of the accordions from sessionStorage
1009
+ Accordion.prototype.setInitialState = function ($section) {
1010
+ if (this.browserSupportsSessionStorage) {
1011
+ var $button = $section.querySelector('.' + this.sectionButtonClass);
1012
+
1013
+ if ($button) {
1014
+ var contentId = $button.getAttribute('aria-controls');
1015
+ var contentState = contentId ? window.sessionStorage.getItem(contentId) : null;
1016
+
1017
+ if (contentState !== null) {
1018
+ this.setExpanded(contentState === 'true', $section);
1019
+ }
1020
+ }
1021
+ }
1022
+ };
1023
+
1024
+ (function(undefined) {
1025
+
1026
+ // Detection from https://github.com/Financial-Times/polyfill-service/blob/master/packages/polyfill-library/polyfills/Window/detect.js
1027
+ var detect = ('Window' in this);
1028
+
1029
+ if (detect) return
1030
+
1031
+ // Polyfill from https://cdn.polyfill.io/v2/polyfill.js?features=Window&flags=always
1032
+ if ((typeof WorkerGlobalScope === "undefined") && (typeof importScripts !== "function")) {
1033
+ (function (global) {
1034
+ if (global.constructor) {
1035
+ global.Window = global.constructor;
1036
+ } else {
1037
+ (global.Window = global.constructor = new Function('return function Window() {}')()).prototype = this;
1038
+ }
1039
+ }(this));
1040
+ }
1041
+
1042
+ })
1043
+ .call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
1044
+
1045
+ (function(undefined) {
1046
+
1047
+ // Detection from https://github.com/Financial-Times/polyfill-service/blob/master/packages/polyfill-library/polyfills/Event/detect.js
1048
+ var detect = (
1049
+ (function(global) {
1050
+
1051
+ if (!('Event' in global)) return false;
1052
+ if (typeof global.Event === 'function') return true;
1053
+
1054
+ try {
1055
+
1056
+ // In IE 9-11, the Event object exists but cannot be instantiated
1057
+ new Event('click');
1058
+ return true;
1059
+ } catch(e) {
1060
+ return false;
1061
+ }
1062
+ }(this))
1063
+ );
1064
+
1065
+ if (detect) return
1066
+
1067
+ // Polyfill from https://cdn.polyfill.io/v2/polyfill.js?features=Event&flags=always
1068
+ (function () {
1069
+ var unlistenableWindowEvents = {
1070
+ click: 1,
1071
+ dblclick: 1,
1072
+ keyup: 1,
1073
+ keypress: 1,
1074
+ keydown: 1,
1075
+ mousedown: 1,
1076
+ mouseup: 1,
1077
+ mousemove: 1,
1078
+ mouseover: 1,
1079
+ mouseenter: 1,
1080
+ mouseleave: 1,
1081
+ mouseout: 1,
1082
+ storage: 1,
1083
+ storagecommit: 1,
1084
+ textinput: 1
1085
+ };
1086
+
1087
+ // This polyfill depends on availability of `document` so will not run in a worker
1088
+ // However, we asssume there are no browsers with worker support that lack proper
1089
+ // support for `Event` within the worker
1090
+ if (typeof document === 'undefined' || typeof window === 'undefined') return;
1091
+
1092
+ function indexOf(array, element) {
1093
+ var
1094
+ index = -1,
1095
+ length = array.length;
1096
+
1097
+ while (++index < length) {
1098
+ if (index in array && array[index] === element) {
1099
+ return index;
1100
+ }
1101
+ }
1102
+
1103
+ return -1;
1104
+ }
1105
+
1106
+ var existingProto = (window.Event && window.Event.prototype) || null;
1107
+ window.Event = Window.prototype.Event = function Event(type, eventInitDict) {
1108
+ if (!type) {
1109
+ throw new Error('Not enough arguments');
1110
+ }
1111
+
1112
+ var event;
1113
+ // Shortcut if browser supports createEvent
1114
+ if ('createEvent' in document) {
1115
+ event = document.createEvent('Event');
1116
+ var bubbles = eventInitDict && eventInitDict.bubbles !== undefined ? eventInitDict.bubbles : false;
1117
+ var cancelable = eventInitDict && eventInitDict.cancelable !== undefined ? eventInitDict.cancelable : false;
1118
+
1119
+ event.initEvent(type, bubbles, cancelable);
1120
+
1121
+ return event;
1122
+ }
1123
+
1124
+ event = document.createEventObject();
1125
+
1126
+ event.type = type;
1127
+ event.bubbles = eventInitDict && eventInitDict.bubbles !== undefined ? eventInitDict.bubbles : false;
1128
+ event.cancelable = eventInitDict && eventInitDict.cancelable !== undefined ? eventInitDict.cancelable : false;
1129
+
1130
+ return event;
1131
+ };
1132
+ if (existingProto) {
1133
+ Object.defineProperty(window.Event, 'prototype', {
1134
+ configurable: false,
1135
+ enumerable: false,
1136
+ writable: true,
1137
+ value: existingProto
1138
+ });
1139
+ }
1140
+
1141
+ if (!('createEvent' in document)) {
1142
+ window.addEventListener = Window.prototype.addEventListener = Document.prototype.addEventListener = Element.prototype.addEventListener = function addEventListener() {
1143
+ var
1144
+ element = this,
1145
+ type = arguments[0],
1146
+ listener = arguments[1];
1147
+
1148
+ if (element === window && type in unlistenableWindowEvents) {
1149
+ 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.');
1150
+ }
1151
+
1152
+ if (!element._events) {
1153
+ element._events = {};
1154
+ }
1155
+
1156
+ if (!element._events[type]) {
1157
+ element._events[type] = function (event) {
1158
+ var
1159
+ list = element._events[event.type].list,
1160
+ events = list.slice(),
1161
+ index = -1,
1162
+ length = events.length,
1163
+ eventElement;
1164
+
1165
+ event.preventDefault = function preventDefault() {
1166
+ if (event.cancelable !== false) {
1167
+ event.returnValue = false;
1168
+ }
1169
+ };
1170
+
1171
+ event.stopPropagation = function stopPropagation() {
1172
+ event.cancelBubble = true;
1173
+ };
1174
+
1175
+ event.stopImmediatePropagation = function stopImmediatePropagation() {
1176
+ event.cancelBubble = true;
1177
+ event.cancelImmediate = true;
1178
+ };
1179
+
1180
+ event.currentTarget = element;
1181
+ event.relatedTarget = event.fromElement || null;
1182
+ event.target = event.target || event.srcElement || element;
1183
+ event.timeStamp = new Date().getTime();
1184
+
1185
+ if (event.clientX) {
1186
+ event.pageX = event.clientX + document.documentElement.scrollLeft;
1187
+ event.pageY = event.clientY + document.documentElement.scrollTop;
1188
+ }
1189
+
1190
+ while (++index < length && !event.cancelImmediate) {
1191
+ if (index in events) {
1192
+ eventElement = events[index];
1193
+
1194
+ if (indexOf(list, eventElement) !== -1 && typeof eventElement === 'function') {
1195
+ eventElement.call(element, event);
1196
+ }
1197
+ }
1198
+ }
1199
+ };
1200
+
1201
+ element._events[type].list = [];
1202
+
1203
+ if (element.attachEvent) {
1204
+ element.attachEvent('on' + type, element._events[type]);
1205
+ }
1206
+ }
1207
+
1208
+ element._events[type].list.push(listener);
1209
+ };
1210
+
1211
+ window.removeEventListener = Window.prototype.removeEventListener = Document.prototype.removeEventListener = Element.prototype.removeEventListener = function removeEventListener() {
1212
+ var
1213
+ element = this,
1214
+ type = arguments[0],
1215
+ listener = arguments[1],
1216
+ index;
1217
+
1218
+ if (element._events && element._events[type] && element._events[type].list) {
1219
+ index = indexOf(element._events[type].list, listener);
1220
+
1221
+ if (index !== -1) {
1222
+ element._events[type].list.splice(index, 1);
1223
+
1224
+ if (!element._events[type].list.length) {
1225
+ if (element.detachEvent) {
1226
+ element.detachEvent('on' + type, element._events[type]);
1227
+ }
1228
+ delete element._events[type];
1229
+ }
1230
+ }
1231
+ }
1232
+ };
1233
+
1234
+ window.dispatchEvent = Window.prototype.dispatchEvent = Document.prototype.dispatchEvent = Element.prototype.dispatchEvent = function dispatchEvent(event) {
1235
+ if (!arguments.length) {
1236
+ throw new Error('Not enough arguments');
1237
+ }
1238
+
1239
+ if (!event || typeof event.type !== 'string') {
1240
+ throw new Error('DOM Events Exception 0');
1241
+ }
1242
+
1243
+ var element = this, type = event.type;
1244
+
1245
+ try {
1246
+ if (!event.bubbles) {
1247
+ event.cancelBubble = true;
1248
+
1249
+ var cancelBubbleEvent = function (event) {
1250
+ event.cancelBubble = true;
1251
+
1252
+ (element || window).detachEvent('on' + type, cancelBubbleEvent);
1253
+ };
1254
+
1255
+ this.attachEvent('on' + type, cancelBubbleEvent);
1256
+ }
1257
+
1258
+ this.fireEvent('on' + type, event);
1259
+ } catch (error) {
1260
+ event.target = element;
1261
+
1262
+ do {
1263
+ event.currentTarget = element;
1264
+
1265
+ if ('_events' in element && typeof element._events[type] === 'function') {
1266
+ element._events[type].call(element, event);
1267
+ }
1268
+
1269
+ if (typeof element['on' + type] === 'function') {
1270
+ element['on' + type].call(element, event);
1271
+ }
1272
+
1273
+ element = element.nodeType === 9 ? element.parentWindow : element.parentNode;
1274
+ } while (element && !event.cancelBubble);
1275
+ }
1276
+
1277
+ return true;
1278
+ };
1279
+
1280
+ // Add the DOMContentLoaded Event
1281
+ document.attachEvent('onreadystatechange', function() {
1282
+ if (document.readyState === 'complete') {
1283
+ document.dispatchEvent(new Event('DOMContentLoaded', {
1284
+ bubbles: true
1285
+ }));
1286
+ }
1287
+ });
1288
+ }
1289
+ }());
1290
+
1291
+ })
1292
+ .call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
1293
+
1294
+ var KEY_SPACE = 32;
1295
+ var DEBOUNCE_TIMEOUT_IN_SECONDS = 1;
1296
+
1297
+ function Button ($module) {
1298
+ this.$module = $module;
1299
+ this.debounceFormSubmitTimer = null;
1300
+ }
1301
+
1302
+ /**
1303
+ * JavaScript 'shim' to trigger the click event of element(s) when the space key is pressed.
1304
+ *
1305
+ * Created since some Assistive Technologies (for example some Screenreaders)
1306
+ * will tell a user to press space on a 'button', so this functionality needs to be shimmed
1307
+ * See https://github.com/alphagov/govuk_elements/pull/272#issuecomment-233028270
1308
+ *
1309
+ * @param {object} event event
1310
+ */
1311
+ Button.prototype.handleKeyDown = function (event) {
1312
+ // get the target element
1313
+ var target = event.target;
1314
+ // if the element has a role='button' and the pressed key is a space, we'll simulate a click
1315
+ if (target.getAttribute('role') === 'button' && event.keyCode === KEY_SPACE) {
1316
+ event.preventDefault();
1317
+ // trigger the target's click event
1318
+ target.click();
1319
+ }
1320
+ };
1321
+
1322
+ /**
1323
+ * If the click quickly succeeds a previous click then nothing will happen.
1324
+ * This stops people accidentally causing multiple form submissions by
1325
+ * double clicking buttons.
1326
+ */
1327
+ Button.prototype.debounce = function (event) {
1328
+ var target = event.target;
1329
+ // Check the button that is clicked on has the preventDoubleClick feature enabled
1330
+ if (target.getAttribute('data-prevent-double-click') !== 'true') {
1331
+ return
1332
+ }
1333
+
1334
+ // If the timer is still running then we want to prevent the click from submitting the form
1335
+ if (this.debounceFormSubmitTimer) {
1336
+ event.preventDefault();
1337
+ return false
1338
+ }
1339
+
1340
+ this.debounceFormSubmitTimer = setTimeout(function () {
1341
+ this.debounceFormSubmitTimer = null;
1342
+ }.bind(this), DEBOUNCE_TIMEOUT_IN_SECONDS * 1000);
1343
+ };
1344
+
1345
+ /**
1346
+ * Initialise an event listener for keydown at document level
1347
+ * this will help listening for later inserted elements with a role="button"
1348
+ */
1349
+ Button.prototype.init = function () {
1350
+ this.$module.addEventListener('keydown', this.handleKeyDown);
1351
+ this.$module.addEventListener('click', this.debounce);
1352
+ };
1353
+
1354
+ /**
1355
+ * JavaScript 'polyfill' for HTML5's <details> and <summary> elements
1356
+ * and 'shim' to add accessiblity enhancements for all browsers
1357
+ *
1358
+ * http://caniuse.com/#feat=details
1359
+ */
1360
+
1361
+ var KEY_ENTER = 13;
1362
+ var KEY_SPACE$1 = 32;
1363
+
1364
+ function Details ($module) {
1365
+ this.$module = $module;
1366
+ }
1367
+
1368
+ Details.prototype.init = function () {
1369
+ if (!this.$module) {
1370
+ return
1371
+ }
1372
+
1373
+ // If there is native details support, we want to avoid running code to polyfill native behaviour.
1374
+ var hasNativeDetails = typeof this.$module.open === 'boolean';
1375
+
1376
+ if (hasNativeDetails) {
1377
+ return
1378
+ }
1379
+
1380
+ this.polyfillDetails();
1381
+ };
1382
+
1383
+ Details.prototype.polyfillDetails = function () {
1384
+ var $module = this.$module;
1385
+
1386
+ // Save shortcuts to the inner summary and content elements
1387
+ var $summary = this.$summary = $module.getElementsByTagName('summary').item(0);
1388
+ var $content = this.$content = $module.getElementsByTagName('div').item(0);
1389
+
1390
+ // If <details> doesn't have a <summary> and a <div> representing the content
1391
+ // it means the required HTML structure is not met so the script will stop
1392
+ if (!$summary || !$content) {
1393
+ return
1394
+ }
1395
+
1396
+ // If the content doesn't have an ID, assign it one now
1397
+ // which we'll need for the summary's aria-controls assignment
1398
+ if (!$content.id) {
1399
+ $content.id = 'details-content-' + generateUniqueID();
1400
+ }
1401
+
1402
+ // Add ARIA role="group" to details
1403
+ $module.setAttribute('role', 'group');
1404
+
1405
+ // Add role=button to summary
1406
+ $summary.setAttribute('role', 'button');
1407
+
1408
+ // Add aria-controls
1409
+ $summary.setAttribute('aria-controls', $content.id);
1410
+
1411
+ // Set tabIndex so the summary is keyboard accessible for non-native elements
1412
+ //
1413
+ // We have to use the camelcase `tabIndex` property as there is a bug in IE6/IE7 when we set the correct attribute lowercase:
1414
+ // See http://web.archive.org/web/20170120194036/http://www.saliences.com/browserBugs/tabIndex.html for more information.
1415
+ $summary.tabIndex = 0;
1416
+
1417
+ // Detect initial open state
1418
+ var openAttr = $module.getAttribute('open') !== null;
1419
+ if (openAttr === true) {
1420
+ $summary.setAttribute('aria-expanded', 'true');
1421
+ $content.setAttribute('aria-hidden', 'false');
1422
+ } else {
1423
+ $summary.setAttribute('aria-expanded', 'false');
1424
+ $content.setAttribute('aria-hidden', 'true');
1425
+ $content.style.display = 'none';
1426
+ }
1427
+
1428
+ // Bind an event to handle summary elements
1429
+ this.polyfillHandleInputs($summary, this.polyfillSetAttributes.bind(this));
1430
+ };
1431
+
1432
+ /**
1433
+ * Define a statechange function that updates aria-expanded and style.display
1434
+ * @param {object} summary element
1435
+ */
1436
+ Details.prototype.polyfillSetAttributes = function () {
1437
+ var $module = this.$module;
1438
+ var $summary = this.$summary;
1439
+ var $content = this.$content;
1440
+
1441
+ var expanded = $summary.getAttribute('aria-expanded') === 'true';
1442
+ var hidden = $content.getAttribute('aria-hidden') === 'true';
1443
+
1444
+ $summary.setAttribute('aria-expanded', (expanded ? 'false' : 'true'));
1445
+ $content.setAttribute('aria-hidden', (hidden ? 'false' : 'true'));
1446
+
1447
+ $content.style.display = (expanded ? 'none' : '');
1448
+
1449
+ var hasOpenAttr = $module.getAttribute('open') !== null;
1450
+ if (!hasOpenAttr) {
1451
+ $module.setAttribute('open', 'open');
1452
+ } else {
1453
+ $module.removeAttribute('open');
1454
+ }
1455
+
1456
+ return true
1457
+ };
1458
+
1459
+ /**
1460
+ * Handle cross-modal click events
1461
+ * @param {object} node element
1462
+ * @param {function} callback function
1463
+ */
1464
+ Details.prototype.polyfillHandleInputs = function (node, callback) {
1465
+ node.addEventListener('keypress', function (event) {
1466
+ var target = event.target;
1467
+ // When the key gets pressed - check if it is enter or space
1468
+ if (event.keyCode === KEY_ENTER || event.keyCode === KEY_SPACE$1) {
1469
+ if (target.nodeName.toLowerCase() === 'summary') {
1470
+ // Prevent space from scrolling the page
1471
+ // and enter from submitting a form
1472
+ event.preventDefault();
1473
+ // Click to let the click event do all the necessary action
1474
+ if (target.click) {
1475
+ target.click();
1476
+ } else {
1477
+ // except Safari 5.1 and under don't support .click() here
1478
+ callback(event);
1479
+ }
1480
+ }
1481
+ }
1482
+ });
1483
+
1484
+ // Prevent keyup to prevent clicking twice in Firefox when using space key
1485
+ node.addEventListener('keyup', function (event) {
1486
+ var target = event.target;
1487
+ if (event.keyCode === KEY_SPACE$1) {
1488
+ if (target.nodeName.toLowerCase() === 'summary') {
1489
+ event.preventDefault();
1490
+ }
1491
+ }
1492
+ });
1493
+
1494
+ node.addEventListener('click', callback);
1495
+ };
1496
+
1497
+ function CharacterCount ($module) {
1498
+ this.$module = $module;
1499
+ this.$textarea = $module.querySelector('.govuk-js-character-count');
1500
+ if (this.$textarea) {
1501
+ this.$countMessage = $module.querySelector('[id="' + this.$textarea.id + '-info"]');
1502
+ }
1503
+ }
1504
+
1505
+ CharacterCount.prototype.defaults = {
1506
+ characterCountAttribute: 'data-maxlength',
1507
+ wordCountAttribute: 'data-maxwords'
1508
+ };
1509
+
1510
+ // Initialize component
1511
+ CharacterCount.prototype.init = function () {
1512
+ // Check for module
1513
+ var $module = this.$module;
1514
+ var $textarea = this.$textarea;
1515
+ var $countMessage = this.$countMessage;
1516
+
1517
+ if (!$textarea || !$countMessage) {
1518
+ return
1519
+ }
1520
+
1521
+ // We move count message right after the field
1522
+ // Kept for backwards compatibility
1523
+ $textarea.insertAdjacentElement('afterend', $countMessage);
1524
+
1525
+ // Read options set using dataset ('data-' values)
1526
+ this.options = this.getDataset($module);
1527
+
1528
+ // Determine the limit attribute (characters or words)
1529
+ var countAttribute = this.defaults.characterCountAttribute;
1530
+ if (this.options.maxwords) {
1531
+ countAttribute = this.defaults.wordCountAttribute;
1532
+ }
1533
+
1534
+ // Save the element limit
1535
+ this.maxLength = $module.getAttribute(countAttribute);
1536
+
1537
+ // Check for limit
1538
+ if (!this.maxLength) {
1539
+ return
1540
+ }
1541
+
1542
+ // Remove hard limit if set
1543
+ $module.removeAttribute('maxlength');
1544
+
1545
+ // When the page is restored after navigating 'back' in some browsers the
1546
+ // state of the character count is not restored until *after* the DOMContentLoaded
1547
+ // event is fired, so we need to sync after the pageshow event in browsers
1548
+ // that support it.
1549
+ if ('onpageshow' in window) {
1550
+ window.addEventListener('pageshow', this.sync.bind(this));
1551
+ } else {
1552
+ window.addEventListener('DOMContentLoaded', this.sync.bind(this));
1553
+ }
1554
+
1555
+ this.sync();
1556
+ };
1557
+
1558
+ CharacterCount.prototype.sync = function () {
1559
+ this.bindChangeEvents();
1560
+ this.updateCountMessage();
1561
+ };
1562
+
1563
+ // Read data attributes
1564
+ CharacterCount.prototype.getDataset = function (element) {
1565
+ var dataset = {};
1566
+ var attributes = element.attributes;
1567
+ if (attributes) {
1568
+ for (var i = 0; i < attributes.length; i++) {
1569
+ var attribute = attributes[i];
1570
+ var match = attribute.name.match(/^data-(.+)/);
1571
+ if (match) {
1572
+ dataset[match[1]] = attribute.value;
1573
+ }
1574
+ }
1575
+ }
1576
+ return dataset
1577
+ };
1578
+
1579
+ // Counts characters or words in text
1580
+ CharacterCount.prototype.count = function (text) {
1581
+ var length;
1582
+ if (this.options.maxwords) {
1583
+ var tokens = text.match(/\S+/g) || []; // Matches consecutive non-whitespace chars
1584
+ length = tokens.length;
1585
+ } else {
1586
+ length = text.length;
1587
+ }
1588
+ return length
1589
+ };
1590
+
1591
+ // Bind input propertychange to the elements and update based on the change
1592
+ CharacterCount.prototype.bindChangeEvents = function () {
1593
+ var $textarea = this.$textarea;
1594
+ $textarea.addEventListener('keyup', this.checkIfValueChanged.bind(this));
1595
+
1596
+ // Bind focus/blur events to start/stop polling
1597
+ $textarea.addEventListener('focus', this.handleFocus.bind(this));
1598
+ $textarea.addEventListener('blur', this.handleBlur.bind(this));
1599
+ };
1600
+
1601
+ // Speech recognition software such as Dragon NaturallySpeaking will modify the
1602
+ // fields by directly changing its `value`. These changes don't trigger events
1603
+ // in JavaScript, so we need to poll to handle when and if they occur.
1604
+ CharacterCount.prototype.checkIfValueChanged = function () {
1605
+ if (!this.$textarea.oldValue) this.$textarea.oldValue = '';
1606
+ if (this.$textarea.value !== this.$textarea.oldValue) {
1607
+ this.$textarea.oldValue = this.$textarea.value;
1608
+ this.updateCountMessage();
1609
+ }
1610
+ };
1611
+
1612
+ // Update message box
1613
+ CharacterCount.prototype.updateCountMessage = function () {
1614
+ var countElement = this.$textarea;
1615
+ var options = this.options;
1616
+ var countMessage = this.$countMessage;
1617
+
1618
+ // Determine the remaining number of characters/words
1619
+ var currentLength = this.count(countElement.value);
1620
+ var maxLength = this.maxLength;
1621
+ var remainingNumber = maxLength - currentLength;
1622
+
1623
+ // Set threshold if presented in options
1624
+ var thresholdPercent = options.threshold ? options.threshold : 0;
1625
+ var thresholdValue = maxLength * thresholdPercent / 100;
1626
+ if (thresholdValue > currentLength) {
1627
+ countMessage.classList.add('govuk-character-count__message--disabled');
1628
+ // Ensure threshold is hidden for users of assistive technologies
1629
+ countMessage.setAttribute('aria-hidden', true);
1630
+ } else {
1631
+ countMessage.classList.remove('govuk-character-count__message--disabled');
1632
+ // Ensure threshold is visible for users of assistive technologies
1633
+ countMessage.removeAttribute('aria-hidden');
1634
+ }
1635
+
1636
+ // Update styles
1637
+ if (remainingNumber < 0) {
1638
+ countElement.classList.add('govuk-textarea--error');
1639
+ countMessage.classList.remove('govuk-hint');
1640
+ countMessage.classList.add('govuk-error-message');
1641
+ } else {
1642
+ countElement.classList.remove('govuk-textarea--error');
1643
+ countMessage.classList.remove('govuk-error-message');
1644
+ countMessage.classList.add('govuk-hint');
1645
+ }
1646
+
1647
+ // Update message
1648
+ var charVerb = 'remaining';
1649
+ var charNoun = 'character';
1650
+ var displayNumber = remainingNumber;
1651
+ if (options.maxwords) {
1652
+ charNoun = 'word';
1653
+ }
1654
+ charNoun = charNoun + ((remainingNumber === -1 || remainingNumber === 1) ? '' : 's');
1655
+
1656
+ charVerb = (remainingNumber < 0) ? 'too many' : 'remaining';
1657
+ displayNumber = Math.abs(remainingNumber);
1658
+
1659
+ countMessage.innerHTML = 'You have ' + displayNumber + ' ' + charNoun + ' ' + charVerb;
1660
+ };
1661
+
1662
+ CharacterCount.prototype.handleFocus = function () {
1663
+ // Check if value changed on focus
1664
+ this.valueChecker = setInterval(this.checkIfValueChanged.bind(this), 1000);
1665
+ };
1666
+
1667
+ CharacterCount.prototype.handleBlur = function () {
1668
+ // Cancel value checking on blur
1669
+ clearInterval(this.valueChecker);
1670
+ };
1671
+
1672
+ function Checkboxes ($module) {
1673
+ this.$module = $module;
1674
+ this.$inputs = $module.querySelectorAll('input[type="checkbox"]');
1675
+ }
1676
+
1677
+ /**
1678
+ * Initialise Checkboxes
1679
+ *
1680
+ * Checkboxes can be associated with a 'conditionally revealed' content block –
1681
+ * for example, a checkbox for 'Phone' could reveal an additional form field for
1682
+ * the user to enter their phone number.
1683
+ *
1684
+ * These associations are made using a `data-aria-controls` attribute, which is
1685
+ * promoted to an aria-controls attribute during initialisation.
1686
+ *
1687
+ * We also need to restore the state of any conditional reveals on the page (for
1688
+ * example if the user has navigated back), and set up event handlers to keep
1689
+ * the reveal in sync with the checkbox state.
1690
+ */
1691
+ Checkboxes.prototype.init = function () {
1692
+ var $module = this.$module;
1693
+ var $inputs = this.$inputs;
1694
+
1695
+ nodeListForEach($inputs, function ($input) {
1696
+ var target = $input.getAttribute('data-aria-controls');
1697
+
1698
+ // Skip checkboxes without data-aria-controls attributes, or where the
1699
+ // target element does not exist.
1700
+ if (!target || !$module.querySelector('#' + target)) {
1701
+ return
1702
+ }
1703
+
1704
+ // Promote the data-aria-controls attribute to a aria-controls attribute
1705
+ // so that the relationship is exposed in the AOM
1706
+ $input.setAttribute('aria-controls', target);
1707
+ $input.removeAttribute('data-aria-controls');
1708
+ });
1709
+
1710
+ // When the page is restored after navigating 'back' in some browsers the
1711
+ // state of form controls is not restored until *after* the DOMContentLoaded
1712
+ // event is fired, so we need to sync after the pageshow event in browsers
1713
+ // that support it.
1714
+ if ('onpageshow' in window) {
1715
+ window.addEventListener('pageshow', this.syncAllConditionalReveals.bind(this));
1716
+ } else {
1717
+ window.addEventListener('DOMContentLoaded', this.syncAllConditionalReveals.bind(this));
1718
+ }
1719
+
1720
+ // Although we've set up handlers to sync state on the pageshow or
1721
+ // DOMContentLoaded event, init could be called after those events have fired,
1722
+ // for example if they are added to the page dynamically, so sync now too.
1723
+ this.syncAllConditionalReveals();
1724
+
1725
+ $module.addEventListener('click', this.handleClick.bind(this));
1726
+ };
1727
+
1728
+ /**
1729
+ * Sync the conditional reveal states for all inputs in this $module.
1730
+ */
1731
+ Checkboxes.prototype.syncAllConditionalReveals = function () {
1732
+ nodeListForEach(this.$inputs, this.syncConditionalRevealWithInputState.bind(this));
1733
+ };
1734
+
1735
+ /**
1736
+ * Sync conditional reveal with the input state
1737
+ *
1738
+ * Synchronise the visibility of the conditional reveal, and its accessible
1739
+ * state, with the input's checked state.
1740
+ *
1741
+ * @param {HTMLInputElement} $input Checkbox input
1742
+ */
1743
+ Checkboxes.prototype.syncConditionalRevealWithInputState = function ($input) {
1744
+ var $target = this.$module.querySelector('#' + $input.getAttribute('aria-controls'));
1745
+
1746
+ if ($target && $target.classList.contains('govuk-checkboxes__conditional')) {
1747
+ var inputIsChecked = $input.checked;
1748
+
1749
+ $input.setAttribute('aria-expanded', inputIsChecked);
1750
+ $target.classList.toggle('govuk-checkboxes__conditional--hidden', !inputIsChecked);
1751
+ }
1752
+ };
1753
+
1754
+ /**
1755
+ * Uncheck other checkboxes
1756
+ *
1757
+ * Find any other checkbox inputs with the same name value, and uncheck them.
1758
+ * This is useful for when a “None of these" checkbox is checked.
1759
+ */
1760
+ Checkboxes.prototype.unCheckAllInputsExcept = function ($input) {
1761
+ var allInputsWithSameName = document.querySelectorAll('input[type="checkbox"][name="' + $input.name + '"]');
1762
+
1763
+ nodeListForEach(allInputsWithSameName, function ($inputWithSameName) {
1764
+ var hasSameFormOwner = ($input.form === $inputWithSameName.form);
1765
+ if (hasSameFormOwner && $inputWithSameName !== $input) {
1766
+ $inputWithSameName.checked = false;
1767
+ }
1768
+ });
1769
+
1770
+ this.syncAllConditionalReveals();
1771
+ };
1772
+
1773
+ /**
1774
+ * Uncheck exclusive inputs
1775
+ *
1776
+ * Find any checkbox inputs with the same name value and the 'exclusive' behaviour,
1777
+ * and uncheck them. This helps prevent someone checking both a regular checkbox and a
1778
+ * "None of these" checkbox in the same fieldset.
1779
+ */
1780
+ Checkboxes.prototype.unCheckExclusiveInputs = function ($input) {
1781
+ var allInputsWithSameNameAndExclusiveBehaviour = document.querySelectorAll(
1782
+ 'input[data-behaviour="exclusive"][type="checkbox"][name="' + $input.name + '"]'
1783
+ );
1784
+
1785
+ nodeListForEach(allInputsWithSameNameAndExclusiveBehaviour, function ($exclusiveInput) {
1786
+ var hasSameFormOwner = ($input.form === $exclusiveInput.form);
1787
+ if (hasSameFormOwner) {
1788
+ $exclusiveInput.checked = false;
1789
+ }
1790
+ });
1791
+
1792
+ this.syncAllConditionalReveals();
1793
+ };
1794
+
1795
+ /**
1796
+ * Click event handler
1797
+ *
1798
+ * Handle a click within the $module – if the click occurred on a checkbox, sync
1799
+ * the state of any associated conditional reveal with the checkbox state.
1800
+ *
1801
+ * @param {MouseEvent} event Click event
1802
+ */
1803
+ Checkboxes.prototype.handleClick = function (event) {
1804
+ var $target = event.target;
1805
+
1806
+ // Ignore clicks on things that aren't checkbox inputs
1807
+ if ($target.type !== 'checkbox') {
1808
+ return
1809
+ }
1810
+
1811
+ // If the checkbox conditionally-reveals some content, sync the state
1812
+ var hasAriaControls = $target.getAttribute('aria-controls');
1813
+ if (hasAriaControls) {
1814
+ this.syncConditionalRevealWithInputState($target);
1815
+ }
1816
+
1817
+ // No further behaviour needed for unchecking
1818
+ if (!$target.checked) {
1819
+ return
1820
+ }
1821
+
1822
+ // Handle 'exclusive' checkbox behaviour (ie "None of these")
1823
+ var hasBehaviourExclusive = ($target.getAttribute('data-behaviour') === 'exclusive');
1824
+ if (hasBehaviourExclusive) {
1825
+ this.unCheckAllInputsExcept($target);
1826
+ } else {
1827
+ this.unCheckExclusiveInputs($target);
1828
+ }
1829
+ };
1830
+
1831
+ (function(undefined) {
1832
+
1833
+ // Detection from https://raw.githubusercontent.com/Financial-Times/polyfill-service/1f3c09b402f65bf6e393f933a15ba63f1b86ef1f/packages/polyfill-library/polyfills/Element/prototype/matches/detect.js
1834
+ var detect = (
1835
+ 'document' in this && "matches" in document.documentElement
1836
+ );
1837
+
1838
+ if (detect) return
1839
+
1840
+ // Polyfill from https://raw.githubusercontent.com/Financial-Times/polyfill-service/1f3c09b402f65bf6e393f933a15ba63f1b86ef1f/packages/polyfill-library/polyfills/Element/prototype/matches/polyfill.js
1841
+ Element.prototype.matches = Element.prototype.webkitMatchesSelector || Element.prototype.oMatchesSelector || Element.prototype.msMatchesSelector || Element.prototype.mozMatchesSelector || function matches(selector) {
1842
+ var element = this;
1843
+ var elements = (element.document || element.ownerDocument).querySelectorAll(selector);
1844
+ var index = 0;
1845
+
1846
+ while (elements[index] && elements[index] !== element) {
1847
+ ++index;
1848
+ }
1849
+
1850
+ return !!elements[index];
1851
+ };
1852
+
1853
+ }).call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
1854
+
1855
+ (function(undefined) {
1856
+
1857
+ // Detection from https://raw.githubusercontent.com/Financial-Times/polyfill-service/1f3c09b402f65bf6e393f933a15ba63f1b86ef1f/packages/polyfill-library/polyfills/Element/prototype/closest/detect.js
1858
+ var detect = (
1859
+ 'document' in this && "closest" in document.documentElement
1860
+ );
1861
+
1862
+ if (detect) return
1863
+
1864
+ // Polyfill from https://raw.githubusercontent.com/Financial-Times/polyfill-service/1f3c09b402f65bf6e393f933a15ba63f1b86ef1f/packages/polyfill-library/polyfills/Element/prototype/closest/polyfill.js
1865
+ Element.prototype.closest = function closest(selector) {
1866
+ var node = this;
1867
+
1868
+ while (node) {
1869
+ if (node.matches(selector)) return node;
1870
+ else node = 'SVGElement' in window && node instanceof SVGElement ? node.parentNode : node.parentElement;
1871
+ }
1872
+
1873
+ return null;
1874
+ };
1875
+
1876
+ }).call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
1877
+
1878
+ function ErrorSummary ($module) {
1879
+ this.$module = $module;
1880
+ }
1881
+
1882
+ ErrorSummary.prototype.init = function () {
1883
+ var $module = this.$module;
1884
+ if (!$module) {
1885
+ return
1886
+ }
1887
+ $module.focus();
1888
+
1889
+ $module.addEventListener('click', this.handleClick.bind(this));
1890
+ };
1891
+
1892
+ /**
1893
+ * Click event handler
1894
+ *
1895
+ * @param {MouseEvent} event - Click event
1896
+ */
1897
+ ErrorSummary.prototype.handleClick = function (event) {
1898
+ var target = event.target;
1899
+ if (this.focusTarget(target)) {
1900
+ event.preventDefault();
1901
+ }
1902
+ };
1903
+
1904
+ /**
1905
+ * Focus the target element
1906
+ *
1907
+ * By default, the browser will scroll the target into view. Because our labels
1908
+ * or legends appear above the input, this means the user will be presented with
1909
+ * an input without any context, as the label or legend will be off the top of
1910
+ * the screen.
1911
+ *
1912
+ * Manually handling the click event, scrolling the question into view and then
1913
+ * focussing the element solves this.
1914
+ *
1915
+ * This also results in the label and/or legend being announced correctly in
1916
+ * NVDA (as tested in 2018.3.2) - without this only the field type is announced
1917
+ * (e.g. "Edit, has autocomplete").
1918
+ *
1919
+ * @param {HTMLElement} $target - Event target
1920
+ * @returns {boolean} True if the target was able to be focussed
1921
+ */
1922
+ ErrorSummary.prototype.focusTarget = function ($target) {
1923
+ // If the element that was clicked was not a link, return early
1924
+ if ($target.tagName !== 'A' || $target.href === false) {
1925
+ return false
1926
+ }
1927
+
1928
+ var inputId = this.getFragmentFromUrl($target.href);
1929
+ var $input = document.getElementById(inputId);
1930
+ if (!$input) {
1931
+ return false
1932
+ }
1933
+
1934
+ var $legendOrLabel = this.getAssociatedLegendOrLabel($input);
1935
+ if (!$legendOrLabel) {
1936
+ return false
1937
+ }
1938
+
1939
+ // Scroll the legend or label into view *before* calling focus on the input to
1940
+ // avoid extra scrolling in browsers that don't support `preventScroll` (which
1941
+ // at time of writing is most of them...)
1942
+ $legendOrLabel.scrollIntoView();
1943
+ $input.focus({ preventScroll: true });
1944
+
1945
+ return true
1946
+ };
1947
+
1948
+ /**
1949
+ * Get fragment from URL
1950
+ *
1951
+ * Extract the fragment (everything after the hash) from a URL, but not including
1952
+ * the hash.
1953
+ *
1954
+ * @param {string} url - URL
1955
+ * @returns {string} Fragment from URL, without the hash
1956
+ */
1957
+ ErrorSummary.prototype.getFragmentFromUrl = function (url) {
1958
+ if (url.indexOf('#') === -1) {
1959
+ return false
1960
+ }
1961
+
1962
+ return url.split('#').pop()
1963
+ };
1964
+
1965
+ /**
1966
+ * Get associated legend or label
1967
+ *
1968
+ * Returns the first element that exists from this list:
1969
+ *
1970
+ * - The `<legend>` associated with the closest `<fieldset>` ancestor, as long
1971
+ * as the top of it is no more than half a viewport height away from the
1972
+ * bottom of the input
1973
+ * - The first `<label>` that is associated with the input using for="inputId"
1974
+ * - The closest parent `<label>`
1975
+ *
1976
+ * @param {HTMLElement} $input - The input
1977
+ * @returns {HTMLElement} Associated legend or label, or null if no associated
1978
+ * legend or label can be found
1979
+ */
1980
+ ErrorSummary.prototype.getAssociatedLegendOrLabel = function ($input) {
1981
+ var $fieldset = $input.closest('fieldset');
1982
+
1983
+ if ($fieldset) {
1984
+ var legends = $fieldset.getElementsByTagName('legend');
1985
+
1986
+ if (legends.length) {
1987
+ var $candidateLegend = legends[0];
1988
+
1989
+ // If the input type is radio or checkbox, always use the legend if there
1990
+ // is one.
1991
+ if ($input.type === 'checkbox' || $input.type === 'radio') {
1992
+ return $candidateLegend
1993
+ }
1994
+
1995
+ // For other input types, only scroll to the fieldset’s legend (instead of
1996
+ // the label associated with the input) if the input would end up in the
1997
+ // top half of the screen.
1998
+ //
1999
+ // This should avoid situations where the input either ends up off the
2000
+ // screen, or obscured by a software keyboard.
2001
+ var legendTop = $candidateLegend.getBoundingClientRect().top;
2002
+ var inputRect = $input.getBoundingClientRect();
2003
+
2004
+ // If the browser doesn't support Element.getBoundingClientRect().height
2005
+ // or window.innerHeight (like IE8), bail and just link to the label.
2006
+ if (inputRect.height && window.innerHeight) {
2007
+ var inputBottom = inputRect.top + inputRect.height;
2008
+
2009
+ if (inputBottom - legendTop < window.innerHeight / 2) {
2010
+ return $candidateLegend
2011
+ }
2012
+ }
2013
+ }
2014
+ }
2015
+
2016
+ return document.querySelector("label[for='" + $input.getAttribute('id') + "']") ||
2017
+ $input.closest('label')
2018
+ };
2019
+
2020
+ function NotificationBanner ($module) {
2021
+ this.$module = $module;
2022
+ }
2023
+
2024
+ /**
2025
+ * Initialise the component
2026
+ */
2027
+ NotificationBanner.prototype.init = function () {
2028
+ var $module = this.$module;
2029
+ // Check for module
2030
+ if (!$module) {
2031
+ return
2032
+ }
2033
+
2034
+ this.setFocus();
2035
+ };
2036
+
2037
+ /**
2038
+ * Focus the element
2039
+ *
2040
+ * If `role="alert"` is set, focus the element to help some assistive technologies
2041
+ * prioritise announcing it.
2042
+ *
2043
+ * You can turn off the auto-focus functionality by setting `data-disable-auto-focus="true"` in the
2044
+ * component HTML. You might wish to do this based on user research findings, or to avoid a clash
2045
+ * with another element which should be focused when the page loads.
2046
+ */
2047
+ NotificationBanner.prototype.setFocus = function () {
2048
+ var $module = this.$module;
2049
+
2050
+ if ($module.getAttribute('data-disable-auto-focus') === 'true') {
2051
+ return
2052
+ }
2053
+
2054
+ if ($module.getAttribute('role') !== 'alert') {
2055
+ return
2056
+ }
2057
+
2058
+ // Set tabindex to -1 to make the element focusable with JavaScript.
2059
+ // Remove the tabindex on blur as the component doesn't need to be focusable after the page has
2060
+ // loaded.
2061
+ if (!$module.getAttribute('tabindex')) {
2062
+ $module.setAttribute('tabindex', '-1');
2063
+
2064
+ $module.addEventListener('blur', function () {
2065
+ $module.removeAttribute('tabindex');
2066
+ });
2067
+ }
2068
+
2069
+ $module.focus();
2070
+ };
2071
+
2072
+ function Header ($module) {
2073
+ this.$module = $module;
2074
+ this.$menuButton = $module && $module.querySelector('.govuk-js-header-toggle');
2075
+ this.$menu = this.$menuButton && $module.querySelector(
2076
+ '#' + this.$menuButton.getAttribute('aria-controls')
2077
+ );
2078
+ }
2079
+
2080
+ /**
2081
+ * Initialise header
2082
+ *
2083
+ * Check for the presence of the header, menu and menu button – if any are
2084
+ * missing then there's nothing to do so return early.
2085
+ */
2086
+ Header.prototype.init = function () {
2087
+ if (!this.$module || !this.$menuButton || !this.$menu) {
2088
+ return
2089
+ }
2090
+
2091
+ this.syncState(this.$menu.classList.contains('govuk-header__navigation--open'));
2092
+ this.$menuButton.addEventListener('click', this.handleMenuButtonClick.bind(this));
2093
+ };
2094
+
2095
+ /**
2096
+ * Sync menu state
2097
+ *
2098
+ * Sync the menu button class and the accessible state of the menu and the menu
2099
+ * button with the visible state of the menu
2100
+ *
2101
+ * @param {boolean} isVisible Whether the menu is currently visible
2102
+ */
2103
+ Header.prototype.syncState = function (isVisible) {
2104
+ this.$menuButton.classList.toggle('govuk-header__menu-button--open', isVisible);
2105
+ this.$menuButton.setAttribute('aria-expanded', isVisible);
2106
+ };
2107
+
2108
+ /**
2109
+ * Handle menu button click
2110
+ *
2111
+ * When the menu button is clicked, change the visibility of the menu and then
2112
+ * sync the accessibility state and menu button state
2113
+ */
2114
+ Header.prototype.handleMenuButtonClick = function () {
2115
+ var isVisible = this.$menu.classList.toggle('govuk-header__navigation--open');
2116
+ this.syncState(isVisible);
2117
+ };
2118
+
2119
+ function Radios ($module) {
2120
+ this.$module = $module;
2121
+ this.$inputs = $module.querySelectorAll('input[type="radio"]');
2122
+ }
2123
+
2124
+ /**
2125
+ * Initialise Radios
2126
+ *
2127
+ * Radios can be associated with a 'conditionally revealed' content block – for
2128
+ * example, a radio for 'Phone' could reveal an additional form field for the
2129
+ * user to enter their phone number.
2130
+ *
2131
+ * These associations are made using a `data-aria-controls` attribute, which is
2132
+ * promoted to an aria-controls attribute during initialisation.
2133
+ *
2134
+ * We also need to restore the state of any conditional reveals on the page (for
2135
+ * example if the user has navigated back), and set up event handlers to keep
2136
+ * the reveal in sync with the radio state.
2137
+ */
2138
+ Radios.prototype.init = function () {
2139
+ var $module = this.$module;
2140
+ var $inputs = this.$inputs;
2141
+
2142
+ nodeListForEach($inputs, function ($input) {
2143
+ var target = $input.getAttribute('data-aria-controls');
2144
+
2145
+ // Skip radios without data-aria-controls attributes, or where the
2146
+ // target element does not exist.
2147
+ if (!target || !$module.querySelector('#' + target)) {
2148
+ return
2149
+ }
2150
+
2151
+ // Promote the data-aria-controls attribute to a aria-controls attribute
2152
+ // so that the relationship is exposed in the AOM
2153
+ $input.setAttribute('aria-controls', target);
2154
+ $input.removeAttribute('data-aria-controls');
2155
+ });
2156
+
2157
+ // When the page is restored after navigating 'back' in some browsers the
2158
+ // state of form controls is not restored until *after* the DOMContentLoaded
2159
+ // event is fired, so we need to sync after the pageshow event in browsers
2160
+ // that support it.
2161
+ if ('onpageshow' in window) {
2162
+ window.addEventListener('pageshow', this.syncAllConditionalReveals.bind(this));
2163
+ } else {
2164
+ window.addEventListener('DOMContentLoaded', this.syncAllConditionalReveals.bind(this));
2165
+ }
2166
+
2167
+ // Although we've set up handlers to sync state on the pageshow or
2168
+ // DOMContentLoaded event, init could be called after those events have fired,
2169
+ // for example if they are added to the page dynamically, so sync now too.
2170
+ this.syncAllConditionalReveals();
2171
+
2172
+ // Handle events
2173
+ $module.addEventListener('click', this.handleClick.bind(this));
2174
+ };
2175
+
2176
+ /**
2177
+ * Sync the conditional reveal states for all inputs in this $module.
2178
+ */
2179
+ Radios.prototype.syncAllConditionalReveals = function () {
2180
+ nodeListForEach(this.$inputs, this.syncConditionalRevealWithInputState.bind(this));
2181
+ };
2182
+
2183
+ /**
2184
+ * Sync conditional reveal with the input state
2185
+ *
2186
+ * Synchronise the visibility of the conditional reveal, and its accessible
2187
+ * state, with the input's checked state.
2188
+ *
2189
+ * @param {HTMLInputElement} $input Radio input
2190
+ */
2191
+ Radios.prototype.syncConditionalRevealWithInputState = function ($input) {
2192
+ var $target = document.querySelector('#' + $input.getAttribute('aria-controls'));
2193
+
2194
+ if ($target && $target.classList.contains('govuk-radios__conditional')) {
2195
+ var inputIsChecked = $input.checked;
2196
+
2197
+ $input.setAttribute('aria-expanded', inputIsChecked);
2198
+ $target.classList.toggle('govuk-radios__conditional--hidden', !inputIsChecked);
2199
+ }
2200
+ };
2201
+
2202
+ /**
2203
+ * Click event handler
2204
+ *
2205
+ * Handle a click within the $module – if the click occurred on a radio, sync
2206
+ * the state of the conditional reveal for all radio buttons in the same form
2207
+ * with the same name (because checking one radio could have un-checked a radio
2208
+ * in another $module)
2209
+ *
2210
+ * @param {MouseEvent} event Click event
2211
+ */
2212
+ Radios.prototype.handleClick = function (event) {
2213
+ var $clickedInput = event.target;
2214
+
2215
+ // Ignore clicks on things that aren't radio buttons
2216
+ if ($clickedInput.type !== 'radio') {
2217
+ return
2218
+ }
2219
+
2220
+ // We only need to consider radios with conditional reveals, which will have
2221
+ // aria-controls attributes.
2222
+ var $allInputs = document.querySelectorAll('input[type="radio"][aria-controls]');
2223
+
2224
+ nodeListForEach($allInputs, function ($input) {
2225
+ var hasSameFormOwner = ($input.form === $clickedInput.form);
2226
+ var hasSameName = ($input.name === $clickedInput.name);
2227
+
2228
+ if (hasSameName && hasSameFormOwner) {
2229
+ this.syncConditionalRevealWithInputState($input);
2230
+ }
2231
+ }.bind(this));
2232
+ };
2233
+
2234
+ (function(undefined) {
2235
+
2236
+ // Detection from https://raw.githubusercontent.com/Financial-Times/polyfill-library/master/polyfills/Element/prototype/nextElementSibling/detect.js
2237
+ var detect = (
2238
+ 'document' in this && "nextElementSibling" in document.documentElement
2239
+ );
2240
+
2241
+ if (detect) return
2242
+
2243
+ // Polyfill from https://raw.githubusercontent.com/Financial-Times/polyfill-library/master/polyfills/Element/prototype/nextElementSibling/polyfill.js
2244
+ Object.defineProperty(Element.prototype, "nextElementSibling", {
2245
+ get: function(){
2246
+ var el = this.nextSibling;
2247
+ while (el && el.nodeType !== 1) { el = el.nextSibling; }
2248
+ return el;
2249
+ }
2250
+ });
2251
+
2252
+ }).call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
2253
+
2254
+ (function(undefined) {
2255
+
2256
+ // Detection from https://raw.githubusercontent.com/Financial-Times/polyfill-library/master/polyfills/Element/prototype/previousElementSibling/detect.js
2257
+ var detect = (
2258
+ 'document' in this && "previousElementSibling" in document.documentElement
2259
+ );
2260
+
2261
+ if (detect) return
2262
+
2263
+ // Polyfill from https://raw.githubusercontent.com/Financial-Times/polyfill-library/master/polyfills/Element/prototype/previousElementSibling/polyfill.js
2264
+ Object.defineProperty(Element.prototype, 'previousElementSibling', {
2265
+ get: function(){
2266
+ var el = this.previousSibling;
2267
+ while (el && el.nodeType !== 1) { el = el.previousSibling; }
2268
+ return el;
2269
+ }
2270
+ });
2271
+
2272
+ }).call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
2273
+
2274
+ function Tabs ($module) {
2275
+ this.$module = $module;
2276
+ this.$tabs = $module.querySelectorAll('.govuk-tabs__tab');
2277
+
2278
+ this.keys = { left: 37, right: 39, up: 38, down: 40 };
2279
+ this.jsHiddenClass = 'govuk-tabs__panel--hidden';
2280
+ }
2281
+
2282
+ Tabs.prototype.init = function () {
2283
+ if (typeof window.matchMedia === 'function') {
2284
+ this.setupResponsiveChecks();
2285
+ } else {
2286
+ this.setup();
2287
+ }
2288
+ };
2289
+
2290
+ Tabs.prototype.setupResponsiveChecks = function () {
2291
+ this.mql = window.matchMedia('(min-width: 40.0625em)');
2292
+ this.mql.addListener(this.checkMode.bind(this));
2293
+ this.checkMode();
2294
+ };
2295
+
2296
+ Tabs.prototype.checkMode = function () {
2297
+ if (this.mql.matches) {
2298
+ this.setup();
2299
+ } else {
2300
+ this.teardown();
2301
+ }
2302
+ };
2303
+
2304
+ Tabs.prototype.setup = function () {
2305
+ var $module = this.$module;
2306
+ var $tabs = this.$tabs;
2307
+ var $tabList = $module.querySelector('.govuk-tabs__list');
2308
+ var $tabListItems = $module.querySelectorAll('.govuk-tabs__list-item');
2309
+
2310
+ if (!$tabs || !$tabList || !$tabListItems) {
2311
+ return
2312
+ }
2313
+
2314
+ $tabList.setAttribute('role', 'tablist');
2315
+
2316
+ nodeListForEach($tabListItems, function ($item) {
2317
+ $item.setAttribute('role', 'presentation');
2318
+ });
2319
+
2320
+ nodeListForEach($tabs, function ($tab) {
2321
+ // Set HTML attributes
2322
+ this.setAttributes($tab);
2323
+
2324
+ // Save bounded functions to use when removing event listeners during teardown
2325
+ $tab.boundTabClick = this.onTabClick.bind(this);
2326
+ $tab.boundTabKeydown = this.onTabKeydown.bind(this);
2327
+
2328
+ // Handle events
2329
+ $tab.addEventListener('click', $tab.boundTabClick, true);
2330
+ $tab.addEventListener('keydown', $tab.boundTabKeydown, true);
2331
+
2332
+ // Remove old active panels
2333
+ this.hideTab($tab);
2334
+ }.bind(this));
2335
+
2336
+ // Show either the active tab according to the URL's hash or the first tab
2337
+ var $activeTab = this.getTab(window.location.hash) || this.$tabs[0];
2338
+ this.showTab($activeTab);
2339
+
2340
+ // Handle hashchange events
2341
+ $module.boundOnHashChange = this.onHashChange.bind(this);
2342
+ window.addEventListener('hashchange', $module.boundOnHashChange, true);
2343
+ };
2344
+
2345
+ Tabs.prototype.teardown = function () {
2346
+ var $module = this.$module;
2347
+ var $tabs = this.$tabs;
2348
+ var $tabList = $module.querySelector('.govuk-tabs__list');
2349
+ var $tabListItems = $module.querySelectorAll('.govuk-tabs__list-item');
2350
+
2351
+ if (!$tabs || !$tabList || !$tabListItems) {
2352
+ return
2353
+ }
2354
+
2355
+ $tabList.removeAttribute('role');
2356
+
2357
+ nodeListForEach($tabListItems, function ($item) {
2358
+ $item.removeAttribute('role', 'presentation');
2359
+ });
2360
+
2361
+ nodeListForEach($tabs, function ($tab) {
2362
+ // Remove events
2363
+ $tab.removeEventListener('click', $tab.boundTabClick, true);
2364
+ $tab.removeEventListener('keydown', $tab.boundTabKeydown, true);
2365
+
2366
+ // Unset HTML attributes
2367
+ this.unsetAttributes($tab);
2368
+ }.bind(this));
2369
+
2370
+ // Remove hashchange event handler
2371
+ window.removeEventListener('hashchange', $module.boundOnHashChange, true);
2372
+ };
2373
+
2374
+ Tabs.prototype.onHashChange = function (e) {
2375
+ var hash = window.location.hash;
2376
+ var $tabWithHash = this.getTab(hash);
2377
+ if (!$tabWithHash) {
2378
+ return
2379
+ }
2380
+
2381
+ // Prevent changing the hash
2382
+ if (this.changingHash) {
2383
+ this.changingHash = false;
2384
+ return
2385
+ }
2386
+
2387
+ // Show either the active tab according to the URL's hash or the first tab
2388
+ var $previousTab = this.getCurrentTab();
2389
+
2390
+ this.hideTab($previousTab);
2391
+ this.showTab($tabWithHash);
2392
+ $tabWithHash.focus();
2393
+ };
2394
+
2395
+ Tabs.prototype.hideTab = function ($tab) {
2396
+ this.unhighlightTab($tab);
2397
+ this.hidePanel($tab);
2398
+ };
2399
+
2400
+ Tabs.prototype.showTab = function ($tab) {
2401
+ this.highlightTab($tab);
2402
+ this.showPanel($tab);
2403
+ };
2404
+
2405
+ Tabs.prototype.getTab = function (hash) {
2406
+ return this.$module.querySelector('.govuk-tabs__tab[href="' + hash + '"]')
2407
+ };
2408
+
2409
+ Tabs.prototype.setAttributes = function ($tab) {
2410
+ // set tab attributes
2411
+ var panelId = this.getHref($tab).slice(1);
2412
+ $tab.setAttribute('id', 'tab_' + panelId);
2413
+ $tab.setAttribute('role', 'tab');
2414
+ $tab.setAttribute('aria-controls', panelId);
2415
+ $tab.setAttribute('aria-selected', 'false');
2416
+ $tab.setAttribute('tabindex', '-1');
2417
+
2418
+ // set panel attributes
2419
+ var $panel = this.getPanel($tab);
2420
+ $panel.setAttribute('role', 'tabpanel');
2421
+ $panel.setAttribute('aria-labelledby', $tab.id);
2422
+ $panel.classList.add(this.jsHiddenClass);
2423
+ };
2424
+
2425
+ Tabs.prototype.unsetAttributes = function ($tab) {
2426
+ // unset tab attributes
2427
+ $tab.removeAttribute('id');
2428
+ $tab.removeAttribute('role');
2429
+ $tab.removeAttribute('aria-controls');
2430
+ $tab.removeAttribute('aria-selected');
2431
+ $tab.removeAttribute('tabindex');
2432
+
2433
+ // unset panel attributes
2434
+ var $panel = this.getPanel($tab);
2435
+ $panel.removeAttribute('role');
2436
+ $panel.removeAttribute('aria-labelledby');
2437
+ $panel.classList.remove(this.jsHiddenClass);
2438
+ };
2439
+
2440
+ Tabs.prototype.onTabClick = function (e) {
2441
+ if (!e.target.classList.contains('govuk-tabs__tab')) {
2442
+ // Allow events on child DOM elements to bubble up to tab parent
2443
+ return false
2444
+ }
2445
+ e.preventDefault();
2446
+ var $newTab = e.target;
2447
+ var $currentTab = this.getCurrentTab();
2448
+ this.hideTab($currentTab);
2449
+ this.showTab($newTab);
2450
+ this.createHistoryEntry($newTab);
2451
+ };
2452
+
2453
+ Tabs.prototype.createHistoryEntry = function ($tab) {
2454
+ var $panel = this.getPanel($tab);
2455
+
2456
+ // Save and restore the id
2457
+ // so the page doesn't jump when a user clicks a tab (which changes the hash)
2458
+ var id = $panel.id;
2459
+ $panel.id = '';
2460
+ this.changingHash = true;
2461
+ window.location.hash = this.getHref($tab).slice(1);
2462
+ $panel.id = id;
2463
+ };
2464
+
2465
+ Tabs.prototype.onTabKeydown = function (e) {
2466
+ switch (e.keyCode) {
2467
+ case this.keys.left:
2468
+ case this.keys.up:
2469
+ this.activatePreviousTab();
2470
+ e.preventDefault();
2471
+ break
2472
+ case this.keys.right:
2473
+ case this.keys.down:
2474
+ this.activateNextTab();
2475
+ e.preventDefault();
2476
+ break
2477
+ }
2478
+ };
2479
+
2480
+ Tabs.prototype.activateNextTab = function () {
2481
+ var currentTab = this.getCurrentTab();
2482
+ var nextTabListItem = currentTab.parentNode.nextElementSibling;
2483
+ if (nextTabListItem) {
2484
+ var nextTab = nextTabListItem.querySelector('.govuk-tabs__tab');
2485
+ }
2486
+ if (nextTab) {
2487
+ this.hideTab(currentTab);
2488
+ this.showTab(nextTab);
2489
+ nextTab.focus();
2490
+ this.createHistoryEntry(nextTab);
2491
+ }
2492
+ };
2493
+
2494
+ Tabs.prototype.activatePreviousTab = function () {
2495
+ var currentTab = this.getCurrentTab();
2496
+ var previousTabListItem = currentTab.parentNode.previousElementSibling;
2497
+ if (previousTabListItem) {
2498
+ var previousTab = previousTabListItem.querySelector('.govuk-tabs__tab');
2499
+ }
2500
+ if (previousTab) {
2501
+ this.hideTab(currentTab);
2502
+ this.showTab(previousTab);
2503
+ previousTab.focus();
2504
+ this.createHistoryEntry(previousTab);
2505
+ }
2506
+ };
2507
+
2508
+ Tabs.prototype.getPanel = function ($tab) {
2509
+ var $panel = this.$module.querySelector(this.getHref($tab));
2510
+ return $panel
2511
+ };
2512
+
2513
+ Tabs.prototype.showPanel = function ($tab) {
2514
+ var $panel = this.getPanel($tab);
2515
+ $panel.classList.remove(this.jsHiddenClass);
2516
+ };
2517
+
2518
+ Tabs.prototype.hidePanel = function (tab) {
2519
+ var $panel = this.getPanel(tab);
2520
+ $panel.classList.add(this.jsHiddenClass);
2521
+ };
2522
+
2523
+ Tabs.prototype.unhighlightTab = function ($tab) {
2524
+ $tab.setAttribute('aria-selected', 'false');
2525
+ $tab.parentNode.classList.remove('govuk-tabs__list-item--selected');
2526
+ $tab.setAttribute('tabindex', '-1');
2527
+ };
2528
+
2529
+ Tabs.prototype.highlightTab = function ($tab) {
2530
+ $tab.setAttribute('aria-selected', 'true');
2531
+ $tab.parentNode.classList.add('govuk-tabs__list-item--selected');
2532
+ $tab.setAttribute('tabindex', '0');
2533
+ };
2534
+
2535
+ Tabs.prototype.getCurrentTab = function () {
2536
+ return this.$module.querySelector('.govuk-tabs__list-item--selected .govuk-tabs__tab')
2537
+ };
2538
+
2539
+ // this is because IE doesn't always return the actual value but a relative full path
2540
+ // should be a utility function most prob
2541
+ // http://labs.thesedays.com/blog/2010/01/08/getting-the-href-value-with-jquery-in-ie/
2542
+ Tabs.prototype.getHref = function ($tab) {
2543
+ var href = $tab.getAttribute('href');
2544
+ var hash = href.slice(href.indexOf('#'), href.length);
2545
+ return hash
2546
+ };
2547
+
2548
+ function initAll (options) {
2549
+ // Set the options to an empty object by default if no options are passed.
2550
+ options = typeof options !== 'undefined' ? options : {};
2551
+
2552
+ // Allow the user to initialise GOV.UK Frontend in only certain sections of the page
2553
+ // Defaults to the entire document if nothing is set.
2554
+ var scope = typeof options.scope !== 'undefined' ? options.scope : document;
2555
+
2556
+ var $buttons = scope.querySelectorAll('[data-module="govuk-button"]');
2557
+ nodeListForEach($buttons, function ($button) {
2558
+ new Button($button).init();
2559
+ });
2560
+
2561
+ var $accordions = scope.querySelectorAll('[data-module="govuk-accordion"]');
2562
+ nodeListForEach($accordions, function ($accordion) {
2563
+ new Accordion($accordion).init();
2564
+ });
2565
+
2566
+ var $details = scope.querySelectorAll('[data-module="govuk-details"]');
2567
+ nodeListForEach($details, function ($detail) {
2568
+ new Details($detail).init();
2569
+ });
2570
+
2571
+ var $characterCounts = scope.querySelectorAll('[data-module="govuk-character-count"]');
2572
+ nodeListForEach($characterCounts, function ($characterCount) {
2573
+ new CharacterCount($characterCount).init();
2574
+ });
2575
+
2576
+ var $checkboxes = scope.querySelectorAll('[data-module="govuk-checkboxes"]');
2577
+ nodeListForEach($checkboxes, function ($checkbox) {
2578
+ new Checkboxes($checkbox).init();
2579
+ });
2580
+
2581
+ // Find first error summary module to enhance.
2582
+ var $errorSummary = scope.querySelector('[data-module="govuk-error-summary"]');
2583
+ new ErrorSummary($errorSummary).init();
2584
+
2585
+ // Find first header module to enhance.
2586
+ var $toggleButton = scope.querySelector('[data-module="govuk-header"]');
2587
+ new Header($toggleButton).init();
2588
+
2589
+ var $notificationBanners = scope.querySelectorAll('[data-module="govuk-notification-banner"]');
2590
+ nodeListForEach($notificationBanners, function ($notificationBanner) {
2591
+ new NotificationBanner($notificationBanner).init();
2592
+ });
2593
+
2594
+ var $radios = scope.querySelectorAll('[data-module="govuk-radios"]');
2595
+ nodeListForEach($radios, function ($radio) {
2596
+ new Radios($radio).init();
2597
+ });
2598
+
2599
+ var $tabs = scope.querySelectorAll('[data-module="govuk-tabs"]');
2600
+ nodeListForEach($tabs, function ($tabs) {
2601
+ new Tabs($tabs).init();
2602
+ });
2603
+ }
2604
+
2605
+ exports.initAll = initAll;
2606
+ exports.Accordion = Accordion;
2607
+ exports.Button = Button;
2608
+ exports.Details = Details;
2609
+ exports.CharacterCount = CharacterCount;
2610
+ exports.Checkboxes = Checkboxes;
2611
+ exports.ErrorSummary = ErrorSummary;
2612
+ exports.Header = Header;
2613
+ exports.Radios = Radios;
2614
+ exports.Tabs = Tabs;
2615
+
2616
+ })));