govuk_tech_docs 3.4.5 → 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/publish.yaml +8 -4
- data/.github/workflows/test.yaml +11 -4
- data/.rubocop.yml +1 -1
- data/CHANGELOG.md +22 -1
- data/example/.ruby-version +1 -1
- data/example/source/javascripts/govuk_frontend.js +1 -0
- data/govuk_tech_docs.gemspec +17 -11
- data/lib/assets/javascripts/_modules/page-expiry.js +2 -2
- data/lib/assets/javascripts/_modules/table-of-contents.js +48 -2
- data/lib/assets/javascripts/govuk_frontend_all.js +3 -0
- data/lib/assets/javascripts/govuk_tech_docs.js +0 -2
- data/lib/assets/stylesheets/_govuk_tech_docs.scss +4 -10
- data/lib/assets/stylesheets/modules/_page-review.scss +0 -2
- data/lib/assets/stylesheets/modules/_search.scss +0 -4
- data/lib/govuk_tech_docs/meta_tags.rb +1 -1
- data/lib/govuk_tech_docs/redirects.rb +1 -1
- data/lib/govuk_tech_docs/table_of_contents/heading_tree_builder.rb +1 -1
- data/lib/govuk_tech_docs/table_of_contents/helpers.rb +2 -2
- data/lib/govuk_tech_docs/tech_docs_html_renderer.rb +6 -2
- data/lib/govuk_tech_docs/version.rb +1 -1
- data/lib/govuk_tech_docs.rb +20 -3
- data/lib/source/layouts/_header.erb +8 -12
- data/lib/source/layouts/_page_review.erb +1 -1
- data/lib/source/layouts/_search.erb +2 -2
- data/lib/source/layouts/core.erb +8 -2
- data/lib/source/stylesheets/manifest.css +1 -1
- data/node_modules/govuk-frontend/dist/govuk/_base.scss +5 -0
- data/node_modules/govuk-frontend/dist/govuk/all.bundle.js +2554 -0
- data/node_modules/govuk-frontend/dist/govuk/all.bundle.mjs +2529 -0
- data/node_modules/govuk-frontend/dist/govuk/all.mjs +18 -0
- data/node_modules/govuk-frontend/dist/govuk/all.scss +3 -0
- data/node_modules/govuk-frontend/dist/govuk/assets/images/favicon.svg +1 -0
- data/node_modules/govuk-frontend/dist/govuk/assets/images/govuk-crest.svg +1 -0
- data/node_modules/govuk-frontend/dist/govuk/assets/images/govuk-icon-180.png +0 -0
- data/node_modules/govuk-frontend/dist/govuk/assets/images/govuk-icon-192.png +0 -0
- data/node_modules/govuk-frontend/dist/govuk/assets/images/govuk-icon-512.png +0 -0
- data/node_modules/govuk-frontend/dist/govuk/assets/images/govuk-icon-mask.svg +1 -0
- data/node_modules/govuk-frontend/dist/govuk/assets/images/govuk-opengraph-image.png +0 -0
- data/node_modules/govuk-frontend/dist/govuk/common/closest-attribute-value.mjs +7 -0
- data/node_modules/govuk-frontend/dist/govuk/common/govuk-frontend-version.mjs +4 -0
- data/node_modules/govuk-frontend/dist/govuk/common/index.mjs +159 -0
- data/node_modules/govuk-frontend/dist/govuk/common/normalise-dataset.mjs +18 -0
- data/node_modules/govuk-frontend/dist/govuk/common/normalise-string.mjs +31 -0
- data/node_modules/govuk-frontend/dist/govuk/components/_all.scss +10 -0
- data/node_modules/govuk-frontend/{govuk/components/_all.scss → dist/govuk/components/_index.scss} +8 -3
- data/node_modules/govuk-frontend/dist/govuk/components/accordion/_accordion.scss +4 -0
- data/node_modules/govuk-frontend/{govuk → dist/govuk}/components/accordion/_index.scss +55 -77
- data/node_modules/govuk-frontend/dist/govuk/components/accordion/accordion.bundle.js +785 -0
- data/node_modules/govuk-frontend/dist/govuk/components/accordion/accordion.bundle.mjs +777 -0
- data/node_modules/govuk-frontend/dist/govuk/components/accordion/accordion.mjs +349 -0
- data/node_modules/govuk-frontend/dist/govuk/components/back-link/_back-link.scss +4 -0
- data/node_modules/govuk-frontend/{govuk → dist/govuk}/components/back-link/_index.scss +12 -36
- data/node_modules/govuk-frontend/dist/govuk/components/breadcrumbs/_breadcrumbs.scss +4 -0
- data/node_modules/govuk-frontend/{govuk → dist/govuk}/components/breadcrumbs/_index.scss +11 -36
- data/node_modules/govuk-frontend/dist/govuk/components/button/_button.scss +4 -0
- data/node_modules/govuk-frontend/{govuk → dist/govuk}/components/button/_index.scss +30 -103
- data/node_modules/govuk-frontend/dist/govuk/components/button/button.bundle.js +318 -0
- data/node_modules/govuk-frontend/dist/govuk/components/button/button.bundle.mjs +310 -0
- data/node_modules/govuk-frontend/dist/govuk/components/button/button.mjs +73 -0
- data/node_modules/govuk-frontend/dist/govuk/components/character-count/_character-count.scss +4 -0
- data/node_modules/govuk-frontend/{govuk → dist/govuk}/components/character-count/_index.scss +8 -6
- data/node_modules/govuk-frontend/dist/govuk/components/character-count/character-count.bundle.js +761 -0
- data/node_modules/govuk-frontend/dist/govuk/components/character-count/character-count.bundle.mjs +753 -0
- data/node_modules/govuk-frontend/dist/govuk/components/character-count/character-count.mjs +295 -0
- data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/_checkboxes.scss +4 -0
- data/node_modules/govuk-frontend/{govuk → dist/govuk}/components/checkboxes/_index.scss +108 -132
- data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/checkboxes.bundle.js +268 -0
- data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/checkboxes.bundle.mjs +260 -0
- data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/checkboxes.mjs +111 -0
- data/node_modules/govuk-frontend/dist/govuk/components/cookie-banner/_cookie-banner.scss +4 -0
- data/node_modules/govuk-frontend/{govuk → dist/govuk}/components/cookie-banner/_index.scss +19 -15
- data/node_modules/govuk-frontend/dist/govuk/components/date-input/_date-input.scss +4 -0
- data/node_modules/govuk-frontend/{govuk → dist/govuk}/components/date-input/_index.scss +3 -2
- data/node_modules/govuk-frontend/dist/govuk/components/details/_details.scss +4 -0
- data/node_modules/govuk-frontend/dist/govuk/components/details/_index.scss +139 -0
- data/node_modules/govuk-frontend/dist/govuk/components/error-message/_error-message.scss +4 -0
- data/node_modules/govuk-frontend/{govuk → dist/govuk}/components/error-message/_index.scss +2 -0
- data/node_modules/govuk-frontend/dist/govuk/components/error-summary/_error-summary.scss +4 -0
- data/node_modules/govuk-frontend/{govuk → dist/govuk}/components/error-summary/_index.scss +19 -6
- data/node_modules/govuk-frontend/dist/govuk/components/error-summary/error-summary.bundle.js +378 -0
- data/node_modules/govuk-frontend/dist/govuk/components/error-summary/error-summary.bundle.mjs +370 -0
- data/node_modules/govuk-frontend/dist/govuk/components/error-summary/error-summary.mjs +103 -0
- data/node_modules/govuk-frontend/dist/govuk/components/exit-this-page/_exit-this-page.scss +4 -0
- data/node_modules/govuk-frontend/{govuk → dist/govuk}/components/exit-this-page/_index.scss +5 -10
- data/node_modules/govuk-frontend/dist/govuk/components/exit-this-page/exit-this-page.bundle.js +662 -0
- data/node_modules/govuk-frontend/dist/govuk/components/exit-this-page/exit-this-page.bundle.mjs +654 -0
- data/node_modules/govuk-frontend/dist/govuk/components/exit-this-page/exit-this-page.mjs +226 -0
- data/node_modules/govuk-frontend/dist/govuk/components/fieldset/_fieldset.scss +4 -0
- data/node_modules/govuk-frontend/{govuk → dist/govuk}/components/fieldset/_index.scss +20 -15
- data/node_modules/govuk-frontend/dist/govuk/components/file-upload/_file-upload.scss +4 -0
- data/node_modules/govuk-frontend/{govuk → dist/govuk}/components/file-upload/_index.scss +11 -15
- data/node_modules/govuk-frontend/dist/govuk/components/footer/_footer.scss +4 -0
- data/node_modules/govuk-frontend/{govuk → dist/govuk}/components/footer/_index.scss +25 -68
- data/node_modules/govuk-frontend/dist/govuk/components/header/_header.scss +4 -0
- data/node_modules/govuk-frontend/{govuk → dist/govuk}/components/header/_index.scss +84 -79
- data/node_modules/govuk-frontend/dist/govuk/components/header/header.bundle.js +252 -0
- data/node_modules/govuk-frontend/dist/govuk/components/header/header.bundle.mjs +244 -0
- data/node_modules/govuk-frontend/dist/govuk/components/header/header.mjs +88 -0
- data/node_modules/govuk-frontend/{govuk → dist/govuk}/components/hint/_hint.scss +2 -0
- data/node_modules/govuk-frontend/{govuk → dist/govuk}/components/hint/_index.scss +3 -0
- data/node_modules/govuk-frontend/{govuk → dist/govuk}/components/input/_index.scss +24 -49
- data/node_modules/govuk-frontend/{govuk → dist/govuk}/components/input/_input.scss +2 -0
- data/node_modules/govuk-frontend/{govuk → dist/govuk}/components/inset-text/_index.scss +2 -0
- data/node_modules/govuk-frontend/dist/govuk/components/inset-text/_inset-text.scss +4 -0
- data/node_modules/govuk-frontend/{govuk → dist/govuk}/components/label/_index.scss +12 -7
- data/node_modules/govuk-frontend/{govuk → dist/govuk}/components/label/_label.scss +2 -0
- data/node_modules/govuk-frontend/{govuk → dist/govuk}/components/notification-banner/_index.scss +11 -7
- data/node_modules/govuk-frontend/dist/govuk/components/notification-banner/_notification-banner.scss +4 -0
- data/node_modules/govuk-frontend/dist/govuk/components/notification-banner/notification-banner.bundle.js +320 -0
- data/node_modules/govuk-frontend/dist/govuk/components/notification-banner/notification-banner.bundle.mjs +312 -0
- data/node_modules/govuk-frontend/dist/govuk/components/notification-banner/notification-banner.mjs +51 -0
- data/node_modules/govuk-frontend/{govuk → dist/govuk}/components/pagination/_index.scss +36 -55
- data/node_modules/govuk-frontend/dist/govuk/components/pagination/_pagination.scss +4 -0
- data/node_modules/govuk-frontend/dist/govuk/components/panel/_index.scss +58 -0
- data/node_modules/govuk-frontend/{govuk → dist/govuk}/components/panel/_panel.scss +2 -0
- data/node_modules/govuk-frontend/dist/govuk/components/password-input/_index.scss +57 -0
- data/node_modules/govuk-frontend/dist/govuk/components/password-input/_password-input.scss +4 -0
- data/node_modules/govuk-frontend/dist/govuk/components/password-input/password-input.bundle.js +594 -0
- data/node_modules/govuk-frontend/dist/govuk/components/password-input/password-input.bundle.mjs +586 -0
- data/node_modules/govuk-frontend/dist/govuk/components/password-input/password-input.mjs +154 -0
- data/node_modules/govuk-frontend/{govuk → dist/govuk}/components/phase-banner/_index.scss +10 -1
- data/node_modules/govuk-frontend/dist/govuk/components/phase-banner/_phase-banner.scss +4 -0
- data/node_modules/govuk-frontend/{govuk → dist/govuk}/components/radios/_index.scss +92 -113
- data/node_modules/govuk-frontend/dist/govuk/components/radios/_radios.scss +4 -0
- data/node_modules/govuk-frontend/dist/govuk/components/radios/radios.bundle.js +245 -0
- data/node_modules/govuk-frontend/dist/govuk/components/radios/radios.bundle.mjs +237 -0
- data/node_modules/govuk-frontend/dist/govuk/components/radios/radios.mjs +88 -0
- data/node_modules/govuk-frontend/{govuk → dist/govuk}/components/select/_index.scss +9 -16
- data/node_modules/govuk-frontend/dist/govuk/components/select/_select.scss +4 -0
- data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/_index.scss +168 -0
- data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/_service-navigation.scss +4 -0
- data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/service-navigation.bundle.js +249 -0
- data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/service-navigation.bundle.mjs +241 -0
- data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/service-navigation.mjs +85 -0
- data/node_modules/govuk-frontend/{govuk → dist/govuk}/components/skip-link/_index.scss +10 -5
- data/node_modules/govuk-frontend/dist/govuk/components/skip-link/_skip-link.scss +4 -0
- data/node_modules/govuk-frontend/dist/govuk/components/skip-link/skip-link.bundle.js +244 -0
- data/node_modules/govuk-frontend/dist/govuk/components/skip-link/skip-link.bundle.mjs +236 -0
- data/node_modules/govuk-frontend/dist/govuk/components/skip-link/skip-link.mjs +58 -0
- data/node_modules/govuk-frontend/{govuk → dist/govuk}/components/summary-list/_index.scss +22 -20
- data/node_modules/govuk-frontend/dist/govuk/components/summary-list/_summary-list.scss +4 -0
- data/node_modules/govuk-frontend/{govuk → dist/govuk}/components/table/_index.scss +21 -17
- data/node_modules/govuk-frontend/{govuk → dist/govuk}/components/table/_table.scss +2 -0
- data/node_modules/govuk-frontend/{govuk → dist/govuk}/components/tabs/_index.scss +13 -9
- data/node_modules/govuk-frontend/{govuk → dist/govuk}/components/tabs/_tabs.scss +2 -0
- data/node_modules/govuk-frontend/dist/govuk/components/tabs/tabs.bundle.js +453 -0
- data/node_modules/govuk-frontend/dist/govuk/components/tabs/tabs.bundle.mjs +445 -0
- data/node_modules/govuk-frontend/dist/govuk/components/tabs/tabs.mjs +283 -0
- data/node_modules/govuk-frontend/dist/govuk/components/tag/_index.scss +97 -0
- data/node_modules/govuk-frontend/{govuk → dist/govuk}/components/tag/_tag.scss +2 -0
- data/node_modules/govuk-frontend/dist/govuk/components/task-list/_index.scss +79 -0
- data/node_modules/govuk-frontend/dist/govuk/components/task-list/_task-list.scss +4 -0
- data/node_modules/govuk-frontend/{govuk → dist/govuk}/components/textarea/_index.scss +6 -10
- data/node_modules/govuk-frontend/dist/govuk/components/textarea/_textarea.scss +4 -0
- data/node_modules/govuk-frontend/{govuk → dist/govuk}/components/warning-text/_index.scss +13 -13
- data/node_modules/govuk-frontend/dist/govuk/components/warning-text/_warning-text.scss +4 -0
- data/node_modules/govuk-frontend/dist/govuk/core/_all.scss +10 -0
- data/node_modules/govuk-frontend/{govuk → dist/govuk}/core/_global-styles.scss +2 -1
- data/node_modules/govuk-frontend/dist/govuk/core/_govuk-frontend-properties.scss +12 -0
- data/node_modules/govuk-frontend/{govuk/core/_all.scss → dist/govuk/core/_index.scss} +3 -1
- data/node_modules/govuk-frontend/{govuk → dist/govuk}/core/_links.scss +8 -1
- data/node_modules/govuk-frontend/{govuk → dist/govuk}/core/_lists.scss +2 -1
- data/node_modules/govuk-frontend/{govuk → dist/govuk}/core/_section-break.scss +2 -7
- data/node_modules/govuk-frontend/{govuk → dist/govuk}/core/_typography.scss +8 -5
- data/node_modules/govuk-frontend/dist/govuk/errors/index.mjs +57 -0
- data/node_modules/govuk-frontend/dist/govuk/govuk-frontend-component.mjs +60 -0
- data/node_modules/govuk-frontend/dist/govuk/govuk-frontend.min.js +1 -0
- data/node_modules/govuk-frontend/dist/govuk/helpers/_all.scss +10 -0
- data/node_modules/govuk-frontend/{govuk → dist/govuk}/helpers/_clearfix.scss +3 -1
- data/node_modules/govuk-frontend/dist/govuk/helpers/_colour.scss +127 -0
- data/node_modules/govuk-frontend/{govuk → dist/govuk}/helpers/_device-pixels.scss +4 -3
- data/node_modules/govuk-frontend/{govuk → dist/govuk}/helpers/_focused.scss +22 -6
- data/node_modules/govuk-frontend/dist/govuk/helpers/_font-faces.scss +41 -0
- data/node_modules/govuk-frontend/{govuk → dist/govuk}/helpers/_grid.scss +3 -1
- data/node_modules/govuk-frontend/{govuk/helpers/_all.scss → dist/govuk/helpers/_index.scss} +2 -0
- data/node_modules/govuk-frontend/{govuk → dist/govuk}/helpers/_links.scss +38 -76
- data/node_modules/govuk-frontend/{govuk → dist/govuk}/helpers/_media-queries.scss +3 -12
- data/node_modules/govuk-frontend/{govuk → dist/govuk}/helpers/_shape-arrow.scss +3 -1
- data/node_modules/govuk-frontend/{govuk → dist/govuk}/helpers/_spacing.scss +12 -10
- data/node_modules/govuk-frontend/dist/govuk/helpers/_typography.scss +288 -0
- data/node_modules/govuk-frontend/{govuk → dist/govuk}/helpers/_visually-hidden.scss +39 -50
- data/node_modules/govuk-frontend/dist/govuk/i18n.mjs +195 -0
- data/node_modules/govuk-frontend/dist/govuk/index.scss +11 -0
- data/node_modules/govuk-frontend/dist/govuk/init.mjs +162 -0
- data/node_modules/govuk-frontend/dist/govuk/objects/_all.scss +10 -0
- data/node_modules/govuk-frontend/{govuk → dist/govuk}/objects/_button-group.scss +7 -12
- data/node_modules/govuk-frontend/{govuk → dist/govuk}/objects/_form-group.scss +2 -0
- data/node_modules/govuk-frontend/{govuk → dist/govuk}/objects/_grid.scss +4 -2
- data/node_modules/govuk-frontend/{govuk/objects/_all.scss → dist/govuk/objects/_index.scss} +2 -0
- data/node_modules/govuk-frontend/{govuk → dist/govuk}/objects/_main-wrapper.scss +2 -0
- data/node_modules/govuk-frontend/{govuk → dist/govuk}/objects/_template.scss +2 -1
- data/node_modules/govuk-frontend/{govuk → dist/govuk}/objects/_width-container.scss +2 -9
- data/node_modules/govuk-frontend/dist/govuk/overrides/_all.scss +9 -0
- data/node_modules/govuk-frontend/{govuk → dist/govuk}/overrides/_display.scss +2 -0
- data/node_modules/govuk-frontend/{govuk/overrides/_all.scss → dist/govuk/overrides/_index.scss} +2 -0
- data/node_modules/govuk-frontend/{govuk → dist/govuk}/overrides/_spacing.scss +3 -19
- data/node_modules/govuk-frontend/{govuk → dist/govuk}/overrides/_text-align.scss +2 -0
- data/node_modules/govuk-frontend/dist/govuk/overrides/_typography.scss +42 -0
- data/node_modules/govuk-frontend/{govuk → dist/govuk}/overrides/_width.scss +2 -0
- data/node_modules/govuk-frontend/dist/govuk/settings/_all.scss +10 -0
- data/node_modules/govuk-frontend/{govuk → dist/govuk}/settings/_assets.scss +2 -0
- data/node_modules/govuk-frontend/{govuk → dist/govuk}/settings/_colours-applied.scss +9 -7
- data/node_modules/govuk-frontend/dist/govuk/settings/_colours-organisations.scss +378 -0
- data/node_modules/govuk-frontend/dist/govuk/settings/_colours-palette.scss +37 -0
- data/node_modules/govuk-frontend/{govuk → dist/govuk}/settings/_global-styles.scss +2 -0
- data/node_modules/govuk-frontend/{govuk/settings/_all.scss → dist/govuk/settings/_index.scss} +2 -3
- data/node_modules/govuk-frontend/{govuk → dist/govuk}/settings/_links.scss +3 -20
- data/node_modules/govuk-frontend/{govuk → dist/govuk}/settings/_measurements.scss +18 -6
- data/node_modules/govuk-frontend/{govuk → dist/govuk}/settings/_media-queries.scss +5 -3
- data/node_modules/govuk-frontend/{govuk → dist/govuk}/settings/_spacing.scss +2 -0
- data/node_modules/govuk-frontend/dist/govuk/settings/_typography-font.scss +52 -0
- data/node_modules/govuk-frontend/dist/govuk/settings/_typography-responsive.scss +322 -0
- data/node_modules/govuk-frontend/{govuk → dist/govuk}/settings/_warnings.scss +33 -8
- data/node_modules/govuk-frontend/dist/govuk/tools/_all.scss +10 -0
- data/node_modules/govuk-frontend/{govuk → dist/govuk}/tools/_exports.scss +2 -0
- data/node_modules/govuk-frontend/{govuk → dist/govuk}/tools/_font-url.scss +3 -0
- data/node_modules/govuk-frontend/{govuk → dist/govuk}/tools/_image-url.scss +3 -0
- data/node_modules/govuk-frontend/{govuk/tools/_all.scss → dist/govuk/tools/_index.scss} +2 -2
- data/node_modules/govuk-frontend/{govuk → dist/govuk}/tools/_px-to-em.scss +2 -0
- data/node_modules/govuk-frontend/{govuk → dist/govuk}/tools/_px-to-rem.scss +2 -0
- data/node_modules/govuk-frontend/dist/govuk/utilities/_all.scss +10 -0
- data/node_modules/govuk-frontend/{govuk → dist/govuk}/utilities/_clearfix.scss +2 -0
- data/node_modules/govuk-frontend/{govuk/utilities/_all.scss → dist/govuk/utilities/_index.scss} +2 -0
- data/node_modules/govuk-frontend/{govuk → dist/govuk}/utilities/_visually-hidden.scss +2 -0
- data/node_modules/govuk-frontend/{govuk → dist/govuk}/vendor/_sass-mq.scss +3 -1
- data/node_modules/govuk-frontend/dist/govuk-prototype-kit/init.js +15 -0
- data/node_modules/govuk-frontend/{govuk-prototype-kit → dist/govuk-prototype-kit}/init.scss +3 -2
- data/package-lock.json +37 -37
- data/package.json +6 -1
- metadata +316 -206
- data/node_modules/govuk-frontend/govuk/_base.scss +0 -3
- data/node_modules/govuk-frontend/govuk/all-ie8.scss +0 -14
- data/node_modules/govuk-frontend/govuk/all.js +0 -5172
- data/node_modules/govuk-frontend/govuk/all.scss +0 -9
- data/node_modules/govuk-frontend/govuk/assets/images/favicon.ico +0 -0
- data/node_modules/govuk-frontend/govuk/assets/images/govuk-apple-touch-icon-152x152.png +0 -0
- data/node_modules/govuk-frontend/govuk/assets/images/govuk-apple-touch-icon-167x167.png +0 -0
- data/node_modules/govuk-frontend/govuk/assets/images/govuk-apple-touch-icon-180x180.png +0 -0
- data/node_modules/govuk-frontend/govuk/assets/images/govuk-apple-touch-icon.png +0 -0
- data/node_modules/govuk-frontend/govuk/assets/images/govuk-crest-2x.png +0 -0
- data/node_modules/govuk-frontend/govuk/assets/images/govuk-crest.png +0 -0
- data/node_modules/govuk-frontend/govuk/assets/images/govuk-logotype-crown.png +0 -0
- data/node_modules/govuk-frontend/govuk/assets/images/govuk-mask-icon.svg +0 -7
- data/node_modules/govuk-frontend/govuk/assets/images/govuk-opengraph-image.png +0 -0
- data/node_modules/govuk-frontend/govuk/common/closest-attribute-value.js +0 -75
- data/node_modules/govuk-frontend/govuk/common/govuk-frontend-version.js +0 -17
- data/node_modules/govuk-frontend/govuk/common/index.js +0 -192
- data/node_modules/govuk-frontend/govuk/common/normalise-dataset.js +0 -386
- data/node_modules/govuk-frontend/govuk/common.js +0 -194
- data/node_modules/govuk-frontend/govuk/components/accordion/_accordion.scss +0 -2
- data/node_modules/govuk-frontend/govuk/components/accordion/accordion.js +0 -2386
- data/node_modules/govuk-frontend/govuk/components/back-link/_back-link.scss +0 -2
- data/node_modules/govuk-frontend/govuk/components/breadcrumbs/_breadcrumbs.scss +0 -2
- data/node_modules/govuk-frontend/govuk/components/button/_button.scss +0 -2
- data/node_modules/govuk-frontend/govuk/components/button/button.js +0 -1027
- data/node_modules/govuk-frontend/govuk/components/character-count/_character-count.scss +0 -2
- data/node_modules/govuk-frontend/govuk/components/character-count/character-count.js +0 -2281
- data/node_modules/govuk-frontend/govuk/components/checkboxes/_checkboxes.scss +0 -2
- data/node_modules/govuk-frontend/govuk/components/checkboxes/checkboxes.js +0 -1277
- data/node_modules/govuk-frontend/govuk/components/cookie-banner/_cookie-banner.scss +0 -2
- data/node_modules/govuk-frontend/govuk/components/date-input/_date-input.scss +0 -2
- data/node_modules/govuk-frontend/govuk/components/details/_details.scss +0 -2
- data/node_modules/govuk-frontend/govuk/components/details/_index.scss +0 -88
- data/node_modules/govuk-frontend/govuk/components/details/details.js +0 -873
- data/node_modules/govuk-frontend/govuk/components/error-message/_error-message.scss +0 -2
- data/node_modules/govuk-frontend/govuk/components/error-summary/_error-summary.scss +0 -2
- data/node_modules/govuk-frontend/govuk/components/error-summary/error-summary.js +0 -1189
- data/node_modules/govuk-frontend/govuk/components/exit-this-page/_exit-this-page.scss +0 -2
- data/node_modules/govuk-frontend/govuk/components/exit-this-page/exit-this-page.js +0 -2120
- data/node_modules/govuk-frontend/govuk/components/fieldset/_fieldset.scss +0 -2
- data/node_modules/govuk-frontend/govuk/components/file-upload/_file-upload.scss +0 -2
- data/node_modules/govuk-frontend/govuk/components/footer/_footer.scss +0 -2
- data/node_modules/govuk-frontend/govuk/components/header/_header.scss +0 -2
- data/node_modules/govuk-frontend/govuk/components/header/header.js +0 -794
- data/node_modules/govuk-frontend/govuk/components/inset-text/_inset-text.scss +0 -2
- data/node_modules/govuk-frontend/govuk/components/notification-banner/_notification-banner.scss +0 -2
- data/node_modules/govuk-frontend/govuk/components/notification-banner/notification-banner.js +0 -843
- data/node_modules/govuk-frontend/govuk/components/pagination/_pagination.scss +0 -2
- data/node_modules/govuk-frontend/govuk/components/panel/_index.scss +0 -56
- data/node_modules/govuk-frontend/govuk/components/phase-banner/_phase-banner.scss +0 -2
- data/node_modules/govuk-frontend/govuk/components/radios/_radios.scss +0 -2
- data/node_modules/govuk-frontend/govuk/components/radios/radios.js +0 -1222
- data/node_modules/govuk-frontend/govuk/components/select/_select.scss +0 -2
- data/node_modules/govuk-frontend/govuk/components/skip-link/_skip-link.scss +0 -2
- data/node_modules/govuk-frontend/govuk/components/skip-link/skip-link.js +0 -1145
- data/node_modules/govuk-frontend/govuk/components/summary-list/_summary-list.scss +0 -2
- data/node_modules/govuk-frontend/govuk/components/tabs/tabs.js +0 -1621
- data/node_modules/govuk-frontend/govuk/components/tag/_index.scss +0 -81
- data/node_modules/govuk-frontend/govuk/components/textarea/_textarea.scss +0 -2
- data/node_modules/govuk-frontend/govuk/components/warning-text/_warning-text.scss +0 -2
- data/node_modules/govuk-frontend/govuk/core/_govuk-frontend-version.scss +0 -5
- data/node_modules/govuk-frontend/govuk/helpers/_colour.scss +0 -98
- data/node_modules/govuk-frontend/govuk/helpers/_font-faces.scss +0 -41
- data/node_modules/govuk-frontend/govuk/helpers/_typography.scss +0 -214
- data/node_modules/govuk-frontend/govuk/i18n.js +0 -397
- data/node_modules/govuk-frontend/govuk/overrides/_typography.scss +0 -21
- data/node_modules/govuk-frontend/govuk/settings/_colours-organisations.scss +0 -146
- data/node_modules/govuk-frontend/govuk/settings/_colours-palette.scss +0 -120
- data/node_modules/govuk-frontend/govuk/settings/_compatibility.scss +0 -100
- data/node_modules/govuk-frontend/govuk/settings/_ie8.scss +0 -34
- data/node_modules/govuk-frontend/govuk/settings/_typography-font-families.scss +0 -32
- data/node_modules/govuk-frontend/govuk/settings/_typography-font.scss +0 -112
- data/node_modules/govuk-frontend/govuk/settings/_typography-responsive.scss +0 -195
- data/node_modules/govuk-frontend/govuk/tools/_compatibility.scss +0 -50
- data/node_modules/govuk-frontend/govuk/tools/_ie8.scss +0 -87
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/DOMTokenList.js +0 -274
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Date/now.js +0 -23
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Document.js +0 -36
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/classList.js +0 -597
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/closest.js +0 -58
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/dataset.js +0 -307
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/matches.js +0 -33
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/nextElementSibling.js +0 -261
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/previousElementSibling.js +0 -261
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element.js +0 -151
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Event.js +0 -512
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Function/prototype/bind.js +0 -256
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Object/defineProperty.js +0 -96
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/String/prototype/trim.js +0 -23
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Window.js +0 -30
- data/node_modules/govuk-frontend/govuk-prototype-kit/init.js +0 -8
- /data/node_modules/govuk-frontend/{govuk → dist/govuk}/assets/fonts/bold-affa96571d-v2.woff +0 -0
- /data/node_modules/govuk-frontend/{govuk → dist/govuk}/assets/fonts/bold-b542beb274-v2.woff2 +0 -0
- /data/node_modules/govuk-frontend/{govuk → dist/govuk}/assets/fonts/light-94a07e06a1-v2.woff2 +0 -0
- /data/node_modules/govuk-frontend/{govuk → dist/govuk}/assets/fonts/light-f591b13f7d-v2.woff +0 -0
- /data/{lib/source → node_modules/govuk-frontend/dist/govuk/assets/images}/favicon.ico +0 -0
@@ -1,2386 +0,0 @@
|
|
1
|
-
(function (global, factory) {
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
3
|
-
typeof define === 'function' && define.amd ? define('GOVUKFrontend.Accordion', factory) :
|
4
|
-
(global.GOVUKFrontend = global.GOVUKFrontend || {}, global.GOVUKFrontend.Accordion = factory());
|
5
|
-
}(this, (function () { 'use strict';
|
6
|
-
|
7
|
-
/**
|
8
|
-
* Common helpers which do not require polyfill.
|
9
|
-
*
|
10
|
-
* IMPORTANT: If a helper require a polyfill, please isolate it in its own module
|
11
|
-
* so that the polyfill can be properly tree-shaken and does not burden
|
12
|
-
* the components that do not need that helper
|
13
|
-
*
|
14
|
-
* @module common/index
|
15
|
-
*/
|
16
|
-
|
17
|
-
/**
|
18
|
-
* TODO: Ideally this would be a NodeList.prototype.forEach polyfill
|
19
|
-
* This seems to fail in IE8, requires more investigation.
|
20
|
-
* See: https://github.com/imagitama/nodelist-foreach-polyfill
|
21
|
-
*
|
22
|
-
* @deprecated Will be made private in v5.0
|
23
|
-
* @template {Node} ElementType
|
24
|
-
* @param {NodeListOf<ElementType>} nodes - NodeList from querySelectorAll()
|
25
|
-
* @param {nodeListIterator<ElementType>} callback - Callback function to run for each node
|
26
|
-
* @returns {void}
|
27
|
-
*/
|
28
|
-
function nodeListForEach (nodes, callback) {
|
29
|
-
if (window.NodeList.prototype.forEach) {
|
30
|
-
return nodes.forEach(callback)
|
31
|
-
}
|
32
|
-
for (var i = 0; i < nodes.length; i++) {
|
33
|
-
callback.call(window, nodes[i], i, nodes);
|
34
|
-
}
|
35
|
-
}
|
36
|
-
|
37
|
-
/**
|
38
|
-
* Config flattening function
|
39
|
-
*
|
40
|
-
* Takes any number of objects, flattens them into namespaced key-value pairs,
|
41
|
-
* (e.g. {'i18n.showSection': 'Show section'}) and combines them together, with
|
42
|
-
* greatest priority on the LAST item passed in.
|
43
|
-
*
|
44
|
-
* @deprecated Will be made private in v5.0
|
45
|
-
* @returns {Object<string, unknown>} A flattened object of key-value pairs.
|
46
|
-
*/
|
47
|
-
function mergeConfigs (/* configObject1, configObject2, ...configObjects */) {
|
48
|
-
/**
|
49
|
-
* Function to take nested objects and flatten them to a dot-separated keyed
|
50
|
-
* object. Doing this means we don't need to do any deep/recursive merging of
|
51
|
-
* each of our objects, nor transform our dataset from a flat list into a
|
52
|
-
* nested object.
|
53
|
-
*
|
54
|
-
* @param {Object<string, unknown>} configObject - Deeply nested object
|
55
|
-
* @returns {Object<string, unknown>} Flattened object with dot-separated keys
|
56
|
-
*/
|
57
|
-
var flattenObject = function (configObject) {
|
58
|
-
// Prepare an empty return object
|
59
|
-
/** @type {Object<string, unknown>} */
|
60
|
-
var flattenedObject = {};
|
61
|
-
|
62
|
-
/**
|
63
|
-
* Our flattening function, this is called recursively for each level of
|
64
|
-
* depth in the object. At each level we prepend the previous level names to
|
65
|
-
* the key using `prefix`.
|
66
|
-
*
|
67
|
-
* @param {Partial<Object<string, unknown>>} obj - Object to flatten
|
68
|
-
* @param {string} [prefix] - Optional dot-separated prefix
|
69
|
-
*/
|
70
|
-
var flattenLoop = function (obj, prefix) {
|
71
|
-
// Loop through keys...
|
72
|
-
for (var key in obj) {
|
73
|
-
// Check to see if this is a prototypical key/value,
|
74
|
-
// if it is, skip it.
|
75
|
-
if (!Object.prototype.hasOwnProperty.call(obj, key)) {
|
76
|
-
continue
|
77
|
-
}
|
78
|
-
var value = obj[key];
|
79
|
-
var prefixedKey = prefix ? prefix + '.' + key : key;
|
80
|
-
if (typeof value === 'object') {
|
81
|
-
// If the value is a nested object, recurse over that too
|
82
|
-
flattenLoop(value, prefixedKey);
|
83
|
-
} else {
|
84
|
-
// Otherwise, add this value to our return object
|
85
|
-
flattenedObject[prefixedKey] = value;
|
86
|
-
}
|
87
|
-
}
|
88
|
-
};
|
89
|
-
|
90
|
-
// Kick off the recursive loop
|
91
|
-
flattenLoop(configObject);
|
92
|
-
return flattenedObject
|
93
|
-
};
|
94
|
-
|
95
|
-
// Start with an empty object as our base
|
96
|
-
/** @type {Object<string, unknown>} */
|
97
|
-
var formattedConfigObject = {};
|
98
|
-
|
99
|
-
// Loop through each of the remaining passed objects and push their keys
|
100
|
-
// one-by-one into configObject. Any duplicate keys will override the existing
|
101
|
-
// key with the new value.
|
102
|
-
for (var i = 0; i < arguments.length; i++) {
|
103
|
-
var obj = flattenObject(arguments[i]);
|
104
|
-
for (var key in obj) {
|
105
|
-
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
106
|
-
formattedConfigObject[key] = obj[key];
|
107
|
-
}
|
108
|
-
}
|
109
|
-
}
|
110
|
-
|
111
|
-
return formattedConfigObject
|
112
|
-
}
|
113
|
-
|
114
|
-
/**
|
115
|
-
* Extracts keys starting with a particular namespace from a flattened config
|
116
|
-
* object, removing the namespace in the process.
|
117
|
-
*
|
118
|
-
* @deprecated Will be made private in v5.0
|
119
|
-
* @param {Object<string, unknown>} configObject - The object to extract key-value pairs from.
|
120
|
-
* @param {string} namespace - The namespace to filter keys with.
|
121
|
-
* @returns {Object<string, unknown>} Flattened object with dot-separated key namespace removed
|
122
|
-
* @throws {Error} Config object required
|
123
|
-
* @throws {Error} Namespace string required
|
124
|
-
*/
|
125
|
-
function extractConfigByNamespace (configObject, namespace) {
|
126
|
-
// Check we have what we need
|
127
|
-
if (!configObject || typeof configObject !== 'object') {
|
128
|
-
throw new Error('Provide a `configObject` of type "object".')
|
129
|
-
}
|
130
|
-
|
131
|
-
if (!namespace || typeof namespace !== 'string') {
|
132
|
-
throw new Error('Provide a `namespace` of type "string" to filter the `configObject` by.')
|
133
|
-
}
|
134
|
-
|
135
|
-
/** @type {Object<string, unknown>} */
|
136
|
-
var newObject = {};
|
137
|
-
|
138
|
-
for (var key in configObject) {
|
139
|
-
// Split the key into parts, using . as our namespace separator
|
140
|
-
var keyParts = key.split('.');
|
141
|
-
// Check if the first namespace matches the configured namespace
|
142
|
-
if (Object.prototype.hasOwnProperty.call(configObject, key) && keyParts[0] === namespace) {
|
143
|
-
// Remove the first item (the namespace) from the parts array,
|
144
|
-
// but only if there is more than one part (we don't want blank keys!)
|
145
|
-
if (keyParts.length > 1) {
|
146
|
-
keyParts.shift();
|
147
|
-
}
|
148
|
-
// Join the remaining parts back together
|
149
|
-
var newKey = keyParts.join('.');
|
150
|
-
// Add them to our new object
|
151
|
-
newObject[newKey] = configObject[key];
|
152
|
-
}
|
153
|
-
}
|
154
|
-
return newObject
|
155
|
-
}
|
156
|
-
|
157
|
-
/**
|
158
|
-
* @template {Node} ElementType
|
159
|
-
* @callback nodeListIterator
|
160
|
-
* @param {ElementType} value - The current node being iterated on
|
161
|
-
* @param {number} index - The current index in the iteration
|
162
|
-
* @param {NodeListOf<ElementType>} nodes - NodeList from querySelectorAll()
|
163
|
-
* @returns {void}
|
164
|
-
*/
|
165
|
-
|
166
|
-
// @ts-nocheck
|
167
|
-
(function (undefined) {
|
168
|
-
|
169
|
-
// Detection from https://github.com/Financial-Times/polyfill-service/blob/master/packages/polyfill-library/polyfills/Object/defineProperty/detect.js
|
170
|
-
var detect = (
|
171
|
-
// In IE8, defineProperty could only act on DOM elements, so full support
|
172
|
-
// for the feature requires the ability to set a property on an arbitrary object
|
173
|
-
'defineProperty' in Object && (function() {
|
174
|
-
try {
|
175
|
-
var a = {};
|
176
|
-
Object.defineProperty(a, 'test', {value:42});
|
177
|
-
return true;
|
178
|
-
} catch(e) {
|
179
|
-
return false
|
180
|
-
}
|
181
|
-
}())
|
182
|
-
);
|
183
|
-
|
184
|
-
if (detect) return
|
185
|
-
|
186
|
-
// Polyfill from https://cdn.polyfill.io/v2/polyfill.js?features=Object.defineProperty&flags=always
|
187
|
-
(function (nativeDefineProperty) {
|
188
|
-
|
189
|
-
var supportsAccessors = Object.prototype.hasOwnProperty('__defineGetter__');
|
190
|
-
var ERR_ACCESSORS_NOT_SUPPORTED = 'Getters & setters cannot be defined on this javascript engine';
|
191
|
-
var ERR_VALUE_ACCESSORS = 'A property cannot both have accessors and be writable or have a value';
|
192
|
-
|
193
|
-
Object.defineProperty = function defineProperty(object, property, descriptor) {
|
194
|
-
|
195
|
-
// Where native support exists, assume it
|
196
|
-
if (nativeDefineProperty && (object === window || object === document || object === Element.prototype || object instanceof Element)) {
|
197
|
-
return nativeDefineProperty(object, property, descriptor);
|
198
|
-
}
|
199
|
-
|
200
|
-
if (object === null || !(object instanceof Object || typeof object === 'object')) {
|
201
|
-
throw new TypeError('Object.defineProperty called on non-object');
|
202
|
-
}
|
203
|
-
|
204
|
-
if (!(descriptor instanceof Object)) {
|
205
|
-
throw new TypeError('Property description must be an object');
|
206
|
-
}
|
207
|
-
|
208
|
-
var propertyString = String(property);
|
209
|
-
var hasValueOrWritable = 'value' in descriptor || 'writable' in descriptor;
|
210
|
-
var getterType = 'get' in descriptor && typeof descriptor.get;
|
211
|
-
var setterType = 'set' in descriptor && typeof descriptor.set;
|
212
|
-
|
213
|
-
// handle descriptor.get
|
214
|
-
if (getterType) {
|
215
|
-
if (getterType !== 'function') {
|
216
|
-
throw new TypeError('Getter must be a function');
|
217
|
-
}
|
218
|
-
if (!supportsAccessors) {
|
219
|
-
throw new TypeError(ERR_ACCESSORS_NOT_SUPPORTED);
|
220
|
-
}
|
221
|
-
if (hasValueOrWritable) {
|
222
|
-
throw new TypeError(ERR_VALUE_ACCESSORS);
|
223
|
-
}
|
224
|
-
Object.__defineGetter__.call(object, propertyString, descriptor.get);
|
225
|
-
} else {
|
226
|
-
object[propertyString] = descriptor.value;
|
227
|
-
}
|
228
|
-
|
229
|
-
// handle descriptor.set
|
230
|
-
if (setterType) {
|
231
|
-
if (setterType !== 'function') {
|
232
|
-
throw new TypeError('Setter must be a function');
|
233
|
-
}
|
234
|
-
if (!supportsAccessors) {
|
235
|
-
throw new TypeError(ERR_ACCESSORS_NOT_SUPPORTED);
|
236
|
-
}
|
237
|
-
if (hasValueOrWritable) {
|
238
|
-
throw new TypeError(ERR_VALUE_ACCESSORS);
|
239
|
-
}
|
240
|
-
Object.__defineSetter__.call(object, propertyString, descriptor.set);
|
241
|
-
}
|
242
|
-
|
243
|
-
// OK to define value unconditionally - if a getter has been specified as well, an error would be thrown above
|
244
|
-
if ('value' in descriptor) {
|
245
|
-
object[propertyString] = descriptor.value;
|
246
|
-
}
|
247
|
-
|
248
|
-
return object;
|
249
|
-
};
|
250
|
-
}(Object.defineProperty));
|
251
|
-
})
|
252
|
-
.call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
|
253
|
-
|
254
|
-
// @ts-nocheck
|
255
|
-
(function (undefined) {
|
256
|
-
|
257
|
-
// Detection from https://github.com/Financial-Times/polyfill-service/blob/master/packages/polyfill-library/polyfills/Document/detect.js
|
258
|
-
var detect = ("Document" in this);
|
259
|
-
|
260
|
-
if (detect) return
|
261
|
-
|
262
|
-
// Polyfill from https://cdn.polyfill.io/v2/polyfill.js?features=Document&flags=always
|
263
|
-
if ((typeof WorkerGlobalScope === "undefined") && (typeof importScripts !== "function")) {
|
264
|
-
|
265
|
-
if (this.HTMLDocument) { // IE8
|
266
|
-
|
267
|
-
// HTMLDocument is an extension of Document. If the browser has HTMLDocument but not Document, the former will suffice as an alias for the latter.
|
268
|
-
this.Document = this.HTMLDocument;
|
269
|
-
|
270
|
-
} else {
|
271
|
-
|
272
|
-
// 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.
|
273
|
-
this.Document = this.HTMLDocument = document.constructor = (new Function('return function Document() {}')());
|
274
|
-
this.Document.prototype = document;
|
275
|
-
}
|
276
|
-
}
|
277
|
-
|
278
|
-
|
279
|
-
})
|
280
|
-
.call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
|
281
|
-
|
282
|
-
// @ts-nocheck
|
283
|
-
|
284
|
-
(function(undefined) {
|
285
|
-
|
286
|
-
// Detection from https://github.com/Financial-Times/polyfill-service/blob/master/packages/polyfill-library/polyfills/Element/detect.js
|
287
|
-
var detect = ('Element' in this && 'HTMLElement' in this);
|
288
|
-
|
289
|
-
if (detect) return
|
290
|
-
|
291
|
-
// Polyfill from https://cdn.polyfill.io/v2/polyfill.js?features=Element&flags=always
|
292
|
-
(function () {
|
293
|
-
|
294
|
-
// IE8
|
295
|
-
if (window.Element && !window.HTMLElement) {
|
296
|
-
window.HTMLElement = window.Element;
|
297
|
-
return;
|
298
|
-
}
|
299
|
-
|
300
|
-
// create Element constructor
|
301
|
-
window.Element = window.HTMLElement = new Function('return function Element() {}')();
|
302
|
-
|
303
|
-
// generate sandboxed iframe
|
304
|
-
var vbody = document.appendChild(document.createElement('body'));
|
305
|
-
var frame = vbody.appendChild(document.createElement('iframe'));
|
306
|
-
|
307
|
-
// use sandboxed iframe to replicate Element functionality
|
308
|
-
var frameDocument = frame.contentWindow.document;
|
309
|
-
var prototype = Element.prototype = frameDocument.appendChild(frameDocument.createElement('*'));
|
310
|
-
var cache = {};
|
311
|
-
|
312
|
-
// polyfill Element.prototype on an element
|
313
|
-
var shiv = function (element, deep) {
|
314
|
-
var
|
315
|
-
childNodes = element.childNodes || [],
|
316
|
-
index = -1,
|
317
|
-
key, value, childNode;
|
318
|
-
|
319
|
-
if (element.nodeType === 1 && element.constructor !== Element) {
|
320
|
-
element.constructor = Element;
|
321
|
-
|
322
|
-
for (key in cache) {
|
323
|
-
value = cache[key];
|
324
|
-
element[key] = value;
|
325
|
-
}
|
326
|
-
}
|
327
|
-
|
328
|
-
while (childNode = deep && childNodes[++index]) {
|
329
|
-
shiv(childNode, deep);
|
330
|
-
}
|
331
|
-
|
332
|
-
return element;
|
333
|
-
};
|
334
|
-
|
335
|
-
var elements = document.getElementsByTagName('*');
|
336
|
-
var nativeCreateElement = document.createElement;
|
337
|
-
var interval;
|
338
|
-
var loopLimit = 100;
|
339
|
-
|
340
|
-
prototype.attachEvent('onpropertychange', function (event) {
|
341
|
-
var
|
342
|
-
propertyName = event.propertyName,
|
343
|
-
nonValue = !cache.hasOwnProperty(propertyName),
|
344
|
-
newValue = prototype[propertyName],
|
345
|
-
oldValue = cache[propertyName],
|
346
|
-
index = -1,
|
347
|
-
element;
|
348
|
-
|
349
|
-
while (element = elements[++index]) {
|
350
|
-
if (element.nodeType === 1) {
|
351
|
-
if (nonValue || element[propertyName] === oldValue) {
|
352
|
-
element[propertyName] = newValue;
|
353
|
-
}
|
354
|
-
}
|
355
|
-
}
|
356
|
-
|
357
|
-
cache[propertyName] = newValue;
|
358
|
-
});
|
359
|
-
|
360
|
-
prototype.constructor = Element;
|
361
|
-
|
362
|
-
if (!prototype.hasAttribute) {
|
363
|
-
// <Element>.hasAttribute
|
364
|
-
prototype.hasAttribute = function hasAttribute(name) {
|
365
|
-
return this.getAttribute(name) !== null;
|
366
|
-
};
|
367
|
-
}
|
368
|
-
|
369
|
-
// Apply Element prototype to the pre-existing DOM as soon as the body element appears.
|
370
|
-
function bodyCheck() {
|
371
|
-
if (!(loopLimit--)) clearTimeout(interval);
|
372
|
-
if (document.body && !document.body.prototype && /(complete|interactive)/.test(document.readyState)) {
|
373
|
-
shiv(document, true);
|
374
|
-
if (interval && document.body.prototype) clearTimeout(interval);
|
375
|
-
return (!!document.body.prototype);
|
376
|
-
}
|
377
|
-
return false;
|
378
|
-
}
|
379
|
-
if (!bodyCheck()) {
|
380
|
-
document.onreadystatechange = bodyCheck;
|
381
|
-
interval = setInterval(bodyCheck, 25);
|
382
|
-
}
|
383
|
-
|
384
|
-
// Apply to any new elements created after load
|
385
|
-
document.createElement = function createElement(nodeName) {
|
386
|
-
var element = nativeCreateElement(String(nodeName).toLowerCase());
|
387
|
-
return shiv(element);
|
388
|
-
};
|
389
|
-
|
390
|
-
// remove sandboxed iframe
|
391
|
-
document.removeChild(vbody);
|
392
|
-
}());
|
393
|
-
|
394
|
-
})
|
395
|
-
.call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
|
396
|
-
|
397
|
-
// @ts-nocheck
|
398
|
-
|
399
|
-
(function(undefined) {
|
400
|
-
|
401
|
-
// Detection from https://raw.githubusercontent.com/Financial-Times/polyfill-library/13cf7c340974d128d557580b5e2dafcd1b1192d1/polyfills/Element/prototype/dataset/detect.js
|
402
|
-
var detect = (function(){
|
403
|
-
if (!document.documentElement.dataset) {
|
404
|
-
return false;
|
405
|
-
}
|
406
|
-
var el = document.createElement('div');
|
407
|
-
el.setAttribute("data-a-b", "c");
|
408
|
-
return el.dataset && el.dataset.aB == "c";
|
409
|
-
}());
|
410
|
-
|
411
|
-
if (detect) return
|
412
|
-
|
413
|
-
// Polyfill derived from https://raw.githubusercontent.com/Financial-Times/polyfill-library/13cf7c340974d128d557580b5e2dafcd1b1192d1/polyfills/Element/prototype/dataset/polyfill.js
|
414
|
-
Object.defineProperty(Element.prototype, 'dataset', {
|
415
|
-
get: function() {
|
416
|
-
var element = this;
|
417
|
-
var attributes = this.attributes;
|
418
|
-
var map = {};
|
419
|
-
|
420
|
-
for (var i = 0; i < attributes.length; i++) {
|
421
|
-
var attribute = attributes[i];
|
422
|
-
|
423
|
-
// This regex has been edited from the original polyfill, to add
|
424
|
-
// support for period (.) separators in data-* attribute names. These
|
425
|
-
// are allowed in the HTML spec, but were not covered by the original
|
426
|
-
// polyfill's regex. We use periods in our i18n implementation.
|
427
|
-
if (attribute && attribute.name && (/^data-\w[.\w-]*$/).test(attribute.name)) {
|
428
|
-
var name = attribute.name;
|
429
|
-
var value = attribute.value;
|
430
|
-
|
431
|
-
var propName = name.substr(5).replace(/-./g, function (prop) {
|
432
|
-
return prop.charAt(1).toUpperCase();
|
433
|
-
});
|
434
|
-
|
435
|
-
// If this browser supports __defineGetter__ and __defineSetter__,
|
436
|
-
// continue using defineProperty. If not (like IE 8 and below), we use
|
437
|
-
// a hacky fallback which at least gives an object in the right format
|
438
|
-
if ('__defineGetter__' in Object.prototype && '__defineSetter__' in Object.prototype) {
|
439
|
-
Object.defineProperty(map, propName, {
|
440
|
-
enumerable: true,
|
441
|
-
get: function() {
|
442
|
-
return this.value;
|
443
|
-
}.bind({value: value || ''}),
|
444
|
-
set: function setter(name, value) {
|
445
|
-
if (typeof value !== 'undefined') {
|
446
|
-
this.setAttribute(name, value);
|
447
|
-
} else {
|
448
|
-
this.removeAttribute(name);
|
449
|
-
}
|
450
|
-
}.bind(element, name)
|
451
|
-
});
|
452
|
-
} else {
|
453
|
-
map[propName] = value;
|
454
|
-
}
|
455
|
-
|
456
|
-
}
|
457
|
-
}
|
458
|
-
|
459
|
-
return map;
|
460
|
-
}
|
461
|
-
});
|
462
|
-
|
463
|
-
}).call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
|
464
|
-
|
465
|
-
// @ts-nocheck
|
466
|
-
(function (undefined) {
|
467
|
-
|
468
|
-
// Detection from https://github.com/mdn/content/blob/cf607d68522cd35ee7670782d3ee3a361eaef2e4/files/en-us/web/javascript/reference/global_objects/string/trim/index.md#polyfill
|
469
|
-
var detect = ('trim' in String.prototype);
|
470
|
-
|
471
|
-
if (detect) return
|
472
|
-
|
473
|
-
// Polyfill from https://github.com/mdn/content/blob/cf607d68522cd35ee7670782d3ee3a361eaef2e4/files/en-us/web/javascript/reference/global_objects/string/trim/index.md#polyfill
|
474
|
-
String.prototype.trim = function () {
|
475
|
-
return this.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
|
476
|
-
};
|
477
|
-
|
478
|
-
}).call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
|
479
|
-
|
480
|
-
/* eslint-disable es-x/no-string-prototype-trim -- Polyfill imported */
|
481
|
-
|
482
|
-
/**
|
483
|
-
* Normalise string
|
484
|
-
*
|
485
|
-
* 'If it looks like a duck, and it quacks like a duck…' 🦆
|
486
|
-
*
|
487
|
-
* If the passed value looks like a boolean or a number, convert it to a boolean
|
488
|
-
* or number.
|
489
|
-
*
|
490
|
-
* Designed to be used to convert config passed via data attributes (which are
|
491
|
-
* always strings) into something sensible.
|
492
|
-
*
|
493
|
-
* @deprecated Will be made private in v5.0
|
494
|
-
* @param {string} value - The value to normalise
|
495
|
-
* @returns {string | boolean | number | undefined} Normalised data
|
496
|
-
*/
|
497
|
-
function normaliseString (value) {
|
498
|
-
if (typeof value !== 'string') {
|
499
|
-
return value
|
500
|
-
}
|
501
|
-
|
502
|
-
var trimmedValue = value.trim();
|
503
|
-
|
504
|
-
if (trimmedValue === 'true') {
|
505
|
-
return true
|
506
|
-
}
|
507
|
-
|
508
|
-
if (trimmedValue === 'false') {
|
509
|
-
return false
|
510
|
-
}
|
511
|
-
|
512
|
-
// Empty / whitespace-only strings are considered finite so we need to check
|
513
|
-
// the length of the trimmed string as well
|
514
|
-
if (trimmedValue.length > 0 && isFinite(Number(trimmedValue))) {
|
515
|
-
return Number(trimmedValue)
|
516
|
-
}
|
517
|
-
|
518
|
-
return value
|
519
|
-
}
|
520
|
-
|
521
|
-
/**
|
522
|
-
* Normalise dataset
|
523
|
-
*
|
524
|
-
* Loop over an object and normalise each value using normaliseData function
|
525
|
-
*
|
526
|
-
* @deprecated Will be made private in v5.0
|
527
|
-
* @param {DOMStringMap} dataset - HTML element dataset
|
528
|
-
* @returns {Object<string, unknown>} Normalised dataset
|
529
|
-
*/
|
530
|
-
function normaliseDataset (dataset) {
|
531
|
-
/** @type {Object<string, unknown>} */
|
532
|
-
var out = {};
|
533
|
-
|
534
|
-
for (var key in dataset) {
|
535
|
-
out[key] = normaliseString(dataset[key]);
|
536
|
-
}
|
537
|
-
|
538
|
-
return out
|
539
|
-
}
|
540
|
-
|
541
|
-
/**
|
542
|
-
* Internal support for selecting messages to render, with placeholder
|
543
|
-
* interpolation and locale-aware number formatting and pluralisation
|
544
|
-
*
|
545
|
-
* @class
|
546
|
-
* @private
|
547
|
-
* @param {Object<string, unknown>} translations - Key-value pairs of the translation strings to use.
|
548
|
-
* @param {object} [config] - Configuration options for the function.
|
549
|
-
* @param {string} [config.locale] - An overriding locale for the PluralRules functionality.
|
550
|
-
*/
|
551
|
-
function I18n (translations, config) {
|
552
|
-
// Make list of translations available throughout function
|
553
|
-
this.translations = translations || {};
|
554
|
-
|
555
|
-
// The locale to use for PluralRules and NumberFormat
|
556
|
-
this.locale = (config && config.locale) || document.documentElement.lang || 'en';
|
557
|
-
}
|
558
|
-
|
559
|
-
/**
|
560
|
-
* The most used function - takes the key for a given piece of UI text and
|
561
|
-
* returns the appropriate string.
|
562
|
-
*
|
563
|
-
* @param {string} lookupKey - The lookup key of the string to use.
|
564
|
-
* @param {Object<string, unknown>} [options] - Any options passed with the translation string, e.g: for string interpolation.
|
565
|
-
* @returns {string} The appropriate translation string.
|
566
|
-
* @throws {Error} Lookup key required
|
567
|
-
* @throws {Error} Options required for `${}` placeholders
|
568
|
-
*/
|
569
|
-
I18n.prototype.t = function (lookupKey, options) {
|
570
|
-
if (!lookupKey) {
|
571
|
-
// Print a console error if no lookup key has been provided
|
572
|
-
throw new Error('i18n: lookup key missing')
|
573
|
-
}
|
574
|
-
|
575
|
-
// If the `count` option is set, determine which plural suffix is needed and
|
576
|
-
// change the lookupKey to match. We check to see if it's numeric instead of
|
577
|
-
// falsy, as this could legitimately be 0.
|
578
|
-
if (options && typeof options.count === 'number') {
|
579
|
-
// Get the plural suffix
|
580
|
-
lookupKey = lookupKey + '.' + this.getPluralSuffix(lookupKey, options.count);
|
581
|
-
}
|
582
|
-
|
583
|
-
// Fetch the translation string for that lookup key
|
584
|
-
var translationString = this.translations[lookupKey];
|
585
|
-
|
586
|
-
if (typeof translationString === 'string') {
|
587
|
-
// Check for ${} placeholders in the translation string
|
588
|
-
if (translationString.match(/%{(.\S+)}/)) {
|
589
|
-
if (!options) {
|
590
|
-
throw new Error('i18n: cannot replace placeholders in string if no option data provided')
|
591
|
-
}
|
592
|
-
|
593
|
-
return this.replacePlaceholders(translationString, options)
|
594
|
-
} else {
|
595
|
-
return translationString
|
596
|
-
}
|
597
|
-
} else {
|
598
|
-
// If the key wasn't found in our translations object,
|
599
|
-
// return the lookup key itself as the fallback
|
600
|
-
return lookupKey
|
601
|
-
}
|
602
|
-
};
|
603
|
-
|
604
|
-
/**
|
605
|
-
* Takes a translation string with placeholders, and replaces the placeholders
|
606
|
-
* with the provided data
|
607
|
-
*
|
608
|
-
* @param {string} translationString - The translation string
|
609
|
-
* @param {Object<string, unknown>} options - Any options passed with the translation string, e.g: for string interpolation.
|
610
|
-
* @returns {string} The translation string to output, with ${} placeholders replaced
|
611
|
-
*/
|
612
|
-
I18n.prototype.replacePlaceholders = function (translationString, options) {
|
613
|
-
/** @type {Intl.NumberFormat | undefined} */
|
614
|
-
var formatter;
|
615
|
-
|
616
|
-
if (this.hasIntlNumberFormatSupport()) {
|
617
|
-
formatter = new Intl.NumberFormat(this.locale);
|
618
|
-
}
|
619
|
-
|
620
|
-
return translationString.replace(
|
621
|
-
/%{(.\S+)}/g,
|
622
|
-
|
623
|
-
/**
|
624
|
-
* Replace translation string placeholders
|
625
|
-
*
|
626
|
-
* @param {string} placeholderWithBraces - Placeholder with braces
|
627
|
-
* @param {string} placeholderKey - Placeholder key
|
628
|
-
* @returns {string} Placeholder value
|
629
|
-
*/
|
630
|
-
function (placeholderWithBraces, placeholderKey) {
|
631
|
-
if (Object.prototype.hasOwnProperty.call(options, placeholderKey)) {
|
632
|
-
var placeholderValue = options[placeholderKey];
|
633
|
-
|
634
|
-
// If a user has passed `false` as the value for the placeholder
|
635
|
-
// treat it as though the value should not be displayed
|
636
|
-
if (placeholderValue === false || (
|
637
|
-
typeof placeholderValue !== 'number' &&
|
638
|
-
typeof placeholderValue !== 'string')
|
639
|
-
) {
|
640
|
-
return ''
|
641
|
-
}
|
642
|
-
|
643
|
-
// If the placeholder's value is a number, localise the number formatting
|
644
|
-
if (typeof placeholderValue === 'number') {
|
645
|
-
return formatter ? formatter.format(placeholderValue) : placeholderValue.toString()
|
646
|
-
}
|
647
|
-
|
648
|
-
return placeholderValue
|
649
|
-
} else {
|
650
|
-
throw new Error('i18n: no data found to replace ' + placeholderWithBraces + ' placeholder in string')
|
651
|
-
}
|
652
|
-
})
|
653
|
-
};
|
654
|
-
|
655
|
-
/**
|
656
|
-
* Check to see if the browser supports Intl and Intl.PluralRules.
|
657
|
-
*
|
658
|
-
* It requires all conditions to be met in order to be supported:
|
659
|
-
* - The browser supports the Intl class (true in IE11)
|
660
|
-
* - The implementation of Intl supports PluralRules (NOT true in IE11)
|
661
|
-
* - The browser/OS has plural rules for the current locale (browser dependent)
|
662
|
-
*
|
663
|
-
* @returns {boolean} Returns true if all conditions are met. Returns false otherwise.
|
664
|
-
*/
|
665
|
-
I18n.prototype.hasIntlPluralRulesSupport = function () {
|
666
|
-
return Boolean(window.Intl && ('PluralRules' in window.Intl && Intl.PluralRules.supportedLocalesOf(this.locale).length))
|
667
|
-
};
|
668
|
-
|
669
|
-
/**
|
670
|
-
* Check to see if the browser supports Intl and Intl.NumberFormat.
|
671
|
-
*
|
672
|
-
* It requires all conditions to be met in order to be supported:
|
673
|
-
* - The browser supports the Intl class (true in IE11)
|
674
|
-
* - The implementation of Intl supports NumberFormat (also true in IE11)
|
675
|
-
* - The browser/OS has number formatting rules for the current locale (browser dependent)
|
676
|
-
*
|
677
|
-
* @returns {boolean} Returns true if all conditions are met. Returns false otherwise.
|
678
|
-
*/
|
679
|
-
I18n.prototype.hasIntlNumberFormatSupport = function () {
|
680
|
-
return Boolean(window.Intl && ('NumberFormat' in window.Intl && Intl.NumberFormat.supportedLocalesOf(this.locale).length))
|
681
|
-
};
|
682
|
-
|
683
|
-
/**
|
684
|
-
* Get the appropriate suffix for the plural form.
|
685
|
-
*
|
686
|
-
* Uses Intl.PluralRules (or our own fallback implementation) to get the
|
687
|
-
* 'preferred' form to use for the given count.
|
688
|
-
*
|
689
|
-
* Checks that a translation has been provided for that plural form – if it
|
690
|
-
* hasn't, it'll fall back to the 'other' plural form (unless that doesn't exist
|
691
|
-
* either, in which case an error will be thrown)
|
692
|
-
*
|
693
|
-
* @param {string} lookupKey - The lookup key of the string to use.
|
694
|
-
* @param {number} count - Number used to determine which pluralisation to use.
|
695
|
-
* @returns {PluralRule} The suffix associated with the correct pluralisation for this locale.
|
696
|
-
* @throws {Error} Plural form `.other` required when preferred plural form is missing
|
697
|
-
*/
|
698
|
-
I18n.prototype.getPluralSuffix = function (lookupKey, count) {
|
699
|
-
// Validate that the number is actually a number.
|
700
|
-
//
|
701
|
-
// Number(count) will turn anything that can't be converted to a Number type
|
702
|
-
// into 'NaN'. isFinite filters out NaN, as it isn't a finite number.
|
703
|
-
count = Number(count);
|
704
|
-
if (!isFinite(count)) { return 'other' }
|
705
|
-
|
706
|
-
var preferredForm;
|
707
|
-
|
708
|
-
// Check to verify that all the requirements for Intl.PluralRules are met.
|
709
|
-
// If so, we can use that instead of our custom implementation. Otherwise,
|
710
|
-
// use the hardcoded fallback.
|
711
|
-
if (this.hasIntlPluralRulesSupport()) {
|
712
|
-
preferredForm = new Intl.PluralRules(this.locale).select(count);
|
713
|
-
} else {
|
714
|
-
preferredForm = this.selectPluralFormUsingFallbackRules(count);
|
715
|
-
}
|
716
|
-
|
717
|
-
// Use the correct plural form if provided
|
718
|
-
if (lookupKey + '.' + preferredForm in this.translations) {
|
719
|
-
return preferredForm
|
720
|
-
// Fall back to `other` if the plural form is missing, but log a warning
|
721
|
-
// to the console
|
722
|
-
} else if (lookupKey + '.other' in this.translations) {
|
723
|
-
if (console && 'warn' in console) {
|
724
|
-
console.warn('i18n: Missing plural form ".' + preferredForm + '" for "' +
|
725
|
-
this.locale + '" locale. Falling back to ".other".');
|
726
|
-
}
|
727
|
-
|
728
|
-
return 'other'
|
729
|
-
// If the required `other` plural form is missing, all we can do is error
|
730
|
-
} else {
|
731
|
-
throw new Error(
|
732
|
-
'i18n: Plural form ".other" is required for "' + this.locale + '" locale'
|
733
|
-
)
|
734
|
-
}
|
735
|
-
};
|
736
|
-
|
737
|
-
/**
|
738
|
-
* Get the plural form using our fallback implementation
|
739
|
-
*
|
740
|
-
* This is split out into a separate function to make it easier to test the
|
741
|
-
* fallback behaviour in an environment where Intl.PluralRules exists.
|
742
|
-
*
|
743
|
-
* @param {number} count - Number used to determine which pluralisation to use.
|
744
|
-
* @returns {PluralRule} The pluralisation form for count in this locale.
|
745
|
-
*/
|
746
|
-
I18n.prototype.selectPluralFormUsingFallbackRules = function (count) {
|
747
|
-
// Currently our custom code can only handle positive integers, so let's
|
748
|
-
// make sure our number is one of those.
|
749
|
-
count = Math.abs(Math.floor(count));
|
750
|
-
|
751
|
-
var ruleset = this.getPluralRulesForLocale();
|
752
|
-
|
753
|
-
if (ruleset) {
|
754
|
-
return I18n.pluralRules[ruleset](count)
|
755
|
-
}
|
756
|
-
|
757
|
-
return 'other'
|
758
|
-
};
|
759
|
-
|
760
|
-
/**
|
761
|
-
* Work out which pluralisation rules to use for the current locale
|
762
|
-
*
|
763
|
-
* The locale may include a regional indicator (such as en-GB), but we don't
|
764
|
-
* usually care about this part, as pluralisation rules are usually the same
|
765
|
-
* regardless of region. There are exceptions, however, (e.g. Portuguese) so
|
766
|
-
* this searches by both the full and shortened locale codes, just to be sure.
|
767
|
-
*
|
768
|
-
* @returns {string | undefined} The name of the pluralisation rule to use (a key for one
|
769
|
-
* of the functions in this.pluralRules)
|
770
|
-
*/
|
771
|
-
I18n.prototype.getPluralRulesForLocale = function () {
|
772
|
-
var locale = this.locale;
|
773
|
-
var localeShort = locale.split('-')[0];
|
774
|
-
|
775
|
-
// Look through the plural rules map to find which `pluralRule` is
|
776
|
-
// appropriate for our current `locale`.
|
777
|
-
for (var pluralRule in I18n.pluralRulesMap) {
|
778
|
-
if (Object.prototype.hasOwnProperty.call(I18n.pluralRulesMap, pluralRule)) {
|
779
|
-
var languages = I18n.pluralRulesMap[pluralRule];
|
780
|
-
for (var i = 0; i < languages.length; i++) {
|
781
|
-
if (languages[i] === locale || languages[i] === localeShort) {
|
782
|
-
return pluralRule
|
783
|
-
}
|
784
|
-
}
|
785
|
-
}
|
786
|
-
}
|
787
|
-
};
|
788
|
-
|
789
|
-
/**
|
790
|
-
* Map of plural rules to languages where those rules apply.
|
791
|
-
*
|
792
|
-
* Note: These groups are named for the most dominant or recognisable language
|
793
|
-
* that uses each system. The groupings do not imply that the languages are
|
794
|
-
* related to one another. Many languages have evolved the same systems
|
795
|
-
* independently of one another.
|
796
|
-
*
|
797
|
-
* Code to support more languages can be found in the i18n spike:
|
798
|
-
* {@link https://github.com/alphagov/govuk-frontend/blob/spike-i18n-support/src/govuk/i18n.mjs}
|
799
|
-
*
|
800
|
-
* Languages currently supported:
|
801
|
-
*
|
802
|
-
* Arabic: Arabic (ar)
|
803
|
-
* Chinese: Burmese (my), Chinese (zh), Indonesian (id), Japanese (ja),
|
804
|
-
* Javanese (jv), Korean (ko), Malay (ms), Thai (th), Vietnamese (vi)
|
805
|
-
* French: Armenian (hy), Bangla (bn), French (fr), Gujarati (gu), Hindi (hi),
|
806
|
-
* Persian Farsi (fa), Punjabi (pa), Zulu (zu)
|
807
|
-
* German: Afrikaans (af), Albanian (sq), Azerbaijani (az), Basque (eu),
|
808
|
-
* Bulgarian (bg), Catalan (ca), Danish (da), Dutch (nl), English (en),
|
809
|
-
* Estonian (et), Finnish (fi), Georgian (ka), German (de), Greek (el),
|
810
|
-
* Hungarian (hu), Luxembourgish (lb), Norwegian (no), Somali (so),
|
811
|
-
* Swahili (sw), Swedish (sv), Tamil (ta), Telugu (te), Turkish (tr),
|
812
|
-
* Urdu (ur)
|
813
|
-
* Irish: Irish Gaelic (ga)
|
814
|
-
* Russian: Russian (ru), Ukrainian (uk)
|
815
|
-
* Scottish: Scottish Gaelic (gd)
|
816
|
-
* Spanish: European Portuguese (pt-PT), Italian (it), Spanish (es)
|
817
|
-
* Welsh: Welsh (cy)
|
818
|
-
*
|
819
|
-
* @type {Object<string, string[]>}
|
820
|
-
*/
|
821
|
-
I18n.pluralRulesMap = {
|
822
|
-
arabic: ['ar'],
|
823
|
-
chinese: ['my', 'zh', 'id', 'ja', 'jv', 'ko', 'ms', 'th', 'vi'],
|
824
|
-
french: ['hy', 'bn', 'fr', 'gu', 'hi', 'fa', 'pa', 'zu'],
|
825
|
-
german: [
|
826
|
-
'af', 'sq', 'az', 'eu', 'bg', 'ca', 'da', 'nl', 'en', 'et', 'fi', 'ka',
|
827
|
-
'de', 'el', 'hu', 'lb', 'no', 'so', 'sw', 'sv', 'ta', 'te', 'tr', 'ur'
|
828
|
-
],
|
829
|
-
irish: ['ga'],
|
830
|
-
russian: ['ru', 'uk'],
|
831
|
-
scottish: ['gd'],
|
832
|
-
spanish: ['pt-PT', 'it', 'es'],
|
833
|
-
welsh: ['cy']
|
834
|
-
};
|
835
|
-
|
836
|
-
/**
|
837
|
-
* Different pluralisation rule sets
|
838
|
-
*
|
839
|
-
* Returns the appropriate suffix for the plural form associated with `n`.
|
840
|
-
* Possible suffixes: 'zero', 'one', 'two', 'few', 'many', 'other' (the actual
|
841
|
-
* meaning of each differs per locale). 'other' should always exist, even in
|
842
|
-
* languages without plurals, such as Chinese.
|
843
|
-
* {@link https://cldr.unicode.org/index/cldr-spec/plural-rules}
|
844
|
-
*
|
845
|
-
* The count must be a positive integer. Negative numbers and decimals aren't accounted for
|
846
|
-
*
|
847
|
-
* @type {Object<string, function(number): PluralRule>}
|
848
|
-
*/
|
849
|
-
I18n.pluralRules = {
|
850
|
-
/* eslint-disable jsdoc/require-jsdoc */
|
851
|
-
arabic: function (n) {
|
852
|
-
if (n === 0) { return 'zero' }
|
853
|
-
if (n === 1) { return 'one' }
|
854
|
-
if (n === 2) { return 'two' }
|
855
|
-
if (n % 100 >= 3 && n % 100 <= 10) { return 'few' }
|
856
|
-
if (n % 100 >= 11 && n % 100 <= 99) { return 'many' }
|
857
|
-
return 'other'
|
858
|
-
},
|
859
|
-
chinese: function () {
|
860
|
-
return 'other'
|
861
|
-
},
|
862
|
-
french: function (n) {
|
863
|
-
return n === 0 || n === 1 ? 'one' : 'other'
|
864
|
-
},
|
865
|
-
german: function (n) {
|
866
|
-
return n === 1 ? 'one' : 'other'
|
867
|
-
},
|
868
|
-
irish: function (n) {
|
869
|
-
if (n === 1) { return 'one' }
|
870
|
-
if (n === 2) { return 'two' }
|
871
|
-
if (n >= 3 && n <= 6) { return 'few' }
|
872
|
-
if (n >= 7 && n <= 10) { return 'many' }
|
873
|
-
return 'other'
|
874
|
-
},
|
875
|
-
russian: function (n) {
|
876
|
-
var lastTwo = n % 100;
|
877
|
-
var last = lastTwo % 10;
|
878
|
-
if (last === 1 && lastTwo !== 11) { return 'one' }
|
879
|
-
if (last >= 2 && last <= 4 && !(lastTwo >= 12 && lastTwo <= 14)) { return 'few' }
|
880
|
-
if (last === 0 || (last >= 5 && last <= 9) || (lastTwo >= 11 && lastTwo <= 14)) { return 'many' }
|
881
|
-
// Note: The 'other' suffix is only used by decimal numbers in Russian.
|
882
|
-
// We don't anticipate it being used, but it's here for consistency.
|
883
|
-
return 'other'
|
884
|
-
},
|
885
|
-
scottish: function (n) {
|
886
|
-
if (n === 1 || n === 11) { return 'one' }
|
887
|
-
if (n === 2 || n === 12) { return 'two' }
|
888
|
-
if ((n >= 3 && n <= 10) || (n >= 13 && n <= 19)) { return 'few' }
|
889
|
-
return 'other'
|
890
|
-
},
|
891
|
-
spanish: function (n) {
|
892
|
-
if (n === 1) { return 'one' }
|
893
|
-
if (n % 1000000 === 0 && n !== 0) { return 'many' }
|
894
|
-
return 'other'
|
895
|
-
},
|
896
|
-
welsh: function (n) {
|
897
|
-
if (n === 0) { return 'zero' }
|
898
|
-
if (n === 1) { return 'one' }
|
899
|
-
if (n === 2) { return 'two' }
|
900
|
-
if (n === 3) { return 'few' }
|
901
|
-
if (n === 6) { return 'many' }
|
902
|
-
return 'other'
|
903
|
-
}
|
904
|
-
/* eslint-enable jsdoc/require-jsdoc */
|
905
|
-
};
|
906
|
-
|
907
|
-
/**
|
908
|
-
* Plural rule category mnemonic tags
|
909
|
-
*
|
910
|
-
* @typedef {'zero' | 'one' | 'two' | 'few' | 'many' | 'other'} PluralRule
|
911
|
-
*/
|
912
|
-
|
913
|
-
/**
|
914
|
-
* Translated message by plural rule they correspond to.
|
915
|
-
*
|
916
|
-
* Allows to group pluralised messages under a single key when passing
|
917
|
-
* translations to a component's constructor
|
918
|
-
*
|
919
|
-
* @typedef {object} TranslationPluralForms
|
920
|
-
* @property {string} [other] - General plural form
|
921
|
-
* @property {string} [zero] - Plural form used with 0
|
922
|
-
* @property {string} [one] - Plural form used with 1
|
923
|
-
* @property {string} [two] - Plural form used with 2
|
924
|
-
* @property {string} [few] - Plural form used for a few
|
925
|
-
* @property {string} [many] - Plural form used for many
|
926
|
-
*/
|
927
|
-
|
928
|
-
// @ts-nocheck
|
929
|
-
(function (undefined) {
|
930
|
-
|
931
|
-
// Detection from https://raw.githubusercontent.com/Financial-Times/polyfill-service/master/packages/polyfill-library/polyfills/DOMTokenList/detect.js
|
932
|
-
var detect = (
|
933
|
-
'DOMTokenList' in this && (function (x) {
|
934
|
-
return 'classList' in x ? !x.classList.toggle('x', false) && !x.className : true;
|
935
|
-
})(document.createElement('x'))
|
936
|
-
);
|
937
|
-
|
938
|
-
if (detect) return
|
939
|
-
|
940
|
-
// Polyfill from https://raw.githubusercontent.com/Financial-Times/polyfill-service/master/packages/polyfill-library/polyfills/DOMTokenList/polyfill.js
|
941
|
-
(function (global) {
|
942
|
-
var nativeImpl = "DOMTokenList" in global && global.DOMTokenList;
|
943
|
-
|
944
|
-
if (
|
945
|
-
!nativeImpl ||
|
946
|
-
(
|
947
|
-
!!document.createElementNS &&
|
948
|
-
!!document.createElementNS('http://www.w3.org/2000/svg', 'svg') &&
|
949
|
-
!(document.createElementNS("http://www.w3.org/2000/svg", "svg").classList instanceof DOMTokenList)
|
950
|
-
)
|
951
|
-
) {
|
952
|
-
global.DOMTokenList = (function() { // eslint-disable-line no-unused-vars
|
953
|
-
var dpSupport = true;
|
954
|
-
var defineGetter = function (object, name, fn, configurable) {
|
955
|
-
if (Object.defineProperty)
|
956
|
-
Object.defineProperty(object, name, {
|
957
|
-
configurable: false === dpSupport ? true : !!configurable,
|
958
|
-
get: fn
|
959
|
-
});
|
960
|
-
|
961
|
-
else object.__defineGetter__(name, fn);
|
962
|
-
};
|
963
|
-
|
964
|
-
/** Ensure the browser allows Object.defineProperty to be used on native JavaScript objects. */
|
965
|
-
try {
|
966
|
-
defineGetter({}, "support");
|
967
|
-
}
|
968
|
-
catch (e) {
|
969
|
-
dpSupport = false;
|
970
|
-
}
|
971
|
-
|
972
|
-
|
973
|
-
var _DOMTokenList = function (el, prop) {
|
974
|
-
var that = this;
|
975
|
-
var tokens = [];
|
976
|
-
var tokenMap = {};
|
977
|
-
var length = 0;
|
978
|
-
var maxLength = 0;
|
979
|
-
var addIndexGetter = function (i) {
|
980
|
-
defineGetter(that, i, function () {
|
981
|
-
preop();
|
982
|
-
return tokens[i];
|
983
|
-
}, false);
|
984
|
-
|
985
|
-
};
|
986
|
-
var reindex = function () {
|
987
|
-
|
988
|
-
/** Define getter functions for array-like access to the tokenList's contents. */
|
989
|
-
if (length >= maxLength)
|
990
|
-
for (; maxLength < length; ++maxLength) {
|
991
|
-
addIndexGetter(maxLength);
|
992
|
-
}
|
993
|
-
};
|
994
|
-
|
995
|
-
/** Helper function called at the start of each class method. Internal use only. */
|
996
|
-
var preop = function () {
|
997
|
-
var error;
|
998
|
-
var i;
|
999
|
-
var args = arguments;
|
1000
|
-
var rSpace = /\s+/;
|
1001
|
-
|
1002
|
-
/** Validate the token/s passed to an instance method, if any. */
|
1003
|
-
if (args.length)
|
1004
|
-
for (i = 0; i < args.length; ++i)
|
1005
|
-
if (rSpace.test(args[i])) {
|
1006
|
-
error = new SyntaxError('String "' + args[i] + '" ' + "contains" + ' an invalid character');
|
1007
|
-
error.code = 5;
|
1008
|
-
error.name = "InvalidCharacterError";
|
1009
|
-
throw error;
|
1010
|
-
}
|
1011
|
-
|
1012
|
-
|
1013
|
-
/** Split the new value apart by whitespace*/
|
1014
|
-
if (typeof el[prop] === "object") {
|
1015
|
-
tokens = ("" + el[prop].baseVal).replace(/^\s+|\s+$/g, "").split(rSpace);
|
1016
|
-
} else {
|
1017
|
-
tokens = ("" + el[prop]).replace(/^\s+|\s+$/g, "").split(rSpace);
|
1018
|
-
}
|
1019
|
-
|
1020
|
-
/** Avoid treating blank strings as single-item token lists */
|
1021
|
-
if ("" === tokens[0]) tokens = [];
|
1022
|
-
|
1023
|
-
/** Repopulate the internal token lists */
|
1024
|
-
tokenMap = {};
|
1025
|
-
for (i = 0; i < tokens.length; ++i)
|
1026
|
-
tokenMap[tokens[i]] = true;
|
1027
|
-
length = tokens.length;
|
1028
|
-
reindex();
|
1029
|
-
};
|
1030
|
-
|
1031
|
-
/** Populate our internal token list if the targeted attribute of the subject element isn't empty. */
|
1032
|
-
preop();
|
1033
|
-
|
1034
|
-
/** Return the number of tokens in the underlying string. Read-only. */
|
1035
|
-
defineGetter(that, "length", function () {
|
1036
|
-
preop();
|
1037
|
-
return length;
|
1038
|
-
});
|
1039
|
-
|
1040
|
-
/** Override the default toString/toLocaleString methods to return a space-delimited list of tokens when typecast. */
|
1041
|
-
that.toLocaleString =
|
1042
|
-
that.toString = function () {
|
1043
|
-
preop();
|
1044
|
-
return tokens.join(" ");
|
1045
|
-
};
|
1046
|
-
|
1047
|
-
that.item = function (idx) {
|
1048
|
-
preop();
|
1049
|
-
return tokens[idx];
|
1050
|
-
};
|
1051
|
-
|
1052
|
-
that.contains = function (token) {
|
1053
|
-
preop();
|
1054
|
-
return !!tokenMap[token];
|
1055
|
-
};
|
1056
|
-
|
1057
|
-
that.add = function () {
|
1058
|
-
preop.apply(that, args = arguments);
|
1059
|
-
|
1060
|
-
for (var args, token, i = 0, l = args.length; i < l; ++i) {
|
1061
|
-
token = args[i];
|
1062
|
-
if (!tokenMap[token]) {
|
1063
|
-
tokens.push(token);
|
1064
|
-
tokenMap[token] = true;
|
1065
|
-
}
|
1066
|
-
}
|
1067
|
-
|
1068
|
-
/** Update the targeted attribute of the attached element if the token list's changed. */
|
1069
|
-
if (length !== tokens.length) {
|
1070
|
-
length = tokens.length >>> 0;
|
1071
|
-
if (typeof el[prop] === "object") {
|
1072
|
-
el[prop].baseVal = tokens.join(" ");
|
1073
|
-
} else {
|
1074
|
-
el[prop] = tokens.join(" ");
|
1075
|
-
}
|
1076
|
-
reindex();
|
1077
|
-
}
|
1078
|
-
};
|
1079
|
-
|
1080
|
-
that.remove = function () {
|
1081
|
-
preop.apply(that, args = arguments);
|
1082
|
-
|
1083
|
-
/** Build a hash of token names to compare against when recollecting our token list. */
|
1084
|
-
for (var args, ignore = {}, i = 0, t = []; i < args.length; ++i) {
|
1085
|
-
ignore[args[i]] = true;
|
1086
|
-
delete tokenMap[args[i]];
|
1087
|
-
}
|
1088
|
-
|
1089
|
-
/** Run through our tokens list and reassign only those that aren't defined in the hash declared above. */
|
1090
|
-
for (i = 0; i < tokens.length; ++i)
|
1091
|
-
if (!ignore[tokens[i]]) t.push(tokens[i]);
|
1092
|
-
|
1093
|
-
tokens = t;
|
1094
|
-
length = t.length >>> 0;
|
1095
|
-
|
1096
|
-
/** Update the targeted attribute of the attached element. */
|
1097
|
-
if (typeof el[prop] === "object") {
|
1098
|
-
el[prop].baseVal = tokens.join(" ");
|
1099
|
-
} else {
|
1100
|
-
el[prop] = tokens.join(" ");
|
1101
|
-
}
|
1102
|
-
reindex();
|
1103
|
-
};
|
1104
|
-
|
1105
|
-
that.toggle = function (token, force) {
|
1106
|
-
preop.apply(that, [token]);
|
1107
|
-
|
1108
|
-
/** Token state's being forced. */
|
1109
|
-
if (undefined !== force) {
|
1110
|
-
if (force) {
|
1111
|
-
that.add(token);
|
1112
|
-
return true;
|
1113
|
-
} else {
|
1114
|
-
that.remove(token);
|
1115
|
-
return false;
|
1116
|
-
}
|
1117
|
-
}
|
1118
|
-
|
1119
|
-
/** Token already exists in tokenList. Remove it, and return FALSE. */
|
1120
|
-
if (tokenMap[token]) {
|
1121
|
-
that.remove(token);
|
1122
|
-
return false;
|
1123
|
-
}
|
1124
|
-
|
1125
|
-
/** Otherwise, add the token and return TRUE. */
|
1126
|
-
that.add(token);
|
1127
|
-
return true;
|
1128
|
-
};
|
1129
|
-
|
1130
|
-
return that;
|
1131
|
-
};
|
1132
|
-
|
1133
|
-
return _DOMTokenList;
|
1134
|
-
}());
|
1135
|
-
}
|
1136
|
-
|
1137
|
-
// Add second argument to native DOMTokenList.toggle() if necessary
|
1138
|
-
(function () {
|
1139
|
-
var e = document.createElement('span');
|
1140
|
-
if (!('classList' in e)) return;
|
1141
|
-
e.classList.toggle('x', false);
|
1142
|
-
if (!e.classList.contains('x')) return;
|
1143
|
-
e.classList.constructor.prototype.toggle = function toggle(token /*, force*/) {
|
1144
|
-
var force = arguments[1];
|
1145
|
-
if (force === undefined) {
|
1146
|
-
var add = !this.contains(token);
|
1147
|
-
this[add ? 'add' : 'remove'](token);
|
1148
|
-
return add;
|
1149
|
-
}
|
1150
|
-
force = !!force;
|
1151
|
-
this[force ? 'add' : 'remove'](token);
|
1152
|
-
return force;
|
1153
|
-
};
|
1154
|
-
}());
|
1155
|
-
|
1156
|
-
// Add multiple arguments to native DOMTokenList.add() if necessary
|
1157
|
-
(function () {
|
1158
|
-
var e = document.createElement('span');
|
1159
|
-
if (!('classList' in e)) return;
|
1160
|
-
e.classList.add('a', 'b');
|
1161
|
-
if (e.classList.contains('b')) return;
|
1162
|
-
var native = e.classList.constructor.prototype.add;
|
1163
|
-
e.classList.constructor.prototype.add = function () {
|
1164
|
-
var args = arguments;
|
1165
|
-
var l = arguments.length;
|
1166
|
-
for (var i = 0; i < l; i++) {
|
1167
|
-
native.call(this, args[i]);
|
1168
|
-
}
|
1169
|
-
};
|
1170
|
-
}());
|
1171
|
-
|
1172
|
-
// Add multiple arguments to native DOMTokenList.remove() if necessary
|
1173
|
-
(function () {
|
1174
|
-
var e = document.createElement('span');
|
1175
|
-
if (!('classList' in e)) return;
|
1176
|
-
e.classList.add('a');
|
1177
|
-
e.classList.add('b');
|
1178
|
-
e.classList.remove('a', 'b');
|
1179
|
-
if (!e.classList.contains('b')) return;
|
1180
|
-
var native = e.classList.constructor.prototype.remove;
|
1181
|
-
e.classList.constructor.prototype.remove = function () {
|
1182
|
-
var args = arguments;
|
1183
|
-
var l = arguments.length;
|
1184
|
-
for (var i = 0; i < l; i++) {
|
1185
|
-
native.call(this, args[i]);
|
1186
|
-
}
|
1187
|
-
};
|
1188
|
-
}());
|
1189
|
-
|
1190
|
-
}(this));
|
1191
|
-
|
1192
|
-
}).call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
|
1193
|
-
|
1194
|
-
// @ts-nocheck
|
1195
|
-
|
1196
|
-
(function(undefined) {
|
1197
|
-
|
1198
|
-
// Detection from https://raw.githubusercontent.com/Financial-Times/polyfill-service/8717a9e04ac7aff99b4980fbedead98036b0929a/packages/polyfill-library/polyfills/Element/prototype/classList/detect.js
|
1199
|
-
var detect = (
|
1200
|
-
'document' in this && "classList" in document.documentElement && 'Element' in this && 'classList' in Element.prototype && (function () {
|
1201
|
-
var e = document.createElement('span');
|
1202
|
-
e.classList.add('a', 'b');
|
1203
|
-
return e.classList.contains('b');
|
1204
|
-
}())
|
1205
|
-
);
|
1206
|
-
|
1207
|
-
if (detect) return
|
1208
|
-
|
1209
|
-
// Polyfill from https://cdn.polyfill.io/v2/polyfill.js?features=Element.prototype.classList&flags=always
|
1210
|
-
(function (global) {
|
1211
|
-
var dpSupport = true;
|
1212
|
-
var defineGetter = function (object, name, fn, configurable) {
|
1213
|
-
if (Object.defineProperty)
|
1214
|
-
Object.defineProperty(object, name, {
|
1215
|
-
configurable: false === dpSupport ? true : !!configurable,
|
1216
|
-
get: fn
|
1217
|
-
});
|
1218
|
-
|
1219
|
-
else object.__defineGetter__(name, fn);
|
1220
|
-
};
|
1221
|
-
/** Ensure the browser allows Object.defineProperty to be used on native JavaScript objects. */
|
1222
|
-
try {
|
1223
|
-
defineGetter({}, "support");
|
1224
|
-
}
|
1225
|
-
catch (e) {
|
1226
|
-
dpSupport = false;
|
1227
|
-
}
|
1228
|
-
/** Polyfills a property with a DOMTokenList */
|
1229
|
-
var addProp = function (o, name, attr) {
|
1230
|
-
|
1231
|
-
defineGetter(o.prototype, name, function () {
|
1232
|
-
var tokenList;
|
1233
|
-
|
1234
|
-
var THIS = this,
|
1235
|
-
|
1236
|
-
/** Prevent this from firing twice for some reason. What the hell, IE. */
|
1237
|
-
gibberishProperty = "__defineGetter__" + "DEFINE_PROPERTY" + name;
|
1238
|
-
if(THIS[gibberishProperty]) return tokenList;
|
1239
|
-
THIS[gibberishProperty] = true;
|
1240
|
-
|
1241
|
-
/**
|
1242
|
-
* IE8 can't define properties on native JavaScript objects, so we'll use a dumb hack instead.
|
1243
|
-
*
|
1244
|
-
* What this is doing is creating a dummy element ("reflection") inside a detached phantom node ("mirror")
|
1245
|
-
* that serves as the target of Object.defineProperty instead. While we could simply use the subject HTML
|
1246
|
-
* element instead, this would conflict with element types which use indexed properties (such as forms and
|
1247
|
-
* select lists).
|
1248
|
-
*/
|
1249
|
-
if (false === dpSupport) {
|
1250
|
-
|
1251
|
-
var visage;
|
1252
|
-
var mirror = addProp.mirror || document.createElement("div");
|
1253
|
-
var reflections = mirror.childNodes;
|
1254
|
-
var l = reflections.length;
|
1255
|
-
|
1256
|
-
for (var i = 0; i < l; ++i)
|
1257
|
-
if (reflections[i]._R === THIS) {
|
1258
|
-
visage = reflections[i];
|
1259
|
-
break;
|
1260
|
-
}
|
1261
|
-
|
1262
|
-
/** Couldn't find an element's reflection inside the mirror. Materialise one. */
|
1263
|
-
visage || (visage = mirror.appendChild(document.createElement("div")));
|
1264
|
-
|
1265
|
-
tokenList = DOMTokenList.call(visage, THIS, attr);
|
1266
|
-
} else tokenList = new DOMTokenList(THIS, attr);
|
1267
|
-
|
1268
|
-
defineGetter(THIS, name, function () {
|
1269
|
-
return tokenList;
|
1270
|
-
});
|
1271
|
-
delete THIS[gibberishProperty];
|
1272
|
-
|
1273
|
-
return tokenList;
|
1274
|
-
}, true);
|
1275
|
-
};
|
1276
|
-
|
1277
|
-
addProp(global.Element, "classList", "className");
|
1278
|
-
addProp(global.HTMLElement, "classList", "className");
|
1279
|
-
addProp(global.HTMLLinkElement, "relList", "rel");
|
1280
|
-
addProp(global.HTMLAnchorElement, "relList", "rel");
|
1281
|
-
addProp(global.HTMLAreaElement, "relList", "rel");
|
1282
|
-
}(this));
|
1283
|
-
|
1284
|
-
}).call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
|
1285
|
-
|
1286
|
-
// @ts-nocheck
|
1287
|
-
(function (undefined) {
|
1288
|
-
|
1289
|
-
// Detection from https://raw.githubusercontent.com/Financial-Times/polyfill-service/1f3c09b402f65bf6e393f933a15ba63f1b86ef1f/packages/polyfill-library/polyfills/Element/prototype/matches/detect.js
|
1290
|
-
var detect = (
|
1291
|
-
'document' in this && "matches" in document.documentElement
|
1292
|
-
);
|
1293
|
-
|
1294
|
-
if (detect) return
|
1295
|
-
|
1296
|
-
// Polyfill from https://raw.githubusercontent.com/Financial-Times/polyfill-service/1f3c09b402f65bf6e393f933a15ba63f1b86ef1f/packages/polyfill-library/polyfills/Element/prototype/matches/polyfill.js
|
1297
|
-
Element.prototype.matches = Element.prototype.webkitMatchesSelector || Element.prototype.oMatchesSelector || Element.prototype.msMatchesSelector || Element.prototype.mozMatchesSelector || function matches(selector) {
|
1298
|
-
var element = this;
|
1299
|
-
var elements = (element.document || element.ownerDocument).querySelectorAll(selector);
|
1300
|
-
var index = 0;
|
1301
|
-
|
1302
|
-
while (elements[index] && elements[index] !== element) {
|
1303
|
-
++index;
|
1304
|
-
}
|
1305
|
-
|
1306
|
-
return !!elements[index];
|
1307
|
-
};
|
1308
|
-
|
1309
|
-
}).call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
|
1310
|
-
|
1311
|
-
// @ts-nocheck
|
1312
|
-
|
1313
|
-
(function(undefined) {
|
1314
|
-
|
1315
|
-
// Detection from https://raw.githubusercontent.com/Financial-Times/polyfill-service/1f3c09b402f65bf6e393f933a15ba63f1b86ef1f/packages/polyfill-library/polyfills/Element/prototype/closest/detect.js
|
1316
|
-
var detect = (
|
1317
|
-
'document' in this && "closest" in document.documentElement
|
1318
|
-
);
|
1319
|
-
|
1320
|
-
if (detect) return
|
1321
|
-
|
1322
|
-
// Polyfill from https://raw.githubusercontent.com/Financial-Times/polyfill-service/1f3c09b402f65bf6e393f933a15ba63f1b86ef1f/packages/polyfill-library/polyfills/Element/prototype/closest/polyfill.js
|
1323
|
-
Element.prototype.closest = function closest(selector) {
|
1324
|
-
var node = this;
|
1325
|
-
|
1326
|
-
while (node) {
|
1327
|
-
if (node.matches(selector)) return node;
|
1328
|
-
else node = 'SVGElement' in window && node instanceof SVGElement ? node.parentNode : node.parentElement;
|
1329
|
-
}
|
1330
|
-
|
1331
|
-
return null;
|
1332
|
-
};
|
1333
|
-
|
1334
|
-
}).call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
|
1335
|
-
|
1336
|
-
// @ts-nocheck
|
1337
|
-
(function (undefined) {
|
1338
|
-
|
1339
|
-
// Detection from https://github.com/Financial-Times/polyfill-service/blob/master/packages/polyfill-library/polyfills/Window/detect.js
|
1340
|
-
var detect = ('Window' in this);
|
1341
|
-
|
1342
|
-
if (detect) return
|
1343
|
-
|
1344
|
-
// Polyfill from https://cdn.polyfill.io/v2/polyfill.js?features=Window&flags=always
|
1345
|
-
if ((typeof WorkerGlobalScope === "undefined") && (typeof importScripts !== "function")) {
|
1346
|
-
(function (global) {
|
1347
|
-
if (global.constructor) {
|
1348
|
-
global.Window = global.constructor;
|
1349
|
-
} else {
|
1350
|
-
(global.Window = global.constructor = new Function('return function Window() {}')()).prototype = this;
|
1351
|
-
}
|
1352
|
-
}(this));
|
1353
|
-
}
|
1354
|
-
|
1355
|
-
})
|
1356
|
-
.call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
|
1357
|
-
|
1358
|
-
// @ts-nocheck
|
1359
|
-
|
1360
|
-
(function(undefined) {
|
1361
|
-
|
1362
|
-
// Detection from https://github.com/Financial-Times/polyfill-service/blob/master/packages/polyfill-library/polyfills/Event/detect.js
|
1363
|
-
var detect = (
|
1364
|
-
(function(global) {
|
1365
|
-
|
1366
|
-
if (!('Event' in global)) return false;
|
1367
|
-
if (typeof global.Event === 'function') return true;
|
1368
|
-
|
1369
|
-
try {
|
1370
|
-
|
1371
|
-
// In IE 9-11, the Event object exists but cannot be instantiated
|
1372
|
-
new Event('click');
|
1373
|
-
return true;
|
1374
|
-
} catch(e) {
|
1375
|
-
return false;
|
1376
|
-
}
|
1377
|
-
}(this))
|
1378
|
-
);
|
1379
|
-
|
1380
|
-
if (detect) return
|
1381
|
-
|
1382
|
-
// Polyfill from https://cdn.polyfill.io/v2/polyfill.js?features=Event&flags=always
|
1383
|
-
(function () {
|
1384
|
-
var unlistenableWindowEvents = {
|
1385
|
-
click: 1,
|
1386
|
-
dblclick: 1,
|
1387
|
-
keyup: 1,
|
1388
|
-
keypress: 1,
|
1389
|
-
keydown: 1,
|
1390
|
-
mousedown: 1,
|
1391
|
-
mouseup: 1,
|
1392
|
-
mousemove: 1,
|
1393
|
-
mouseover: 1,
|
1394
|
-
mouseenter: 1,
|
1395
|
-
mouseleave: 1,
|
1396
|
-
mouseout: 1,
|
1397
|
-
storage: 1,
|
1398
|
-
storagecommit: 1,
|
1399
|
-
textinput: 1
|
1400
|
-
};
|
1401
|
-
|
1402
|
-
// This polyfill depends on availability of `document` so will not run in a worker
|
1403
|
-
// However, we asssume there are no browsers with worker support that lack proper
|
1404
|
-
// support for `Event` within the worker
|
1405
|
-
if (typeof document === 'undefined' || typeof window === 'undefined') return;
|
1406
|
-
|
1407
|
-
function indexOf(array, element) {
|
1408
|
-
var
|
1409
|
-
index = -1,
|
1410
|
-
length = array.length;
|
1411
|
-
|
1412
|
-
while (++index < length) {
|
1413
|
-
if (index in array && array[index] === element) {
|
1414
|
-
return index;
|
1415
|
-
}
|
1416
|
-
}
|
1417
|
-
|
1418
|
-
return -1;
|
1419
|
-
}
|
1420
|
-
|
1421
|
-
var existingProto = (window.Event && window.Event.prototype) || null;
|
1422
|
-
window.Event = Window.prototype.Event = function Event(type, eventInitDict) {
|
1423
|
-
if (!type) {
|
1424
|
-
throw new Error('Not enough arguments');
|
1425
|
-
}
|
1426
|
-
|
1427
|
-
var event;
|
1428
|
-
// Shortcut if browser supports createEvent
|
1429
|
-
if ('createEvent' in document) {
|
1430
|
-
event = document.createEvent('Event');
|
1431
|
-
var bubbles = eventInitDict && eventInitDict.bubbles !== undefined ? eventInitDict.bubbles : false;
|
1432
|
-
var cancelable = eventInitDict && eventInitDict.cancelable !== undefined ? eventInitDict.cancelable : false;
|
1433
|
-
|
1434
|
-
event.initEvent(type, bubbles, cancelable);
|
1435
|
-
|
1436
|
-
return event;
|
1437
|
-
}
|
1438
|
-
|
1439
|
-
event = document.createEventObject();
|
1440
|
-
|
1441
|
-
event.type = type;
|
1442
|
-
event.bubbles = eventInitDict && eventInitDict.bubbles !== undefined ? eventInitDict.bubbles : false;
|
1443
|
-
event.cancelable = eventInitDict && eventInitDict.cancelable !== undefined ? eventInitDict.cancelable : false;
|
1444
|
-
|
1445
|
-
return event;
|
1446
|
-
};
|
1447
|
-
if (existingProto) {
|
1448
|
-
Object.defineProperty(window.Event, 'prototype', {
|
1449
|
-
configurable: false,
|
1450
|
-
enumerable: false,
|
1451
|
-
writable: true,
|
1452
|
-
value: existingProto
|
1453
|
-
});
|
1454
|
-
}
|
1455
|
-
|
1456
|
-
if (!('createEvent' in document)) {
|
1457
|
-
window.addEventListener = Window.prototype.addEventListener = Document.prototype.addEventListener = Element.prototype.addEventListener = function addEventListener() {
|
1458
|
-
var
|
1459
|
-
element = this,
|
1460
|
-
type = arguments[0],
|
1461
|
-
listener = arguments[1];
|
1462
|
-
|
1463
|
-
if (element === window && type in unlistenableWindowEvents) {
|
1464
|
-
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.');
|
1465
|
-
}
|
1466
|
-
|
1467
|
-
if (!element._events) {
|
1468
|
-
element._events = {};
|
1469
|
-
}
|
1470
|
-
|
1471
|
-
if (!element._events[type]) {
|
1472
|
-
element._events[type] = function (event) {
|
1473
|
-
var
|
1474
|
-
list = element._events[event.type].list,
|
1475
|
-
events = list.slice(),
|
1476
|
-
index = -1,
|
1477
|
-
length = events.length,
|
1478
|
-
eventElement;
|
1479
|
-
|
1480
|
-
event.preventDefault = function preventDefault() {
|
1481
|
-
if (event.cancelable !== false) {
|
1482
|
-
event.returnValue = false;
|
1483
|
-
}
|
1484
|
-
};
|
1485
|
-
|
1486
|
-
event.stopPropagation = function stopPropagation() {
|
1487
|
-
event.cancelBubble = true;
|
1488
|
-
};
|
1489
|
-
|
1490
|
-
event.stopImmediatePropagation = function stopImmediatePropagation() {
|
1491
|
-
event.cancelBubble = true;
|
1492
|
-
event.cancelImmediate = true;
|
1493
|
-
};
|
1494
|
-
|
1495
|
-
event.currentTarget = element;
|
1496
|
-
event.relatedTarget = event.fromElement || null;
|
1497
|
-
event.target = event.target || event.srcElement || element;
|
1498
|
-
event.timeStamp = new Date().getTime();
|
1499
|
-
|
1500
|
-
if (event.clientX) {
|
1501
|
-
event.pageX = event.clientX + document.documentElement.scrollLeft;
|
1502
|
-
event.pageY = event.clientY + document.documentElement.scrollTop;
|
1503
|
-
}
|
1504
|
-
|
1505
|
-
while (++index < length && !event.cancelImmediate) {
|
1506
|
-
if (index in events) {
|
1507
|
-
eventElement = events[index];
|
1508
|
-
|
1509
|
-
if (indexOf(list, eventElement) !== -1 && typeof eventElement === 'function') {
|
1510
|
-
eventElement.call(element, event);
|
1511
|
-
}
|
1512
|
-
}
|
1513
|
-
}
|
1514
|
-
};
|
1515
|
-
|
1516
|
-
element._events[type].list = [];
|
1517
|
-
|
1518
|
-
if (element.attachEvent) {
|
1519
|
-
element.attachEvent('on' + type, element._events[type]);
|
1520
|
-
}
|
1521
|
-
}
|
1522
|
-
|
1523
|
-
element._events[type].list.push(listener);
|
1524
|
-
};
|
1525
|
-
|
1526
|
-
window.removeEventListener = Window.prototype.removeEventListener = Document.prototype.removeEventListener = Element.prototype.removeEventListener = function removeEventListener() {
|
1527
|
-
var
|
1528
|
-
element = this,
|
1529
|
-
type = arguments[0],
|
1530
|
-
listener = arguments[1],
|
1531
|
-
index;
|
1532
|
-
|
1533
|
-
if (element._events && element._events[type] && element._events[type].list) {
|
1534
|
-
index = indexOf(element._events[type].list, listener);
|
1535
|
-
|
1536
|
-
if (index !== -1) {
|
1537
|
-
element._events[type].list.splice(index, 1);
|
1538
|
-
|
1539
|
-
if (!element._events[type].list.length) {
|
1540
|
-
if (element.detachEvent) {
|
1541
|
-
element.detachEvent('on' + type, element._events[type]);
|
1542
|
-
}
|
1543
|
-
delete element._events[type];
|
1544
|
-
}
|
1545
|
-
}
|
1546
|
-
}
|
1547
|
-
};
|
1548
|
-
|
1549
|
-
window.dispatchEvent = Window.prototype.dispatchEvent = Document.prototype.dispatchEvent = Element.prototype.dispatchEvent = function dispatchEvent(event) {
|
1550
|
-
if (!arguments.length) {
|
1551
|
-
throw new Error('Not enough arguments');
|
1552
|
-
}
|
1553
|
-
|
1554
|
-
if (!event || typeof event.type !== 'string') {
|
1555
|
-
throw new Error('DOM Events Exception 0');
|
1556
|
-
}
|
1557
|
-
|
1558
|
-
var element = this, type = event.type;
|
1559
|
-
|
1560
|
-
try {
|
1561
|
-
if (!event.bubbles) {
|
1562
|
-
event.cancelBubble = true;
|
1563
|
-
|
1564
|
-
var cancelBubbleEvent = function (event) {
|
1565
|
-
event.cancelBubble = true;
|
1566
|
-
|
1567
|
-
(element || window).detachEvent('on' + type, cancelBubbleEvent);
|
1568
|
-
};
|
1569
|
-
|
1570
|
-
this.attachEvent('on' + type, cancelBubbleEvent);
|
1571
|
-
}
|
1572
|
-
|
1573
|
-
this.fireEvent('on' + type, event);
|
1574
|
-
} catch (error) {
|
1575
|
-
event.target = element;
|
1576
|
-
|
1577
|
-
do {
|
1578
|
-
event.currentTarget = element;
|
1579
|
-
|
1580
|
-
if ('_events' in element && typeof element._events[type] === 'function') {
|
1581
|
-
element._events[type].call(element, event);
|
1582
|
-
}
|
1583
|
-
|
1584
|
-
if (typeof element['on' + type] === 'function') {
|
1585
|
-
element['on' + type].call(element, event);
|
1586
|
-
}
|
1587
|
-
|
1588
|
-
element = element.nodeType === 9 ? element.parentWindow : element.parentNode;
|
1589
|
-
} while (element && !event.cancelBubble);
|
1590
|
-
}
|
1591
|
-
|
1592
|
-
return true;
|
1593
|
-
};
|
1594
|
-
|
1595
|
-
// Add the DOMContentLoaded Event
|
1596
|
-
document.attachEvent('onreadystatechange', function() {
|
1597
|
-
if (document.readyState === 'complete') {
|
1598
|
-
document.dispatchEvent(new Event('DOMContentLoaded', {
|
1599
|
-
bubbles: true
|
1600
|
-
}));
|
1601
|
-
}
|
1602
|
-
});
|
1603
|
-
}
|
1604
|
-
}());
|
1605
|
-
|
1606
|
-
})
|
1607
|
-
.call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
|
1608
|
-
|
1609
|
-
// @ts-nocheck
|
1610
|
-
|
1611
|
-
(function(undefined) {
|
1612
|
-
// Detection from https://github.com/Financial-Times/polyfill-service/blob/master/packages/polyfill-library/polyfills/Function/prototype/bind/detect.js
|
1613
|
-
var detect = 'bind' in Function.prototype;
|
1614
|
-
|
1615
|
-
if (detect) return
|
1616
|
-
|
1617
|
-
// Polyfill from https://cdn.polyfill.io/v2/polyfill.js?features=Function.prototype.bind&flags=always
|
1618
|
-
Object.defineProperty(Function.prototype, 'bind', {
|
1619
|
-
value: function bind(that) { // .length is 1
|
1620
|
-
// add necessary es5-shim utilities
|
1621
|
-
var $Array = Array;
|
1622
|
-
var $Object = Object;
|
1623
|
-
var ObjectPrototype = $Object.prototype;
|
1624
|
-
var ArrayPrototype = $Array.prototype;
|
1625
|
-
var Empty = function Empty() {};
|
1626
|
-
var to_string = ObjectPrototype.toString;
|
1627
|
-
var hasToStringTag = typeof Symbol === 'function' && typeof Symbol.toStringTag === 'symbol';
|
1628
|
-
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; };
|
1629
|
-
var array_slice = ArrayPrototype.slice;
|
1630
|
-
var array_concat = ArrayPrototype.concat;
|
1631
|
-
var array_push = ArrayPrototype.push;
|
1632
|
-
var max = Math.max;
|
1633
|
-
// /add necessary es5-shim utilities
|
1634
|
-
|
1635
|
-
// 1. Let Target be the this value.
|
1636
|
-
var target = this;
|
1637
|
-
// 2. If IsCallable(Target) is false, throw a TypeError exception.
|
1638
|
-
if (!isCallable(target)) {
|
1639
|
-
throw new TypeError('Function.prototype.bind called on incompatible ' + target);
|
1640
|
-
}
|
1641
|
-
// 3. Let A be a new (possibly empty) internal list of all of the
|
1642
|
-
// argument values provided after thisArg (arg1, arg2 etc), in order.
|
1643
|
-
// XXX slicedArgs will stand in for "A" if used
|
1644
|
-
var args = array_slice.call(arguments, 1); // for normal call
|
1645
|
-
// 4. Let F be a new native ECMAScript object.
|
1646
|
-
// 11. Set the [[Prototype]] internal property of F to the standard
|
1647
|
-
// built-in Function prototype object as specified in 15.3.3.1.
|
1648
|
-
// 12. Set the [[Call]] internal property of F as described in
|
1649
|
-
// 15.3.4.5.1.
|
1650
|
-
// 13. Set the [[Construct]] internal property of F as described in
|
1651
|
-
// 15.3.4.5.2.
|
1652
|
-
// 14. Set the [[HasInstance]] internal property of F as described in
|
1653
|
-
// 15.3.4.5.3.
|
1654
|
-
var bound;
|
1655
|
-
var binder = function () {
|
1656
|
-
|
1657
|
-
if (this instanceof bound) {
|
1658
|
-
// 15.3.4.5.2 [[Construct]]
|
1659
|
-
// When the [[Construct]] internal method of a function object,
|
1660
|
-
// F that was created using the bind function is called with a
|
1661
|
-
// list of arguments ExtraArgs, the following steps are taken:
|
1662
|
-
// 1. Let target be the value of F's [[TargetFunction]]
|
1663
|
-
// internal property.
|
1664
|
-
// 2. If target has no [[Construct]] internal method, a
|
1665
|
-
// TypeError exception is thrown.
|
1666
|
-
// 3. Let boundArgs be the value of F's [[BoundArgs]] internal
|
1667
|
-
// property.
|
1668
|
-
// 4. Let args be a new list containing the same values as the
|
1669
|
-
// list boundArgs in the same order followed by the same
|
1670
|
-
// values as the list ExtraArgs in the same order.
|
1671
|
-
// 5. Return the result of calling the [[Construct]] internal
|
1672
|
-
// method of target providing args as the arguments.
|
1673
|
-
|
1674
|
-
var result = target.apply(
|
1675
|
-
this,
|
1676
|
-
array_concat.call(args, array_slice.call(arguments))
|
1677
|
-
);
|
1678
|
-
if ($Object(result) === result) {
|
1679
|
-
return result;
|
1680
|
-
}
|
1681
|
-
return this;
|
1682
|
-
|
1683
|
-
} else {
|
1684
|
-
// 15.3.4.5.1 [[Call]]
|
1685
|
-
// When the [[Call]] internal method of a function object, F,
|
1686
|
-
// which was created using the bind function is called with a
|
1687
|
-
// this value and a list of arguments ExtraArgs, the following
|
1688
|
-
// steps are taken:
|
1689
|
-
// 1. Let boundArgs be the value of F's [[BoundArgs]] internal
|
1690
|
-
// property.
|
1691
|
-
// 2. Let boundThis be the value of F's [[BoundThis]] internal
|
1692
|
-
// property.
|
1693
|
-
// 3. Let target be the value of F's [[TargetFunction]] internal
|
1694
|
-
// property.
|
1695
|
-
// 4. Let args be a new list containing the same values as the
|
1696
|
-
// list boundArgs in the same order followed by the same
|
1697
|
-
// values as the list ExtraArgs in the same order.
|
1698
|
-
// 5. Return the result of calling the [[Call]] internal method
|
1699
|
-
// of target providing boundThis as the this value and
|
1700
|
-
// providing args as the arguments.
|
1701
|
-
|
1702
|
-
// equiv: target.call(this, ...boundArgs, ...args)
|
1703
|
-
return target.apply(
|
1704
|
-
that,
|
1705
|
-
array_concat.call(args, array_slice.call(arguments))
|
1706
|
-
);
|
1707
|
-
|
1708
|
-
}
|
1709
|
-
|
1710
|
-
};
|
1711
|
-
|
1712
|
-
// 15. If the [[Class]] internal property of Target is "Function", then
|
1713
|
-
// a. Let L be the length property of Target minus the length of A.
|
1714
|
-
// b. Set the length own property of F to either 0 or L, whichever is
|
1715
|
-
// larger.
|
1716
|
-
// 16. Else set the length own property of F to 0.
|
1717
|
-
|
1718
|
-
var boundLength = max(0, target.length - args.length);
|
1719
|
-
|
1720
|
-
// 17. Set the attributes of the length own property of F to the values
|
1721
|
-
// specified in 15.3.5.1.
|
1722
|
-
var boundArgs = [];
|
1723
|
-
for (var i = 0; i < boundLength; i++) {
|
1724
|
-
array_push.call(boundArgs, '$' + i);
|
1725
|
-
}
|
1726
|
-
|
1727
|
-
// XXX Build a dynamic function with desired amount of arguments is the only
|
1728
|
-
// way to set the length property of a function.
|
1729
|
-
// In environments where Content Security Policies enabled (Chrome extensions,
|
1730
|
-
// for ex.) all use of eval or Function costructor throws an exception.
|
1731
|
-
// However in all of these environments Function.prototype.bind exists
|
1732
|
-
// and so this code will never be executed.
|
1733
|
-
bound = Function('binder', 'return function (' + boundArgs.join(',') + '){ return binder.apply(this, arguments); }')(binder);
|
1734
|
-
|
1735
|
-
if (target.prototype) {
|
1736
|
-
Empty.prototype = target.prototype;
|
1737
|
-
bound.prototype = new Empty();
|
1738
|
-
// Clean up dangling references.
|
1739
|
-
Empty.prototype = null;
|
1740
|
-
}
|
1741
|
-
|
1742
|
-
// TODO
|
1743
|
-
// 18. Set the [[Extensible]] internal property of F to true.
|
1744
|
-
|
1745
|
-
// TODO
|
1746
|
-
// 19. Let thrower be the [[ThrowTypeError]] function Object (13.2.3).
|
1747
|
-
// 20. Call the [[DefineOwnProperty]] internal method of F with
|
1748
|
-
// arguments "caller", PropertyDescriptor {[[Get]]: thrower, [[Set]]:
|
1749
|
-
// thrower, [[Enumerable]]: false, [[Configurable]]: false}, and
|
1750
|
-
// false.
|
1751
|
-
// 21. Call the [[DefineOwnProperty]] internal method of F with
|
1752
|
-
// arguments "arguments", PropertyDescriptor {[[Get]]: thrower,
|
1753
|
-
// [[Set]]: thrower, [[Enumerable]]: false, [[Configurable]]: false},
|
1754
|
-
// and false.
|
1755
|
-
|
1756
|
-
// TODO
|
1757
|
-
// NOTE Function objects created using Function.prototype.bind do not
|
1758
|
-
// have a prototype property or the [[Code]], [[FormalParameters]], and
|
1759
|
-
// [[Scope]] internal properties.
|
1760
|
-
// XXX can't delete prototype in pure-js.
|
1761
|
-
|
1762
|
-
// 22. Return F.
|
1763
|
-
return bound;
|
1764
|
-
}
|
1765
|
-
});
|
1766
|
-
})
|
1767
|
-
.call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
|
1768
|
-
|
1769
|
-
/* eslint-disable es-x/no-function-prototype-bind -- Polyfill imported */
|
1770
|
-
|
1771
|
-
/**
|
1772
|
-
* @constant
|
1773
|
-
* @type {AccordionTranslations}
|
1774
|
-
* @see Default value for {@link AccordionConfig.i18n}
|
1775
|
-
* @default
|
1776
|
-
*/
|
1777
|
-
var ACCORDION_TRANSLATIONS = {
|
1778
|
-
hideAllSections: 'Hide all sections',
|
1779
|
-
hideSection: 'Hide',
|
1780
|
-
hideSectionAriaLabel: 'Hide this section',
|
1781
|
-
showAllSections: 'Show all sections',
|
1782
|
-
showSection: 'Show',
|
1783
|
-
showSectionAriaLabel: 'Show this section'
|
1784
|
-
};
|
1785
|
-
|
1786
|
-
/**
|
1787
|
-
* Accordion component
|
1788
|
-
*
|
1789
|
-
* This allows a collection of sections to be collapsed by default, showing only
|
1790
|
-
* their headers. Sections can be expanded or collapsed individually by clicking
|
1791
|
-
* their headers. A "Show all sections" button is also added to the top of the
|
1792
|
-
* accordion, which switches to "Hide all sections" when all the sections are
|
1793
|
-
* expanded.
|
1794
|
-
*
|
1795
|
-
* The state of each section is saved to the DOM via the `aria-expanded`
|
1796
|
-
* attribute, which also provides accessibility.
|
1797
|
-
*
|
1798
|
-
* @class
|
1799
|
-
* @param {Element} $module - HTML element to use for accordion
|
1800
|
-
* @param {AccordionConfig} [config] - Accordion config
|
1801
|
-
*/
|
1802
|
-
function Accordion ($module, config) {
|
1803
|
-
if (!($module instanceof HTMLElement)) {
|
1804
|
-
return this
|
1805
|
-
}
|
1806
|
-
|
1807
|
-
/** @deprecated Will be made private in v5.0 */
|
1808
|
-
this.$module = $module;
|
1809
|
-
|
1810
|
-
var defaultConfig = {
|
1811
|
-
i18n: ACCORDION_TRANSLATIONS,
|
1812
|
-
rememberExpanded: true
|
1813
|
-
};
|
1814
|
-
|
1815
|
-
/**
|
1816
|
-
* @deprecated Will be made private in v5.0
|
1817
|
-
* @type {AccordionConfig}
|
1818
|
-
*/
|
1819
|
-
this.config = mergeConfigs(
|
1820
|
-
defaultConfig,
|
1821
|
-
config || {},
|
1822
|
-
normaliseDataset($module.dataset)
|
1823
|
-
);
|
1824
|
-
|
1825
|
-
/** @deprecated Will be made private in v5.0 */
|
1826
|
-
this.i18n = new I18n(extractConfigByNamespace(this.config, 'i18n'));
|
1827
|
-
|
1828
|
-
/** @deprecated Will be made private in v5.0 */
|
1829
|
-
this.controlsClass = 'govuk-accordion__controls';
|
1830
|
-
|
1831
|
-
/** @deprecated Will be made private in v5.0 */
|
1832
|
-
this.showAllClass = 'govuk-accordion__show-all';
|
1833
|
-
|
1834
|
-
/** @deprecated Will be made private in v5.0 */
|
1835
|
-
this.showAllTextClass = 'govuk-accordion__show-all-text';
|
1836
|
-
|
1837
|
-
/** @deprecated Will be made private in v5.0 */
|
1838
|
-
this.sectionClass = 'govuk-accordion__section';
|
1839
|
-
|
1840
|
-
/** @deprecated Will be made private in v5.0 */
|
1841
|
-
this.sectionExpandedClass = 'govuk-accordion__section--expanded';
|
1842
|
-
|
1843
|
-
/** @deprecated Will be made private in v5.0 */
|
1844
|
-
this.sectionButtonClass = 'govuk-accordion__section-button';
|
1845
|
-
|
1846
|
-
/** @deprecated Will be made private in v5.0 */
|
1847
|
-
this.sectionHeaderClass = 'govuk-accordion__section-header';
|
1848
|
-
|
1849
|
-
/** @deprecated Will be made private in v5.0 */
|
1850
|
-
this.sectionHeadingClass = 'govuk-accordion__section-heading';
|
1851
|
-
|
1852
|
-
/** @deprecated Will be made private in v5.0 */
|
1853
|
-
this.sectionHeadingDividerClass = 'govuk-accordion__section-heading-divider';
|
1854
|
-
|
1855
|
-
/** @deprecated Will be made private in v5.0 */
|
1856
|
-
this.sectionHeadingTextClass = 'govuk-accordion__section-heading-text';
|
1857
|
-
|
1858
|
-
/** @deprecated Will be made private in v5.0 */
|
1859
|
-
this.sectionHeadingTextFocusClass = 'govuk-accordion__section-heading-text-focus';
|
1860
|
-
|
1861
|
-
/** @deprecated Will be made private in v5.0 */
|
1862
|
-
this.sectionShowHideToggleClass = 'govuk-accordion__section-toggle';
|
1863
|
-
|
1864
|
-
/** @deprecated Will be made private in v5.0 */
|
1865
|
-
this.sectionShowHideToggleFocusClass = 'govuk-accordion__section-toggle-focus';
|
1866
|
-
|
1867
|
-
/** @deprecated Will be made private in v5.0 */
|
1868
|
-
this.sectionShowHideTextClass = 'govuk-accordion__section-toggle-text';
|
1869
|
-
|
1870
|
-
/** @deprecated Will be made private in v5.0 */
|
1871
|
-
this.upChevronIconClass = 'govuk-accordion-nav__chevron';
|
1872
|
-
|
1873
|
-
/** @deprecated Will be made private in v5.0 */
|
1874
|
-
this.downChevronIconClass = 'govuk-accordion-nav__chevron--down';
|
1875
|
-
|
1876
|
-
/** @deprecated Will be made private in v5.0 */
|
1877
|
-
this.sectionSummaryClass = 'govuk-accordion__section-summary';
|
1878
|
-
|
1879
|
-
/** @deprecated Will be made private in v5.0 */
|
1880
|
-
this.sectionSummaryFocusClass = 'govuk-accordion__section-summary-focus';
|
1881
|
-
|
1882
|
-
/** @deprecated Will be made private in v5.0 */
|
1883
|
-
this.sectionContentClass = 'govuk-accordion__section-content';
|
1884
|
-
|
1885
|
-
var $sections = this.$module.querySelectorAll('.' + this.sectionClass);
|
1886
|
-
if (!$sections.length) {
|
1887
|
-
return this
|
1888
|
-
}
|
1889
|
-
|
1890
|
-
/** @deprecated Will be made private in v5.0 */
|
1891
|
-
this.$sections = $sections;
|
1892
|
-
|
1893
|
-
/** @deprecated Will be made private in v5.0 */
|
1894
|
-
this.browserSupportsSessionStorage = helper.checkForSessionStorage();
|
1895
|
-
|
1896
|
-
/** @deprecated Will be made private in v5.0 */
|
1897
|
-
this.$showAllButton = null;
|
1898
|
-
|
1899
|
-
/** @deprecated Will be made private in v5.0 */
|
1900
|
-
this.$showAllIcon = null;
|
1901
|
-
|
1902
|
-
/** @deprecated Will be made private in v5.0 */
|
1903
|
-
this.$showAllText = null;
|
1904
|
-
}
|
1905
|
-
|
1906
|
-
/**
|
1907
|
-
* Initialise component
|
1908
|
-
*/
|
1909
|
-
Accordion.prototype.init = function () {
|
1910
|
-
// Check that required elements are present
|
1911
|
-
if (!this.$module || !this.$sections) {
|
1912
|
-
return
|
1913
|
-
}
|
1914
|
-
|
1915
|
-
this.initControls();
|
1916
|
-
this.initSectionHeaders();
|
1917
|
-
|
1918
|
-
// See if "Show all sections" button text should be updated
|
1919
|
-
var areAllSectionsOpen = this.checkIfAllSectionsOpen();
|
1920
|
-
this.updateShowAllButton(areAllSectionsOpen);
|
1921
|
-
};
|
1922
|
-
|
1923
|
-
/**
|
1924
|
-
* Initialise controls and set attributes
|
1925
|
-
*
|
1926
|
-
* @deprecated Will be made private in v5.0
|
1927
|
-
*/
|
1928
|
-
Accordion.prototype.initControls = function () {
|
1929
|
-
// Create "Show all" button and set attributes
|
1930
|
-
this.$showAllButton = document.createElement('button');
|
1931
|
-
this.$showAllButton.setAttribute('type', 'button');
|
1932
|
-
this.$showAllButton.setAttribute('class', this.showAllClass);
|
1933
|
-
this.$showAllButton.setAttribute('aria-expanded', 'false');
|
1934
|
-
|
1935
|
-
// Create icon, add to element
|
1936
|
-
this.$showAllIcon = document.createElement('span');
|
1937
|
-
this.$showAllIcon.classList.add(this.upChevronIconClass);
|
1938
|
-
this.$showAllButton.appendChild(this.$showAllIcon);
|
1939
|
-
|
1940
|
-
// Create control wrapper and add controls to it
|
1941
|
-
var $accordionControls = document.createElement('div');
|
1942
|
-
$accordionControls.setAttribute('class', this.controlsClass);
|
1943
|
-
$accordionControls.appendChild(this.$showAllButton);
|
1944
|
-
this.$module.insertBefore($accordionControls, this.$module.firstChild);
|
1945
|
-
|
1946
|
-
// Build additional wrapper for Show all toggle text and place after icon
|
1947
|
-
this.$showAllText = document.createElement('span');
|
1948
|
-
this.$showAllText.classList.add(this.showAllTextClass);
|
1949
|
-
this.$showAllButton.appendChild(this.$showAllText);
|
1950
|
-
|
1951
|
-
// Handle click events on the show/hide all button
|
1952
|
-
this.$showAllButton.addEventListener('click', this.onShowOrHideAllToggle.bind(this));
|
1953
|
-
|
1954
|
-
// Handle 'beforematch' events, if the user agent supports them
|
1955
|
-
if ('onbeforematch' in document) {
|
1956
|
-
document.addEventListener('beforematch', this.onBeforeMatch.bind(this));
|
1957
|
-
}
|
1958
|
-
};
|
1959
|
-
|
1960
|
-
/**
|
1961
|
-
* Initialise section headers
|
1962
|
-
*
|
1963
|
-
* @deprecated Will be made private in v5.0
|
1964
|
-
*/
|
1965
|
-
Accordion.prototype.initSectionHeaders = function () {
|
1966
|
-
var $component = this;
|
1967
|
-
var $sections = this.$sections;
|
1968
|
-
|
1969
|
-
// Loop through sections
|
1970
|
-
nodeListForEach($sections, function ($section, i) {
|
1971
|
-
var $header = $section.querySelector('.' + $component.sectionHeaderClass);
|
1972
|
-
if (!$header) {
|
1973
|
-
return
|
1974
|
-
}
|
1975
|
-
|
1976
|
-
// Set header attributes
|
1977
|
-
$component.constructHeaderMarkup($header, i);
|
1978
|
-
$component.setExpanded($component.isExpanded($section), $section);
|
1979
|
-
|
1980
|
-
// Handle events
|
1981
|
-
$header.addEventListener('click', $component.onSectionToggle.bind($component, $section));
|
1982
|
-
|
1983
|
-
// See if there is any state stored in sessionStorage and set the sections to
|
1984
|
-
// open or closed.
|
1985
|
-
$component.setInitialState($section);
|
1986
|
-
});
|
1987
|
-
};
|
1988
|
-
|
1989
|
-
/**
|
1990
|
-
* Construct section header
|
1991
|
-
*
|
1992
|
-
* @deprecated Will be made private in v5.0
|
1993
|
-
* @param {Element} $header - Section header
|
1994
|
-
* @param {number} index - Section index
|
1995
|
-
*/
|
1996
|
-
Accordion.prototype.constructHeaderMarkup = function ($header, index) {
|
1997
|
-
var $span = $header.querySelector('.' + this.sectionButtonClass);
|
1998
|
-
var $heading = $header.querySelector('.' + this.sectionHeadingClass);
|
1999
|
-
var $summary = $header.querySelector('.' + this.sectionSummaryClass);
|
2000
|
-
|
2001
|
-
if (!$span || !$heading) {
|
2002
|
-
return
|
2003
|
-
}
|
2004
|
-
|
2005
|
-
// Create a button element that will replace the '.govuk-accordion__section-button' span
|
2006
|
-
var $button = document.createElement('button');
|
2007
|
-
$button.setAttribute('type', 'button');
|
2008
|
-
$button.setAttribute('aria-controls', this.$module.id + '-content-' + (index + 1).toString());
|
2009
|
-
|
2010
|
-
// Copy all attributes (https://developer.mozilla.org/en-US/docs/Web/API/Element/attributes) from $span to $button
|
2011
|
-
for (var i = 0; i < $span.attributes.length; i++) {
|
2012
|
-
var attr = $span.attributes.item(i);
|
2013
|
-
// Add all attributes but not ID as this is being added to
|
2014
|
-
// the section heading ($headingText)
|
2015
|
-
if (attr.nodeName !== 'id') {
|
2016
|
-
$button.setAttribute(attr.nodeName, attr.nodeValue);
|
2017
|
-
}
|
2018
|
-
}
|
2019
|
-
|
2020
|
-
// Create container for heading text so it can be styled
|
2021
|
-
var $headingText = document.createElement('span');
|
2022
|
-
$headingText.classList.add(this.sectionHeadingTextClass);
|
2023
|
-
// Copy the span ID to the heading text to allow it to be referenced by `aria-labelledby` on the
|
2024
|
-
// hidden content area without "Show this section"
|
2025
|
-
$headingText.id = $span.id;
|
2026
|
-
|
2027
|
-
// Create an inner heading text container to limit the width of the focus state
|
2028
|
-
var $headingTextFocus = document.createElement('span');
|
2029
|
-
$headingTextFocus.classList.add(this.sectionHeadingTextFocusClass);
|
2030
|
-
$headingText.appendChild($headingTextFocus);
|
2031
|
-
// span could contain HTML elements (see https://www.w3.org/TR/2011/WD-html5-20110525/content-models.html#phrasing-content)
|
2032
|
-
$headingTextFocus.innerHTML = $span.innerHTML;
|
2033
|
-
|
2034
|
-
// Create container for show / hide icons and text.
|
2035
|
-
var $showHideToggle = document.createElement('span');
|
2036
|
-
$showHideToggle.classList.add(this.sectionShowHideToggleClass);
|
2037
|
-
// Tell Google not to index the 'show' text as part of the heading
|
2038
|
-
// For the snippet to work with JavaScript, it must be added before adding the page element to the
|
2039
|
-
// page's DOM. See https://developers.google.com/search/docs/advanced/robots/robots_meta_tag#data-nosnippet-attr
|
2040
|
-
$showHideToggle.setAttribute('data-nosnippet', '');
|
2041
|
-
// Create an inner container to limit the width of the focus state
|
2042
|
-
var $showHideToggleFocus = document.createElement('span');
|
2043
|
-
$showHideToggleFocus.classList.add(this.sectionShowHideToggleFocusClass);
|
2044
|
-
$showHideToggle.appendChild($showHideToggleFocus);
|
2045
|
-
// Create wrapper for the show / hide text. Append text after the show/hide icon
|
2046
|
-
var $showHideText = document.createElement('span');
|
2047
|
-
var $showHideIcon = document.createElement('span');
|
2048
|
-
$showHideIcon.classList.add(this.upChevronIconClass);
|
2049
|
-
$showHideToggleFocus.appendChild($showHideIcon);
|
2050
|
-
$showHideText.classList.add(this.sectionShowHideTextClass);
|
2051
|
-
$showHideToggleFocus.appendChild($showHideText);
|
2052
|
-
|
2053
|
-
// Append elements to the button:
|
2054
|
-
// 1. Heading text
|
2055
|
-
// 2. Punctuation
|
2056
|
-
// 3. (Optional: Summary line followed by punctuation)
|
2057
|
-
// 4. Show / hide toggle
|
2058
|
-
$button.appendChild($headingText);
|
2059
|
-
$button.appendChild(this.getButtonPunctuationEl());
|
2060
|
-
|
2061
|
-
// If summary content exists add to DOM in correct order
|
2062
|
-
if ($summary) {
|
2063
|
-
// Create a new `span` element and copy the summary line content from the original `div` to the
|
2064
|
-
// new `span`
|
2065
|
-
// This is because the summary line text is now inside a button element, which can only contain
|
2066
|
-
// phrasing content
|
2067
|
-
var $summarySpan = document.createElement('span');
|
2068
|
-
// Create an inner summary container to limit the width of the summary focus state
|
2069
|
-
var $summarySpanFocus = document.createElement('span');
|
2070
|
-
$summarySpanFocus.classList.add(this.sectionSummaryFocusClass);
|
2071
|
-
$summarySpan.appendChild($summarySpanFocus);
|
2072
|
-
|
2073
|
-
// Get original attributes, and pass them to the replacement
|
2074
|
-
for (var j = 0, l = $summary.attributes.length; j < l; ++j) {
|
2075
|
-
var nodeName = $summary.attributes.item(j).nodeName;
|
2076
|
-
var nodeValue = $summary.attributes.item(j).nodeValue;
|
2077
|
-
$summarySpan.setAttribute(nodeName, nodeValue);
|
2078
|
-
}
|
2079
|
-
|
2080
|
-
// Copy original contents of summary to the new summary span
|
2081
|
-
$summarySpanFocus.innerHTML = $summary.innerHTML;
|
2082
|
-
|
2083
|
-
// Replace the original summary `div` with the new summary `span`
|
2084
|
-
$summary.parentNode.replaceChild($summarySpan, $summary);
|
2085
|
-
|
2086
|
-
$button.appendChild($summarySpan);
|
2087
|
-
$button.appendChild(this.getButtonPunctuationEl());
|
2088
|
-
}
|
2089
|
-
|
2090
|
-
$button.appendChild($showHideToggle);
|
2091
|
-
|
2092
|
-
$heading.removeChild($span);
|
2093
|
-
$heading.appendChild($button);
|
2094
|
-
};
|
2095
|
-
|
2096
|
-
/**
|
2097
|
-
* When a section is opened by the user agent via the 'beforematch' event
|
2098
|
-
*
|
2099
|
-
* @deprecated Will be made private in v5.0
|
2100
|
-
* @param {Event} event - Generic event
|
2101
|
-
*/
|
2102
|
-
Accordion.prototype.onBeforeMatch = function (event) {
|
2103
|
-
var $fragment = event.target;
|
2104
|
-
|
2105
|
-
// Handle elements with `.closest()` support only
|
2106
|
-
if (!($fragment instanceof Element)) {
|
2107
|
-
return
|
2108
|
-
}
|
2109
|
-
|
2110
|
-
// Handle when fragment is inside section
|
2111
|
-
var $section = $fragment.closest('.' + this.sectionClass);
|
2112
|
-
if ($section) {
|
2113
|
-
this.setExpanded(true, $section);
|
2114
|
-
}
|
2115
|
-
};
|
2116
|
-
|
2117
|
-
/**
|
2118
|
-
* When section toggled, set and store state
|
2119
|
-
*
|
2120
|
-
* @deprecated Will be made private in v5.0
|
2121
|
-
* @param {Element} $section - Section element
|
2122
|
-
*/
|
2123
|
-
Accordion.prototype.onSectionToggle = function ($section) {
|
2124
|
-
var expanded = this.isExpanded($section);
|
2125
|
-
this.setExpanded(!expanded, $section);
|
2126
|
-
|
2127
|
-
// Store the state in sessionStorage when a change is triggered
|
2128
|
-
this.storeState($section);
|
2129
|
-
};
|
2130
|
-
|
2131
|
-
/**
|
2132
|
-
* When Open/Close All toggled, set and store state
|
2133
|
-
*
|
2134
|
-
* @deprecated Will be made private in v5.0
|
2135
|
-
*/
|
2136
|
-
Accordion.prototype.onShowOrHideAllToggle = function () {
|
2137
|
-
var $component = this;
|
2138
|
-
var $sections = this.$sections;
|
2139
|
-
|
2140
|
-
var nowExpanded = !this.checkIfAllSectionsOpen();
|
2141
|
-
|
2142
|
-
// Loop through sections
|
2143
|
-
nodeListForEach($sections, function ($section) {
|
2144
|
-
$component.setExpanded(nowExpanded, $section);
|
2145
|
-
// Store the state in sessionStorage when a change is triggered
|
2146
|
-
$component.storeState($section);
|
2147
|
-
});
|
2148
|
-
|
2149
|
-
$component.updateShowAllButton(nowExpanded);
|
2150
|
-
};
|
2151
|
-
|
2152
|
-
/**
|
2153
|
-
* Set section attributes when opened/closed
|
2154
|
-
*
|
2155
|
-
* @deprecated Will be made private in v5.0
|
2156
|
-
* @param {boolean} expanded - Section expanded
|
2157
|
-
* @param {Element} $section - Section element
|
2158
|
-
*/
|
2159
|
-
Accordion.prototype.setExpanded = function (expanded, $section) {
|
2160
|
-
var $showHideIcon = $section.querySelector('.' + this.upChevronIconClass);
|
2161
|
-
var $showHideText = $section.querySelector('.' + this.sectionShowHideTextClass);
|
2162
|
-
var $button = $section.querySelector('.' + this.sectionButtonClass);
|
2163
|
-
var $content = $section.querySelector('.' + this.sectionContentClass);
|
2164
|
-
|
2165
|
-
if (!$showHideIcon ||
|
2166
|
-
!($showHideText instanceof HTMLElement) ||
|
2167
|
-
!$button ||
|
2168
|
-
!$content) {
|
2169
|
-
return
|
2170
|
-
}
|
2171
|
-
|
2172
|
-
var newButtonText = expanded
|
2173
|
-
? this.i18n.t('hideSection')
|
2174
|
-
: this.i18n.t('showSection');
|
2175
|
-
|
2176
|
-
$showHideText.innerText = newButtonText;
|
2177
|
-
$button.setAttribute('aria-expanded', expanded.toString());
|
2178
|
-
|
2179
|
-
// Update aria-label combining
|
2180
|
-
var ariaLabelParts = [];
|
2181
|
-
|
2182
|
-
var $headingText = $section.querySelector('.' + this.sectionHeadingTextClass);
|
2183
|
-
if ($headingText instanceof HTMLElement) {
|
2184
|
-
ariaLabelParts.push($headingText.innerText.trim());
|
2185
|
-
}
|
2186
|
-
|
2187
|
-
var $summary = $section.querySelector('.' + this.sectionSummaryClass);
|
2188
|
-
if ($summary instanceof HTMLElement) {
|
2189
|
-
ariaLabelParts.push($summary.innerText.trim());
|
2190
|
-
}
|
2191
|
-
|
2192
|
-
var ariaLabelMessage = expanded
|
2193
|
-
? this.i18n.t('hideSectionAriaLabel')
|
2194
|
-
: this.i18n.t('showSectionAriaLabel');
|
2195
|
-
ariaLabelParts.push(ariaLabelMessage);
|
2196
|
-
|
2197
|
-
/*
|
2198
|
-
* Join with a comma to add pause for assistive technology.
|
2199
|
-
* Example: [heading]Section A ,[pause] Show this section.
|
2200
|
-
* https://accessibility.blog.gov.uk/2017/12/18/what-working-on-gov-uk-navigation-taught-us-about-accessibility/
|
2201
|
-
*/
|
2202
|
-
$button.setAttribute('aria-label', ariaLabelParts.join(' , '));
|
2203
|
-
|
2204
|
-
// Swap icon, change class
|
2205
|
-
if (expanded) {
|
2206
|
-
$content.removeAttribute('hidden');
|
2207
|
-
$section.classList.add(this.sectionExpandedClass);
|
2208
|
-
$showHideIcon.classList.remove(this.downChevronIconClass);
|
2209
|
-
} else {
|
2210
|
-
$content.setAttribute('hidden', 'until-found');
|
2211
|
-
$section.classList.remove(this.sectionExpandedClass);
|
2212
|
-
$showHideIcon.classList.add(this.downChevronIconClass);
|
2213
|
-
}
|
2214
|
-
|
2215
|
-
// See if "Show all sections" button text should be updated
|
2216
|
-
var areAllSectionsOpen = this.checkIfAllSectionsOpen();
|
2217
|
-
this.updateShowAllButton(areAllSectionsOpen);
|
2218
|
-
};
|
2219
|
-
|
2220
|
-
/**
|
2221
|
-
* Get state of section
|
2222
|
-
*
|
2223
|
-
* @deprecated Will be made private in v5.0
|
2224
|
-
* @param {Element} $section - Section element
|
2225
|
-
* @returns {boolean} True if expanded
|
2226
|
-
*/
|
2227
|
-
Accordion.prototype.isExpanded = function ($section) {
|
2228
|
-
return $section.classList.contains(this.sectionExpandedClass)
|
2229
|
-
};
|
2230
|
-
|
2231
|
-
/**
|
2232
|
-
* Check if all sections are open
|
2233
|
-
*
|
2234
|
-
* @deprecated Will be made private in v5.0
|
2235
|
-
* @returns {boolean} True if all sections are open
|
2236
|
-
*/
|
2237
|
-
Accordion.prototype.checkIfAllSectionsOpen = function () {
|
2238
|
-
// Get a count of all the Accordion sections
|
2239
|
-
var sectionsCount = this.$sections.length;
|
2240
|
-
// Get a count of all Accordion sections that are expanded
|
2241
|
-
var expandedSectionCount = this.$module.querySelectorAll('.' + this.sectionExpandedClass).length;
|
2242
|
-
var areAllSectionsOpen = sectionsCount === expandedSectionCount;
|
2243
|
-
|
2244
|
-
return areAllSectionsOpen
|
2245
|
-
};
|
2246
|
-
|
2247
|
-
/**
|
2248
|
-
* Update "Show all sections" button
|
2249
|
-
*
|
2250
|
-
* @deprecated Will be made private in v5.0
|
2251
|
-
* @param {boolean} expanded - Section expanded
|
2252
|
-
*/
|
2253
|
-
Accordion.prototype.updateShowAllButton = function (expanded) {
|
2254
|
-
var newButtonText = expanded
|
2255
|
-
? this.i18n.t('hideAllSections')
|
2256
|
-
: this.i18n.t('showAllSections');
|
2257
|
-
|
2258
|
-
this.$showAllButton.setAttribute('aria-expanded', expanded.toString());
|
2259
|
-
this.$showAllText.innerText = newButtonText;
|
2260
|
-
|
2261
|
-
// Swap icon, toggle class
|
2262
|
-
if (expanded) {
|
2263
|
-
this.$showAllIcon.classList.remove(this.downChevronIconClass);
|
2264
|
-
} else {
|
2265
|
-
this.$showAllIcon.classList.add(this.downChevronIconClass);
|
2266
|
-
}
|
2267
|
-
};
|
2268
|
-
|
2269
|
-
var helper = {
|
2270
|
-
/**
|
2271
|
-
* Check for `window.sessionStorage`, and that it actually works.
|
2272
|
-
*
|
2273
|
-
* @returns {boolean} True if session storage is available
|
2274
|
-
*/
|
2275
|
-
checkForSessionStorage: function () {
|
2276
|
-
var testString = 'this is the test string';
|
2277
|
-
var result;
|
2278
|
-
try {
|
2279
|
-
window.sessionStorage.setItem(testString, testString);
|
2280
|
-
result = window.sessionStorage.getItem(testString) === testString.toString();
|
2281
|
-
window.sessionStorage.removeItem(testString);
|
2282
|
-
return result
|
2283
|
-
} catch (exception) {
|
2284
|
-
return false
|
2285
|
-
}
|
2286
|
-
}
|
2287
|
-
};
|
2288
|
-
|
2289
|
-
/**
|
2290
|
-
* Set the state of the accordions in sessionStorage
|
2291
|
-
*
|
2292
|
-
* @deprecated Will be made private in v5.0
|
2293
|
-
* @param {Element} $section - Section element
|
2294
|
-
*/
|
2295
|
-
Accordion.prototype.storeState = function ($section) {
|
2296
|
-
if (this.browserSupportsSessionStorage && this.config.rememberExpanded) {
|
2297
|
-
// We need a unique way of identifying each content in the Accordion. Since
|
2298
|
-
// an `#id` should be unique and an `id` is required for `aria-` attributes
|
2299
|
-
// `id` can be safely used.
|
2300
|
-
var $button = $section.querySelector('.' + this.sectionButtonClass);
|
2301
|
-
|
2302
|
-
if ($button) {
|
2303
|
-
var contentId = $button.getAttribute('aria-controls');
|
2304
|
-
var contentState = $button.getAttribute('aria-expanded');
|
2305
|
-
|
2306
|
-
// Only set the state when both `contentId` and `contentState` are taken from the DOM.
|
2307
|
-
if (contentId && contentState) {
|
2308
|
-
window.sessionStorage.setItem(contentId, contentState);
|
2309
|
-
}
|
2310
|
-
}
|
2311
|
-
}
|
2312
|
-
};
|
2313
|
-
|
2314
|
-
/**
|
2315
|
-
* Read the state of the accordions from sessionStorage
|
2316
|
-
*
|
2317
|
-
* @deprecated Will be made private in v5.0
|
2318
|
-
* @param {Element} $section - Section element
|
2319
|
-
*/
|
2320
|
-
Accordion.prototype.setInitialState = function ($section) {
|
2321
|
-
if (this.browserSupportsSessionStorage && this.config.rememberExpanded) {
|
2322
|
-
var $button = $section.querySelector('.' + this.sectionButtonClass);
|
2323
|
-
|
2324
|
-
if ($button) {
|
2325
|
-
var contentId = $button.getAttribute('aria-controls');
|
2326
|
-
var contentState = contentId ? window.sessionStorage.getItem(contentId) : null;
|
2327
|
-
|
2328
|
-
if (contentState !== null) {
|
2329
|
-
this.setExpanded(contentState === 'true', $section);
|
2330
|
-
}
|
2331
|
-
}
|
2332
|
-
}
|
2333
|
-
};
|
2334
|
-
|
2335
|
-
/**
|
2336
|
-
* Create an element to improve semantics of the section button with punctuation
|
2337
|
-
*
|
2338
|
-
* Adding punctuation to the button can also improve its general semantics by dividing its contents
|
2339
|
-
* into thematic chunks.
|
2340
|
-
* See https://github.com/alphagov/govuk-frontend/issues/2327#issuecomment-922957442
|
2341
|
-
*
|
2342
|
-
* @deprecated Will be made private in v5.0
|
2343
|
-
* @returns {Element} DOM element
|
2344
|
-
*/
|
2345
|
-
Accordion.prototype.getButtonPunctuationEl = function () {
|
2346
|
-
var $punctuationEl = document.createElement('span');
|
2347
|
-
$punctuationEl.classList.add('govuk-visually-hidden', this.sectionHeadingDividerClass);
|
2348
|
-
$punctuationEl.innerHTML = ', ';
|
2349
|
-
return $punctuationEl
|
2350
|
-
};
|
2351
|
-
|
2352
|
-
/**
|
2353
|
-
* Accordion config
|
2354
|
-
*
|
2355
|
-
* @typedef {object} AccordionConfig
|
2356
|
-
* @property {AccordionTranslations} [i18n = ACCORDION_TRANSLATIONS] - See constant {@link ACCORDION_TRANSLATIONS}
|
2357
|
-
* @property {boolean} [rememberExpanded] - Whether the expanded and collapsed
|
2358
|
-
* state of each section is remembered and restored when navigating.
|
2359
|
-
*/
|
2360
|
-
|
2361
|
-
/**
|
2362
|
-
* Accordion translations
|
2363
|
-
*
|
2364
|
-
* @typedef {object} AccordionTranslations
|
2365
|
-
*
|
2366
|
-
* Messages used by the component for the labels of its buttons. This includes
|
2367
|
-
* the visible text shown on screen, and text to help assistive technology users
|
2368
|
-
* for the buttons toggling each section.
|
2369
|
-
* @property {string} [hideAllSections] - The text content for the 'Hide all
|
2370
|
-
* sections' button, used when at least one section is expanded.
|
2371
|
-
* @property {string} [hideSection] - The text content for the 'Hide'
|
2372
|
-
* button, used when a section is expanded.
|
2373
|
-
* @property {string} [hideSectionAriaLabel] - The text content appended to the
|
2374
|
-
* 'Hide' button's accessible name when a section is expanded.
|
2375
|
-
* @property {string} [showAllSections] - The text content for the 'Show all
|
2376
|
-
* sections' button, used when all sections are collapsed.
|
2377
|
-
* @property {string} [showSection] - The text content for the 'Show'
|
2378
|
-
* button, used when a section is collapsed.
|
2379
|
-
* @property {string} [showSectionAriaLabel] - The text content appended to the
|
2380
|
-
* 'Show' button's accessible name when a section is expanded.
|
2381
|
-
*/
|
2382
|
-
|
2383
|
-
return Accordion;
|
2384
|
-
|
2385
|
-
})));
|
2386
|
-
//# sourceMappingURL=accordion.js.map
|