From 27cdff3110a5678880c2b990cb02bd1978c62ee6 Mon Sep 17 00:00:00 2001 From: James Tsay Date: Fri, 3 Jan 2025 13:19:23 -0800 Subject: [PATCH 1/3] handle redirectUrl --- acrobat/blocks/verb-widget/verb-widget.js | 84 +++++++++++------------ 1 file changed, 41 insertions(+), 43 deletions(-) diff --git a/acrobat/blocks/verb-widget/verb-widget.js b/acrobat/blocks/verb-widget/verb-widget.js index 8f5eaee1..3191c84f 100644 --- a/acrobat/blocks/verb-widget/verb-widget.js +++ b/acrobat/blocks/verb-widget/verb-widget.js @@ -42,24 +42,19 @@ const setDraggingClass = (widget, shouldToggle) => { shouldToggle ? widget.classList.add('dragging') : widget.classList.remove('dragging'); }; -function prefetchNextPage(verb) { - const { locale } = getConfig(); - const localePath = localeMap[locale.prefix.replace('/', '')].split('-').reverse().join('/'); - const nextPageHost = getEnv() === 'prod' ? 'acrobat.adobe.com' : 'stage.acrobat.adobe.com'; - const nextPageUrl = `https://${nextPageHost}/${localePath}/${verb}`; - +function prefetchNextPage(url) { const link = document.createElement('link'); link.rel = 'prefetch'; - link.href = nextPageUrl; + link.href = url; link.crossOrigin = 'anonymous'; link.as = 'document'; document.head.appendChild(link); } -function initiatePrefetch(verb) { +function initiatePrefetch(url) { if (!window.prefetchInitiated) { - prefetchNextPage(verb); + prefetchNextPage(url); window.prefetchInitiated = true; } } @@ -225,7 +220,6 @@ export default async function init(element) { button.addEventListener('click', () => { verbAnalytics('filepicker:shown', VERB); verbAnalytics('dropzone:choose-file-clicked', VERB); - initiatePrefetch(VERB); }); button.addEventListener('cancel', () => { @@ -235,7 +229,6 @@ export default async function init(element) { widget.addEventListener('dragover', (e) => { e.preventDefault(); setDraggingClass(widget, true); - initiatePrefetch(VERB); }); widget.addEventListener('dragleave', () => { @@ -249,38 +242,43 @@ export default async function init(element) { element.addEventListener('unity:track-analytics', (e) => { const cookieExp = new Date(Date.now() + 90 * 1000).toUTCString(); - - if (e.detail?.event === 'change') { - verbAnalytics('choose-file:open', VERB, e.detail?.data); - setUser(); - } - // maybe new event name files-dropped? - if (e.detail?.event === 'drop') { - initiatePrefetch(VERB); - verbAnalytics('files-dropped', VERB, e.detail?.data); - setDraggingClass(widget, false); - setUser(); - } - - if (e.detail?.event === 'cancel') { - verbAnalytics('job:cancel', VERB, e.detail?.data); - setUser(); - } - - if (e.detail?.event === 'uploading') { - verbAnalytics('job:uploading', VERB, e.detail?.data); - setUser(); - document.cookie = `UTS_Uploading=${Date.now()};domain=.adobe.com;path=/;expires=${cookieExp}`; - window.addEventListener('beforeunload', (w) => { - handleExit(w); - }); - } - - if (e.detail?.event === 'uploaded') { - verbAnalytics('job:test-uploaded', VERB, e.detail?.data, false); - exitFlag = true; - setUser(); - document.cookie = `UTS_Uploaded=${Date.now()};domain=.adobe.com;path=/;expires=${cookieExp}`; + const { event, data } = e.detail || {}; + + if (!event) return; + + const analyticsMap = { + change: () => { + verbAnalytics('choose-file:open', VERB, data); + setUser(); + }, + drop: () => { + verbAnalytics('files-dropped', VERB, data); + setDraggingClass(widget, false); + setUser(); + }, + cancel: () => { + verbAnalytics('job:cancel', VERB, data); + setUser(); + }, + uploading: () => { + verbAnalytics('job:uploading', VERB, data); + setUser(); + document.cookie = `UTS_Uploading=${Date.now()};domain=.adobe.com;path=/;expires=${cookieExp}`; + window.addEventListener('beforeunload', handleExit); + }, + uploaded: () => { + verbAnalytics('job:test-uploaded', VERB, data, false); + exitFlag = true; + setUser(); + document.cookie = `UTS_Uploaded=${Date.now()};domain=.adobe.com;path=/;expires=${cookieExp}`; + }, + redirectUrl: () => { + if (data) initiatePrefetch(data); + }, + }; + + if (analyticsMap[event]) { + analyticsMap[event](); } }); From 364816952de737b3636c7c50fb8abf4c800c155c Mon Sep 17 00:00:00 2001 From: James Tsay Date: Fri, 3 Jan 2025 14:02:39 -0800 Subject: [PATCH 2/3] Remove localMap reference --- acrobat/blocks/verb-widget/verb-widget.js | 1 - 1 file changed, 1 deletion(-) diff --git a/acrobat/blocks/verb-widget/verb-widget.js b/acrobat/blocks/verb-widget/verb-widget.js index 3191c84f..94f02a90 100644 --- a/acrobat/blocks/verb-widget/verb-widget.js +++ b/acrobat/blocks/verb-widget/verb-widget.js @@ -2,7 +2,6 @@ import LIMITS from './limits.js'; import { setLibs, getEnv, isOldBrowser } from '../../scripts/utils.js'; import verbAnalytics from '../../scripts/alloy/verb-widget.js'; import createSvgElement from './icons.js'; -import { localeMap } from '../unity/unity.js'; const miloLibs = setLibs('/libs'); const { createTag, getConfig } = await import(`${miloLibs}/utils/utils.js`); From 30ab0f28313c1aeb3791729f7800dd54fdc50ab5 Mon Sep 17 00:00:00 2001 From: Adam Peller <46139+peller@users.noreply.github.com> Date: Mon, 6 Jan 2025 22:29:49 -0500 Subject: [PATCH 3/3] DCXY-28094 Map Unity locales to supported Acrobat Web locales --- acrobat/blocks/unity/unity.js | 128 +++++++++++++++++----------------- 1 file changed, 64 insertions(+), 64 deletions(-) diff --git a/acrobat/blocks/unity/unity.js b/acrobat/blocks/unity/unity.js index 5ae9c9f8..2d732c29 100644 --- a/acrobat/blocks/unity/unity.js +++ b/acrobat/blocks/unity/unity.js @@ -3,94 +3,94 @@ import LIMITS from '../verb-widget/limits.js'; export const localeMap = { '': 'en-us', br: 'pt-br', - ca: 'en-ca', - ca_fr: 'fr-ca', - mx: 'es-mx', - la: 'es-la', - africa: 'en-za', - za: 'en-za', - be_nl: 'nl-be', - be_fr: 'fr-be', - be_en: 'en-be', + ca: 'en-us', + ca_fr: 'fr-fr', + mx: 'es-es', + la: 'es-es', + africa: 'en-us', + za: 'en-us', + be_nl: 'nl-nl', + be_fr: 'fr-fr', + be_en: 'en-us', cz: 'cs-cz', - cy_en: 'en-cy', + cy_en: 'en-us', dk: 'da-dk', de: 'de-de', - ee: 'et-ee', + ee: 'en-us', es: 'es-es', fr: 'fr-fr', - gr_en: 'en-gr', - gr_el: 'el-gr', - ie: 'en-ie', - il_en: 'en-il', - il_he: 'he-il', + gr_en: 'en-us', + gr_el: 'en-us', + ie: 'en-us', + il_en: 'en-us', + il_he: 'en-us', it: 'it-it', - lv: 'lv-lv', - lt: 'lt-lt', - lu_de: 'de-lu', - lu_en: 'en-lu', - lu_fr: 'fr-lu', - hu: 'hu-hu', - mt: 'en-mt', - mena_en: 'en-ae', - mena_ar: 'ar-ae', + lv: 'en-us', + lt: 'en-us', + lu_de: 'de-de', + lu_en: 'en-us', + lu_fr: 'fr-fr', + hu: 'en-us', + mt: 'en-us', + mena_en: 'en-us', + mena_ar: 'en-us', nl: 'nl-nl', no: 'nb-no', - at: 'de-at', + at: 'de-de', pl: 'pl-pl', - pt: 'pt-pt', + pt: 'pt-br', ro: 'ro-ro', - ch_de: 'de-ch', - si: 'sl-si', - sk: 'sk-sk', - ch_fr: 'fr-ch', + ch_de: 'de-de', + si: 'en-us', + sk: 'en-us', + ch_fr: 'fr-fr', fi: 'fi-fi', se: 'sv-se', - ch_it: 'it-ch', + ch_it: 'it-it', tr: 'tr-tr', uk: 'en-gb', - bg: 'bg-bg', + bg: 'en-us', ru: 'ru-ru', - ua: 'uk-ua', + ua: 'en-us', au: 'en-au', - hk_en: 'en-hk', - in: 'en-in', + hk_en: 'en-us', + in: 'en-us', in_hi: 'hi-in', nz: 'en-nz', hk_zh: 'zh-tw', tw: 'zh-tw', jp: 'ja-jp', kr: 'ko-kr', - ae_en: 'en-ae', - ae_ar: 'ar-ae', - sa_en: 'en-sa', - sa_ar: 'ar-sa', - th_en: 'en-th', + ae_en: 'en-us', + ae_ar: 'en-us', + sa_en: 'en-us', + sa_ar: 'en-us', + th_en: 'en-us', th_th: 'th-th', - sg: 'en-sg', - cl: 'es-cl', - co: 'es-co', - ar: 'es-ar', - cr: 'es-cr', - pr: 'es-pr', - ec: 'es-ec', - pe: 'es-pe', - eg_en: 'en-eg', - eg_ar: 'ar-eg', - gt: 'es-gt', - id_en: 'en-id', + sg: 'en-us', + cl: 'es-es', + co: 'es-es', + ar: 'es-es', + cr: 'es-es', + pr: 'es-es', + ec: 'es-es', + pe: 'es-es', + eg_en: 'en-us', + eg_ar: 'en-us', + gt: 'es-es', + id_en: 'en-us', id_id: 'id-id', - ph_en: 'en-ph', - ph_fil: 'en-ph', - my_en: 'en-my', - my_ms: 'ms-my', - kw_en: 'en-kw', - kw_ar: 'ar-kw', - ng: 'en-ng', - qa_en: 'en-qa', - qa_ar: 'ar-qa', - vn_en: 'en-vn', - vn_vi: 'vi-vn', + ph_en: 'en-us', + ph_fil: 'en-us', + my_en: 'en-us', + my_ms: 'en-us', + kw_en: 'en-us', + kw_ar: 'en-us', + ng: 'en-us', + qa_en: 'en-us', + qa_ar: 'en-us', + vn_en: 'en-us', + vn_vi: 'en-us', }; function getUnityLibs(prodLibs = '/unitylibs') {