mirror of
https://github.com/jgthms/bulma.git
synced 2025-01-09 15:44:25 +00:00
Add cookie expiration date
This commit is contained in:
parent
af5e17a96d
commit
1a4c242fc6
@ -2,14 +2,15 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
|
||||
// Cookies
|
||||
|
||||
const bdCookies = Cookies.getJSON('bulma') || {};
|
||||
const cookieBookModalName = 'bulma_closed_book_modal';
|
||||
const cookieBookModal = Cookies.getJSON(cookieBookModalName) || false;
|
||||
|
||||
// Book modal
|
||||
|
||||
const $bookModal = document.getElementById('bookModal');
|
||||
const $bookModalCloseButtons = getAll('.bd-book-modal-close');
|
||||
|
||||
if (!bdCookies['closed_book_modal']) {
|
||||
if (!cookieBookModal) {
|
||||
setTimeout(() => {
|
||||
openModal('bookModal');
|
||||
}, 5000);
|
||||
@ -19,8 +20,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
$bookModalCloseButtons.forEach($el => {
|
||||
$el.addEventListener('click', event => {
|
||||
event.stopPropagation();
|
||||
bdCookies['closed_book_modal'] = true;
|
||||
Cookies.set('bulma', bdCookies);
|
||||
Cookies.set(cookieBookModalName, true, { expires: 30 });
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -4,14 +4,15 @@ document.addEventListener('DOMContentLoaded', function () {
|
||||
|
||||
// Cookies
|
||||
|
||||
var bdCookies = Cookies.getJSON('bulma') || {};
|
||||
var cookieBookModalName = 'bulma_closed_book_modal';
|
||||
var cookieBookModal = Cookies.getJSON(cookieBookModalName) || false;
|
||||
|
||||
// Book modal
|
||||
|
||||
var $bookModal = document.getElementById('bookModal');
|
||||
var $bookModalCloseButtons = getAll('.bd-book-modal-close');
|
||||
|
||||
if (!bdCookies['closed_book_modal']) {
|
||||
if (!cookieBookModal) {
|
||||
setTimeout(function () {
|
||||
openModal('bookModal');
|
||||
}, 5000);
|
||||
@ -21,8 +22,7 @@ document.addEventListener('DOMContentLoaded', function () {
|
||||
$bookModalCloseButtons.forEach(function ($el) {
|
||||
$el.addEventListener('click', function (event) {
|
||||
event.stopPropagation();
|
||||
bdCookies['closed_book_modal'] = true;
|
||||
Cookies.set('bulma', bdCookies);
|
||||
Cookies.set(cookieBookModalName, true, { expires: 30 });
|
||||
});
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user