Skip to content

Instantly share code, notes, and snippets.

@jeanox
Created December 20, 2017 17:16
Show Gist options
  • Save jeanox/77c945004a27e5a80b7d8430956f85f0 to your computer and use it in GitHub Desktop.
Save jeanox/77c945004a27e5a80b7d8430956f85f0 to your computer and use it in GitHub Desktop.
Black Friday Popup JS
// ---------------------
// Black Friday Popup
// ---------------------
Exclude all pages with .brand (includes review pages)
const excludePages = !$('body').hasClass('brand');
// Sale Dates: 24, 25, 27, 28
const saleDates = [24, 25, 27, 28];
const d = new Date();
const currentDate = d.getDate();
const dateMatch = saleDates.includes(currentDate);
console.log(`Is today a sale?: ${dateMatch}`);
if (dateMatch && excludePages) {
console.log('Black Friday Popup: ACTIVATE!');
// TODO: Remove previous popups
$(dialogEl).remove();
// TODO: Dialog object
const dialogBlackFriday = '[data-js="black-friday-popup"]';
dialog(dialogBlackFriday, {
exitIntent: true,
closedDuration: 60,
breakpoint: '(min-width: 600px)',
mobileScrollPercent: false,
});
} else {
console.log('Black Friday Popup: REJECTED');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment