Created
December 20, 2017 17:16
-
-
Save jeanox/77c945004a27e5a80b7d8430956f85f0 to your computer and use it in GitHub Desktop.
Black Friday Popup 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
// --------------------- | |
// 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