Skip to content

Commit

Permalink
Merge pull request #869 from adobecom/MWPW-160726_
Browse files Browse the repository at this point in the history
MWPW-160726: Implement Exit Prompt
  • Loading branch information
Blainegunn authored Oct 23, 2024
2 parents e4e440a + 4b8c138 commit d72dcb1
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions acrobat/blocks/verb-widget/verb-widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,13 @@ function redDir(verb) {
window.location.href = newLocation;
}

let exitFlag;
function handleExit(event) {
if (exitFlag) { return; }
event.preventDefault();
event.returnValue = true;
}

export default async function init(element) {
if (isOldBrowser()) {
window.location.href = EOLBrowserPage;
Expand Down Expand Up @@ -250,24 +257,17 @@ export default async function init(element) {
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') {
exitFlag = true;
verbAnalytics('job:uploaded', VERB, e.detail?.data);
setUser();
document.cookie = `UTS_Uploaded=${Date.now()};domain=.adobe.com;path=/;expires=${cookieExp}`;
}

if (e.detail?.event === 'redirect to product') {
verbAnalytics('transition', VERB);
setUser();
document.cookie = `UTS_Redirect=${Date.now()};domain=.adobe.com;path=/;expires=${cookieExp}`;
}

if (e.detail?.event === 'redirect to product') {
verbAnalytics('transition', VERB);
setUser();
}
});

// Errors, Analytics & Logging
Expand Down

0 comments on commit d72dcb1

Please sign in to comment.