Fix banner-dismiss.js null object
Signed-off-by: Dmitry Shurupov <dmitry.shurupov@palark.com>pull/49472/head
parent
de4903de04
commit
2c598792c4
|
@ -21,6 +21,7 @@ $(document).ready(function() {
|
|||
|
||||
/* Check the presence of a cookie */
|
||||
let announcement = document.querySelector("#announcement");
|
||||
if (announcement) {
|
||||
let token = `announcement_ack_${announcement.getAttribute('data-announcement-name').replace(/\s/g, '_')}`; // Generate the unique token for announcement
|
||||
let acknowledged = getCookie(token);
|
||||
if (acknowledged === "true") {
|
||||
|
@ -29,13 +30,16 @@ $(document).ready(function() {
|
|||
else {
|
||||
announcement.classList.add('display-announcement') // Display the announcement if the cookie is not set
|
||||
}
|
||||
}
|
||||
|
||||
/* Driver code to set the cookie */
|
||||
let button = document.querySelector('#banner-dismiss');
|
||||
if (button) {
|
||||
button.removeAttribute('style');
|
||||
button.addEventListener('click', function() {
|
||||
setCookie(token, "true",
|
||||
button.getAttribute('data-ttl')); // Set a cookie with time to live parameter
|
||||
announcement.remove();
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue