From cb347d5fe9b9633e03973083c25af84417eb4ca3 Mon Sep 17 00:00:00 2001 From: saragajic11 Date: Mon, 23 Sep 2024 14:26:52 +0200 Subject: [PATCH 1/7] implemented support for susi buttons --- acrobat/scripts/scripts.js | 13 +++++++++++++ acrobat/scripts/susiAuthHandler.js | 17 +++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 acrobat/scripts/susiAuthHandler.js diff --git a/acrobat/scripts/scripts.js b/acrobat/scripts/scripts.js index 2fcecfa8..1b6b24a7 100644 --- a/acrobat/scripts/scripts.js +++ b/acrobat/scripts/scripts.js @@ -18,6 +18,10 @@ document.querySelectorAll('a').forEach((p, idx) => { } }); +document.querySelectorAll('a[href*="susi-"]').forEach((el) => { + el.style.display = 'none'; +}); + /** * The decision engine for where to get Milo's libs from. */ @@ -460,6 +464,15 @@ const { ietf } = getLocale(locales); setConfig({ ...CONFIG, miloLibs }); + window.addEventListener('IMS:Ready', async () => { + const susiSignUpElems = document.querySelectorAll('a[href*="susi-sign-up"]'); + const susiSignInElems = document.querySelectorAll('a[href*="susi-sign-in"]'); + if(susiSignUpElems.length > 0 || susiSignInElems.length > 0) { + const { default: handleImsSusi } = await import('./susiAuthHandler.js'); + handleImsSusi(susiSignUpElems, susiSignInElems); + } + }); + loadIms().then(() => { const imsIsReady = new CustomEvent('IMS:Ready'); window.dispatchEvent(imsIsReady); diff --git a/acrobat/scripts/susiAuthHandler.js b/acrobat/scripts/susiAuthHandler.js new file mode 100644 index 00000000..59c3c862 --- /dev/null +++ b/acrobat/scripts/susiAuthHandler.js @@ -0,0 +1,17 @@ +export default function handleImsSusi(susiSignUpElems, susiSignInElems) { + susiSignUpElems.forEach((link) => { + link.addEventListener('click', (e) => { + e.preventDefault(); + window.adobeIMS.signUp(); + }); + link.style.display = ''; + }); + + susiSignInElems.forEach((link) => { + link.addEventListener('click', (e) => { + e.preventDefault(); + window.adobeIMS.signIn(); + }); + link.style.display = ''; + }); +} From b1963800853f900134f5d25be6fd1c51767e7b81 Mon Sep 17 00:00:00 2001 From: saragajic11 Date: Mon, 23 Sep 2024 14:35:49 +0200 Subject: [PATCH 2/7] eslint fixes --- acrobat/scripts/scripts.js | 2 +- acrobat/scripts/susiAuthHandler.js | 24 ++++++++++++------------ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/acrobat/scripts/scripts.js b/acrobat/scripts/scripts.js index 1b6b24a7..f08b3eaa 100644 --- a/acrobat/scripts/scripts.js +++ b/acrobat/scripts/scripts.js @@ -467,7 +467,7 @@ const { ietf } = getLocale(locales); window.addEventListener('IMS:Ready', async () => { const susiSignUpElems = document.querySelectorAll('a[href*="susi-sign-up"]'); const susiSignInElems = document.querySelectorAll('a[href*="susi-sign-in"]'); - if(susiSignUpElems.length > 0 || susiSignInElems.length > 0) { + if (susiSignUpElems.length > 0 || susiSignInElems.length > 0) { const { default: handleImsSusi } = await import('./susiAuthHandler.js'); handleImsSusi(susiSignUpElems, susiSignInElems); } diff --git a/acrobat/scripts/susiAuthHandler.js b/acrobat/scripts/susiAuthHandler.js index 59c3c862..d207e7d6 100644 --- a/acrobat/scripts/susiAuthHandler.js +++ b/acrobat/scripts/susiAuthHandler.js @@ -1,17 +1,17 @@ export default function handleImsSusi(susiSignUpElems, susiSignInElems) { - susiSignUpElems.forEach((link) => { - link.addEventListener('click', (e) => { - e.preventDefault(); - window.adobeIMS.signUp(); - }); - link.style.display = ''; + susiSignUpElems.forEach((link) => { + link.addEventListener('click', (e) => { + e.preventDefault(); + window.adobeIMS.signUp(); }); + link.style.display = ''; + }); - susiSignInElems.forEach((link) => { - link.addEventListener('click', (e) => { - e.preventDefault(); - window.adobeIMS.signIn(); - }); - link.style.display = ''; + susiSignInElems.forEach((link) => { + link.addEventListener('click', (e) => { + e.preventDefault(); + window.adobeIMS.signIn(); }); + link.style.display = ''; + }); } From 98edddaaf1edd26392871a6e961d3625089cf653 Mon Sep 17 00:00:00 2001 From: saragajic11 Date: Tue, 24 Sep 2024 10:19:49 +0200 Subject: [PATCH 3/7] refactoring --- acrobat/scripts/scripts.js | 11 +++-------- acrobat/scripts/susiAuthHandler.js | 31 +++++++++++++++--------------- acrobat/styles/styles.css | 5 +++++ 3 files changed, 24 insertions(+), 23 deletions(-) diff --git a/acrobat/scripts/scripts.js b/acrobat/scripts/scripts.js index f08b3eaa..9c17f390 100644 --- a/acrobat/scripts/scripts.js +++ b/acrobat/scripts/scripts.js @@ -18,10 +18,6 @@ document.querySelectorAll('a').forEach((p, idx) => { } }); -document.querySelectorAll('a[href*="susi-"]').forEach((el) => { - el.style.display = 'none'; -}); - /** * The decision engine for where to get Milo's libs from. */ @@ -465,11 +461,10 @@ const { ietf } = getLocale(locales); setConfig({ ...CONFIG, miloLibs }); window.addEventListener('IMS:Ready', async () => { - const susiSignUpElems = document.querySelectorAll('a[href*="susi-sign-up"]'); - const susiSignInElems = document.querySelectorAll('a[href*="susi-sign-in"]'); - if (susiSignUpElems.length > 0 || susiSignInElems.length > 0) { + const susiElems = document.querySelectorAll('a[href*="susi"]'); + if (susiElems.length > 0) { const { default: handleImsSusi } = await import('./susiAuthHandler.js'); - handleImsSusi(susiSignUpElems, susiSignInElems); + handleImsSusi(susiElems); } }); diff --git a/acrobat/scripts/susiAuthHandler.js b/acrobat/scripts/susiAuthHandler.js index d207e7d6..a27cc940 100644 --- a/acrobat/scripts/susiAuthHandler.js +++ b/acrobat/scripts/susiAuthHandler.js @@ -1,17 +1,18 @@ -export default function handleImsSusi(susiSignUpElems, susiSignInElems) { - susiSignUpElems.forEach((link) => { - link.addEventListener('click', (e) => { - e.preventDefault(); - window.adobeIMS.signUp(); - }); - link.style.display = ''; - }); - - susiSignInElems.forEach((link) => { - link.addEventListener('click', (e) => { - e.preventDefault(); - window.adobeIMS.signIn(); - }); - link.style.display = ''; +export default function handleImsSusi(susiElems) { + susiElems.forEach((link) => { + if(link.href.includes('-sign-up')) { + link.addEventListener('click', (e) => { + e.preventDefault(); + window.adobeIMS.signUp(); + }); + } + else if(link.href.includes('-sign-in')) { + link.addEventListener('click', (e) => { + e.preventDefault(); + window.adobeIMS.signIn(); + }); + } + link.style.pointerEvents = 'auto'; + link.style.cursor = 'pointer'; }); } diff --git a/acrobat/styles/styles.css b/acrobat/styles/styles.css index 31ede7aa..8da955dd 100644 --- a/acrobat/styles/styles.css +++ b/acrobat/styles/styles.css @@ -878,3 +878,8 @@ main { display: none; } } + +a[href*="susi"] { + pointer-events: none; + cursor: default; +} From bc2100acb8801311aec825130ef031a1e8bed9ba Mon Sep 17 00:00:00 2001 From: saragajic11 Date: Tue, 24 Sep 2024 10:25:18 +0200 Subject: [PATCH 4/7] eslint fix --- acrobat/scripts/susiAuthHandler.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/acrobat/scripts/susiAuthHandler.js b/acrobat/scripts/susiAuthHandler.js index a27cc940..034fb5c8 100644 --- a/acrobat/scripts/susiAuthHandler.js +++ b/acrobat/scripts/susiAuthHandler.js @@ -1,12 +1,11 @@ export default function handleImsSusi(susiElems) { susiElems.forEach((link) => { - if(link.href.includes('-sign-up')) { + if (link.href.includes('-sign-up')) { link.addEventListener('click', (e) => { e.preventDefault(); window.adobeIMS.signUp(); }); - } - else if(link.href.includes('-sign-in')) { + } else if (link.href.includes('-sign-in')) { link.addEventListener('click', (e) => { e.preventDefault(); window.adobeIMS.signIn(); From b673c9b0d38b964f993e59a2d798f0470921368c Mon Sep 17 00:00:00 2001 From: saragajic11 Date: Tue, 24 Sep 2024 11:05:15 +0200 Subject: [PATCH 5/7] implemented analytics --- acrobat/scripts/alloy/susi-auth-handler.js | 18 ++++++++++++++++++ acrobat/scripts/susiAuthHandler.js | 4 ++++ 2 files changed, 22 insertions(+) create mode 100644 acrobat/scripts/alloy/susi-auth-handler.js diff --git a/acrobat/scripts/alloy/susi-auth-handler.js b/acrobat/scripts/alloy/susi-auth-handler.js new file mode 100644 index 00000000..394cac53 --- /dev/null +++ b/acrobat/scripts/alloy/susi-auth-handler.js @@ -0,0 +1,18 @@ +export default function init(ctaName, action, device) { + + const event = { + // always trigger the event using navigator.sendBeacon + documentUnloading: true, + data: { + eventType: 'web.webinteraction.linkClicks', + web: { + webInteraction: { + linkClicks: { value: 1 }, + type: 'other', + name: `${ctaName}|marquee-${action}|overview|${device}`, + }, + }, + }, + }; + window?._satellite?.track('event', event); +} diff --git a/acrobat/scripts/susiAuthHandler.js b/acrobat/scripts/susiAuthHandler.js index 034fb5c8..79e31173 100644 --- a/acrobat/scripts/susiAuthHandler.js +++ b/acrobat/scripts/susiAuthHandler.js @@ -1,13 +1,17 @@ +import susiAnalytics from '../scripts/alloy/susi-auth-handler.js'; + export default function handleImsSusi(susiElems) { susiElems.forEach((link) => { if (link.href.includes('-sign-up')) { link.addEventListener('click', (e) => { e.preventDefault(); + susiAnalytics(link.text, 'sign-up', window.browser.isMobile ? 'mobile' : 'desktop'); window.adobeIMS.signUp(); }); } else if (link.href.includes('-sign-in')) { link.addEventListener('click', (e) => { e.preventDefault(); + susiAnalytics(link.text, 'sign-in', window.browser.isMobile ? 'mobile' : 'desktop'); window.adobeIMS.signIn(); }); } From e0361b046c2af6f422ae5d10edc60473d34c8eff Mon Sep 17 00:00:00 2001 From: saragajic11 Date: Tue, 24 Sep 2024 11:09:47 +0200 Subject: [PATCH 6/7] eslint fixes --- acrobat/scripts/alloy/susi-auth-handler.js | 1 - acrobat/scripts/susiAuthHandler.js | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/acrobat/scripts/alloy/susi-auth-handler.js b/acrobat/scripts/alloy/susi-auth-handler.js index 394cac53..be6b7092 100644 --- a/acrobat/scripts/alloy/susi-auth-handler.js +++ b/acrobat/scripts/alloy/susi-auth-handler.js @@ -1,5 +1,4 @@ export default function init(ctaName, action, device) { - const event = { // always trigger the event using navigator.sendBeacon documentUnloading: true, diff --git a/acrobat/scripts/susiAuthHandler.js b/acrobat/scripts/susiAuthHandler.js index 79e31173..1416d79b 100644 --- a/acrobat/scripts/susiAuthHandler.js +++ b/acrobat/scripts/susiAuthHandler.js @@ -1,4 +1,4 @@ -import susiAnalytics from '../scripts/alloy/susi-auth-handler.js'; +import susiAnalytics from './alloy/susi-auth-handler.js'; export default function handleImsSusi(susiElems) { susiElems.forEach((link) => { From 0161ccb113ae95805ca1df39543de177614ae019 Mon Sep 17 00:00:00 2001 From: saragajic11 Date: Wed, 25 Sep 2024 11:05:25 +0200 Subject: [PATCH 7/7] fixed eslint issue --- acrobat/scripts/alloy/susi-auth-handler.js | 1 + 1 file changed, 1 insertion(+) diff --git a/acrobat/scripts/alloy/susi-auth-handler.js b/acrobat/scripts/alloy/susi-auth-handler.js index be6b7092..7f11740d 100644 --- a/acrobat/scripts/alloy/susi-auth-handler.js +++ b/acrobat/scripts/alloy/susi-auth-handler.js @@ -13,5 +13,6 @@ export default function init(ctaName, action, device) { }, }, }; + // eslint-disable-next-line no-underscore-dangle window?._satellite?.track('event', event); }