Bug 1754832 - Update PBM to support opening spotlight tab modal r=Mardak,mviar,fluent-reviewers,flod

Differential Revision: https://phabricator.services.mozilla.com/D140565
This commit is contained in:
Punam Dahiya
2022-03-17 06:41:47 +00:00
parent 0d7fa051a3
commit 241b77481c
17 changed files with 443 additions and 246 deletions

View File

@@ -87,6 +87,7 @@ async function renderPromo({
promoHeader,
promoImageLarge,
promoImageSmall,
promoButton = null,
} = {}) {
const container = document.querySelector(".promo");
if (promoEnabled === false) {
@@ -102,20 +103,22 @@ async function renderPromo({
const promoImageSmallEl = document.querySelector(".promo-image-small img");
const dismissBtn = document.querySelector("#dismiss-btn");
// Setup the private browsing VPN link.
const vpnPromoUrl =
promoLinkUrl || RPMGetFormatURLPref("browser.privatebrowsing.vpnpromourl");
if (promoLinkType === "button") {
linkEl.classList.add("button");
}
if (vpnPromoUrl) {
linkEl.setAttribute("href", vpnPromoUrl);
if (promoLinkUrl) {
linkEl.setAttribute("href", promoLinkUrl);
linkEl.setAttribute("target", "_blank");
linkEl.addEventListener("click", () => {
window.PrivateBrowsingRecordClick("promo_link");
});
} else if (promoButton?.action?.type === "SHOW_SPOTLIGHT") {
linkEl.setAttribute("href", "#");
linkEl.addEventListener("click", async () => {
window.PrivateBrowsingRecordClick("promo_link");
await RPMSendQuery("SpecialMessageActionDispatch", promoButton.action);
});
} else {
// If the link is undefined, remove the promo completely
container.remove();