Skip to content

Commit

Permalink
Merge branch 'stage' into MWPW-163684
Browse files Browse the repository at this point in the history
  • Loading branch information
TsayAdobe authored Jan 9, 2025
2 parents 7595b6a + df00938 commit 7de75d0
Show file tree
Hide file tree
Showing 2 changed files with 111 additions and 113 deletions.
128 changes: 64 additions & 64 deletions acrobat/blocks/unity/unity.js
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand Down
96 changes: 47 additions & 49 deletions acrobat/blocks/verb-widget/verb-widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`);
Expand Down Expand Up @@ -42,24 +41,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;
}
}
Expand Down Expand Up @@ -264,7 +258,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', () => {
Expand All @@ -274,7 +267,6 @@ export default async function init(element) {
widget.addEventListener('dragover', (e) => {
e.preventDefault();
setDraggingClass(widget, true);
initiatePrefetch(VERB);
});

widget.addEventListener('dragleave', () => {
Expand All @@ -289,43 +281,49 @@ 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') {
if (LIMITS[VERB].trial) {
const key = `${VERB}_trial`;
const stored = localStorage.getItem(key);
const count = parseInt(stored, 10);
localStorage.setItem(key, count + 1 || 1);
}
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: () => {
if (LIMITS[VERB].trial) {
const key = `${VERB}_trial`;
const stored = localStorage.getItem(key);
const count = parseInt(stored, 10);
localStorage.setItem(key, count + 1 || 1);
}
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]();
}
});

Expand Down

0 comments on commit 7de75d0

Please sign in to comment.