-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #918 from adobecom/2450
DC MILO Release 0.2450
- Loading branch information
Showing
3 changed files
with
47 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,44 @@ | ||
import susiAnalytics from './alloy/susi-auth-handler.js'; | ||
|
||
export default function handleImsSusi(susiElems) { | ||
function handleButton(link, action) { | ||
link.classList.add('susi-cta'); | ||
link.href = window.mph['susi-default-redirect'] || 'https://acrobat.adobe.com/link/home/'; | ||
link.addEventListener('click', (e) => { | ||
e.preventDefault(); | ||
susiAnalytics(link.text, action, window.browser.isMobile ? 'mobile' : 'desktop'); | ||
if (action === 'sign-up') { | ||
window.adobeIMS.signUp(); | ||
} else if (action === 'sign-in') { | ||
window.adobeIMS.signIn(); | ||
} | ||
}); | ||
} | ||
|
||
export default async function handleImsSusi(susiElems) { | ||
const { setLibs } = await import('./utils.js'); | ||
const miloLibs = setLibs('/libs'); | ||
const { getConfig } = await import(`${miloLibs}/utils/utils.js`); | ||
const config = getConfig(); | ||
|
||
if (!Object.keys(window.mph || {}).length) { | ||
const placeholdersPath = `${config.locale.contentRoot}/placeholders.json`; | ||
try { | ||
const response = await fetch(placeholdersPath); | ||
if (response.ok) { | ||
const placeholderData = await response.json(); | ||
placeholderData.data.forEach(({ key, value }) => { | ||
window.mph[key] = value.replace(/\u00A0/g, ' '); | ||
}); | ||
} | ||
} catch (error) { | ||
window.lana?.log(`Failed to load placeholders: ${error?.message}`); | ||
} | ||
} | ||
|
||
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(); | ||
}); | ||
const match = link.href.match(/-(sign-up|sign-in)/); | ||
if (match) { | ||
handleButton(link, match[1]); | ||
} | ||
link.style.pointerEvents = 'auto'; | ||
link.style.cursor = 'pointer'; | ||
}); | ||
} |