| @@ -203,14 +203,23 @@ | ||
| 203 | 203 | |
| 204 | 204 | function cookieadmin_set_cookie(name, value, days = 365, domain = "") { |
| 205 | 205 | if (!name || !value) return false; |
| 206 | 206 | |
| 207 | + if((cookieadmin_policy.is_pro != 0) && (cookieadmin_pro_vars !== 'undefined')){ | |
| 208 | + if(cookieadmin_pro_vars.shared_subdomain_consent && cookieadmin_pro_vars.base_domain){ | |
| 209 | + // Delete the cookie if exist with the subdomin | |
| 210 | + // Previously, cookie was set without specifying domain name, we'll not specify domain while deleting. | |
| 211 | + document.cookie = `cookieadmin_consent=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=${cookieadmin_policy.base_path};`; | |
| 212 | + domain = cookieadmin_pro_vars.base_domain; | |
| 213 | + } | |
| 214 | + } | |
| 215 | + | |
| 207 | 216 | var date = new Date(); |
| 208 | 217 | date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000); // default 1 year |
| 209 | 218 | |
| 210 | 219 | var cookieString = `${encodeURIComponent(name)}=${JSON.stringify(value)};`; |
| 211 | 220 | cookieString += ` expires=${date.toUTCString()};`; |
| 212 | - cookieString += ` path=${cookieadmin_policy.base_path};`; | |
| 221 | + cookieString += ` path=${!domain ? cookieadmin_policy.base_path : '/'};`; | |
| 213 | 222 | cookieString += ` SameSite=Lax;`; |
| 214 | 223 | if(cookieadmin_policy.is_ssl || window.location.protocol === 'https:'){ |
| 215 | 224 | cookieString += ` Secure;`; |
| 216 | 225 | } |
| @@ -275,9 +284,10 @@ | ||
| 275 | 284 | |
| 276 | 285 | if(!card_container){ |
| 277 | 286 | continue; |
| 278 | 287 | } |
| 279 | - card_container.innerHTML = (card_container.innerHTML == 'None') ? '' : card_container.innerHTML; | |
| 288 | + | |
| 289 | + card_container.querySelector(".cookieadmin-nocookie-cat").style.display = 'none'; | |
| 280 | 290 | |
| 281 | 291 | var cookieadmin_exp = cookieadmin_policy.lang.session; |
| 282 | 292 | |
| 283 | 293 | if( |
| @@ -382,9 +392,13 @@ | ||
| 382 | 392 | //Show notice or re-consent icon as needed |
| 383 | 393 | if(!cookieadmin_is_obj(cookieadmin_is_consent) && !cookieadmin_policy.hide_banner){ |
| 384 | 394 | |
| 385 | 395 | if(cookieadmin_policy.cookieadmin_layout !== "popup"){ |
| 386 | - document.getElementsByClassName("cookieadmin_law_container")[0].style.display = "block"; | |
| 396 | + var cookieadmin_banner_el = document.getElementsByClassName("cookieadmin_law_container")[0]; | |
| 397 | + if(cookieadmin_banner_el){ | |
| 398 | + cookieadmin_banner_el.style.display = "block"; | |
| 399 | + cookieadmin_banner_el.focus(); | |
| 400 | + } | |
| 387 | 401 | }else{ |
| 388 | 402 | cookieadmin_toggle_overlay(); |
| 389 | 403 | document.getElementsByClassName("cookieadmin_cookie_modal")[0].style.display = "flex"; |
| 390 | 404 | } |
| @@ -484,8 +498,10 @@ | ||
| 484 | 498 | if(cookieadmin_policy.cookieadmin_layout == "popup"){ |
| 485 | 499 | document.getElementsByClassName("cookieadmin_close_pref")[0].style.display = "none"; |
| 486 | 500 | } |
| 487 | 501 | |
| 502 | + var cookieadmin_modal_el = document.getElementsByClassName("cookieadmin_cookie_modal")[0]; | |
| 503 | + | |
| 488 | 504 | //show preference modal |
| 489 | 505 | cookieadmin_show_modal_elemnts = document.querySelectorAll(".cookieadmin_re_consent, .cookieadmin_customize_btn"); |
| 490 | 506 | cookieadmin_show_modal_elemnts.forEach(function(e){ |
| 491 | 507 | |
| @@ -518,8 +534,10 @@ | ||
| 518 | 534 | document.getElementsByClassName("cookieadmin_close_pref")[0].id = "cookieadmin_re_consent"; |
| 519 | 535 | }else{ |
| 520 | 536 | document.getElementsByClassName("cookieadmin_close_pref")[0].id = "cookieadmin_law_container"; |
| 521 | 537 | } |
| 538 | + | |
| 539 | + cookieadmin_modal_el.focus(); | |
| 522 | 540 | }); |
| 523 | 541 | }); |
| 524 | 542 | |
| 525 | 543 | //Save preference |
| @@ -598,24 +616,36 @@ | ||
| 598 | 616 | cookieadmin_set_consent(prefer2, days); |
| 599 | 617 | }); |
| 600 | 618 | }); |
| 601 | 619 | |
| 602 | - document.querySelectorAll(".cookieadmin_show_pref_cookies").forEach(function(e){ | |
| 603 | - e.addEventListener("click", function(el){ | |
| 604 | - | |
| 605 | - var tgt = el.target.id; | |
| 606 | - tgt = tgt.replace(/-container$/, ""); | |
| 607 | - | |
| 608 | - if(el.target.classList.contains("dwn")){ | |
| 609 | - el.target.innerHTML = "►"; | |
| 610 | - el.target.classList.remove("dwn"); | |
| 611 | - document.querySelector("."+tgt).style.display = "none"; | |
| 620 | + document.querySelectorAll(".cookieadmin_show_pref_cookies").forEach(function(btn){ | |
| 621 | + | |
| 622 | + // Shared toggle function | |
| 623 | + function toggleAccordion(event){ | |
| 624 | + // Use currentTarget to target the element with the listener, even if child nodes are clicked | |
| 625 | + var trigger = event.currentTarget; | |
| 626 | + var tgt = trigger.id.replace(/-container$/, ""); | |
| 627 | + var targetEl = document.querySelector("." + tgt); | |
| 628 | + | |
| 629 | + if (!targetEl){ | |
| 630 | + return; | |
| 631 | + }; | |
| 632 | + | |
| 633 | + if(trigger.classList.contains("dwn")){ | |
| 634 | + trigger.innerHTML = "►"; // Right arrow | |
| 635 | + trigger.classList.remove("dwn"); | |
| 636 | + trigger.setAttribute("aria-expanded", "false"); | |
| 637 | + targetEl.style.display = "none"; | |
| 612 | 638 | }else{ |
| 613 | - el.target.innerHTML = "▼"; | |
| 614 | - el.target.classList.add("dwn"); | |
| 615 | - document.querySelector("."+tgt).style.display = "block"; | |
| 639 | + trigger.innerHTML = "▼"; // Down arrow | |
| 640 | + trigger.classList.add("dwn"); | |
| 641 | + trigger.setAttribute("aria-expanded", "true"); | |
| 642 | + targetEl.style.display = "block"; | |
| 616 | 643 | } |
| 617 | - }); | |
| 644 | + } | |
| 645 | + | |
| 646 | + // 2. Native buttons fire click on mouse, Enter and Space | |
| 647 | + btn.addEventListener("click", toggleAccordion); | |
| 618 | 648 | }); |
| 619 | 649 | |
| 620 | 650 | document.getElementsByClassName("cookieadmin_close_pref")[0].addEventListener("click", function(e){ |
| 621 | 651 | document.getElementsByClassName("cookieadmin_cookie_modal")[0].style.display = "none"; |