diff --git a/assets/js/main.js b/assets/js/main.js index 206da8ebe5b..a68e241924f 100644 --- a/assets/js/main.js +++ b/assets/js/main.js @@ -1,5 +1,44 @@ $(document).ready(function () { + //////////////////////////////////////// + // Shared helpers + //////////////////////////////////////// + + const trackSubscribeClick = function (event) { + if ( typeof gtag !== 'function' ) { + return; + } + + const subscribe_target = event.currentTarget; + + gtag('event', 'click_subscribe', { + page: window.location.pathname, + place: subscribe_target.dataset.subscribeClick, + }); + }; + + const queueSubscribeModal = function (subscribe_trigger) { + const parent_modal_selector = subscribe_trigger.data('subscribe-parent-modal'); + const subscribe_modal = $('#subscribeModal'); + + if ( !parent_modal_selector || !subscribe_modal.length ) { + return; + } + + const parent_modal = $(parent_modal_selector); + + if ( !parent_modal.length ) { + subscribe_modal.modal('show'); + return; + } + + parent_modal.one('hidden.bs.modal', function () { + subscribe_modal.modal('show'); + }); + + parent_modal.modal('hide'); + }; + //////////////////////////////////////// // Mutation observer - watch for RTL //////////////////////////////////////// @@ -8,9 +47,10 @@ $(document).ready(function () { const observer = new MutationObserver( function(mutations) { mutations.forEach( function() { - var classes = target.getAttribute('class'); - var single_class = 'translated-rtl'; - if (classes.includes(single_class)) { + const classes = target.getAttribute('class') || ''; + const single_class = 'translated-rtl'; + + if ( classes.includes(single_class) ) { target.setAttribute('dir', 'rtl'); } else { target.setAttribute('dir', 'ltr'); @@ -22,7 +62,7 @@ $(document).ready(function () { attributes: true, attributeFilter: ['class'] } - + observer.observe(target, config); //////////////////////////////////////// @@ -61,9 +101,24 @@ $(document).ready(function () { }); //////////////////////////////////////// - // Email Subscription Modal + // Subscribe links and modal //////////////////////////////////////// + const subscribe_triggers = $('[data-subscribe-click]'); + + if ( subscribe_triggers.length ) { + subscribe_triggers.on('click', function (event) { + const subscribe_trigger = $(this); + + trackSubscribeClick(event); + + if ( subscribe_trigger.data('subscribe-parent-modal') ) { + event.preventDefault(); + queueSubscribeModal(subscribe_trigger); + } + }); + } + const subscribe_modal = $('#subscribeModal'); if ( subscribe_modal.length ) { @@ -80,19 +135,23 @@ $(document).ready(function () { const subscribe_iframe = $('
+Email us with thoughts, questions, or concerns at ehdp@health.nyc.gov, or sign up for our email list. We won't share your email address. [Questions about the data? Visit our Github repo for info or to file an issue](https://www.github.com/nychealth/EH-dataportal). diff --git a/content/about/redesign/index.md b/content/about/redesign/index.md index 5c637476a89..31f24dfef40 100644 --- a/content/about/redesign/index.md +++ b/content/about/redesign/index.md @@ -88,7 +88,7 @@ If you’re curious about the nuts and bolts, you can find out more in our [site We built this site for you, so please help us continue developing it: -* [Sign up for our email list](https://docs.google.com/forms/d/e/1FAIpQLSfUg3JE5ODNc6aqBPJwM8mZ80TYtK6ISw-OM7PBwKuoN3M--g/viewform?embedded=true) – we'll send occasional requests for users to participate in user testing or co-design work +* Sign up for our email list – we'll send occasional requests for users to participate in user testing or co-design work * Visit our Github repositories ([site](https://github.com/nychealth/EH-dataportal), [data](https://github.com/nychealth/EHDP-data)) and explore the code, file an issue, or suggest features * Email us with any questions you have at ehdp@health.nyc.gov – we're here to help. diff --git a/content/about/roadmap/index.md b/content/about/roadmap/index.md index f17467a4123..c2865896f19 100644 --- a/content/about/roadmap/index.md +++ b/content/about/roadmap/index.md @@ -40,7 +40,7 @@ Open Tech Strategies prepared a report with recommendations for our strategy and We built this site for you, so please help us continue developing it: -- [Sign up for our email list](https://docs.google.com/forms/d/e/1FAIpQLSfUg3JE5ODNc6aqBPJwM8mZ80TYtK6ISw-OM7PBwKuoN3M--g/viewform?embedded=true) – we'll send occasional requests for users to participate in user testing or co-design work +- Sign up for our email list – we'll send occasional requests for users to participate in user testing or co-design work - Visit our Github repositories ([site](https://github.com/nychealth/EH-dataportal), [data](https://github.com/nychealth/EHDP-data)) and explore the code, file an issue, or suggest features - Email us with any questions you have at ehdp@health.nyc.gov – we're here to help. diff --git a/content/about/subscribe.md b/content/about/subscribe.md index d627f37daef..ffa004596f1 100644 --- a/content/about/subscribe.md +++ b/content/about/subscribe.md @@ -12,5 +12,5 @@ Thanks for visiting the Environment and Health Data Portal. We'd like to add you to our email list. We'll email you every few months with site updates, and occasional opportunities to participate in user research. We won't share your email and you can unsubscribe at any time. diff --git a/content/data-stories/redesign/index.md b/content/data-stories/redesign/index.md index ce70b3b9162..c87076b8b03 100644 --- a/content/data-stories/redesign/index.md +++ b/content/data-stories/redesign/index.md @@ -93,7 +93,7 @@ If you’re curious about the nuts and bolts, you can find out more in our [site We built this site for you, so please help us continue developing it: -- [Sign up for our email list](https://docs.google.com/forms/d/e/1FAIpQLSfUg3JE5ODNc6aqBPJwM8mZ80TYtK6ISw-OM7PBwKuoN3M--g/viewform?embedded=true) – we'll send occasional requests for users to participate in user testing or co-design work +- Sign up for our email list – we'll send occasional requests for users to participate in user testing or co-design work - Visit our Github repositories ([site](https://github.com/nychealth/EH-dataportal), [data](https://github.com/nychealth/EHDP-data)) and explore the code, file an issue, or suggest features - Email us with any questions you have at ehdp@health.nyc.gov – we're here to help. diff --git a/themes/dohmh/layouts/data-stories/single.html b/themes/dohmh/layouts/data-stories/single.html index 0d5123d31c3..a4b53d1b3e3 100644 --- a/themes/dohmh/layouts/data-stories/single.html +++ b/themes/dohmh/layouts/data-stories/single.html @@ -62,7 +62,7 @@- Like this story? Sign up to find out when we post something new.
+ Like this story? Sign up to find out when we post something new.Sign up here! We won't share your email address.
+Sign up here! We won't share your email address.
Please sign up for our email list. We will email you every few months with updates, or opportunities to participate in user research. - Click here to sign up. + Click here to sign up.
Please sign up for our email list. We will email you every few months with updates, or opportunities to participate in user research. - Click here to sign up. + Click here to sign up.