forked from adobecom/cc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'adobecom:main' into main
- Loading branch information
Showing
19 changed files
with
1,371 additions
and
94 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
9 changes: 9 additions & 0 deletions
9
creativecloud/blocks/universal-promo-terms/universal-promo-terms.css
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
@media (min-width: 900px) { | ||
body .feds-topnav-wrapper { | ||
border: 0; | ||
} | ||
} | ||
|
||
body .global-footer { | ||
background: none; | ||
} |
52 changes: 52 additions & 0 deletions
52
creativecloud/blocks/universal-promo-terms/universal-promo-terms.js
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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
const OFFER_ID_API_BASE = 'https://aos.adobe.io/offers/'; | ||
const SELECTOR_ID_API_BASE = 'https://aos.adobe.io/offers:search.selector'; | ||
const STAGE_OFFER_ID_API_BASE = 'https://aos-stage.adobe.io/offers/'; | ||
const STAGE_SELECTOR_ID_API_BASE = 'https://aos-stage.adobe.io/offers:search.selector'; | ||
const API_KEY = 'universalPromoTerm'; | ||
const SERVICE_PROVIDERS = 'PROMO_TERMS'; | ||
|
||
function getEnv(env) { | ||
if (env) return env; | ||
if (window.location.hostname === 'www.adobe.com') return 'production'; | ||
return 'stage'; | ||
} | ||
|
||
async function getTermsHTML(params, el, env, search) { | ||
const locationSearch = search ?? window.location.search; | ||
let promoTerms; | ||
if (!params.get('offer_selector_ids')) { | ||
let fetchURL = `${env === 'stage' ? STAGE_OFFER_ID_API_BASE : OFFER_ID_API_BASE}${params.get('offer_id')}${locationSearch}`; | ||
fetchURL += params.get('api_key') ? '' : `&api_key=${API_KEY}`; | ||
fetchURL += params.get('service_providers') ? '' : `&service_providers=${SERVICE_PROVIDERS}`; | ||
|
||
const res = await fetch(fetchURL); | ||
if (!res.ok) return false; | ||
const json = await res.json(); | ||
promoTerms = json[0]?.promo_terms; | ||
} else { | ||
let fetchURL = `${env === 'stage' ? STAGE_SELECTOR_ID_API_BASE : SELECTOR_ID_API_BASE}${locationSearch}`; | ||
fetchURL += params.get('api_key') ? '' : `&api_key=${API_KEY}`; | ||
fetchURL += params.get('service_providers') ? '' : `&service_providers=${SERVICE_PROVIDERS}`; | ||
|
||
const res = await fetch(fetchURL); | ||
if (!res.ok) return false; | ||
const json = await res.json(); | ||
promoTerms = json[0]?.offers[0]?.promo_terms; | ||
} | ||
|
||
if (!promoTerms || !promoTerms.header || !promoTerms.text) { | ||
return false; | ||
} | ||
return `<div class="container">${el.innerHTML}<h1>${promoTerms.header}</h1><p>${promoTerms.text}</p></div>`; | ||
} | ||
|
||
export default async function init(el, search) { | ||
const params = new URLSearchParams(search ?? window.location.search); | ||
const env = getEnv(params.get('env')); | ||
const termsHTML = await getTermsHTML(params, el, env, search); | ||
if (!termsHTML && env !== 'stage') { | ||
window.location = '404.html'; | ||
} else { | ||
el.innerHTML = termsHTML; | ||
} | ||
} |
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
Oops, something went wrong.