Skip to content

Commit

Permalink
implemented support for susi buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
saragajic11 committed Sep 23, 2024
1 parent 46ba26b commit cb347d5
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
13 changes: 13 additions & 0 deletions acrobat/scripts/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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);
Expand Down
17 changes: 17 additions & 0 deletions acrobat/scripts/susiAuthHandler.js
Original file line number Diff line number Diff line change
@@ -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 = '';
});
}

0 comments on commit cb347d5

Please sign in to comment.