govuk_publishing_components 32.1.0 → 35.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +1 -0
- data/app/assets/config/govuk_publishing_components_manifest.js +75 -1
- data/app/assets/images/govuk_publishing_components/icon-search.svg +3 -0
- data/app/assets/images/govuk_publishing_components/youtube-play-icon.png +0 -0
- data/app/assets/images/govuk_publishing_components/youtube-play-icon.svg +4 -0
- data/app/assets/javascripts/component_guide/accessibility-test.js +0 -1
- data/app/assets/javascripts/govuk_publishing_components/analytics/auto-scroll-tracker.js +2 -1
- data/app/assets/javascripts/govuk_publishing_components/analytics/linked-domains.js +135 -0
- data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-auto-tracker.js +49 -0
- data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-core.js +341 -27
- data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-ecommerce-tracker.js +17 -92
- data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-event-tracker.js +11 -23
- data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-form-tracker.js +121 -0
- data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-link-tracker.js +86 -305
- data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-page-views.js +13 -6
- data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-schemas.js +31 -1
- data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-smart-answer-results-tracker.js +57 -0
- data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-specialist-link-tracker.js +131 -0
- data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/init-ga4.js +9 -4
- data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/pii-remover.js +4 -2
- data/app/assets/javascripts/govuk_publishing_components/analytics-ga4.js +4 -0
- data/app/assets/javascripts/govuk_publishing_components/components/accordion.js +12 -1
- data/app/assets/javascripts/govuk_publishing_components/components/cookie-banner.js +2 -2
- data/app/assets/javascripts/govuk_publishing_components/components/image-card.js +19 -0
- data/app/assets/javascripts/govuk_publishing_components/components/layout-super-navigation-header.js +2 -81
- data/app/assets/javascripts/govuk_publishing_components/components/single-page-notification-button.js +24 -8
- data/app/assets/javascripts/govuk_publishing_components/components/step-by-step-nav.js +23 -1
- data/app/assets/javascripts/govuk_publishing_components/dependencies.js +13 -0
- data/app/assets/javascripts/govuk_publishing_components/lib/govspeak/youtube-link-enhancement.js +3 -2
- data/app/assets/javascripts/govuk_publishing_components/lib/trigger-event.js +1 -0
- data/app/assets/javascripts/govuk_publishing_components/load-analytics.js +116 -0
- data/app/assets/javascripts/govuk_publishing_components/modules.js +7 -2
- data/app/assets/javascripts/govuk_publishing_components/vendor/lux/lux-reporter.js +140 -191
- data/app/assets/stylesheets/govuk_publishing_components/_individual_component_support.scss +10 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_accordion.scss +29 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_action-link.scss +2 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_attachment.scss +2 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_back-link.scss +1 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_big-number.scss +4 -5
- data/app/assets/stylesheets/govuk_publishing_components/components/_breadcrumbs.scss +1 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_button.scss +12 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_cards.scss +20 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_character-count.scss +1 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_checkboxes.scss +1 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_contents-list.scss +21 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_contextual-guidance.scss +2 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_contextual-sidebar.scss +2 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_cookie-banner.scss +7 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_date-input.scss +1 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_details.scss +1 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_devolved-nations.scss +2 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_document-list.scss +8 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_emergency-banner.scss +8 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_error-alert.scss +2 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_error-message.scss +1 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_error-summary.scss +1 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_feedback.scss +17 -19
- data/app/assets/stylesheets/govuk_publishing_components/components/_fieldset.scss +1 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_file-upload.scss +1 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_govspeak-html-publication.scss +10 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_govspeak.scss +85 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_heading.scss +2 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_hint.scss +1 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_image-card.scss +85 -6
- data/app/assets/stylesheets/govuk_publishing_components/components/_input.scss +6 -6
- data/app/assets/stylesheets/govuk_publishing_components/components/_inset-text.scss +1 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_intervention.scss +2 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_inverse-header.scss +2 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_label.scss +1 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_layout-footer.scss +1 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_layout-for-public.scss +2 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_layout-super-navigation-header.scss +253 -483
- data/app/assets/stylesheets/govuk_publishing_components/components/_lead-paragraph.scss +2 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_metadata.scss +2 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_modal-dialogue.scss +2 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_notice.scss +1 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_organisation-logo.scss +2 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_panel.scss +1 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_phase-banner.scss +1 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_previous-and-next-navigation.scss +1 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_print-link.scss +2 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_radio.scss +1 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_related-navigation.scss +2 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_reorderable-list.scss +2 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_search.scss +2 -7
- data/app/assets/stylesheets/govuk_publishing_components/components/_select.scss +1 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_share-links.scss +2 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_show-password.scss +2 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_signup-link.scss +2 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_single-page-notification-button.scss +2 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_skip-link.scss +1 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_step-by-step-nav-header.scss +17 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_step-by-step-nav-related.scss +2 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_step-by-step-nav.scss +8 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_subscription-links.scss +2 -1
- data/app/assets/stylesheets/govuk_publishing_components/components/_success-alert.scss +1 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_summary-list.scss +1 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_table.scss +1 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_tabs.scss +1 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_textarea.scss +17 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_title.scss +12 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_translation-nav.scss +2 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_warning-text.scss +1 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_steps.scss +26 -9
- data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_tables.scss +12 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/helpers/_brand-colours.scss +2 -2
- data/app/assets/stylesheets/govuk_publishing_components/components/helpers/_contents-list-helper.scss +0 -1
- data/app/controllers/govuk_publishing_components/application_controller.rb +0 -13
- data/app/controllers/govuk_publishing_components/audit_controller.rb +1 -1
- data/app/controllers/govuk_publishing_components/component_guide_controller.rb +6 -9
- data/app/models/govuk_publishing_components/audit_applications.rb +10 -19
- data/app/models/govuk_publishing_components/audit_comparer.rb +29 -24
- data/app/models/govuk_publishing_components/audit_components.rb +157 -82
- data/app/models/govuk_publishing_components/component_doc.rb +14 -0
- data/app/models/govuk_publishing_components/component_wrapper_helper_options.rb +15 -0
- data/app/views/govuk_publishing_components/audit/_applications.html.erb +3 -3
- data/app/views/govuk_publishing_components/audit/_component_contents.html.erb +47 -39
- data/app/views/govuk_publishing_components/audit/_components.html.erb +47 -2
- data/app/views/govuk_publishing_components/component_guide/_application_stylesheet.html.erb +0 -3
- data/app/views/govuk_publishing_components/component_guide/index.html.erb +0 -7
- data/app/views/govuk_publishing_components/component_guide/show.html.erb +21 -6
- data/app/views/govuk_publishing_components/components/_accordion.html.erb +30 -36
- data/app/views/govuk_publishing_components/components/_action_link.html.erb +7 -2
- data/app/views/govuk_publishing_components/components/_attachment.html.erb +2 -0
- data/app/views/govuk_publishing_components/components/_attachment_link.html.erb +2 -0
- data/app/views/govuk_publishing_components/components/_back_link.html.erb +2 -0
- data/app/views/govuk_publishing_components/components/_big_number.html.erb +3 -1
- data/app/views/govuk_publishing_components/components/_breadcrumbs.html.erb +8 -2
- data/app/views/govuk_publishing_components/components/_button.html.erb +2 -0
- data/app/views/govuk_publishing_components/components/_cards.html.erb +6 -4
- data/app/views/govuk_publishing_components/components/_character_count.html.erb +2 -0
- data/app/views/govuk_publishing_components/components/_checkboxes.html.erb +6 -2
- data/app/views/govuk_publishing_components/components/_contents_list.html.erb +11 -15
- data/app/views/govuk_publishing_components/components/_contextual_breadcrumbs.html.erb +7 -4
- data/app/views/govuk_publishing_components/components/_contextual_footer.html.erb +2 -0
- data/app/views/govuk_publishing_components/components/_contextual_guidance.html.erb +2 -0
- data/app/views/govuk_publishing_components/components/_contextual_sidebar.html.erb +13 -6
- data/app/views/govuk_publishing_components/components/_cookie_banner.html.erb +12 -6
- data/app/views/govuk_publishing_components/components/_date_input.html.erb +2 -0
- data/app/views/govuk_publishing_components/components/_details.html.erb +5 -1
- data/app/views/govuk_publishing_components/components/_devolved_nations.html.erb +2 -0
- data/app/views/govuk_publishing_components/components/_document_list.html.erb +3 -0
- data/app/views/govuk_publishing_components/components/_emergency_banner.html.erb +2 -0
- data/app/views/govuk_publishing_components/components/_error_alert.html.erb +2 -0
- data/app/views/govuk_publishing_components/components/_error_message.html.erb +4 -1
- data/app/views/govuk_publishing_components/components/_error_summary.html.erb +29 -26
- data/app/views/govuk_publishing_components/components/_feedback.html.erb +2 -0
- data/app/views/govuk_publishing_components/components/_fieldset.html.erb +2 -0
- data/app/views/govuk_publishing_components/components/_file_upload.html.erb +2 -0
- data/app/views/govuk_publishing_components/components/_google_tag_manager_script.html.erb +2 -2
- data/app/views/govuk_publishing_components/components/_govspeak.html.erb +1 -0
- data/app/views/govuk_publishing_components/components/_govspeak_html_publication.html.erb +2 -0
- data/app/views/govuk_publishing_components/components/_heading.html.erb +2 -0
- data/app/views/govuk_publishing_components/components/_hint.html.erb +4 -1
- data/app/views/govuk_publishing_components/components/_image_card.html.erb +17 -12
- data/app/views/govuk_publishing_components/components/_input.html.erb +10 -2
- data/app/views/govuk_publishing_components/components/_inset_text.html.erb +2 -0
- data/app/views/govuk_publishing_components/components/_intervention.html.erb +2 -0
- data/app/views/govuk_publishing_components/components/_inverse_header.html.erb +2 -0
- data/app/views/govuk_publishing_components/components/_label.html.erb +7 -3
- data/app/views/govuk_publishing_components/components/_layout_footer.html.erb +2 -0
- data/app/views/govuk_publishing_components/components/_layout_for_admin.html.erb +8 -5
- data/app/views/govuk_publishing_components/components/_layout_for_public.html.erb +8 -3
- data/app/views/govuk_publishing_components/components/_layout_header.html.erb +2 -0
- data/app/views/govuk_publishing_components/components/_layout_super_navigation_header.html.erb +238 -267
- data/app/views/govuk_publishing_components/components/_lead_paragraph.html.erb +2 -0
- data/app/views/govuk_publishing_components/components/_metadata.html.erb +2 -0
- data/app/views/govuk_publishing_components/components/_modal_dialogue.html.erb +2 -0
- data/app/views/govuk_publishing_components/components/_notice.html.erb +2 -0
- data/app/views/govuk_publishing_components/components/_organisation_logo.html.erb +2 -0
- data/app/views/govuk_publishing_components/components/_panel.html.erb +2 -0
- data/app/views/govuk_publishing_components/components/_phase_banner.html.erb +3 -1
- data/app/views/govuk_publishing_components/components/_previous_and_next_navigation.html.erb +6 -1
- data/app/views/govuk_publishing_components/components/_print_link.html.erb +2 -0
- data/app/views/govuk_publishing_components/components/_radio.html.erb +2 -0
- data/app/views/govuk_publishing_components/components/_related_navigation.html.erb +16 -6
- data/app/views/govuk_publishing_components/components/_reorderable_list.html.erb +2 -0
- data/app/views/govuk_publishing_components/components/_search.html.erb +2 -0
- data/app/views/govuk_publishing_components/components/_select.html.erb +2 -0
- data/app/views/govuk_publishing_components/components/_share_links.html.erb +13 -13
- data/app/views/govuk_publishing_components/components/_show_password.html.erb +2 -0
- data/app/views/govuk_publishing_components/components/_signup_link.html.erb +2 -0
- data/app/views/govuk_publishing_components/components/_single_page_notification_button.html.erb +8 -2
- data/app/views/govuk_publishing_components/components/_skip_link.html.erb +2 -0
- data/app/views/govuk_publishing_components/components/_step_by_step_nav.html.erb +8 -1
- data/app/views/govuk_publishing_components/components/_step_by_step_nav_header.html.erb +12 -2
- data/app/views/govuk_publishing_components/components/_step_by_step_nav_related.html.erb +21 -8
- data/app/views/govuk_publishing_components/components/_subscription_links.html.erb +3 -1
- data/app/views/govuk_publishing_components/components/_success_alert.html.erb +2 -0
- data/app/views/govuk_publishing_components/components/_summary_list.html.erb +2 -0
- data/app/views/govuk_publishing_components/components/_table.html.erb +3 -1
- data/app/views/govuk_publishing_components/components/_tabs.html.erb +22 -2
- data/app/views/govuk_publishing_components/components/_textarea.html.erb +12 -2
- data/app/views/govuk_publishing_components/components/_title.html.erb +2 -0
- data/app/views/govuk_publishing_components/components/_translation_nav.html.erb +2 -0
- data/app/views/govuk_publishing_components/components/_warning_text.html.erb +2 -0
- data/app/views/govuk_publishing_components/components/contextual_sidebar/_ukraine_cta.html.erb +16 -6
- data/app/views/govuk_publishing_components/components/docs/accordion.yml +16 -3
- data/app/views/govuk_publishing_components/components/docs/action_link.yml +1 -0
- data/app/views/govuk_publishing_components/components/docs/breadcrumbs.yml +2 -1
- data/app/views/govuk_publishing_components/components/docs/button.yml +10 -0
- data/app/views/govuk_publishing_components/components/docs/cards.yml +1 -0
- data/app/views/govuk_publishing_components/components/docs/checkboxes.yml +1 -0
- data/app/views/govuk_publishing_components/components/docs/contents_list.yml +1 -12
- data/app/views/govuk_publishing_components/components/docs/contextual_breadcrumbs.yml +13 -0
- data/app/views/govuk_publishing_components/components/docs/contextual_footer.yml +43 -0
- data/app/views/govuk_publishing_components/components/docs/contextual_sidebar.yml +65 -0
- data/app/views/govuk_publishing_components/components/docs/details.yml +17 -0
- data/app/views/govuk_publishing_components/components/docs/document_list.yml +18 -1
- data/app/views/govuk_publishing_components/components/docs/emergency_banner.yml +3 -1
- data/app/views/govuk_publishing_components/components/docs/error_message.yml +13 -0
- data/app/views/govuk_publishing_components/components/docs/govspeak.yml +22 -1
- data/app/views/govuk_publishing_components/components/docs/hint.yml +6 -0
- data/app/views/govuk_publishing_components/components/docs/image_card.yml +24 -1
- data/app/views/govuk_publishing_components/components/docs/input.yml +32 -0
- data/app/views/govuk_publishing_components/components/docs/intervention.yml +2 -1
- data/app/views/govuk_publishing_components/components/docs/label.yml +17 -0
- data/app/views/govuk_publishing_components/components/docs/layout_header.yml +1 -0
- data/app/views/govuk_publishing_components/components/docs/previous_and_next_navigation.yml +2 -0
- data/app/views/govuk_publishing_components/components/docs/related_navigation.yml +47 -0
- data/app/views/govuk_publishing_components/components/docs/share_links.yml +59 -30
- data/app/views/govuk_publishing_components/components/docs/single_page_notification_button.yml +16 -1
- data/app/views/govuk_publishing_components/components/docs/step_by_step_nav.yml +54 -0
- data/app/views/govuk_publishing_components/components/docs/step_by_step_nav_header.yml +6 -0
- data/app/views/govuk_publishing_components/components/docs/step_by_step_nav_related.yml +10 -0
- data/app/views/govuk_publishing_components/components/docs/tabs.yml +15 -0
- data/app/views/govuk_publishing_components/components/docs/textarea.yml +31 -0
- data/app/views/govuk_publishing_components/components/docs/translation_nav.yml +2 -0
- data/app/views/govuk_publishing_components/components/feedback/_problem_form.html.erb +3 -3
- data/app/views/govuk_publishing_components/components/feedback/_survey_signup_form.html.erb +1 -1
- data/app/views/govuk_publishing_components/components/feedback/_yes_no_banner.html.erb +4 -5
- data/app/views/govuk_publishing_components/components/metadata/_sentence.html.erb +4 -2
- data/app/views/govuk_publishing_components/components/related_navigation/_section.html.erb +36 -16
- data/app/views/layouts/govuk_publishing_components/application.html.erb +3 -4
- data/config/locales/ar.yml +14 -14
- data/config/locales/az.yml +15 -14
- data/config/locales/be.yml +14 -14
- data/config/locales/bg.yml +14 -14
- data/config/locales/bn.yml +14 -14
- data/config/locales/cs.yml +14 -14
- data/config/locales/cy.yml +14 -14
- data/config/locales/da.yml +14 -14
- data/config/locales/de.yml +14 -14
- data/config/locales/dr.yml +14 -14
- data/config/locales/el.yml +14 -14
- data/config/locales/en.yml +21 -28
- data/config/locales/es-419.yml +14 -14
- data/config/locales/es.yml +14 -14
- data/config/locales/et.yml +14 -14
- data/config/locales/fa.yml +15 -14
- data/config/locales/fi.yml +14 -14
- data/config/locales/fr.yml +14 -14
- data/config/locales/gd.yml +14 -14
- data/config/locales/gu.yml +14 -14
- data/config/locales/he.yml +14 -14
- data/config/locales/hi.yml +14 -14
- data/config/locales/hr.yml +14 -14
- data/config/locales/hu.yml +14 -14
- data/config/locales/hy.yml +14 -14
- data/config/locales/id.yml +14 -14
- data/config/locales/is.yml +14 -14
- data/config/locales/it.yml +14 -14
- data/config/locales/ja.yml +14 -14
- data/config/locales/ka.yml +14 -14
- data/config/locales/kk.yml +14 -14
- data/config/locales/ko.yml +14 -14
- data/config/locales/lt.yml +14 -14
- data/config/locales/lv.yml +14 -14
- data/config/locales/ms.yml +14 -14
- data/config/locales/mt.yml +14 -14
- data/config/locales/nl.yml +14 -14
- data/config/locales/no.yml +14 -14
- data/config/locales/pa-pk.yml +14 -14
- data/config/locales/pa.yml +14 -14
- data/config/locales/pl.yml +14 -14
- data/config/locales/ps.yml +14 -14
- data/config/locales/pt.yml +14 -14
- data/config/locales/ro.yml +14 -14
- data/config/locales/ru.yml +14 -14
- data/config/locales/si.yml +14 -14
- data/config/locales/sk.yml +14 -14
- data/config/locales/sl.yml +14 -14
- data/config/locales/so.yml +14 -14
- data/config/locales/sq.yml +14 -14
- data/config/locales/sr.yml +14 -14
- data/config/locales/sv.yml +14 -14
- data/config/locales/sw.yml +14 -14
- data/config/locales/ta.yml +14 -14
- data/config/locales/th.yml +14 -14
- data/config/locales/tk.yml +14 -14
- data/config/locales/tr.yml +14 -14
- data/config/locales/uk.yml +14 -14
- data/config/locales/ur.yml +14 -14
- data/config/locales/uz.yml +14 -14
- data/config/locales/vi.yml +14 -14
- data/config/locales/zh-hk.yml +14 -14
- data/config/locales/zh-tw.yml +14 -14
- data/config/locales/zh.yml +14 -14
- data/lib/govuk_publishing_components/app_helpers/asset_helper.rb +86 -0
- data/lib/govuk_publishing_components/config.rb +3 -3
- data/lib/govuk_publishing_components/presenters/accordion_helper.rb +38 -0
- data/lib/govuk_publishing_components/presenters/breadcrumb_selector.rb +3 -2
- data/lib/govuk_publishing_components/presenters/{breadcrumbs.rb → breadcrumbs_helper.rb} +8 -0
- data/lib/govuk_publishing_components/presenters/button_helper.rb +9 -2
- data/lib/govuk_publishing_components/presenters/component_wrapper_helper.rb +95 -0
- data/lib/govuk_publishing_components/presenters/image_card_helper.rb +65 -2
- data/lib/govuk_publishing_components/presenters/page_with_step_by_step_navigation.rb +3 -2
- data/lib/govuk_publishing_components/presenters/related_navigation_helper.rb +16 -7
- data/lib/govuk_publishing_components/presenters/single_page_notification_button_helper.rb +43 -2
- data/lib/govuk_publishing_components/presenters/step_by_step_nav_helper.rb +16 -0
- data/lib/govuk_publishing_components/railtie.rb +7 -0
- data/lib/govuk_publishing_components/version.rb +1 -1
- data/lib/govuk_publishing_components.rb +6 -1
- data/node_modules/axe-core/README.md +1 -1
- data/node_modules/axe-core/axe.d.ts +76 -24
- data/node_modules/axe-core/axe.js +9200 -9059
- data/node_modules/axe-core/axe.min.js +3 -3
- data/node_modules/axe-core/package.json +29 -29
- data/node_modules/axe-core/sri-history.json +20 -0
- data/node_modules/govuk-frontend/README.md +1 -2
- data/node_modules/govuk-frontend/govuk/all.js +4035 -2673
- data/node_modules/govuk-frontend/govuk/all.js.map +1 -0
- data/node_modules/govuk-frontend/govuk/common/closest-attribute-value.js +71 -0
- data/node_modules/govuk-frontend/govuk/common/closest-attribute-value.js.map +1 -0
- data/node_modules/govuk-frontend/govuk/common/index.js +180 -0
- data/node_modules/govuk-frontend/govuk/common/index.js.map +1 -0
- data/node_modules/govuk-frontend/govuk/common/normalise-dataset.js +376 -0
- data/node_modules/govuk-frontend/govuk/common/normalise-dataset.js.map +1 -0
- data/node_modules/govuk-frontend/govuk/common.js +173 -30
- data/node_modules/govuk-frontend/govuk/common.js.map +1 -0
- data/node_modules/govuk-frontend/govuk/components/_all.scss +1 -1
- data/node_modules/govuk-frontend/govuk/components/accordion/_index.scss +23 -4
- data/node_modules/govuk-frontend/govuk/components/accordion/accordion.js +2116 -983
- data/node_modules/govuk-frontend/govuk/components/accordion/accordion.js.map +1 -0
- data/node_modules/govuk-frontend/govuk/components/accordion/fixtures.json +54 -22
- data/node_modules/govuk-frontend/govuk/components/accordion/macro-options.json +36 -0
- data/node_modules/govuk-frontend/govuk/components/accordion/template.njk +8 -2
- data/node_modules/govuk-frontend/govuk/components/back-link/_index.scss +19 -19
- data/node_modules/govuk-frontend/govuk/components/back-link/fixtures.json +12 -12
- data/node_modules/govuk-frontend/govuk/components/breadcrumbs/_index.scss +21 -10
- data/node_modules/govuk-frontend/govuk/components/breadcrumbs/fixtures.json +22 -22
- data/node_modules/govuk-frontend/govuk/components/button/_index.scss +23 -5
- data/node_modules/govuk-frontend/govuk/components/button/button.js +958 -690
- data/node_modules/govuk-frontend/govuk/components/button/button.js.map +1 -0
- data/node_modules/govuk-frontend/govuk/components/button/fixtures.json +85 -66
- data/node_modules/govuk-frontend/govuk/components/button/template.njk +1 -1
- data/node_modules/govuk-frontend/govuk/components/character-count/_index.scss +9 -0
- data/node_modules/govuk-frontend/govuk/components/character-count/character-count.js +2083 -1161
- data/node_modules/govuk-frontend/govuk/components/character-count/character-count.js.map +1 -0
- data/node_modules/govuk-frontend/govuk/components/character-count/fixtures.json +112 -36
- data/node_modules/govuk-frontend/govuk/components/character-count/macro-options.json +42 -0
- data/node_modules/govuk-frontend/govuk/components/character-count/template.njk +27 -3
- data/node_modules/govuk-frontend/govuk/components/checkboxes/checkboxes.js +1155 -1119
- data/node_modules/govuk-frontend/govuk/components/checkboxes/checkboxes.js.map +1 -0
- data/node_modules/govuk-frontend/govuk/components/checkboxes/fixtures.json +96 -93
- data/node_modules/govuk-frontend/govuk/components/cookie-banner/fixtures.json +46 -46
- data/node_modules/govuk-frontend/govuk/components/cookie-banner/template.njk +1 -1
- data/node_modules/govuk-frontend/govuk/components/date-input/fixtures.json +50 -50
- data/node_modules/govuk-frontend/govuk/components/details/details.js +797 -766
- data/node_modules/govuk-frontend/govuk/components/details/details.js.map +1 -0
- data/node_modules/govuk-frontend/govuk/components/details/fixtures.json +20 -20
- data/node_modules/govuk-frontend/govuk/components/error-message/fixtures.json +20 -20
- data/node_modules/govuk-frontend/govuk/components/error-summary/error-summary.js +1089 -814
- data/node_modules/govuk-frontend/govuk/components/error-summary/error-summary.js.map +1 -0
- data/node_modules/govuk-frontend/govuk/components/error-summary/fixtures.json +44 -35
- data/node_modules/govuk-frontend/govuk/components/error-summary/template.njk +25 -21
- data/node_modules/govuk-frontend/govuk/components/fieldset/fixtures.json +51 -39
- data/node_modules/govuk-frontend/govuk/components/file-upload/fixtures.json +26 -26
- data/node_modules/govuk-frontend/govuk/components/footer/_index.scss +1 -1
- data/node_modules/govuk-frontend/govuk/components/footer/fixtures.json +46 -46
- data/node_modules/govuk-frontend/govuk/components/footer/macro-options.json +2 -2
- data/node_modules/govuk-frontend/govuk/components/header/_index.scss +6 -0
- data/node_modules/govuk-frontend/govuk/components/header/fixtures.json +93 -38
- data/node_modules/govuk-frontend/govuk/components/header/header.js +646 -992
- data/node_modules/govuk-frontend/govuk/components/header/header.js.map +1 -0
- data/node_modules/govuk-frontend/govuk/components/header/macro-options.json +8 -2
- data/node_modules/govuk-frontend/govuk/components/header/template.njk +4 -2
- data/node_modules/govuk-frontend/govuk/components/hint/fixtures.json +12 -12
- data/node_modules/govuk-frontend/govuk/components/input/fixtures.json +80 -80
- data/node_modules/govuk-frontend/govuk/components/inset-text/fixtures.json +12 -12
- data/node_modules/govuk-frontend/govuk/components/label/fixtures.json +34 -34
- data/node_modules/govuk-frontend/govuk/components/notification-banner/fixtures.json +56 -46
- data/node_modules/govuk-frontend/govuk/components/notification-banner/notification-banner.js +790 -532
- data/node_modules/govuk-frontend/govuk/components/notification-banner/notification-banner.js.map +1 -0
- data/node_modules/govuk-frontend/govuk/components/notification-banner/template.njk +1 -1
- data/node_modules/govuk-frontend/govuk/components/pagination/_index.scss +10 -7
- data/node_modules/govuk-frontend/govuk/components/pagination/fixtures.json +94 -26
- data/node_modules/govuk-frontend/govuk/components/pagination/template.njk +1 -1
- data/node_modules/govuk-frontend/govuk/components/panel/fixtures.json +18 -18
- data/node_modules/govuk-frontend/govuk/components/phase-banner/fixtures.json +14 -14
- data/node_modules/govuk-frontend/govuk/components/phase-banner/macro-options.json +1 -1
- data/node_modules/govuk-frontend/govuk/components/radios/fixtures.json +94 -91
- data/node_modules/govuk-frontend/govuk/components/radios/radios.js +1110 -1079
- data/node_modules/govuk-frontend/govuk/components/radios/radios.js.map +1 -0
- data/node_modules/govuk-frontend/govuk/components/select/fixtures.json +32 -32
- data/node_modules/govuk-frontend/govuk/components/skip-link/fixtures.json +22 -20
- data/node_modules/govuk-frontend/govuk/components/skip-link/skip-link.js +1017 -1008
- data/node_modules/govuk-frontend/govuk/components/skip-link/skip-link.js.map +1 -0
- data/node_modules/govuk-frontend/govuk/components/summary-list/_index.scss +107 -0
- data/node_modules/govuk-frontend/govuk/components/summary-list/fixtures.json +345 -50
- data/node_modules/govuk-frontend/govuk/components/summary-list/macro-options.json +110 -0
- data/node_modules/govuk-frontend/govuk/components/summary-list/template.njk +72 -28
- data/node_modules/govuk-frontend/govuk/components/table/_index.scss +1 -1
- data/node_modules/govuk-frontend/govuk/components/table/fixtures.json +40 -40
- data/node_modules/govuk-frontend/govuk/components/tabs/fixtures.json +29 -29
- data/node_modules/govuk-frontend/govuk/components/tabs/tabs.js +1389 -1233
- data/node_modules/govuk-frontend/govuk/components/tabs/tabs.js.map +1 -0
- data/node_modules/govuk-frontend/govuk/components/tag/fixtures.json +28 -28
- data/node_modules/govuk-frontend/govuk/components/textarea/fixtures.json +34 -34
- data/node_modules/govuk-frontend/govuk/components/warning-text/fixtures.json +14 -14
- data/node_modules/govuk-frontend/govuk/core/_section-break.scss +1 -1
- data/node_modules/govuk-frontend/govuk/helpers/_colour.scss +2 -2
- data/node_modules/govuk-frontend/govuk/helpers/_focused.scss +5 -0
- data/node_modules/govuk-frontend/govuk/helpers/_links.scss +6 -6
- data/node_modules/govuk-frontend/govuk/i18n.js +389 -0
- data/node_modules/govuk-frontend/govuk/i18n.js.map +1 -0
- data/node_modules/govuk-frontend/govuk/macros/i18n.njk +15 -0
- data/node_modules/govuk-frontend/govuk/settings/_all.scss +1 -0
- data/node_modules/govuk-frontend/govuk/settings/_colours-palette.scss +12 -0
- data/node_modules/govuk-frontend/govuk/settings/_compatibility.scss +26 -0
- data/node_modules/govuk-frontend/govuk/settings/_measurements.scss +5 -5
- data/node_modules/govuk-frontend/govuk/settings/_typography-font.scss +23 -0
- data/node_modules/govuk-frontend/govuk/settings/_typography-responsive.scss +12 -0
- data/node_modules/govuk-frontend/govuk/settings/_warnings.scss +53 -0
- data/node_modules/govuk-frontend/govuk/tools/_compatibility.scss +20 -6
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/DOMTokenList.js +242 -241
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/DOMTokenList.js.map +1 -0
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Date/now.js +22 -0
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Date/now.js.map +1 -0
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Document.js +17 -16
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Document.js.map +1 -0
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/classList.js +547 -546
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/classList.js.map +1 -0
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/closest.js +37 -36
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/closest.js.map +1 -0
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/dataset.js +301 -0
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/dataset.js.map +1 -0
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/matches.js +21 -20
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/matches.js.map +1 -0
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/nextElementSibling.js +198 -197
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/nextElementSibling.js.map +1 -0
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/previousElementSibling.js +198 -197
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/previousElementSibling.js.map +1 -0
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element.js +106 -105
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element.js.map +1 -0
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Event.js +400 -399
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Event.js.map +1 -0
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Function/prototype/bind.js +239 -238
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Function/prototype/bind.js.map +1 -0
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Object/defineProperty.js +72 -71
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Object/defineProperty.js.map +1 -0
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/String/prototype/trim.js +22 -0
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/String/prototype/trim.js.map +1 -0
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Window.js +17 -16
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Window.js.map +1 -0
- data/node_modules/govuk-frontend/govuk-esm/all.mjs +52 -29
- data/node_modules/govuk-frontend/govuk-esm/common/closest-attribute-value.mjs +15 -0
- data/node_modules/govuk-frontend/govuk-esm/common/index.mjs +166 -0
- data/node_modules/govuk-frontend/govuk-esm/common/normalise-dataset.mjs +60 -0
- data/node_modules/govuk-frontend/govuk-esm/common.mjs +6 -28
- data/node_modules/govuk-frontend/govuk-esm/components/accordion/accordion.mjs +238 -85
- data/node_modules/govuk-frontend/govuk-esm/components/button/button.mjs +73 -34
- data/node_modules/govuk-frontend/govuk-esm/components/character-count/character-count.mjs +329 -124
- data/node_modules/govuk-frontend/govuk-esm/components/checkboxes/checkboxes.mjs +32 -20
- data/node_modules/govuk-frontend/govuk-esm/components/details/details.mjs +41 -20
- data/node_modules/govuk-frontend/govuk-esm/components/error-summary/error-summary.mjs +60 -14
- data/node_modules/govuk-frontend/govuk-esm/components/header/header.mjs +9 -2
- data/node_modules/govuk-frontend/govuk-esm/components/notification-banner/notification-banner.mjs +33 -4
- data/node_modules/govuk-frontend/govuk-esm/components/radios/radios.mjs +18 -11
- data/node_modules/govuk-frontend/govuk-esm/components/skip-link/skip-link.mjs +15 -7
- data/node_modules/govuk-frontend/govuk-esm/components/tabs/tabs.mjs +171 -38
- data/node_modules/govuk-frontend/govuk-esm/i18n.mjs +378 -0
- data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Date/now.mjs +13 -0
- data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Element/prototype/dataset.mjs +68 -0
- data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/String/prototype/trim.mjs +13 -0
- data/node_modules/govuk-frontend/govuk-prototype-kit/init.js +7 -0
- data/node_modules/govuk-frontend/govuk-prototype-kit/init.scss +12 -0
- data/node_modules/govuk-frontend/govuk-prototype-kit.config.json +138 -7
- data/node_modules/govuk-frontend/package.json +1 -1
- metadata +70 -19
- data/app/assets/stylesheets/component_guide/print.scss +0 -1
- data/app/assets/stylesheets/govuk_publishing_components/_all_components_print.scss +0 -18
- data/app/assets/stylesheets/govuk_publishing_components/components/print/_accordion.scss +0 -28
- data/app/assets/stylesheets/govuk_publishing_components/components/print/_button.scss +0 -8
- data/app/assets/stylesheets/govuk_publishing_components/components/print/_cards.scss +0 -4
- data/app/assets/stylesheets/govuk_publishing_components/components/print/_contents-list.scss +0 -19
- data/app/assets/stylesheets/govuk_publishing_components/components/print/_emergency-banner.scss +0 -3
- data/app/assets/stylesheets/govuk_publishing_components/components/print/_govspeak-html-publication.scss +0 -5
- data/app/assets/stylesheets/govuk_publishing_components/components/print/_govspeak.scss +0 -80
- data/app/assets/stylesheets/govuk_publishing_components/components/print/_layout-super-navigation-header.scss +0 -3
- data/app/assets/stylesheets/govuk_publishing_components/components/print/_organisation-logo.scss +0 -7
- data/app/assets/stylesheets/govuk_publishing_components/components/print/_step-by-step-nav-header.scss +0 -7
- data/app/assets/stylesheets/govuk_publishing_components/components/print/_step-by-step-nav.scss +0 -116
- data/app/assets/stylesheets/govuk_publishing_components/components/print/_textarea.scss +0 -13
- data/app/assets/stylesheets/govuk_publishing_components/components/print/_title.scss +0 -7
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
//= require ../vendor/polyfills/closest.js
|
|
1
2
|
window.GOVUK = window.GOVUK || {}
|
|
2
3
|
window.GOVUK.analyticsGa4 = window.GOVUK.analyticsGa4 || {};
|
|
3
4
|
|
|
@@ -10,34 +11,23 @@ window.GOVUK.analyticsGa4 = window.GOVUK.analyticsGa4 || {};
|
|
|
10
11
|
var newScript = document.createElement('script')
|
|
11
12
|
newScript.async = true
|
|
12
13
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
window.dataLayer.push({ 'gtm.blocklist': ['customPixels', 'customScripts', 'html', 'nonGoogleScripts'] })
|
|
26
|
-
window.dataLayer.push({ 'gtm.start': new Date().getTime(), event: 'gtm.js' })
|
|
27
|
-
|
|
28
|
-
var auth = window.GOVUK.analyticsGa4.vars.auth || ''
|
|
29
|
-
var preview = window.GOVUK.analyticsGa4.vars.preview || ''
|
|
30
|
-
if (auth) {
|
|
31
|
-
auth = '>m_auth=' + auth
|
|
32
|
-
}
|
|
33
|
-
if (preview) {
|
|
34
|
-
preview = '>m_preview=' + preview + '>m_cookies_win=x'
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
this.googleSrc = 'https://www.googletagmanager.com/gtm.js?id=' + window.GOVUK.analyticsGa4.vars.id + auth + preview
|
|
38
|
-
newScript.src = this.googleSrc
|
|
39
|
-
firstScript.parentNode.insertBefore(newScript, firstScript)
|
|
14
|
+
// initialise GTM
|
|
15
|
+
window.dataLayer = window.dataLayer || []
|
|
16
|
+
window.dataLayer.push({ 'gtm.blocklist': ['customPixels', 'customScripts', 'html', 'nonGoogleScripts'] })
|
|
17
|
+
window.dataLayer.push({ 'gtm.start': new Date().getTime(), event: 'gtm.js' })
|
|
18
|
+
|
|
19
|
+
var auth = window.GOVUK.analyticsGa4.vars.auth || ''
|
|
20
|
+
var preview = window.GOVUK.analyticsGa4.vars.preview || ''
|
|
21
|
+
if (auth) {
|
|
22
|
+
auth = '>m_auth=' + auth
|
|
23
|
+
}
|
|
24
|
+
if (preview) {
|
|
25
|
+
preview = '>m_preview=' + preview + '>m_cookies_win=x'
|
|
40
26
|
}
|
|
27
|
+
|
|
28
|
+
this.googleSrc = 'https://www.googletagmanager.com/gtm.js?id=' + window.GOVUK.analyticsGa4.vars.id + auth + preview
|
|
29
|
+
newScript.src = this.googleSrc
|
|
30
|
+
firstScript.parentNode.insertBefore(newScript, firstScript)
|
|
41
31
|
},
|
|
42
32
|
|
|
43
33
|
sendData: function (data) {
|
|
@@ -47,6 +37,330 @@ window.GOVUK.analyticsGa4 = window.GOVUK.analyticsGa4 || {};
|
|
|
47
37
|
|
|
48
38
|
getGemVersion: function () {
|
|
49
39
|
return window.GOVUK.analyticsGa4.vars.gem_version || 'not found'
|
|
40
|
+
},
|
|
41
|
+
|
|
42
|
+
trackFunctions: {
|
|
43
|
+
|
|
44
|
+
getDomainRegex: function () {
|
|
45
|
+
// This regex matches a protocol and domain name at the start of a string such as https://www.gov.uk, http://gov.uk, //gov.uk
|
|
46
|
+
return /^(http:||https:)?(\/\/)([^\/]*)/ // eslint-disable-line no-useless-escape
|
|
47
|
+
},
|
|
48
|
+
|
|
49
|
+
findTrackingAttributes: function (clicked, trackingTrigger) {
|
|
50
|
+
if (clicked.hasAttribute('[' + trackingTrigger + ']')) {
|
|
51
|
+
return clicked
|
|
52
|
+
} else {
|
|
53
|
+
return clicked.closest('[' + trackingTrigger + ']')
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
|
|
57
|
+
// create an object to split up long URLs and get around the 100 character limit on GTM data
|
|
58
|
+
// this gets reassembled in GA4
|
|
59
|
+
populateLinkPathParts: function (href) {
|
|
60
|
+
var path = ''
|
|
61
|
+
if (this.hrefIsRelative(href) || this.isMailToLink(href)) {
|
|
62
|
+
path = href
|
|
63
|
+
} else {
|
|
64
|
+
// This regex matches a protocol and domain name at the start of a string such as https://www.gov.uk, http://gov.uk, //gov.uk
|
|
65
|
+
path = href.replace(/^(http:||https:)?(\/\/)([^\/]*)/, '') // eslint-disable-line no-useless-escape
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (path === '/' || path.length === 0) {
|
|
69
|
+
return
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return this.splitStringIntoParts(path)
|
|
73
|
+
},
|
|
74
|
+
|
|
75
|
+
splitStringIntoParts: function (string) {
|
|
76
|
+
/*
|
|
77
|
+
This will create an object with 5 keys that are indexes ("1", "2", etc.)
|
|
78
|
+
The values will be each part of the string split every 100 characters, or undefined.
|
|
79
|
+
For example: {"1": "/hello/world/etc...", "2": "/more/path/text...", "3": undefined, "4": undefined, "5": undefined}
|
|
80
|
+
Undefined values are needed to override the persistent object in GTM so that any values from old pushes are overwritten.
|
|
81
|
+
*/
|
|
82
|
+
var parts = string.match(/.{1,100}/g)
|
|
83
|
+
var obj = {}
|
|
84
|
+
for (var i = 0; i < 5; i++) {
|
|
85
|
+
obj[(i + 1).toString()] = parts[i]
|
|
86
|
+
}
|
|
87
|
+
return obj
|
|
88
|
+
},
|
|
89
|
+
|
|
90
|
+
hrefIsRelative: function (href) {
|
|
91
|
+
// Checks that a href is relative by the lack of http:, https:// or // at the start of the href.
|
|
92
|
+
var domain = this.getDomainRegex().exec(href)
|
|
93
|
+
|
|
94
|
+
return !domain
|
|
95
|
+
},
|
|
96
|
+
|
|
97
|
+
isMailToLink: function (href) {
|
|
98
|
+
return href.substring(0, 7) === 'mailto:'
|
|
99
|
+
},
|
|
100
|
+
|
|
101
|
+
getClickType: function (event) {
|
|
102
|
+
switch (event.type) {
|
|
103
|
+
case 'click':
|
|
104
|
+
if (event.ctrlKey) {
|
|
105
|
+
return 'ctrl click'
|
|
106
|
+
} else if (event.metaKey) {
|
|
107
|
+
return 'command/win click'
|
|
108
|
+
} else if (event.shiftKey) {
|
|
109
|
+
return 'shift click'
|
|
110
|
+
} else {
|
|
111
|
+
return 'primary click'
|
|
112
|
+
}
|
|
113
|
+
case 'mousedown':
|
|
114
|
+
return 'middle click'
|
|
115
|
+
case 'contextmenu':
|
|
116
|
+
return 'secondary click'
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
|
|
120
|
+
isInternalLink: function (href) {
|
|
121
|
+
var internalDomains = window.GOVUK.analyticsGa4.vars.internalDomains
|
|
122
|
+
if (this.hrefIsRelative(href)) {
|
|
123
|
+
return true
|
|
124
|
+
}
|
|
125
|
+
var result = false
|
|
126
|
+
for (var i = 0; i < internalDomains.length; i++) {
|
|
127
|
+
var internalDomain = internalDomains[i]
|
|
128
|
+
if (this.hrefPointsToDomain(href, internalDomain)) {
|
|
129
|
+
result = true
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return result
|
|
133
|
+
},
|
|
134
|
+
|
|
135
|
+
isExternalLink: function (href) {
|
|
136
|
+
return !this.isInternalLink(href)
|
|
137
|
+
},
|
|
138
|
+
|
|
139
|
+
hrefPointsToDomain: function (href, domain) {
|
|
140
|
+
/* Add a trailing slash to prevent an edge case such
|
|
141
|
+
as the href www.gov.uk.domain.co.uk being detected as an internal link,
|
|
142
|
+
if we were checking for 'www.gov.uk' instead of 'www.gov.uk/' */
|
|
143
|
+
if (domain.substring(domain.length) !== '/') {
|
|
144
|
+
domain = domain + '/'
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/* If the href doesn't end in a slash, we add one.
|
|
148
|
+
This fixes an edge case where the <a href> is exactly `https://www.gov.uk`
|
|
149
|
+
but these checks would only look for `https://www.gov.uk/` */
|
|
150
|
+
if (href.substring(href.length) !== '/') {
|
|
151
|
+
href = href + '/'
|
|
152
|
+
}
|
|
153
|
+
// matches the domain preceded by https:// http:// or //
|
|
154
|
+
var regex = new RegExp('^((http)*(s)*(:)*//)(' + domain + ')', 'g')
|
|
155
|
+
return regex.test(href)
|
|
156
|
+
},
|
|
157
|
+
|
|
158
|
+
removeLinesAndExtraSpaces: function (text) {
|
|
159
|
+
text = text.trim()
|
|
160
|
+
text = text.replace(/(\r\n|\n|\r)/gm, ' ') // Replace line breaks with 1 space
|
|
161
|
+
text = text.replace(/\s+/g, ' ') // Replace instances of 2+ spaces with 1 space
|
|
162
|
+
return text
|
|
163
|
+
},
|
|
164
|
+
|
|
165
|
+
removeCrossDomainParams: function (href) {
|
|
166
|
+
if (href.indexOf('_ga') !== -1 || href.indexOf('_gl') !== -1) {
|
|
167
|
+
// _ga & _gl are values needed for cross domain tracking, but we don't want them included in our click tracking.
|
|
168
|
+
href = href.replaceAll(/_g[al]=([^&]*)/g, '')
|
|
169
|
+
|
|
170
|
+
// The following code cleans up inconsistencies such as gov.uk/&&, gov.uk/?&hello=world, gov.uk/?, and gov.uk/&.
|
|
171
|
+
href = href.replaceAll(/(&&)+/g, '&')
|
|
172
|
+
href = href.replace('?&', '?')
|
|
173
|
+
if (this.stringEndsWith(href, '?') || this.stringEndsWith(href, '&')) {
|
|
174
|
+
href = href.substring(0, href.length - 1)
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
return href
|
|
178
|
+
},
|
|
179
|
+
|
|
180
|
+
stringStartsWith: function (string, stringToFind) {
|
|
181
|
+
return string.substring(0, stringToFind.length) === stringToFind
|
|
182
|
+
},
|
|
183
|
+
|
|
184
|
+
stringEndsWith: function (string, stringToFind) {
|
|
185
|
+
return string.substring(string.length - stringToFind.length, string.length) === stringToFind
|
|
186
|
+
},
|
|
187
|
+
|
|
188
|
+
populateLinkDomain: function (href) {
|
|
189
|
+
// We always want mailto links to have an undefined link_domain
|
|
190
|
+
if (this.isMailToLink(href)) {
|
|
191
|
+
return undefined
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
if (this.hrefIsRelative(href)) {
|
|
195
|
+
return this.getProtocol() + '//' + this.getHostname()
|
|
196
|
+
} else {
|
|
197
|
+
var domain = this.getDomainRegex().exec(href)
|
|
198
|
+
if (domain) {
|
|
199
|
+
return domain[0]
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
},
|
|
203
|
+
|
|
204
|
+
getProtocol: function () {
|
|
205
|
+
return window.location.protocol
|
|
206
|
+
},
|
|
207
|
+
|
|
208
|
+
getHostname: function () {
|
|
209
|
+
return window.location.hostname
|
|
210
|
+
},
|
|
211
|
+
|
|
212
|
+
appendDomainsWithoutWWW: function (domainsArrays) {
|
|
213
|
+
// Add domains with www. removed, in case site hrefs are marked up without www. included.
|
|
214
|
+
for (var i = 0; i < domainsArrays.length; i++) {
|
|
215
|
+
var domain = domainsArrays[i]
|
|
216
|
+
if (this.stringStartsWith(domain, 'www.')) {
|
|
217
|
+
var domainWithoutWww = domain.replace('www.', '')
|
|
218
|
+
domainsArrays.push(domainWithoutWww)
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
},
|
|
222
|
+
|
|
223
|
+
// The index and index_total properties are usually set by the application's templating engine however in instances where this isn't possible,
|
|
224
|
+
// we use JavaScript to calculate the index_total and append it to data-ga4-link and add an index property to each link
|
|
225
|
+
setIndexes: function (module) {
|
|
226
|
+
var links = module.querySelectorAll('a')
|
|
227
|
+
var totalLinks = 0
|
|
228
|
+
for (var i = 0; i < links.length; i++) {
|
|
229
|
+
var link = links[i]
|
|
230
|
+
// Only index links that are not search results
|
|
231
|
+
if (!link.getAttribute('data-ga4-ecommerce-path')) {
|
|
232
|
+
totalLinks++
|
|
233
|
+
link.setAttribute('data-ga4-index', totalLinks)
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
var ga4LinkData = JSON.parse(module.getAttribute('data-ga4-link'))
|
|
238
|
+
ga4LinkData.index_total = totalLinks
|
|
239
|
+
module.setAttribute('data-ga4-link', JSON.stringify(ga4LinkData))
|
|
240
|
+
},
|
|
241
|
+
|
|
242
|
+
// index is given as a string of the form 1.2.3 or 1.2
|
|
243
|
+
// split this into named sub-parameters
|
|
244
|
+
createIndexObject: function (index) {
|
|
245
|
+
if (typeof index === 'undefined') {
|
|
246
|
+
return undefined
|
|
247
|
+
}
|
|
248
|
+
if (typeof index === 'object') {
|
|
249
|
+
return index
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
index = index.toString().split('.')
|
|
253
|
+
// this will soon include 'index_section_count'
|
|
254
|
+
// number of sections overall in the thing being tracked (but not yet in use)
|
|
255
|
+
switch (index.length) {
|
|
256
|
+
case 1:
|
|
257
|
+
return {
|
|
258
|
+
index_section: parseInt(index[0])
|
|
259
|
+
}
|
|
260
|
+
case 2:
|
|
261
|
+
return {
|
|
262
|
+
index_section: parseInt(index[0]),
|
|
263
|
+
index_link: parseInt(index[1])
|
|
264
|
+
}
|
|
265
|
+
case 3:
|
|
266
|
+
return {
|
|
267
|
+
index_section: parseInt(index[1]),
|
|
268
|
+
index_link: parseInt(index[2])
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
},
|
|
273
|
+
|
|
274
|
+
ecommerceHelperFunctions: {
|
|
275
|
+
clearEcommerceObject: function () {
|
|
276
|
+
window.GOVUK.analyticsGa4.core.sendData({ search_results: { ecommerce: null } })
|
|
277
|
+
},
|
|
278
|
+
|
|
279
|
+
getIndex: function (element, startPosition) {
|
|
280
|
+
var index = element.getAttribute('data-ecommerce-index')
|
|
281
|
+
|
|
282
|
+
if (!index) {
|
|
283
|
+
return null
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
return parseInt(index) + startPosition - 1
|
|
287
|
+
},
|
|
288
|
+
|
|
289
|
+
getResultCount: function (element, id) {
|
|
290
|
+
var resultCount = element.querySelector('#' + id)
|
|
291
|
+
|
|
292
|
+
if (!resultCount) {
|
|
293
|
+
return null
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
// In order to extract the number of results from resultCount (which is a string at this point (e.g. '12,345 results')), we remove the comma and
|
|
297
|
+
// split string at the space character so it can be parsed as an integer
|
|
298
|
+
resultCount = resultCount.textContent.replace(',', '')
|
|
299
|
+
resultCount = resultCount.split(' ')[0]
|
|
300
|
+
|
|
301
|
+
return parseInt(resultCount)
|
|
302
|
+
},
|
|
303
|
+
|
|
304
|
+
populateEcommerceSchema: function (data) {
|
|
305
|
+
var element = data.element
|
|
306
|
+
var resultsId = data.resultsId
|
|
307
|
+
var isClickEvent = data.event !== undefined
|
|
308
|
+
var isSearchResult = element.getAttribute('data-search-query')
|
|
309
|
+
|
|
310
|
+
var ecommerceSchema = new window.GOVUK.analyticsGa4.Schemas().ecommerceSchema()
|
|
311
|
+
var PIIRemover = new window.GOVUK.analyticsGa4.PIIRemover()
|
|
312
|
+
var DEFAULT_LIST_TITLE = 'Smart answer results'
|
|
313
|
+
|
|
314
|
+
if (isSearchResult) {
|
|
315
|
+
// Limiting to 100 characters to avoid noise from extra long search queries and to stop the size of the payload going over 8k limit.
|
|
316
|
+
var searchQuery = PIIRemover.stripPII(element.getAttribute('data-search-query')).substring(0, 100).toLowerCase()
|
|
317
|
+
var variant = element.getAttribute('data-ecommerce-variant')
|
|
318
|
+
DEFAULT_LIST_TITLE = 'Site search results'
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
var items = element.querySelectorAll('[data-ga4-ecommerce-path]')
|
|
322
|
+
var listTitle = element.getAttribute('data-list-title') || DEFAULT_LIST_TITLE
|
|
323
|
+
var startPosition = parseInt(element.getAttribute('data-ecommerce-start-index'), 10)
|
|
324
|
+
|
|
325
|
+
ecommerceSchema.event = 'search_results'
|
|
326
|
+
ecommerceSchema.search_results.event_name = isClickEvent ? 'select_item' : 'view_item_list'
|
|
327
|
+
ecommerceSchema.search_results.results = window.GOVUK.analyticsGa4.core.ecommerceHelperFunctions.getResultCount(element, resultsId)
|
|
328
|
+
ecommerceSchema.search_results.term = searchQuery || undefined
|
|
329
|
+
ecommerceSchema.search_results.sort = variant || undefined
|
|
330
|
+
|
|
331
|
+
if (isClickEvent) {
|
|
332
|
+
var target = data.event.target
|
|
333
|
+
ecommerceSchema.search_results.ecommerce.items.push({
|
|
334
|
+
item_id: target.getAttribute('data-ga4-ecommerce-path'),
|
|
335
|
+
item_name: target.textContent,
|
|
336
|
+
item_list_name: listTitle,
|
|
337
|
+
index: window.GOVUK.analyticsGa4.core.ecommerceHelperFunctions.getIndex(target, startPosition)
|
|
338
|
+
})
|
|
339
|
+
|
|
340
|
+
ecommerceSchema.event_data = {
|
|
341
|
+
external: window.GOVUK.analyticsGa4.core.trackFunctions.isExternalLink(target.getAttribute('data-ga4-ecommerce-path')) ? 'true' : 'false'
|
|
342
|
+
}
|
|
343
|
+
} else {
|
|
344
|
+
for (var i = 0; i < items.length; i++) {
|
|
345
|
+
var item = items[i]
|
|
346
|
+
var path = item.getAttribute('data-ga4-ecommerce-path')
|
|
347
|
+
|
|
348
|
+
// If the element does not have a data-ecommerce-index attribute, we set one so that we can use it later when setting the index property
|
|
349
|
+
// on the ecommerce object.
|
|
350
|
+
if (!item.getAttribute('data-ecommerce-index')) {
|
|
351
|
+
item.setAttribute('data-ecommerce-index', i + 1)
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
ecommerceSchema.search_results.ecommerce.items.push({
|
|
355
|
+
item_id: path,
|
|
356
|
+
item_list_name: listTitle,
|
|
357
|
+
index: window.GOVUK.analyticsGa4.core.ecommerceHelperFunctions.getIndex(item, startPosition)
|
|
358
|
+
})
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
return ecommerceSchema
|
|
363
|
+
}
|
|
50
364
|
}
|
|
51
365
|
}
|
|
52
366
|
|
data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-ecommerce-tracker.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
//= require govuk/vendor/polyfills/Element/prototype/closest.js
|
|
2
2
|
;(function (global) {
|
|
3
3
|
'use strict'
|
|
4
4
|
|
|
@@ -6,9 +6,6 @@
|
|
|
6
6
|
GOVUK.analyticsGa4 = GOVUK.analyticsGa4 || {}
|
|
7
7
|
|
|
8
8
|
GOVUK.analyticsGa4.Ga4EcommerceTracker = {
|
|
9
|
-
PIIRemover: new GOVUK.analyticsGa4.PIIRemover(),
|
|
10
|
-
DEFAULT_LIST_TITLE: 'Site search results',
|
|
11
|
-
|
|
12
9
|
init: function (referrer) {
|
|
13
10
|
if (window.dataLayer) {
|
|
14
11
|
/* The referrer parameter is only passed to the init() function as a result of an AJAX request
|
|
@@ -37,7 +34,7 @@
|
|
|
37
34
|
}
|
|
38
35
|
|
|
39
36
|
for (var i = 0; i < this.searchResultsBlocks.length; i++) {
|
|
40
|
-
this.
|
|
37
|
+
this.trackResults(this.searchResultsBlocks[i])
|
|
41
38
|
|
|
42
39
|
if (isNewPageLoad) {
|
|
43
40
|
this.searchResultsBlocks[i].addEventListener('click', this.handleClick.bind(this))
|
|
@@ -46,101 +43,29 @@
|
|
|
46
43
|
}
|
|
47
44
|
},
|
|
48
45
|
|
|
49
|
-
|
|
50
|
-
var
|
|
46
|
+
trackResults: function (searchResultsBlock) {
|
|
47
|
+
var ecommerceSchema = GOVUK.analyticsGa4.core.ecommerceHelperFunctions.populateEcommerceSchema({
|
|
48
|
+
element: searchResultsBlock,
|
|
49
|
+
resultsId: 'js-result-count'
|
|
50
|
+
})
|
|
51
51
|
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
GOVUK.analyticsGa4.core.ecommerceHelperFunctions.clearEcommerceObject()
|
|
53
|
+
GOVUK.analyticsGa4.core.sendData(ecommerceSchema)
|
|
54
54
|
},
|
|
55
55
|
|
|
56
56
|
handleClick: function (event) {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
if (isSearchResult) {
|
|
61
|
-
var searchResult = event.target
|
|
62
|
-
var schema = this.populateEcommerceSchema(searchResultsBlock, true, searchResult)
|
|
57
|
+
if (event.target.getAttribute('data-ga4-ecommerce-path')) {
|
|
58
|
+
var searchResultsBlock = event.target.closest('[data-ga4-ecommerce]')
|
|
63
59
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
populateEcommerceSchema: function (searchResultsBlock, searchResultClicked, searchResult) {
|
|
70
|
-
// Limiting to 100 characters to avoid noise from extra long search queries and to stop the size of the payload going over 8k limit.
|
|
71
|
-
var searchQuery = this.PIIRemover.stripPII(searchResultsBlock.getAttribute('data-search-query')).substring(0, 100).toLowerCase()
|
|
72
|
-
var variant = searchResultsBlock.getAttribute('data-ecommerce-variant') || undefined
|
|
73
|
-
var ecommerceRows = searchResultsBlock.querySelectorAll('[data-ecommerce-row]')
|
|
74
|
-
var listTitle = searchResultsBlock.getAttribute('data-list-title') || this.DEFAULT_LIST_TITLE
|
|
75
|
-
var startPosition = parseInt(searchResultsBlock.getAttribute('data-ecommerce-start-index'), 10)
|
|
76
|
-
|
|
77
|
-
var ecommerceObject = {
|
|
78
|
-
event: 'search_results',
|
|
79
|
-
search_results: {
|
|
80
|
-
event_name: searchResultClicked && searchResult ? 'select_item' : 'view_item_list',
|
|
81
|
-
term: searchQuery,
|
|
82
|
-
sort: variant,
|
|
83
|
-
results: this.getResultsCount(searchResultsBlock),
|
|
84
|
-
ecommerce: {
|
|
85
|
-
items: []
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
// Populate items array
|
|
91
|
-
if (searchResultClicked && searchResult) {
|
|
92
|
-
ecommerceObject.search_results.ecommerce.items.push({
|
|
93
|
-
item_id: searchResult.getAttribute('data-ecommerce-path'),
|
|
94
|
-
item_name: searchResult.textContent,
|
|
95
|
-
item_list_name: listTitle,
|
|
96
|
-
index: this.getIndex(searchResult, startPosition)
|
|
60
|
+
var ecommerceSchema = GOVUK.analyticsGa4.core.ecommerceHelperFunctions.populateEcommerceSchema({
|
|
61
|
+
element: searchResultsBlock,
|
|
62
|
+
resultsId: 'js-result-count',
|
|
63
|
+
event: event
|
|
97
64
|
})
|
|
98
65
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
}
|
|
102
|
-
} else {
|
|
103
|
-
for (var i = 0; i < ecommerceRows.length; i++) {
|
|
104
|
-
var ecommerceRow = ecommerceRows[i]
|
|
105
|
-
var path = ecommerceRow.getAttribute('data-ecommerce-path')
|
|
106
|
-
|
|
107
|
-
/* If the element does not have a data-ecommerce-index attribute, we set one so that we can use it later when setting the index property
|
|
108
|
-
on the ecommerce object. This for loop will always run on page load and so data-ecommerce-index will be available when we use it in the
|
|
109
|
-
initial if block above that checks if a search result has been clicked. */
|
|
110
|
-
if (!ecommerceRow.getAttribute('data-ecommerce-index')) {
|
|
111
|
-
ecommerceRow.setAttribute('data-ecommerce-index', i + 1)
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
ecommerceObject.search_results.ecommerce.items.push({
|
|
115
|
-
item_id: path,
|
|
116
|
-
item_list_name: listTitle,
|
|
117
|
-
index: this.getIndex(ecommerceRow, startPosition)
|
|
118
|
-
})
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
return ecommerceObject
|
|
123
|
-
},
|
|
124
|
-
|
|
125
|
-
getIndex: function (element, startPosition) {
|
|
126
|
-
return parseInt(element.getAttribute('data-ecommerce-index')) + startPosition - 1
|
|
127
|
-
},
|
|
128
|
-
|
|
129
|
-
clearPreviousEcommerceObject: function () {
|
|
130
|
-
window.dataLayer.push({ search_results: { ecommerce: null } })
|
|
131
|
-
},
|
|
132
|
-
|
|
133
|
-
getResultsCount: function (searchResultsBlock) {
|
|
134
|
-
// This returns a string e.g. '12,345 results'. Therefore to extract the number, we need to remove the comma and split the string at the space
|
|
135
|
-
var resultsCount = searchResultsBlock.querySelector('#js-result-count')
|
|
136
|
-
|
|
137
|
-
if (!resultsCount) {
|
|
138
|
-
return null
|
|
66
|
+
GOVUK.analyticsGa4.core.ecommerceHelperFunctions.clearEcommerceObject()
|
|
67
|
+
GOVUK.analyticsGa4.core.sendData(ecommerceSchema)
|
|
139
68
|
}
|
|
140
|
-
|
|
141
|
-
resultsCount = resultsCount.textContent.replace(',', '')
|
|
142
|
-
resultsCount = resultsCount.split(' ')[0]
|
|
143
|
-
return parseInt(resultsCount)
|
|
144
69
|
}
|
|
145
70
|
}
|
|
146
71
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
//= require ../vendor/polyfills/closest.js
|
|
2
2
|
window.GOVUK = window.GOVUK || {}
|
|
3
3
|
window.GOVUK.Modules = window.GOVUK.Modules || {};
|
|
4
4
|
|
|
@@ -7,7 +7,7 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
|
|
|
7
7
|
|
|
8
8
|
function Ga4EventTracker (module) {
|
|
9
9
|
this.module = module
|
|
10
|
-
this.trackingTrigger = 'data-ga4' // elements with this attribute get tracked
|
|
10
|
+
this.trackingTrigger = 'data-ga4-event' // elements with this attribute get tracked
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
Ga4EventTracker.prototype.init = function () {
|
|
@@ -29,10 +29,8 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
Ga4EventTracker.prototype.trackClick = function (event) {
|
|
32
|
-
var target =
|
|
32
|
+
var target = window.GOVUK.analyticsGa4.core.trackFunctions.findTrackingAttributes(event.target, this.trackingTrigger)
|
|
33
33
|
if (target) {
|
|
34
|
-
var schema = new window.GOVUK.analyticsGa4.Schemas().eventSchema()
|
|
35
|
-
|
|
36
34
|
try {
|
|
37
35
|
var data = target.getAttribute(this.trackingTrigger)
|
|
38
36
|
data = JSON.parse(data)
|
|
@@ -42,17 +40,15 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
|
|
|
42
40
|
return
|
|
43
41
|
}
|
|
44
42
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
}
|
|
43
|
+
var text = data.text || event.target.textContent
|
|
44
|
+
data.text = window.GOVUK.analyticsGa4.core.trackFunctions.removeLinesAndExtraSpaces(text)
|
|
45
|
+
data.index = window.GOVUK.analyticsGa4.core.trackFunctions.createIndexObject(data.index)
|
|
46
|
+
|
|
47
|
+
var schemas = new window.GOVUK.analyticsGa4.Schemas()
|
|
48
|
+
var schema = schemas.mergeProperties(data, 'event_data')
|
|
53
49
|
|
|
54
|
-
/* Ensure it only tracks aria-expanded in an
|
|
55
|
-
if (target.closest('
|
|
50
|
+
/* Ensure it only tracks aria-expanded in an element with data-ga4-expandable on it. */
|
|
51
|
+
if (target.closest('[data-ga4-expandable]')) {
|
|
56
52
|
var ariaExpanded = this.getClosestAttribute(target, 'aria-expanded')
|
|
57
53
|
}
|
|
58
54
|
|
|
@@ -88,14 +84,6 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
|
|
|
88
84
|
}
|
|
89
85
|
}
|
|
90
86
|
|
|
91
|
-
Ga4EventTracker.prototype.findTrackingAttributes = function (clicked) {
|
|
92
|
-
if (clicked.hasAttribute('[' + this.trackingTrigger + ']')) {
|
|
93
|
-
return clicked
|
|
94
|
-
} else {
|
|
95
|
-
return clicked.closest('[' + this.trackingTrigger + ']')
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
87
|
// check if an attribute exists or contains the attribute
|
|
100
88
|
Ga4EventTracker.prototype.getClosestAttribute = function (clicked, attribute) {
|
|
101
89
|
var isAttributeOnElement = clicked.getAttribute(attribute)
|