1/* ====================================================== 2 # Cookies Policy Notification Bar for Joomla! - v5.1.1 (pro version) 3 # ------------------------------------------------------- 4 # For Joomla! CMS (v4.x, v5.x, v6.x) 5 # Author: Web357 (Yiannis Christodoulou) 6 # Copyright: (©) 2014-2026 Web357. All rights reserved. 7 # License: GNU/GPLv3, https://www.gnu.org/licenses/gpl-3.0.html 8 # Website: https://www.web357.com 9 # Demo: https://demo-joomla.web357.com/cookies-policy-notification-bar 10 # Support: [email protected] 11 # Last modified: Tuesday 22 September 2026, 09:15:47 PM 12 ========================================================= */ 13 14var categoriesSettingsCookie = {}; // Create array with all categories ID for: modalManager 15var categoriesSettingsCookieOuter = {}; //Create array with first id (outter) and second id (inner) 16var categoriesSettingsCookieInner = {}; //Create array with first id (inner) and second id (outter) 17var m_modalManager_confirmationText = ''; //Modal LOCKED-CHECKBOX Confirmation Alert 18var modalManagerSettings = []; 19 20var afterCategoriesSettingsCookie; 21var afterExpirationCookies; 22var cpnb_renderSettingsOverride = null; // temporary in-memory settings used for rendering scripts 23var settings = typeof cpnb_config !== 'undefined' ? cpnb_config : {}; 24 25window.addEventListener( 26 'load', 27 function () { 28 // Default Settings 29 var settings = { 30 w357_joomla_caching: 0, 31 w357_position: 'bottom', 32 w357_show_close_x_icon: 1, 33 w357_hide_after_time: 'yes', 34 w357_duration: 60, 35 w357_animate_duration: 1000, 36 w357_limit: 0, 37 w357_message: null, 38 w357_display_ok_btn: 1, 39 w357_buttonText: "Ok, I've understood!", 40 w357_display_decline_btn: 1, 41 w357_buttonDeclineText: 'Decline', 42 w357_display_cancel_btn: 1, 43 w357_buttonCancelText: 'Cancel', 44 w357_display_settings_btn: 1, 45 w357_buttonSettingsText: 'Settings', 46 w357_buttonMoreText: 'More Info', 47 w357_buttonMoreLink: '', 48 w357_display_more_info_btn: 1, 49 w357_fontColor: '#F1F1F3', 50 w357_linkColor: '#FFF', 51 w357_fontSize: '12px', 52 w357_backgroundColor: '#323A45', 53 w357_borderWidth: 1, 54 w357_body_cover: 1, 55 w357_overlay_state: 0, 56 w357_overlay_color: 'rgba(10,10,10, 0.3)', 57 w357_height: 'auto', 58 w357_cookie_name: 'cookiesDirective',
59 w357_cookie_name_declined: 'cpnbCookiesDeclined', 60 w357_cookie_name_cancelled: 'cpnbCookiesCancelled', 61 w357_has_consent_decision: 0, 62 w357_cookie_settings_value: null, 63 w357_link_target: '_self', 64 w357_popup_width: '800', 65 w357_popup_height: '600', 66 w357_customText: 67 'Your custom text for the cookies policy goes here...', 68 w357_more_info_btn_type: 'custom_text', 69 w357_blockCookies: 0, 70 w357_autoAcceptAfterScrolling: 0, 71 w357_numOfScrolledPixelsBeforeAutoAccept: 300, 72 w357_reloadPageAfterAccept: 0, 73 w357_enableConfirmationAlerts: 0, 74 w357_enableConfirmationAlertsForAcceptBtn: 0, 75 w357_enableConfirmationAlertsForDeclineBtn: 0, 76 w357_enableConfirmationAlertsForDeleteBtn: 0, 77 w357_confirm_allow_msg: 78 'Performing this action will enable all cookies set by this website. Are you sure that you want to enable all cookies on this website?', 79 w357_confirm_delete_msg: 80 'Performing this action will remove all cookies set by this website. Are you sure that you want to disable and delete all cookies from your browser?', 81 w357_show_in_iframes: 0, 82 w357_shortcode_is_enabled_on_this_page: 1, 83 w357_base_url: '', 84 w357_base_ajax_url: '', 85 w357_current_url: '', 86 w357_always_display: 0, 87 w357_show_notification_bar: true, 88 w357_expiration_cookies: 365, // days 89 w357_expiration_cookieSettings: 365, // days 90 w357_expiration_cookieAccept: 365, // days 91 w357_expiration_cookieDecline: 180, // days 92 w357_expiration_cookieCancel: 3, // days 93 w357_accept_button_class_notification_bar: 'cpnb-accept-btn', 94 w357_decline_button_class_notification_bar: 'cpnb-decline-btn', 95 w357_cancel_button_class_notification_bar: 'cpnb-cancel-btn', 96 w357_settings_button_class_notification_bar: 'cpnb-settings-btn', 97 w357_moreinfo_button_class_notification_bar: 'cpnb-moreinfo-btn', 98 w357_accept_button_class_notification_bar_modal_window: 99 'cpnb-accept-btn-m', 100 w357_decline_button_class_notification_bar_modal_window: 101 'cpnb-decline-btn-m', 102 w357_save_button_class_notification_bar_modal_window: 103 'cpnb-save-btn-m', 104 w357_buttons_ordering: '', 105 }; 106 107 var modalManager = { 108 // base settings 109 w357_m_modalState: 1, 110 w357_m_floatButtonState: 1, 111 w357_m_floatButtonPosition: 'bottom_left', 112 w357_m_HashLink: 'cookies', 113 114 // styling 115 w357_m_modal_menuItemSelectedBgColor: 'rgba(200, 200, 200, 1)', 116 w357_m_saveChangesButtonColorAfterChange: 'rgba(255, 202, 152, 1)', 117 w357_m_floatButtonIconSrc: 118 'media/plg_system_cookiespolicynotificationbar/icons/cpnb-cookies-manager-icon-1-64x64.png', 119 w357_m_FloatButtonIconType: 'image', 120 w357_m_FloatButtonIconFontAwesomeName: 'fas fa-cookie-bite', 121 w357_m_FloatButtonIconFontAwesomeSize: 'fa-lg', 122 w357_m_FloatButtonIconFontAwesomeColor: 'rgba(61, 47, 44, 0.84)', 123 w357_m_FloatButtonIconUikitName: 'cog', 124 w357_m_FloatButtonIconUikitSize: '1', 125 w357_m_FloatButtonIconUikitColor: 'rgba(61, 47, 44, 0.84)', 126 127 // texts 128 w357_m_floatButtonText: 'Cookies Manager', 129 w357_m_modalHeadingText: 'Advanced Cookie Settings', 130 w357_m_checkboxText: 'Enable', 131 w357_m_lockedText: '(Locked)', 132 w357_m_EnableAllButtonText: 'Allow All Cookies', 133 w357_m_DeclineAllButtonText: 'Decline All Cookies', 134 w357_m_SaveChangesButtonText: 'Save Settings', 135 w357_m_confirmationAlertRequiredCookies: 136 "These cookies are strictly necessary for this website. You can't disable this category of cookies. Thank y
136ou for understanding!", 137 }; 138 139 // var cpnb_config = {}; 140 141 // Get data from server, check for each if empty or null then use default settings 142 // EXAMPLE: PHP ECHO SCRIPT -> var newSettings = { .. } 143 var varsToBeParsedInt = [ 144 'w357_joomla_caching', 145 'w357_overlay_state', 146 'w357_borderWidth', 147 'w357_body_cover', 148 'w357_expiration_cookies', 149 'w357_expiration_cookieSettings', 150 'w357_expiration_cookieAccept', 151 'w357_expiration_cookieDecline', 152 'w357_expiration_cookieCancel', 153 'w357_duration', 154 'w357_animate_duration', 155 'w357_limit', 156 'w357_display_ok_btn', 157 'w357_display_decline_btn', 158 'w357_display_cancel_btn', 159 'w357_display_settings_btn', 160 'w357_display_more_info_btn', 161 'w357_blockCookies', 162 'w357_autoAcceptAfterScrolling', 163 'w357_numOfScrolledPixelsBeforeAutoAccept', 164 'w357_reloadPageAfterAccept', 165 'w357_enableConfirmationAlerts', 166 'w357_enableConfirmationAlertsForAcceptBtn', 167 'w357_enableConfirmationAlertsForDeclineBtn', 168 'w357_enableConfirmationAlertsForDeleteBtn', 169 'w357_show_in_iframes', 170 'w357_shortcode_is_enabled_on_this_page', 171 'w357_always_display', 172 ]; 173 for (var obj in cpnb_config) { 174 if ((cpnb_config[obj] !== null) & (cpnb_config[obj] !== '')) { 175 if (varsToBeParsedInt.indexOf(obj) >= 0) { 176 var rawValue = cpnb_config[obj]; 177 if ( 178 typeof rawValue === 'string' && 179 rawValue.trim().toUpperCase() === 'SESSION' 180 ) { 181 settings[obj] = 'SESSION'; 182 } else { 183 settings[obj] = parseInt(rawValue); // Overwrite settings 184 } 185 } else { 186 settings[obj] = cpnb_config[obj]; //Overwrite settings 187 } 188 } 189 } 190 191 // Create-Read Cookie Limit => cpnb_cookie_limit + Check if higher + counter warning seen 192 if (settings.w357_limit > 0) { 193 if (cpnb_readCookie('cpnb_cookie_limit') == null) { 194 // Create cookie limit 195 cpnb_createCookie( 196 'cpnb_cookie_limit', 197 1, 198 settings.w357_expiration_cookies 199 ); 200 } else { 201 // Counter +1 and Check if higher 202 if (settings.w357_blockCookies == 0) { 203 var counterCookie = 204 parseInt(cpnb_readCookie('cpnb_cookie_limit')) + 1; 205 cpnb_createCookie( 206 'cpnb_cookie_limit', 207 counterCookie, 208 settings.w357_expiration_cookies 209 ); 210 } 211 } 212 } 213 214 // Used in "if statement" for design perpuse (margin-top), so as not to hide text 215 var warning_div_position = [ 216 'top-left', 217 'top-right', 218 'bottom-left', 219 'bottom-right', 220 'center', 221 ]; 222 223 // Check if Iframe 224 function cpnb_checkDIfIframeDisplay() { 225 if (settings.w357_show_in_iframes == 0) { 226 if (self == top) { 227 return true; // Not In frame 228 } else { 229 return false; // In frame 230 } 231 } else { 232 return true; 233 } 234 } 235 236 // Check Always Display 237 // cpnb_createCookie("cpnb_cookie_alwaysDisplay", settings.w357_always_display, settings.w357_expiration_cookies); 238 function cpnb_checkAlwaysDisplay() { 239 if (settings.w357_always_display == 1) { 240 return true; 241 } 242 return !cpnb_hasAnyConsentDecision(settings); 243 } 244 245 // Check Limit (cookie: cpnb_cookie_limit)
246 function cpnb_checkCookieLimitDisplay() { 247 if (settings.w357_always_display !== 1) { 248 if (settings.w357_limit > 0) { 249 if (cpnb_readCookie('cpnb_cookie_limit') !== null) { 250 var counterCookie = parseInt( 251 cpnb_readCookie('cpnb_cookie_limit') 252 ); 253 if (counterCookie > settings.w357_limit) { 254 return false; 255 } else { 256 return true; 257 } 258 } 259 } else { 260 return true; 261 } 262 } else { 263 return true; 264 } 265 } 266 267 window.cpnb_handleKeyboardActivate=function (event) { 268 var key = event.key || event.keyCode; 269 if (key === 'Enter' || key === ' ' || key === 13 || key === 32) { 270 event.preventDefault(); 271 event.target.click(); 272 } 273 } 274 275 // Max-height create 276 var windowHeight = 277 window.innerHeight || 278 document.documentElement.clientHeight || 279 document.body.clientHeight; 280 var maxHeight = windowHeight - 0.2 * windowHeight; 281 maxHeight = parseInt(maxHeight.toFixed(0)); 282 var marginTopWindow = windowHeight * 0.06; 283 marginTopWindow = parseInt(marginTopWindow.toFixed(0)); 284 285 // Check if => iFrame && Always Display (w357_always_display) && Limit (cpnb_cookie_limit) 286 if ( 287 cpnb_checkDIfIframeDisplay() && 288 cpnb_checkAlwaysDisplay() &&
289 cpnb_checkCookieLimitDisplay() && 290 settings.w357_show_notification_bar == true 291 ) { 292 // Create js to show warning 293 var elem = document.createElement('div'); 294 295 // MaxHeight for WarningBox 296 var maxHeightWarningBox = 297 window.innerHeight || 298 document.documentElement.clientHeight || 299 document.body.clientHeight; 300 maxHeightWarningBox -= 40; 301 302 var cnbwb = ''; 303 cnbwb += 304 ' <div id="cpnb" class="cpnb" data-cookie-name="' + 305 decodeURI(settings.w357_cookie_name) + 306 '">'; 307 cnbwb += 308 ' <div role="contentinfo" aria-label="Cookie consent notification" class="cpnb-warningBox-show-fade-in cpnb-outer cpnb-div-position-' + 309 settings.w357_position + 310 '" id="w357_cpnb_outer" style=" display: flex; justify-content: center; flex-direction: column; position: fixed; height: ' + 311 settings.w357_height + 312 '; background: ' + 313 settings.w357_backgroundColor + 314 '; color: ' + 315 settings.w357_fontColor + 316 '; font-size: ' + 317 settings.w357_fontSize + 318 ';">'; 319 320 // Close X icon 321 let cpnb_close_icon_html = ''; 322 if ( 323 settings.w357_show_close_x_icon == 1 && 324 settings.w357_position != 'top' && 325 settings.w357_position != 'bottom' 326 ) { 327 var cookieNameFun = settings.w357_cookie_name; 328 var linkFun = settings.w357_current_url; 329 var expiration = settings.w357_expiration_cookieCancel; 330 cpnb_close_icon_html = 331 ' <span id="cpnb-close-x-btn" onClick="cpnb_warning_cancel_button(\'' + 332 cookieNameFun + 333 "', '" + 334 expiration + 335 "', '" + 336 linkFun + 337 "', '" + 338 settings.w357_overlay_state + 339 '\')" class="cpnb-x-close-icon"></span>'; 340 } 341 342 if ( 343 (settings.w357_message !== null) & 344 (settings.w357_message !== '') 345 ) { 346 cnbwb += 347 ' <div class="cpnb-inner" style="max-height: ' + 348 maxHeightWarningBox + 349 'px;">' + 350 cpnb_close_icon_html + 351 '<div class="cpnb-message">' + 352 decodeURI(settings.w357_message) + 353 '</div>'; 354 } else { 355 cnbwb += 356 ' <div class="cpnb-inner" style="max-height: ' + 357 maxHeightWarningBox + 358 'px;">' + 359 cpnb_close_icon_html + 360 '<div class="cpnb-message">We use cookies to improve your experience on our website. By browsing this website, you agree to our use of cookies.</div>'; 361 } 362 363 if (warning_div_position.indexOf(settings.w357_position) >= 0) { 364 cnbwb += ' <div class="cpnb-buttons" style="margin-top:10px;">'; 365 } else { 366 cnbwb += ' <div class="cpnb-buttons">'; 367 } 368 369 // BEGIN: Buttons Sorting 370 var buttons_ordering_array = JSON.parse( 371 settings.w357_buttons_ordering 372 ); 373 for (var i = 0; i < buttons_ordering_array.length; i++) { 374 var btn = buttons_ordering_array[i]; 375 switch (btn) { 376 case 'ok': 377 // ACCEPT BUTTON 378 if (settings.w357_display_ok_btn == 1) { 379 var enableConfirFun = 380 settings.w357_enableConfirmationAlertsForAcceptBtn; 381 var msgFun = settings.w357_confirm_allow_msg; 382 var cookieNameFun = settings.w357_cookie_name; 383 var linkFun = settings.w357_current_url; 384 var expiration = 385 settings.w357_expiration_cookieAccept; 386 cnbwb += 387 ' <span id="cpnb-accept-btn" role="button" tabindex="0" onkeydown="cpnb_handleKeyboardActivate(event)" onkeypress="cpnb_handleKeyboardActivate(event)" aria-label="' + 388 decodeURI(settings.w357_buttonText) + 389 '" onClick="cpnb_warning_accept_button(\'' + 390 settings.w357_joomla_caching + 391 "', '" + 392 decodeURI(enableConfirFun) + 393 "', '" + 394 decodeURI(msgFun) + 395 "', '" + 396 cookieNameFun + 397 "', '" + 398 linkFun + 399 "', '" + 400 expiration + 401 "', '" + 402 settings.w357_base_ajax_url + 403 "', 'notification_bar', '" + 404 settings.w357_reloadPageAfterAccept + 405 "', '" + 406 settings.w357_overlay_state + 407 '\')" class="cpnb-button cpnb-button-ok ' + 408 decodeURI( 409 settings.w357_accept_button_class_notification_bar 410 ) + 411 '">' + 412 decodeURI(settings.w357_buttonText) + 413 '</span>'; 414 } 415 break; 416 417 case 'decline': 418 // DECLINE BUTTON 419 if (settings.w357_display_decline_btn == 1) { 420 var enableConfirFun = 421 settings.w357_enableConfirmationAlertsForDeclineBtn; 422 var msgFun = settings.w357_confirm_delete_msg; 423 var cookieNameFun = settings.w357_cookie_name; 424 var linkFun = settings.w357_current_url; 425 var expiration = 426 settings.w357_expiration_cookieDecline; 427 cnbwb += 428 ' <span id="cpnb-decline-btn" role="button" tabindex="0" onkeydown="cpnb_handleKeyboardActivate(event)" onkeypress="cpnb_handleKeyboardActivate(event)" aria-label="' + 429 decodeURI(settings.w357_buttonDeclineText) + 430 '" onClick="cpnb_warning_decline_button(\'' + 431 settings.w357_joomla_caching + 432 "', '" + 433 decodeURI(enableConfirFun) + 434 "', '" + 435 decodeURI(msgFun) + 436 "', '" + 437 cookieNameFun + 438 "', '" + 439 linkFun + 440 "', '" + 441 expiration + 442 '\')" class="cpnb-button cpnb-button-decline ' + 443 decodeURI( 444 settings.w357_decline_button_class_notification_bar 445 ) + 446 '">' + 447 decodeURI(settings.w357_buttonDeclineText) + 448 '</span>'; 449 } 450 break; 451 452 case 'cancel': 453 // CANCEL BUTTON
454 if (settings.w357_display_cancel_btn == 1) { 455 var cookieNameFun = settings.w357_cookie_name; 456 var linkFun = settings.w357_current_url; 457 var expiration = 458 settings.w357_expiration_cookieCancel; 459 cnbwb += 460 ' <span id="cpnb-cancel-btn" role="button" tabindex="0" onkeydown="cpnb_handleKeyboardActivate(event)" onkeypress="cpnb_handleKeyboardActivate(event)" aria-label="' + 461 decodeURI(settings.w357_buttonCancelText) + 462 '" onClick="cpnb_warning_cancel_button(\'' + 463 cookieNameFun + 464 "', '" + 465 expiration + 466 "', '" + 467 linkFun + 468 "', '" + 469 settings.w357_overlay_state + 470 '\')" class="cpnb-button cpnb-button-cancel ' + 471 decodeURI( 472 settings.w357_cancel_button_class_notification_bar 473 ) + 474 '">' + 475 decodeURI(settings.w357_buttonCancelText) + 476 '</span>'; 477 } 478 break; 479 480 case 'moreinfo': 481 // MORE INFO BUTTON 482 if (settings.w357_display_more_info_btn == 1) { 483 if ( 484 settings.w357_more_info_btn_type == 'link' || 485 settings.w357_more_info_btn_type == 'menu_item' 486 ) { 487 if (settings.w357_link_target == '_self') { 488 cnbwb += 489 ' <a id="cpnb-moreinfo-btn" href="' + 490 settings.w357_buttonMoreLink + 491 '" target="_self" class="cpnb-button cpnb-button-more-default ' + 492 decodeURI( 493 settings.w357_moreinfo_button_class_notification_bar 494 ) + 495 '">' + 496 decodeURI( 497 settings.w357_buttonMoreText 498 ) + 499 '</a>'; 500 } else if ( 501 settings.w357_link_target == '_blank' 502 ) { 503 cnbwb += 504 ' <a id="cpnb-moreinfo-btn" href="' + 505 settings.w357_buttonMoreLink + 506 '" target="_blank" class="cpnb-button cpnb-button-more-default ' + 507 decodeURI( 508 settings.w357_moreinfo_button_class_notification_bar 509 ) + 510 '">' + 511 decodeURI( 512 settings.w357_buttonMoreText 513 ) + 514 '</a>'; 515 } else if ( 516 settings.w357_link_target == 'popup' 517 ) { 518 cnbwb += 519 ' <span id="cpnb-moreinfo-btn" role="button" tabindex="0" onkeydown="cpnb_handleKeyboardActivate(event)" onkeypress="cpnb_handleKeyboardActivate(event)" aria-label="' + 520 decodeURI( 521 settings.w357_buttonMoreText 522 ) + 523 '" onClick="w357_openPopUpWindowMoreInfo(\'' + 524 settings.w357_buttonMoreLink + 525 "','titlos', '" + 526 settings.w357_popup_height + 527 "', '" + 528 settings.w357_popup_width + 529 '\')" class="cpnb-button cpnb-button-more-default ' + 530 decodeURI( 531 settings.w357_moreinfo_button_class_notification_bar 532 ) + 533 '">' + 534 decodeURI( 535 settings.w357_buttonMoreText 536 ) + 537 '</span>'; 538 } 539 } else if ( 540 settings.w357_more_info_btn_type == 541 'custom_text' 542 ) { 543 cnbwb += 544 ' <span id="cpnb-moreinfo-btn" role="button" tabindex="0" onkeydown="cpnb_handleKeyboardActivate(event)" onkeypress="cpnb_handleKeyboardActivate(event)" aria-label="' + 545 decodeURI(settings.w357_buttonMoreText) + 546 '" onClick="cpnb_openModalMoreInfo()" class="cpnb-button cpnb-button-more-default ' + 547 decodeURI( 548 settings.w357_moreinfo_button_class_notification_bar 549 ) + 550 '" id="cpnb_button_more_modal">' + 551 decodeURI(settings.w357_buttonMoreText) + 552 '</span>'; 553 } 554 } 555 556 break; 557 558 case 'settings': 559 // SETTINGS BUTTON 560 if (settings.w357_display_settings_btn == 1) { 561 cnbwb += 562 ' <span id="cpnb-settings-btn" role="button" tabindex="0" onkeydown="cpnb_handleKeyboardActivate(event)" onkeypress="cpnb_handleKeyboardActivate(event)" aria-label="' + 563 decodeURI(settings.w357_buttonSettingsText) + 564 '" onClick="cpnb_m_openModal()" class="cpnb-button cpnb-button-settings ' + 565 decodeURI( 566 settings.w357_settings_button_class_notification_bar 567 ) + 568 '">' + 569 decodeURI(settings.w357_buttonSettingsText) + 570 '</span>'; 571 } 572 573 break; 574 575 default: 576 // nothing to display 577 break; 578 } 579 } 580 // END: Buttons Sorting 581 582 cnbwb += ' <div class="cpnb-clear-both"></div>';
583 cnbwb += ' </div>'; 584 cnbwb += ' </div>'; 585 cnbwb += ' </div>'; 586 cnbwb += '</div>'; 587 588 // Check if background overlay is enabled 589 if (settings.w357_overlay_state == 1) { 590 cnbwb += 591 '<div id="cpnb_warningBoxBgOverlay" style="background-color:' + 592 settings.w357_overlay_color + 593 ';">'; 594 } 595 596 elem.innerHTML = cnbwb; 597 document.body.insertBefore(elem, document.body.firstChild); 598 599 //Center WarningBox Style 600 if (settings.w357_position == 'center') { 601 var windowWidth = 602 window.innerWidth || 603 document.documentElement.clientWidth || 604 document.body.clientWidth; 605 var warningBoxHeight = 606 document.getElementById('w357_cpnb_outer').clientHeight; 607 var pus = document.createElement('style'); 608 pus.type = 'text/css'; 609 pus.innerHTML = 610 '.cpnb-div-position-center {top:0; left:0; margin-top: ' + 611 (windowHeight - warningBoxHeight) / 2 + 612 'px; margin-left: ' + 613 (windowWidth - 500) / 2 + 614 'px} '; 615 document.getElementsByTagName('head')[0].appendChild(pus); 616 } 617 618 // Auto-accept after scrolling 619 if (settings.w357_autoAcceptAfterScrolling) { 620 var scroll_counter = 0; 621 window.addEventListener('scroll', function () { 622 if (scroll_counter == 0) { 623 // if counter is 1, it will not execute 624 if ( 625 window.pageYOffset > 626 settings.w357_numOfScrolledPixelsBeforeAutoAccept 627 ) { 628 var enableConfirFun = 629 settings.w357_enableConfirmationAlertsForAcceptBtn; 630 var msgFun = settings.w357_confirm_allow_msg; 631 var cookieNameFun = settings.w357_cookie_name; 632 var linkFun = settings.w357_current_url; 633 var expiration = 634 settings.w357_expiration_cookieAccept; 635 636 cpnb_warning_accept_button( 637 settings.w357_joomla_caching, 638 decodeURI(enableConfirFun), 639 decodeURI(msgFun), 640 cookieNameFun, 641 linkFun, 642 expiration, 643 settings.w357_base_ajax_url, 644 'notification_bar', 645 settings.w357_reloadPageAfterAccept, 646 settings.w357_overlay_state 647 ); 648 649 scroll_counter++; // increment the counter by 1, new value = 1 650 } 651 } 652 }); 653 } 654 655 // Timeout Duration function, Hide warning box box-shadow => w357_duration 656 function cpnb_hideInfoBox(ms, gapMs) { 657 setTimeout(function () { 658 var e = document.getElementById('w357_cpnb_outer'); 659 if (e) { 660 e.classList.remove('cpnb-warningBox-show-fade-in'); 661 e.classList.add('cpnb-warningBox-show-fade-out'); 662 } 663 664 if (settings.w357_overlay_state == 1) { 665 var overlay = document.getElementById( 666 'cpnb_warningBoxBgOverlay' 667 ); 668 if (overlay) { 669 overlay.classList.add( 670 'cpnb-warningBox-show-fade-out' 671 ); 672 } 673 } 674 }, ms); 675 // Hide warning 676 setTimeout(function () { 677 var bar = document.getElementById('w357_cpnb_outer'); 678 if (bar) { 679 bar.style.display = 'none'; 680 } 681 if (settings.w357_overlay_state == 1) {
682 var overlay = document.getElementById( 683 'cpnb_warningBoxBgOverlay' 684 ); 685 if (overlay) { 686 overlay.style.display = 'none'; 687 } 688 } 689 }, ms + gapMs); 690 } 691 692 // Hide the notification bar after X seconds 693 if (settings.w357_hide_after_time != 'display_always') { 694 cpnb_hideInfoBox( 695 settings.w357_duration * 1000, 696 settings.w357_animate_duration 697 ); 698 } 699 700 // Create style WarningBox duration open & close 701 var stDur = settings.w357_animate_duration / 1000; 702 703 // If border on warning box, problem with animation height. 704 var offsetHeightBorderx1 = ['top', 'bottom']; 705 if (offsetHeightBorderx1.indexOf(settings.w357_position) >= 0) { 706 var subOffsetHeight = settings.w357_borderWidth; 707 } else { 708 var subOffsetHeight = settings.w357_borderWidth * 2; 709 } 710 711 var offsetHeight = 712 document.getElementById('w357_cpnb_outer').offsetHeight - 713 subOffsetHeight; 714 var w357_cpnb_outer_height = 715 document.getElementById('w357_cpnb_outer').offsetHeight; 716 717 var pus = document.createElement('style'); 718 pus.type = 'text/css'; 719 pus.innerHTML = 720 '.cpnb-warningBox-show-fade-in {overflow:hidden; animation-name: slidein; animation-duration: ' + 721 stDur + 722 's;} '; 723 pus.innerHTML += 724 '.cpnb-warningBox-show-fade-out { opacity:0; overflow:hidden; padding:0; animation-name: slideout; animation-duration: ' + 725 stDur + 726 's;} '; 727 pus.innerHTML += 728 '@keyframes slidein { from { height:0px; opacity:0; } to { height:' + 729 offsetHeight + 730 'px; opacity:1;} }'; 731 pus.innerHTML += 732 '@keyframes slideout { from { opacity:1; } to { opacity:0; } }'; 733 document.getElementsByTagName('head')[0].appendChild(pus); 734 735 // Create Modal 736 if (settings.w357_more_info_btn_type == 'custom_text') { 737 // Create style with modal duration open & close 738 var stDur = settings.w357_animate_duration / 5000; 739 var pus = document.createElement('style'); 740 pus.type = 'text/css'; 741 pus.innerHTML = 742 '.cpnb-modal-show-fade-in { visibility: visible; opacity: 1; -webkit-transition: opacity ' + 743 stDur + 744 's, visibility ' + 745 stDur + 746 's; transition: opacity ' + 747 stDur + 748 's, visibility ' + 749 stDur + 750 's; } '; 751 pus.innerHTML += 752 '.cpnb-modal-show-fade-out { visibility: hidden; opacity: 0; -webkit-transition: opacity ' + 753 stDur + 754 's, visibility ' + 755 stDur + 756 's; transition: opacity ' + 757 stDur + 758 's, visibility ' + 759 stDur + 760 's; } '; 761 document.getElementsByTagName('head')[0].appendChild(pus); 762 763 var elem = document.createElement('div'); 764 var cnbwb = 765 '<div id="cpnb_modal_wrap" class="cpnb-modal-wrap cpnb-modal-show-fade-out">'; 766 cnbwb += 767 ' <div class="cpnb-modal-outer cpnb-modal-bg cpnb-close" id="cpnb_outter-moreinfo" style="top: 0px; left: 0px; align-items: flex-start;">'; 768 cnbwb += 769 ' <div class="cpnb-modal-inner cpnb-modal--medium" id="cpnb_inner-moreinfo" style="z-index: 100000000; max-height:' + 770 maxHeight + 771 'px; margin-top:' + 772 marginTopWindow + 773 'px;">'; 774 cnbwb += 775 ''; 776 cnbwb += 777 ' <div class="cpnb-modal-inner-text">' + 778 settings.w357_customText + 779 '</div>'; 780 cnbwb += 781 ' <span role="button" tabindex="0" onkeydown="cpnb_handleKeyboardActivate(event)" onkeypress="cpnb_handleKeyboardActivate(event)" aria-label="Close" onClick="cpnb_closeModalMoreInfo()" id="cpnb-modal-close-moreinfo" class="cpnb-modal-close cpnb-close cpnb-close-icon-x"></span>'; 782 cnbwb += 783 ' <div id="close_cpnb_modal_footer" class="cpnb-modal-footer">'; 784 cnbwb += 785 ' <div id="close_cpnb_modal_actions" class="cpnb-modal-actions">'; 786 787 // BEGIN: Buttons Sorting 788 var buttons_ordering_array = JSON.parse( 789 settings.w357_buttons_ordering 790 ); 791 for (var i = 0; i < buttons_ordering_array.length; i++) { 792 var btn = buttons_ordering_array[i]; 793 switch (btn) { 794 case 'ok': 795 // ACCEPT BUTTON 796 if (settings.w357_display_ok_btn == 1) { 797 var msgFun = settings.w357_confirm_allow_msg; 798 var expiration = 799 settings.w357_expiration_cookieAccept; 800 var linkFun = settings.w357_current_url; 801 cnbwb += 802 ' <span id="cpnb-accept-btn-m-info" role="button" tabindex="0" onkeydown="cpnb_handleKeyboardActivate(event)" onkeypress="cpnb_handleKeyboardActivate(event)" aria-label="' + 803 decodeURI(settings.w357_buttonText) + 804 '" onClick="cpnb_warning_accept_button(\'' + 805 settings.w357_joomla_caching + 806 "', '" + 807 decodeURI(enableConfirFun) + 808 "', '" + 809 decodeURI(msgFun) + 810 "', '" + 811 cookieNameFun + 812 "', '" + 813 linkFun + 814 "', '" + 815 expiration + 816 "', '" + 817 settings.w357_base_ajax_url + 818 "', 'modal', '" + 819 settings.w357_reloadPageAfterAccept + 820 "', '" + 821 settings.w357_overlay_state + 822 '\')" class="cpnb-button cpnb-button-ok ' + 823 decodeURI( 824 settings.w357_accept_button_class_notification_bar 825 ) + 826 '">' + 827 decodeURI(settings.w357_buttonText) + 828 '</span>'; 829 } 830 break; 831 832 case 'decline': 833 // DECLINE BUTTON 834 if (settings.w357_display_decline_btn == 1) { 835 var msgFun = settings.w357_confirm_delete_msg; 836 var expiration = 837 settings.w357_expiration_cookieDecline; 838 var linkFun = settings.w357_current_url; 839 cnbwb += 840 ' <span id="cpnb-decline-btn-m-info" role="button" tabindex="0" onkeydown="cpnb_handleKeyboardActivate(event)" onkeypress="cpnb_handleKeyboardActivate(event)" aria-label="' + 841 decodeURI(settings.w357_buttonDeclineText) + 842 '" onClick="cpnb_warning_decline_button(\'' + 843 settings.w357_joomla_caching + 844 "', '" + 845 decodeURI(enableConfirFun) + 846 "', '" + 847 decodeURI(msgFun) + 848 "', '" + 849 cookieNameFun + 850 "', '" + 851 linkFun + 852 "', '" + 853 expiration + 854 "', true)\" class=\"cpnb-button cpnb-button-decline " + 855 decodeURI( 856 settings.w357_decline_button_class_notification_bar 857 ) + 858 '">' + 859 decodeURI(settings.w357_buttonDeclineText) + 860 '</span>'; 861 } 862 break; 863 864 case 'cancel': 865 // CANCEL BUTTON
866 if (settings.w357_display_cancel_btn == 1) { 867 var expiration = 868 settings.w357_expiration_cookieCancel; 869 var linkFun = settings.w357_current_url; 870 cnbwb += 871 ' <span id="cpnb-cancel-btn-m-info" role="button" tabindex="0" onkeydown="cpnb_handleKeyboardActivate(event)" onkeypress="cpnb_handleKeyboardActivate(event)" aria-label="' + 872 decodeURI(settings.w357_buttonCancelText) + 873 '" onClick="cpnb_warning_cancel_button(\'' + 874 cookieNameFun + 875 "', '" + 876 expiration + 877 "', '" + 878 linkFun + 879 "', '" + 880 settings.w357_overlay_state + 881 "', true)\" class=\"cpnb-button cpnb-button-cancel " + 882 decodeURI( 883 settings.w357_cancel_button_class_notification_bar 884 ) + 885 '">' + 886 decodeURI(settings.w357_buttonCancelText) + 887 '</span>'; 888 } 889 break; 890 891 case 'settings': 892 // SETTINGS BUTTON 893 if (settings.w357_display_settings_btn == 1) { 894 cnbwb += 895 ' <span id="cpnb-settings-btn-m-info" role="button" tabindex="0" onkeydown="cpnb_handleKeyboardActivate(event)" onkeypress="cpnb_handleKeyboardActivate(event)" aria-label="' + 896 decodeURI( 897 settings.w357_buttonSettingsText 898 ) + 899 '" onClick="cpnb_m_openModal(); cpnb_closeModalMoreInfo();" class="cpnb-button cpnb-button-settings ' + 900 decodeURI( 901 settings.w357_settings_button_class_notification_bar 902 ) + 903 '">' + 904 decodeURI( 905 settings.w357_buttonSettingsText 906 ) + 907 '</span>'; 908 } 909 910 break; 911 912 default: 913 // nothing to display 914 break; 915 } 916 } 917 // END: Buttons Sorting 918 919 cnbwb += ' </div>'; 920 cnbwb += ' </div>'; 921 cnbwb += ' </div>'; 922 cnbwb += 923 ' <div class="cpnb-modal-show-fade-out" id="modal_close_bg" role="button" tabindex="0" aria-label="Close modal" onkeydown="cpnb_handleKeyboardActivate(event)" onkeypress="cpnb_handleKeyboardActivate(event)" onClick="cpnb_closeModalMoreInfo()" style=" z-index: 99999999; top:0; left:0; position:fixed; width:100%; height:100%;"></div>'; 924 cnbwb += ' </div>'; 925 cnbwb += '</div>'; 926 elem.innerHTML = cnbwb; 927 document.body.insertBefore(elem, document.body.firstChild); 928 } 929 } // END: Check if => iFrame && Always Display (w357_always_display) && Limit (cpnb_cookie_limit) 930 931 // Do not cover the body of the page. 932 if (settings.w357_body_cover === 0) { 933 if (w357_cpnb_outer_height != null && w357_cpnb_outer_height > 0) { 934 if (settings.w357_position == 'top') { 935 document.getElementsByTagName('body')[0].style.paddingTop = 936 w357_cpnb_outer_height + 'px'; 937 } else { 938 document.getElementsByTagName( 939 'body' 940 )[0].style.paddingBottom = w357_cpnb_outer_height + 'px'; 941 } 942 } 943 } 944 945 ////***************** START MANAGER *****************///
945/ 946 // Get data from server, check for each if empty or null then use default settings 947 // EXAMPLE: PHP ECHO SCRIPT -> var newSettings = { .. } 948 949 //Overide ModalManager settings 950 var varsToBeParsedInt = [ 951 'w357_m_modalState', 952 'w357_m_floatButtonState', 953 ]; 954 //var cpnb_manager = []; 955 for (var obj in cpnb_manager) { 956 if ((cpnb_manager[obj] !== null) & (cpnb_manager[obj] !== '')) { 957 if (varsToBeParsedInt.indexOf(obj) >= 0) { 958 modalManager[obj] = parseInt(cpnb_manager[obj]); // Overwrite settings 959 } else { 960 modalManager[obj] = cpnb_manager[obj]; //Overwrite settings 961 } 962 } 963 } 964 965 modalManagerSettings = modalManager; 966 967 //Get array with information about cookies categories (Read Cookie) 968 var settingsPayload = cpnb_getConsentCookiePayload( 969 'cpnb_cookiesSettings' 970 ); 971 if (settingsPayload && settingsPayload.v) { 972 categoriesSettingsCookie = settingsPayload.v; 973 } else { 974 categoriesSettingsCookie = {}; 975 //categoriesSettingsCookie = {"required-cookies":1,"analytical-cookies":0,"social-media-cookies":0,"targeted-advertising-cookies":0}; 976 } 977 978 //cpnb_createCookie("cpnb_cookiesSettings", JSON.stringify(categoriesSettingsCookie), settings.w357_expiration_cookies); 979 afterCategoriesSettingsCookie = categoriesSettingsCookie; 980 afterExpirationCookies = settings.w357_expiration_cookieSettings; 981 cpnb_syncConsentCookieExpiration( 982 settings.w357_cookie_name, 983 settings.w357_expiration_cookieAccept 984 ); 985 cpnb_syncConsentCookieExpiration( 986 settings.w357_cookie_name_declined, 987 settings.w357_expiration_cookieDecline 988 ); 989 cpnb_syncConsentCookieExpiration( 990 settings.w357_cookie_name_cancelled, 991 settings.w357_expiration_cookieCancel 992 ); 993 cpnb_syncConsentCookieExpiration( 994 'cpnb_cookiesSettings', 995 settings.w357_expiration_cookieSettings 996 ); 997 cpnb_syncConsentCookieExpiration( 998 'cpnb_cookiesSettingsTemp', 999 settings.w357_expiration_cookieSettings 1000 ); 1001 1002 // Sync any blocked scripts that should run before/after consent on page load (init) 1003 cpnb_handleBlockCookieScripts(); 1004 1005 // After the first post-accept reload, poll until document.cookie stops changing 1006 // (meaning GA4/GTM scripts have finished writing their cookies), then reload so 1007 // the {cookiesinfo} shortcode table includes _ga_XXXX and similar async cookies. 1008 try { 1009 if (localStorage.getItem('cpnb_shortcode_cookie_reload') === '1' && settings.w357_shortcode_is_enabled_on_this_page == 1) { 1010 localStorage.removeItem('cpnb_shortcode_cookie_reload'); 1011 var _cpnbPollStart = Date.now(); 1012 var _cpnbPollBaseline = document.cookie; 1013 var _cpnbPollSnapshot = _cpnbPollBaseline; 1014 var _cpnbPollTimer = setInterval(function () { 1015 var _cpnbNow = Date.now(); 1016 var _cpnbCurrent = document.cookie; 1017 var _cpnbStable = (_cpnbCurrent === _cpnbPollSnapshot && (_cpnbNow - _cpnbPollStart) >= 1000); 1018 var _cpnbTimeout = (_cpnbNow - _cpnbPollStart) >= 8000; 1019 if (_cpnbStable || _cpnbTimeout) { 1020 clearInterval(_cpnbPollTimer); 1021 // Only re-fetch the table if GA4/GTM wrote new cookies since the page loaded. 1022 // If nothing changed, the DOMContentLoaded fetch already showed the correct state. 1023 if (_cpnbCurrent !== _cpnbPollBaseline) { 1024 var _cpnbCitEl = document.getElementById('cpnb-cit-container'); 1025 if (_cpnbCitEl && _cpnbCitEl.getAttribute('data-cpnb-table-ajax')) { 1026 cpnb_fetchCookiesInfoTable(); 1027 } else { 1028 window.location.reload(); 1029 } 1030 } 1031 } 1032 _cpnbPollSnapshot = _cpnbCurrent; 1033 }, 850); 1034 } 1035 } catch (e) { 1036 } 1037 1038 //Check if ModalManager is enabled 1039 if ( 1040 cpnb_checkDIfIframeDisplay() && 1041 settings.w357_blockCookies == 1 && 1042 modalManager.w357_m_modalState == 1 1043 ) { 1044 //Pass Modal LOCKED-CHECKBOX Confirmation Alert 1045 m_modalManager_confirmationText =
1046 modalManager.w357_m_confirmationAlertRequiredCookies; 1047 1048 //Create Left Menu Item Selected Class 1049 var pus = document.createElement('style'); 1050 pus.type = 'text/css'; 1051 pus.innerHTML = 1052 '.cpnb-manager-modal-left-item-selected, .cpnb-manager-modal-left-item-unSelected:hover, .cpnb-manager-modal-left-item-unSelected:focus {background: ' + 1053 modalManager.w357_m_modal_menuItemSelectedBgColor + 1054 ';} '; 1055 document.getElementsByTagName('head')[0].appendChild(pus); 1056 1057 var HTMLleftMenu = ''; 1058 var HTMLinformationBoxes = ''; 1059 var categoriesCounter = 0; //Pick first category and first box with information to show. 1060 1061 // Open-Close Left Menu Button 1062 HTMLinformationBoxes += 1063 '<div class="cpnb-left-menu-toggle" role="button" tabindex="0" onkeydown="cpnb_handleKeyboardActivate(event)" onkeypress="cpnb_handleKeyboardActivate(event)" onClick="cpnb_toggle_responsive_menu(this)">'; 1064 HTMLinformationBoxes += 1065 '<div class="cpnb-toggle-menu-container cpnb-left-menu-toggle-button">'; 1066 HTMLinformationBoxes += '<div class="cpnb-toggle-menu-bar1"></div>'; 1067 HTMLinformationBoxes += '<div class="cpnb-toggle-menu-bar2"></div>'; 1068 HTMLinformationBoxes += '<div class="cpnb-toggle-menu-bar3"></div>'; 1069 HTMLinformationBoxes += '</div>'; 1070 HTMLinformationBoxes += '</div>'; 1071 1072 // Modal Manager HEADER 1073 HTMLinformationBoxes += 1074 '<div class="h2 cpnb-m-header">' + 1075 modalManager.w357_m_modalHeadingText + 1076 '</div>'; 1077 1078 for (var categoryID in cpnb_cookiesCategories) { 1079 if ( 1080 cpnb_cookiesCategories[categoryID].cookie_category_status == 1081 1 1082 ) { 1083 var innerCookieCategory = 1084 cpnb_cookiesCategories[categoryID].cookie_category_id; 1085 1086 categoriesCounter++; 1087 1088 // Check if First Category 1089 if (categoriesCounter == 1) { 1090 // Create menu item 1091 HTMLleftMenu += 1092 '<div role="button" tabindex="0" onkeydown="cpnb_handleKeyboardActivate(event)" onkeypress="cpnb_handleKeyboardActivate(event)" aria-label="' + 1093 cpnb_cookiesCategories[categoryID] 1094 .cookie_category_name + 1095 '" onClick="cpnb_m_changeModalCategory(\'' + 1096 categoryID + 1097 '\')" id="mlm_menu_category_id_' + 1098 categoryID + 1099 '" class="cpnb-manager-modal-left-item-selected cpnb-manager-modal-left-item modal-left-menu-item-id-' + 1100 categoryID + 1101 '">' + 1102 cpnb_cookiesCategories[categoryID] 1103 .cookie_category_name + 1104 '</div>'; 1105 //Create new information box (right) 1106 HTMLinformationBoxes += 1107 '<div id="mmr_box_category_id_' + 1108 categoryID + 1109 '" class="cpnb-manager-modal-right-selected cpnb-manager-modal-right cpnb-manager-modal-right-scrollbar">'; 1110 } else { 1111 // Create menu item 1112 HTMLleftMenu += 1113 '<div role="button" tabindex="0" onkeydown="cpnb_handleKeyboardActivate(event)" onkeypress="cpnb_handleKeyboardActivate(event)" aria-label="' + 1114 cpnb_cookiesCategories[categoryID] 1115 .cookie_category_name + 1116 '" onClick="cpnb_m_changeModalCategory(\'' + 1117 categoryID + 1118 '\')" id="mlm_menu_category_id_' + 1119 categoryID + 1120 '" class="cpnb-manager-modal-left-item-unSelected cpnb-manager-modal-left-item modal-left-menu-item-id-' + 1121 categoryID + 1122 '">' + 1123 cpnb_cookiesCategories[categoryID] 1124 .cookie_category_name + 1125 '</div>'; 1126 // Create new information box (right) 1127 HTMLinformationBoxes += 1128 '<div id="mmr_box_category_id_' + 1129 categoryID + 1130 '" class="cpnb-manager-modal-right-unSelected cpnb-manager-modal-right cpnb-manager-modal-right-scrollbar">'; 1131 } 1132 1133 HTMLinformationBoxes += 1134 '<p><strong id="cpnb_category_heading_' + 1135 categoryID + 1136 '" class="cpnb-cookies-category-heading-responsive">' + 1137 cpnb_cookiesCategories[categoryID] 1138 .cookie_category_name + 1139 '</strong></p>'; 1140 HTMLinformationBoxes += 1141 cpnb_cookiesCategories[categoryID] 1142 .cookie_category_description; 1143 HTMLinformationBoxes += 1144 '<div class="cpnb-category-group" role="group" aria-labelledby="cpnb_category_heading_' + 1145 categoryID + 1146 '">'; 1147 1148 //Initialize vars for saveCategoryState 1149 var init_genericExp = settings.w357_expiration_cookies; 1150 var init_baseUrl = settings.w357_current_url; 1151 var init_cookieName = settings.w357_cookie_name; 1152 var init_acceptExp = settings.w357_expiration_cookieAccept; 1153 var init_declineExp = 1154 settings.w357_expiration_cookieDecline; 1155 1156 //(ENABLE-DISABLE BUTTON) - Check if cookie for category state exists. If exists check what state has been saved.
1157 if (categoriesSettingsCookie[innerCookieCategory] == null) { 1158 if ( 1159 cpnb_cookiesCategories[categoryID] 1160 .cookie_category_checked_by_default == 1 1161 ) { 1162 HTMLinformationBoxes += 1163 '<div class="modalCheckBox"><input data-cpnb-save="1" data-cpnb-category-id="' + 1164 categoryID + 1165 '" data-cpnb-exp="' + 1166 init_genericExp + 1167 '" data-cpnb-base-url="' + 1168 init_baseUrl + 1169 '" data-cpnb-cookie-name="' + 1170 init_cookieName + 1171 '" data-cpnb-accept-exp="' + 1172 init_acceptExp + 1173 '" data-cpnb-decline-exp="' + 1174 init_declineExp + 1175 '" class="cpnb-checkbox" type="checkbox" value="1" id="modalCheckBox_id_' + 1176 categoryID + 1177 '" name="modalCheckBox_id_' + 1178 categoryID + 1179 '" checked/><label for="modalCheckBox_id_' + 1180 categoryID + 1181 '">' + 1182 modalManager.w357_m_checkboxText + 1183 '</label></div>'; 1184 categoriesSettingsCookie[innerCookieCategory] = 1; 1185 } else if ( 1186 cpnb_cookiesCategories[categoryID] 1187 .cookie_category_checked_by_default == 2 1188 ) { 1189 //DISABLED CHECKBOX - cpnb_m_lockedCheckbox 1190 HTMLinformationBoxes += 1191 '<div class="modalCheckBox"><input data-cpnb-locked="1" data-cpnb-category-id="' + 1192 categoryID + 1193 '" data-cpnb-exp="' + 1194 settings.w357_expiration_cookies + 1195 '" data-cpnb-confirmation="' + 1196 settings.w357_enableConfirmationAlerts + 1197 '" class="cpnb-checkbox" type="checkbox" value="1" id="modalCheckBox_id_' + 1198 categoryID + 1199 '" name="modalCheckBox_id_' + 1200 categoryID + 1201 '" checked/><label for="modalCheckBox_id_' + 1202 categoryID + 1203 '">' + 1204 modalManager.w357_m_checkboxText + 1205 '</label></div>'; 1206 categoriesSettingsCookie[innerCookieCategory] = 1; 1207 } else { 1208 HTMLinformationBoxes += 1209 '<div class="modalCheckBox"><input data-cpnb-save="1" data-cpnb-category-id="' + 1210 categoryID + 1211 '" data-cpnb-exp="' + 1212 init_genericExp + 1213 '" data-cpnb-base-url="' + 1214 init_baseUrl + 1215 '" data-cpnb-cookie-name="' + 1216 init_cookieName + 1217 '" data-cpnb-accept-exp="' + 1218 init_acceptExp + 1219 '" data-cpnb-decline-exp="' + 1220 init_declineExp + 1221 '" class="cpnb-checkbox" type="checkbox" value="1" id="modalCheckBox_id_' + 1222 categoryID + 1223 '" name="modalCheckBox_id_' + 1224 categoryID + 1225 '" /><label for="modalCheckBox_id_' + 1226 categoryID + 1227 '">' + 1228 modalManager.w357_m_checkboxText + 1229 '</label></div>';
1230 categoriesSettingsCookie[innerCookieCategory] = 0; 1231 } 1232 } else { 1233 //Check if LOCKED 1234 if ( 1235 cpnb_cookiesCategories[categoryID] 1236 .cookie_category_checked_by_default != 2 1237 ) { 1238 if ( 1239 categoriesSettingsCookie[ 1240 '' + innerCookieCategory + '' 1241 ] == 1 1242 ) { 1243 HTMLinformationBoxes += 1244 '<div class="modalCheckBox"><input class="cpnb-checkbox" data-cpnb-save="1" data-cpnb-category-id="' + 1245 categoryID + 1246 '" data-cpnb-exp="' + 1247 init_genericExp + 1248 '" data-cpnb-base-url="' + 1249 init_baseUrl + 1250 '" data-cpnb-cookie-name="' + 1251 init_cookieName + 1252 '" data-cpnb-accept-exp="' + 1253 init_acceptExp + 1254 '" data-cpnb-decline-exp="' + 1255 init_declineExp + 1256 '" type="checkbox" value="1" id="modalCheckBox_id_' + 1257 categoryID + 1258 '" name="modalCheckBox_id_' + 1259 categoryID + 1260 '" checked/><label for="modalCheckBox_id_' + 1261 categoryID + 1262 '">' + 1263 modalManager.w357_m_checkboxText + 1264 '</label></div>'; 1265 categoriesSettingsCookie[ 1266 innerCookieCategory 1267 ] = 1; 1268 } else { 1269 HTMLinformationBoxes += 1270 '<div class="modalCheckBox"><input data-cpnb-save="1" data-cpnb-category-id="' + 1271 categoryID + 1272 '" data-cpnb-exp="' + 1273 init_genericExp + 1274 '" data-cpnb-base-url="' + 1275 init_baseUrl + 1276 '" data-cpnb-cookie-name="' + 1277 init_cookieName + 1278 '" data-cpnb-accept-exp="' + 1279 init_acceptExp + 1280 '" data-cpnb-decline-exp="' + 1281 init_declineExp + 1282 '" class="cpnb-checkbox" type="checkbox" value="1" id="modalCheckBox_id_' + 1283 categoryID + 1284 '" name="modalCheckBox_id_' + 1285 categoryID + 1286 '" /><label for="modalCheckBox_id_' + 1287 categoryID + 1288 '">' + 1289 modalManager.w357_m_checkboxText + 1290 '</label></div>'; 1291 categoriesSettingsCookie[ 1292 innerCookieCategory 1293 ] = 0; 1294 } 1295 } else { 1296 //DISABLED CHECKBOX - cpnb_m_lockedCheckbox 1297 HTMLinformationBoxes += 1298 '<div class="modalCheckBox"><input data-cpnb-locked="1" data-cpnb-category-id="' + 1299 categoryID + 1300 '" data-cpnb-exp="' + 1301 settings.w357_expiration_cookies + 1302 '" data-cpnb-confirmation="' + 1303 settings.w357_enableConfirmationAlerts + 1304 '" class="cpnb-checkbox" type="checkbox" value="1" id="modalCheckBox_id_' + 1305 categoryID + 1306 '" name="modalCheckBox_id_' + 1307 categoryID + 1308 '" checked/><label for="modalCheckBox_id_' + 1309 categoryID + 1310 '">' + 1311 modalManager.w357_m_checkboxText + 1312 ' ' + 1313 modalManager.w357_m_lockedText + 1314 '</label></div>';
1315 categoriesSettingsCookie[innerCookieCategory] = 1; 1316 } 1317 } 1318 1319 HTMLinformationBoxes += '</div>'; 1320 HTMLinformationBoxes += 1321 '<div style="display:block; width:100%; height:30px;"></div>'; 1322 HTMLinformationBoxes += '</div>'; 1323 1324 //Create IO ARRAY with IDs 1325 categoriesSettingsCookieInner[innerCookieCategory] = 1326 categoryID; 1327 categoriesSettingsCookieOuter[categoryID] = 1328 innerCookieCategory; 1329 } 1330 } 1331 1332 HTMLinformationBoxes += '<div class="cpnb-m-bottom-buttons">'; 1333 var enableConfirFun = 1334 settings.w357_enableConfirmationAlertsForAcceptBtn; 1335 var cookieNameFun = settings.w357_cookie_name; 1336 var msgFun = settings.w357_confirm_allow_msg; 1337 var expiration = settings.w357_expiration_cookieAccept; 1338 var linkFun = settings.w357_current_url; 1339 var encodedAcceptMsg = encodeURIComponent(decodeURI(msgFun)); 1340 var encodedAcceptCookieName = encodeURIComponent(cookieNameFun); 1341 var encodedAcceptLink = encodeURIComponent(linkFun); 1342 var encodedAcceptBaseAjaxUrl = encodeURIComponent( 1343 settings.w357_base_ajax_url 1344 ); 1345 HTMLinformationBoxes += 1346 '<button id="cpnb-accept-btn-m" class="cpnb-button cpnb-m-enableAllButton ' + 1347 decodeURI( 1348 settings.w357_accept_button_class_notification_bar_modal_window 1349 ) + 1350 '" type="button" data-cpnb-action="accept" data-cpnb-joomla-caching="' + 1351 settings.w357_joomla_caching + 1352 '" data-cpnb-enable-confirmation="' + 1353 decodeURI(enableConfirFun) + 1354 '" data-cpnb-message="' + 1355 encodedAcceptMsg + 1356 '" data-cpnb-cookie-name="' + 1357 encodedAcceptCookieName + 1358 '" data-cpnb-link="' + 1359 encodedAcceptLink + 1360 '" data-cpnb-expiration="' + 1361 expiration + 1362 '" data-cpnb-base-ajax-url="' + 1363 encodedAcceptBaseAjaxUrl + 1364 '" data-cpnb-context="modal" data-cpnb-reload="' + 1365 settings.w357_reloadPageAfterAccept + 1366 '" data-cpnb-overlay="' + 1367 settings.w357_overlay_state + 1368 '">' + 1369 modalManager.w357_m_EnableAllButtonText + 1370 '</button>'; 1371 1372 var enableConfirFun = 1373 settings.w357_enableConfirmationAlertsForDeclineBtn; 1374 var msgFun = settings.w357_confirm_delete_msg; 1375 var expiration = settings.w357_expiration_cookieDecline; 1376 var linkFun = settings.w357_current_url; 1377 var encodedDeclineMsg = encodeURIComponent(decodeURI(msgFun)); 1378 var encodedDeclineCookieName = encodeURIComponent(cookieNameFun); 1379 var encodedDeclineLink = encodeURIComponent(linkFun); 1380 HTMLinformationBoxes += 1381 '<button id="cpnb-decline-btn-m" class="cpnb-button cpnb-m-DeclineAllButton ' + 1382 decodeURI( 1383 settings.w357_decline_button_class_notification_bar_modal_window 1384 ) + 1385 '" type="button" data-cpnb-action="decline" data-cpnb-joomla-caching="' + 1386 settings.w357_joomla_caching + 1387 '" data-cpnb-enable-confirmation="' + 1388 decodeURI(enableConfirFun) + 1389 '" data-cpnb-message="' + 1390 encodedDeclineMsg + 1391 '" data-cpnb-cookie-name="' + 1392 encodedDeclineCookieName + 1393 '" data-cpnb-link="' + 1394 encodedDeclineLink + 1395 '" data-cpnb-expiration="' + 1396 expiration + 1397 '" data-cpnb-is-modal="true">' + 1398 modalManager.w357_m_DeclineAllButtonText + 1399 '</button>'; 1400 var linkFun = settings.w357_current_url; 1401 var init_genericExp = settings.w357_expiration_cookies; 1402 var init_baseUrl = settings.w357_current_url; 1403 var init_cookieName = settings.w357_cookie_name; 1404 var init_acceptExp = settings.w357_expiration_cookieAccept; 1405 var init_declineExp = settings.w357_expiration_cookieDecline; 1406 var encodedSaveLink = encodeURIComponent(linkFun); 1407 var encodedSaveBaseUrl = encodeURIComponent(init_baseUrl); 1408 var encodedSaveCookieName = encodeURIComponent(init_cookieName); 1409 HTMLinformationBoxes += 1410 '<button type="button" id="cpnb-save-btn-m" class="cpnb-button cpnb-m-SaveChangesButton ' + 1411 decodeURI( 1412 settings.w357_save_button_class_notification_bar_modal_window 1413 ) + 1414 '" data-cpnb-action="save-settings" data-cpnb-link="' + 1415 encodedSaveLink + 1416 '" data-cpnb-expiration="' + 1417 init_genericExp + 1418 '" data-cpnb-base-url="' + 1419 encodedSaveBaseUrl + 1420 '" data-cpnb-cookie-name="' + 1421 encodedSaveCookieName + 1422 '" data-cpnb-accept-expiration="' + 1423 init_acceptExp + 1424 '" data-cpnb-decline-expiration="' + 1425 init_declineExp + 1426 '" data-cpnb-joomla-caching="' + 1427 settings.w357_joomla_caching + 1428 '" data-cpnb-reload="' + 1429 settings.w357_reloadPageAfterAccept + 1430 '">' + 1431 modalManager.w357_m_SaveChangesButtonText + 1432 '</button>'; 1433 HTMLinformationBoxes += '</div>'; 1434 1435 afterCategoriesSettingsCookie = categoriesSettingsCookie; 1436 afterExpirationCookies = settings.w357_expiration_cookies; 1437 1438 var cnbwb = 1439 '<div id="cpnb_manager_wrap" class="cpnb-modal-wrap cpnb-modal-show-fade-out">'; 1440 cnbwb +=
1441 ' <div class="cpnb-modal-outer cpnb-modal-bg cpnb-close" id="cpnb_outter" style="top: 0px; left: 0px; align-items: flex-start;">'; 1442 cnbwb += 1443 ' <div class="cpnb-modal-inner cpnb-modal--medium" id="cpnb_inner" style="z-index: 100000000; height:' + 1444 maxHeight + 1445 'px; margin-top:' + 1446 marginTopWindow + 1447 'px; overflow:hidden;">'; 1448 if (modalManager.w357_m_FloatButtonIconType == 'fontawesome_icon') { 1449 cnbwb += 1450 ' <span role="button" tabindex="0" onkeydown="cpnb_handleKeyboardActivate(event)" onkeypress="cpnb_handleKeyboardActivate(event)" aria-label="Close" onClick="cpnb_m_closeModal()" id="cpnb-modal-close" class="cpnb-modal-close-fontawesome"><i class="fa fas fa-times"></i></span>'; 1451 } else { 1452 cnbwb += 1453 ' <span role="button" tabindex="0" onkeydown="cpnb_handleKeyboardActivate(event)" onkeypress="cpnb_handleKeyboardActivate(event)" aria-label="Close" onClick="cpnb_m_closeModal()" id="cpnb-modal-close" class="cpnb-modal-close cpnb-close cpnb-close-icon-x"></span>'; 1454 } 1455 cnbwb += 1456 ' <section class="cpnb-m-content" aria-label="' + 1457 modalManager.w357_m_modalHeadingText + 1458 '">'; 1459 cnbwb += 1460 ' <div id="cpnb_manager_modal_left" class="cpnb-manager-modal-left">'; 1461 cnbwb += HTMLleftMenu; 1462 cnbwb += ' </div>'; 1463 1464 cnbwb += HTMLinformationBoxes; 1465 1466 cnbwb += ' </section>'; 1467 cnbwb += ' </div>'; 1468 cnbwb += 1469 ' <div class="cpnb-modal-show-fade-out" id="cpnb_manager_wrap_close_bg" aria-label="Close modal" style=" z-index: 99999999; top:0; left:0; position:fixed; width:100%; height:100%;"></div>'; 1470 cnbwb += ' </div>'; 1471 cnbwb += '</div>'; 1472 var elem = document.createElement('div'); 1473 elem.innerHTML = cnbwb; 1474 var bar = document.getElementById('w357_cpnb_outer'); 1475 if (bar && bar.parentNode) { 1476 bar.parentNode.insertBefore(elem, bar.nextSibling); 1477 } else { 1478 document.body.insertBefore(elem, document.body.firstChild); 1479 } 1480 1481 var closeModalOverlay = document.getElementById( 1482 'cpnb_manager_wrap_close_bg' 1483 ); 1484 if (closeModalOverlay) { 1485 closeModalOverlay.addEventListener( 1486 'click', 1487 cpnb_m_closeModal, 1488 false 1489 ); 1490 } 1491 1492 var closeModalOuter = document.getElementById('cpnb_outter'); 1493 if (closeModalOuter) { 1494 closeModalOuter.addEventListener( 1495 'click', 1496 function (event) { 1497 if (event.target === closeModalOuter) { 1498 cpnb_m_closeModal(); 1499 } 1500 }, 1501 false 1502 ); 1503 } 1504 1505 // Check if floatButton is enabled 1506 if ( 1507 modalManager.w357_m_floatButtonState == 1 && 1508 cpnb_hasAnyConsentDecision(settings) 1509 ) { 1510 //Floating Button 1511 var tooltipPosition = 1512 modalManager.w357_m_floatButtonPosition === 'bottom_right' 1513 ? 'left' 1514 : 'right'; 1515 var floatingButton = 1516 '<div role="button" tabindex="0" onkeydown="cpnb_handleKeyboardActivate(event)" onkeypress="cpnb_handleKeyboardActivate(event)" aria-label="' + 1517 modalManager.w357_m_floatButtonText + 1518 '" onClick="cpnb_m_openModal()" class="cpnb-m-cookies-floatButton cpnb-m-cookies-floatButtonPosition_' + 1519 modalManager.w357_m_floatButtonPosition + 1520 '">'; 1521 floatingButton += 1522 '<div class="cpnb-m-cookies-floatButton-icon" data-balloon="' + 1523 modalManager.w357_m_floatButtonText + 1524 '" data-balloon-pos="' + 1525 tooltipPosition + 1526 '">'; 1527 1528 if ( 1529 modalManager.w357_m_FloatButtonIconType == 1530 'fontawesome_icon' 1531 ) { 1532 floatingButton +=
1533 '<i class="cpnb-m-cookies-floatButton-icon-fontawesome-icon ' + 1534 modalManager.w357_m_FloatButtonIconFontAwesomeName + 1535 ' ' + 1536 modalManager.w357_m_FloatButtonIconFontAwesomeSize + 1537 '" style="color: ' + 1538 modalManager.w357_m_FloatButtonIconFontAwesomeColor + 1539 ';"></i>'; 1540 } else if ( 1541 modalManager.w357_m_FloatButtonIconType == 'uikit_icon' 1542 ) { 1543 floatingButton += 1544 '<span class="cpnb-m-cookies-floatButton-icon-uikit-icon" uk-icon="icon:' + 1545 modalManager.w357_m_FloatButtonIconUikitName + 1546 '; ratio: ' + 1547 modalManager.w357_m_FloatButtonIconUikitSize + 1548 '" style="color: ' + 1549 modalManager.w357_m_FloatButtonIconUikitColor + 1550 ';"></span>'; 1551 } else { 1552 floatingButton += 1553 '<img alt="Cookies manager" class="cpnb-m-cookies-floatButton-icon-img" src="' + 1554 modalManager.w357_m_floatButtonIconSrc + 1555 '"/>'; 1556 } 1557 1558 floatingButton += '</div>'; 1559 floatingButton += '</div>'; 1560 var elem = document.createElement('div'); 1561 elem.innerHTML = floatingButton; 1562 document.body.insertBefore(elem, document.body.firstChild); 1563 } 1564 1565 var click_to_open_modal = null; 1566 var el_w357_m_HashLink = document.getElementById( 1567 modalManager.w357_m_HashLink 1568 ); 1569 if (el_w357_m_HashLink) { 1570 click_to_open_modal = el_w357_m_HashLink.addEventListener( 1571 'click', 1572 cpnb_m_openModal, 1573 false 1574 ); 1575 } 1576 1577 var classTriggerName = modalManager.w357_m_HashLink; 1578 var classTriggers = []; 1579 if (classTriggerName) { 1580 classTriggers = document.getElementsByClassName( 1581 classTriggerName 1582 ); 1583 } 1584 var hashTriggers = []; 1585 if (classTriggerName) { 1586 hashTriggers = Array.prototype.slice.call( 1587 document.querySelectorAll( 1588 'a[href$="#' + classTriggerName + '"]' 1589 ) 1590 ); 1591 } 1592 var menuItemTriggers = Array.prototype.slice.call( 1593 document.querySelectorAll( 1594 'a[href*="view=cpnbcookiemanager"]' 1595 ) 1596 ); 1597 if (menuItemTriggers.length) { 1598 menuItemTriggers.forEach(function (menuEl) { 1599 if (menuEl && menuEl.classList) { 1600 menuEl.classList.add('cpnb-modal-trigger'); 1601 } 1602 }); 1603 } 1604 var modalTriggers = Array.prototype.slice.call( 1605 document.getElementsByClassName('cpnb-modal-trigger') 1606 ); 1607 var combinedTriggers = modalTriggers; 1608 if (classTriggers.length) { 1609 combinedTriggers = combinedTriggers.concat( 1610 Array.prototype.slice.call(classTriggers) 1611 ); 1612 } 1613 if (hashTriggers.length) { 1614 combinedTriggers = combinedTriggers.concat(hashTriggers); 1615 } 1616 if (combinedTriggers.length) { 1617 combinedTriggers.forEach(function (triggerEl) { 1618 triggerEl.addEventListener( 1619 'click', 1620 function (event) { 1621 if (event && event.preventDefault) { 1622 event.preventDefault(); 1623 } 1624 click_to_open_modal = true; 1625 cpnb_m_openModal(); 1626 }, 1627 false 1628 ); 1629 }); 1630 } 1631 document.addEventListener( 1632 'click', 1633 function (event) { 1634 var target = event.target; 1635 while (target && target !== document) { 1636 if ( 1637 target.classList && 1638 target.classList.contains('cpnb-modal-trigger') 1639 ) { 1640 if (event && event.preventDefault) { 1641 event.preventDefault(); 1642 } 1643 click_to_open_modal = true; 1644 cpnb_m_openModal(); 1645 break; 1646 } 1647 target = target.parentNode; 1648 } 1649 }, 1650 false 1651 ); 1652 1653 // Check Hash Link to open modal 1654 if ( 1655 window.location.hash == '#' + modalManager.w357_m_HashLink || 1656 click_to_open_modal 1657 ) { 1658 var e = document.getElementById('cpnb_manager_wrap'); 1659 if (e) { 1660 e.classList.remove('cpnb-modal-show-fade-out'); 1661 e.classList.add('cpnb-modal-show-fade-in'); 1662 } 1663 1664 var ec = document.getElementById('cpnb_manager_wrap_close_bg'); 1665 if (ec) { 1666 ec.classList.remove('cpnb-modal-show-fade-out'); 1667 ec.classList.add('cpnb-modal-show-fade-in'); 1668 } 1669 } 1670 } //End - Check if ModalManager is enabled 1671 1672 cpnb_bindKeyboardAccessibility(); 1673 cpnb_bindAcceptLinks(); 1674
1675 ////***************** END MANAGER *****************//// 1676 }, 1677 false 1678); // END: WINDOW.ONLOAD 1679 1680/////******* START MANAGER *******///// 1681 1682//DISABLED CHECKBOX - cpnb_m_lockedCheckbox 1683function cpnb_m_lockedCheckbox(id, exp, confirmationAlert) { 1684 document.getElementById('modalCheckBox_id_' + id).checked = true; 1685 alert(m_modalManager_confirmationText); 1686 return; 1687} 1688 1689function cpnb_handleLockedCheckboxChange(event) { 1690 var target = event.target; 1691 if ( 1692 !target || 1693 !target.matches || 1694 !target.matches('input.cpnb-checkbox[data-cpnb-locked="1"]') 1695 ) { 1696 return; 1697 } 1698 1699 cpnb_m_lockedCheckbox( 1700 target.getAttribute('data-cpnb-category-id'), 1701 target.getAttribute('data-cpnb-exp'), 1702 target.getAttribute('data-cpnb-confirmation') 1703 ); 1704} 1705 1706function cpnb_handleCategoryCheckboxChange(event) { 1707 var target = event.target; 1708 if ( 1709 !target || 1710 !target.matches || 1711 !target.matches('input.cpnb-checkbox[data-cpnb-save="1"]') 1712 ) { 1713 return; 1714 } 1715 1716 cpnb_m_saveCategoryCookiesState( 1717 target.getAttribute('data-cpnb-category-id'), 1718 target.getAttribute('data-cpnb-exp'), 1719 target.getAttribute('data-cpnb-base-url'), 1720 target.getAttribute('data-cpnb-cookie-name'), 1721 target.getAttribute('data-cpnb-accept-exp'), 1722 target.getAttribute('data-cpnb-decline-exp') 1723 ); 1724} 1725 1726// Save Settings Button 1727function cpnb_warning_save_settings_button( 1728 link, 1729 exp, 1730 baseUrl, 1731 acceptCookieName, 1732 acceptCookieExpiration, 1733 declineCookieExpiration, 1734 w357_joomla_caching, 1735 reloadPageAfterAccept 1736) { 1737 var shouldReload = reloadPageAfterAccept == 1; 1738 var closeModalIfOpen = function () { 1739 if (document.getElementById('cpnb_manager_wrap')) { 1740 cpnb_m_closeModal(); 1741 } 1742 }; 1743 var closeBarIfOpen = function () { 1744 cpnb_closeNotificationBar(); 1745 }; 1746 1747 cpnb_setConsentCookie( 1748 'cpnb_cookiesSettings', 1749 afterCategoriesSettingsCookie, 1750 afterExpirationCookies 1751 ); 1752 // Use the temp settings until the "cpnb_warning_save_settings_button" function is called 1753 if (cpnb_getConsentCookiePayload('cpnb_cookiesSettingsTemp') == null) { 1754 cpnb_setConsentCookie( 1755 'cpnb_cookiesSettingsTemp', 1756 cpnb_getConsentCookieValue('cpnb_cookiesSettings'), 1757 exp 1758 ); 1759 } 1760 1761 cpnb_setConsentCookie( 1762 'cpnb_cookiesSettings', 1763 cpnb_getConsentCookieValue('cpnb_cookiesSettingsTemp'), 1764 exp 1765 ); 1766 1767 // save settings 1768 cpnb_handleBlockCookieScripts(); 1769 1770 var savedCookieSettings = cpnb_getConsentCookieValue( 1771 'cpnb_cookiesSettingsTemp' 1772 ); 1773 if (savedCookieSettings) { 1774 afterCategoriesSettingsCookie = savedCookieSettings || {}; 1775 } else { 1776 afterCategoriesSettingsCookie = {}; 1777 } 1778 afterExpirationCookies = exp; 1779 var funCookieSettings = cpnb_getConsentCookieValue( 1780 'cpnb_cookiesSettings' 1781 ); 1782 1783 //CHECK+CHANGE CookieName & cpnb_cookieDeclined = 1 1784 var countAllCategoriesCookies = 0; 1785 var countDisabledCategoriesCookies = 0; 1786 var countLockedCategoriesCookies = 0; 1787 for (var item in funCookieSettings) { 1788 countAllCategoriesCookies++; 1789 1790 if (cpnb_cookiesCategories[categoriesSettingsCookieInner[item]]) { 1791 if ( 1792 cpnb_cookiesCategories[categoriesSettingsCookieInner[item]] 1793 .cookie_category_checked_by_default == 2 1794 ) { 1795 countLockedCategoriesCookies++; 1796 } 1797 1798 if (funCookieSettings[item] == 0) { 1799 countDisabledCategoriesCookies++; 1800 } 1801 } 1802 } 1803 1804 //If remaining cookies are all disabled, delete cookieName and create cookieDeclined=1 1805 if ( 1806 countAllCategoriesCookies - countLockedCategoriesCookies == 1807 countDisabledCategoriesCookies 1808 ) { 1809 if (!cpnb_hasConsentCookie(cpnb_getDeclinedCookieName())) { 1810 cpnb_setConsentCookie( 1811 cpnb_getDeclinedCookieName(), 1812 '1', 1813 declineCookieExpiration 1814 ); 1815 cpnb_eraseCookie(acceptCookieName); 1816 cpnb_eraseCookie(cpnb_getCancelledCookieName()); 1817 cpnb_eraseCookie('cpnb_cookiesSettingsTemp'); 1818 1819 var postData = { 1820 cpnb_method: 'cpnbCookiesDeclined', 1821 dt: w357_joomla_caching > 0 ? new Date().getTime() : undefined, 1822 }; 1823 sendPostRequest(baseUrl, postData); 1824 closeModalIfOpen(); 1825 cpnb_m_ensureFloatButton(); 1826 closeBarIfOpen(); 1827 return; 1828 } 1829 } else { 1830 if (!cpnb_hasConsentCookie(acceptCookieName)) { 1831 cpnb_setConsentCookie( 1832 acceptCookieName, 1833 '1', 1834 acceptCookieExpiration 1835 ); 1836 cpnb_eraseCookie(cpnb_getDeclinedCookieName()); 1837 cpnb_eraseCookie(cpnb_getCancelledCookieName()); 1838 cpnb_eraseCookie('cpnb_cookiesSettingsTemp'); 1839 var postData = { 1840 cpnb_method: 'cpnbCookiesAccepted', 1841 dt: w357_joomla_caching > 0 ? new Date().getTime() : undefined, 1842 }; 1843 sendPostRequest(baseUrl, postData); 1844 if (shouldReload) { 1845 setTimeout(function () { 1846 window.location.reload(); 1847 }, 850); 1848 return; 1849 } 1850 closeModalIfOpen(); 1851 cpnb_m_ensureFloatButton(); 1852 closeBarIfOpen(); 1853 return; 1854 } 1855 } 1856 1857 var postData = { 1858 cpnb_method: 'cpnbCookiesManagerSaveSettings', 1859 dt: w357_joomla_caching > 0 ? new Date().getTime() : undefined, 1860 }; 1861 1862 sendPostRequest(link, postData); 1863 if (shouldReload) { 1864 setTimeout(function () { 1865 window.location.reload(); 1866 }, 850); 1867 return; 1868 } 1869 closeModalIfOpen(); 1870 cpnb_m_ensureFloatButton(); 1871 closeBarIfOpen(); 1872} 1873
1874function cpnb_m_saveCategoryCookiesState( 1875 id, 1876 exp, 1877 baseUrl, 1878 acceptCookieName, 1879 acceptCookieExpiration, 1880 declineCookieExpiration 1881) { 1882 if (cpnb_cookiesCategories[id].cookie_category_checked_by_default != 2) { 1883 // Use the temp settings until the "cpnb_warning_save_settings_button" function is called 1884 if (cpnb_getConsentCookiePayload('cpnb_cookiesSettingsTemp') == null) { 1885 cpnb_setConsentCookie( 1886 'cpnb_cookiesSettingsTemp', 1887 afterCategoriesSettingsCookie || {}, 1888 exp 1889 ); 1890 } 1891 var tempCookie = cpnb_getConsentCookieValue('cpnb_cookiesSettingsTemp'); 1892 var funCookieSettings = tempCookie || {}; 1893 1894 if ( 1895 document.getElementById('modalCheckBox_id_' + id).checked === true 1896 ) { 1897 funCookieSettings[categoriesSettingsCookieOuter[id]] = 1; 1898 } else { 1899 funCookieSettings[categoriesSettingsCookieOuter[id]] = 0; 1900 } 1901 1902 afterCategoriesSettingsCookie = funCookieSettings; 1903 1904 document.getElementById('cpnb-save-btn-m').style.background = 1905 modalManagerSettings.w357_m_saveChangesButtonColorAfterChange; 1906 1907 cpnb_setConsentCookie( 1908 'cpnb_cookiesSettingsTemp', 1909 funCookieSettings, 1910 exp 1911 ); 1912 } 1913} 1914 1915function cpnb_m_changeModalCategory(id) { 1916 //CHANGE LEFT MENU ITEM 1917 var x = document.getElementsByClassName( 1918 'cpnb-manager-modal-left-item-selected' 1919 ); 1920 x[0].classList.add('cpnb-manager-modal-left-item-unSelected'); 1921 x[0].classList.remove('cpnb-manager-modal-left-item-selected'); 1922 var x = document.getElementById('mlm_menu_category_id_' + id); 1923 x.classList.remove('cpnb-manager-modal-left-item-unSelected'); 1924 x.classList.add('cpnb-manager-modal-left-item-selected'); 1925 //CHANGE RIGHT INFORMATION BOX 1926 var x = document.getElementsByClassName( 1927 'cpnb-manager-modal-right-selected' 1928 ); 1929 x[0].classList.add('cpnb-manager-modal-right-unSelected'); 1930 x[0].classList.remove('cpnb-manager-modal-right-selected'); 1931 var x = document.getElementById('mmr_box_category_id_' + id); 1932 x.classList.remove('cpnb-manager-modal-right-unSelected'); 1933 x.classList.add('cpnb-manager-modal-right-selected'); 1934 1935 //Responsive Hide SelectCategoryMenu on ChangeCategory 1936 cpnb_toggle_responsive_menu_hide_menu(); 1937} 1938 1939function cpnb_m_openModal() { 1940 var e = document.getElementById('cpnb_manager_wrap'); 1941 if (e) { 1942 e.classList.remove('cpnb-modal-show-fade-out'); 1943 e.classList.add('cpnb-modal-show-fade-in'); 1944 } 1945 1946 var ec = document.getElementById('cpnb_manager_wrap_close_bg'); 1947 if (ec) { 1948 ec.classList.remove('cpnb-modal-show-fade-out'); 1949 ec.classList.add('cpnb-modal-show-fade-in'); 1950 } 1951} 1952 1953function cpnb_m_ensureFloatButton() { 1954 var cfg = typeof cpnb_config !== 'undefined' ? cpnb_config : settings; 1955 if ( 1956 !modalManagerSettings || 1957 modalManagerSettings.w357_m_floatButtonState != 1 || 1958 modalManagerSettings.w357_m_modalState != 1 || 1959 cfg.w357_blockCookies != 1 || 1960 (typeof cpnb_checkDIfIframeDisplay === 'function' && 1961 !cpnb_checkDIfIframeDisplay()) 1962 ) { 1963 return; 1964 } 1965 if (document.querySelector('.cpnb-m-cookies-floatButton')) { 1966 return; 1967 } 1968 1969 if (!cpnb_hasAnyConsentDecision(cfg)) { 1970 return; 1971 } 1972 1973 var tooltipPosition = 1974 modalManagerSettings.w357_m_floatButtonPosition === 'bottom_right' 1975 ? 'left' 1976 : 'right'; 1977 var floatingButton = 1978 '<div role="button" tabindex="0" onkeydown="cpnb_handleKeyboardActivate(event)" onkeypress="cpnb_handleKeyboardActivate(event)" aria-label="' + 1979 modalManagerSettings.w357_m_floatButtonText + 1980 '" onClick="cpnb_m_openModal()" class="cpnb-m-cookies-floatButton cpnb-m-cookies-floatButtonPosition_' + 1981 modalManagerSettings.w357_m_floatButtonPosition + 1982 '">'; 1983 floatingButton += 1984 '<div class="cpnb-m-cookies-floatButton-icon" data-balloon="' + 1985 modalManagerSettings.w357_m_floatButtonText + 1986 '" data-balloon-pos="' + 1987 tooltipPosition + 1988 '">'; 1989 1990 if (modalManagerSettings.w357_m_FloatButtonIconType == 'fontawesome_icon') { 1991 floatingButton +=
1992 '<i class="cpnb-m-cookies-floatButton-icon-fontawesome-icon ' + 1993 modalManagerSettings.w357_m_FloatButtonIconFontAwesomeName + 1994 ' ' + 1995 modalManagerSettings.w357_m_FloatButtonIconFontAwesomeSize + 1996 '" style="color: ' + 1997 modalManagerSettings.w357_m_FloatButtonIconFontAwesomeColor + 1998 ';"></i>'; 1999 } else if ( 2000 modalManagerSettings.w357_m_FloatButtonIconType == 'uikit_icon' 2001 ) { 2002 floatingButton += 2003 '<span class="cpnb-m-cookies-floatButton-icon-uikit-icon" uk-icon="icon:' + 2004 modalManagerSettings.w357_m_FloatButtonIconUikitName + 2005 '; ratio: ' + 2006 modalManagerSettings.w357_m_FloatButtonIconUikitSize + 2007 '" style="color: ' + 2008 modalManagerSettings.w357_m_FloatButtonIconUikitColor + 2009 ';"></span>'; 2010 } else { 2011 floatingButton += 2012 '<img alt="Cookies manager" class="cpnb-m-cookies-floatButton-icon-img" src="' + 2013 modalManagerSettings.w357_m_floatButtonIconSrc + 2014 '"/>'; 2015 } 2016 2017 floatingButton += '</div>'; 2018 floatingButton += '</div>'; 2019 2020 var elem = document.createElement('div'); 2021 elem.innerHTML = floatingButton; 2022 document.body.insertBefore(elem, document.body.firstChild); 2023} 2024 2025function cpnb_m_closeModal() { 2026 var e = document.getElementById('cpnb_manager_wrap'); 2027 if (e) { 2028 e.classList.remove('cpnb-modal-show-fade-in'); 2029 e.classList.add('cpnb-modal-show-fade-out'); 2030 } 2031 2032 var ec = document.getElementById('cpnb_manager_wrap_close_bg'); 2033 if (ec) { 2034 ec.classList.remove('cpnb-modal-show-fade-in'); 2035 ec.classList.add('cpnb-modal-show-fade-out'); 2036 } 2037} 2038 2039// Enable Enter/Space activation for focusable non-button controls (e.g. modal tabs). 2040function cpnb_bindKeyboardAccessibility() { 2041 if (window.cpnb_keyboard_bound) { 2042 return; 2043 } 2044 window.cpnb_keyboard_bound = true; 2045 document.addEventListener('keydown', function (event) { 2046 var key = event.key || event.keyCode; 2047 var isEnter = key === 'Enter' || key === 13; 2048 var isSpace = key === ' ' || key === 'Spacebar' || key === 32; 2049 if (!isEnter && !isSpace) { 2050 return; 2051 } 2052 var target = event.target; 2053 if (!target || !target.getAttribute) { 2054 return; 2055 } 2056 if (target.getAttribute('role') === 'button' || target.tagName === 'BUTTON') { 2057 event.preventDefault(); 2058 target.click(); 2059 } 2060 }); 2061} 2062 2063function cpnb_closeNotificationBar() { 2064 var bar = document.getElementById('w357_cpnb_outer'); 2065 if (bar) { 2066 bar.classList.add('cpnb-warningBox-show-fade-out'); 2067 setTimeout(function () { 2068 if (bar.parentNode) { 2069 bar.parentNode.removeChild(bar); 2070 } 2071 }, 500); 2072 } 2073 var overlay = document.getElementById('cpnb_warningBoxBgOverlay'); 2074 if (overlay) { 2075 overlay.style.display = 'none'; 2076 } 2077} 2078/////******* END MANAGER *******///// 2079 2080// OK - Accept Button 2081function acceptFunction( 2082 w357_joomla_caching, 2083 confirmationAlert, 2084 confirmMsg, 2085 AcceptCookieName, 2086 link, 2087 expiration, 2088 base_url, 2089 type, 2090 reloadPageAfterAccept, 2091 overlayState 2092) { 2093 cpnb_setConsentCookie( 2094 'cpnb_cookiesSettings', 2095 afterCategoriesSettingsCookie, 2096 afterExpirationCookies 2097 ); 2098 cpnb_setConsentCookie(AcceptCookieName, '1', expiration); 2099 cpnb_eraseCookie(cpnb_getCancelledCookieName()); 2100 cpnb_eraseCookie(cpnb_getDeclinedCookieName()); 2101 cpnb_eraseCookie('cpnb_cookiesSettingsTemp'); 2102 2103 var shouldReload = reloadPageAfterAccept == 1; 2104 if (!shouldReload) { 2105 // Render any scripts that should run after consent is given (accept) 2106 cpnb_handleBlockCookieScripts(); 2107 } 2108 2109 // Modal Manager 2110 var funCookieSettings = cpnb_getConsentCookieValue('cpnb_cookiesSettings'); 2111 for (var item in funCookieSettings) { 2112 funCookieSettings[item] = 1; 2113 } 2114 cpnb_setConsentCookie( 2115 'cpnb_cookiesSettings', 2116 funCookieSettings, 2117 afterExpirationCookies 2118 ); 2119 2120 var postData = { 2121 cpnb_method: 'cpnbCookiesAccepted', 2122 dt: w357_joomla_caching > 0 ? new Date().getTime() : undefined, 2123 }; 2124 2125 if (type == 'notification_bar') { 2126 // hide notification bar 2127 if (shouldReload) { 2128 sendPostRequest(link, postData); 2129 cpnb_handleBlockCookieScripts(); 2130 try { 2131 if (cpnb_config.w357_shortcode_is_enabled_on_this_page == 1) { 2132 localStorage.setItem('cpnb_shortcode_cookie_reload', '1'); 2133 } 2134 } catch (e) {} 2135 setTimeout(function () { 2136 window.location.reload(); 2137 }, 850); 2138 return; 2139 } else { 2140 // Store decision to DB 2141 var xmlhttp = new XMLHttpRequest(); 2142 xmlhttp.onreadystatechange = function () { 2143 if (xmlhttp.readyState == XMLHttpRequest.DONE) { 2144 // XMLHttpRequest.DONE == 4 2145 if (xmlhttp.status == 200) { 2146 // all done 2147 } else if (xmlhttp.status == 400) { 2148 // There was an error 400 2149 } else { 2150 // something else other than 200 was returned 2151 } 2152 } 2153 }; 2154 var url = 2155 base_url + 2156 'index.php?option=com_ajax&plugin=cookiespolicynotificationbar&format=raw&method=cpnbCookiesAccepted'; 2157 xmlhttp.open('POST', url, true); 2158 xmlhttp.setRequestHeader( 2159 'Content-Type', 2160 'application/x-www-form-urlencoded' 2161 ); 2162 xmlhttp.send(postData); 2163 2164 // hide the notification bar 2165 document 2166 .getElementById('w357_cpnb_outer') 2167 .classList.add('cpnb-warningBox-show-fade-out'); 2168 if (overlayState == 1) { 2169 document.getElementById( 2170 'cpnb_warningBoxBgOverlay' 2171 ).style.display = 'none'; 2172 } 2173 } 2174 } // shortcode_table or modal 2175 else { 2176 if (shouldReload) { 2177 sendPostRequest(link, postData); 2178 cpnb_handleBlockCookieScripts(); 2179 try { 2180 if (cpnb_config.w357_shortcode_is_enabled_on_this_page == 1) { 2181 localStorage.setItem('cpnb_shortcode_cookie_reload', '1'); 2182 } 2183 } catch (e) {} 2184 setTimeout(function () { 2185 window.location.reload(); 2186 }, 850); 2187 return; 2188 } else { 2189 sendPostRequest(link, postData);
2190 cpnb_fetchCookiesInfoTable(); 2191 return; 2192 } 2193 } 2194} 2195 2196function checkCookieCategoriesAfterAccept(expiration) { 2197 // after accept check all checkboxes asynchronously. 2198 cpnb_checkboxes = document.getElementsByClassName('cpnb-checkbox'); 2199 for (var i = 0, n = cpnb_checkboxes.length; i < n; i++) { 2200 cpnb_checkboxes[i].checked = true; 2201 } 2202 2203 for (var categoryID in cpnb_cookiesCategories) { 2204 if (cpnb_cookiesCategories[categoryID].cookie_category_status == 1) { 2205 var innerCookieCategory = 2206 cpnb_cookiesCategories[categoryID].cookie_category_id; 2207 categoriesSettingsCookie[innerCookieCategory] = 1; 2208 } 2209 } 2210 2211 // Get the total of enabled categories and if is more than one then create the cpnb_cookiesSettings cookie, or if is only the required-cookies category do not create the cpnb_cookiesSettings cookie to pass the Cookiebot validation service 2212 var categoriesSettingsCookie_arr_values = Object.keys( 2213 categoriesSettingsCookie 2214 ).map(function (itm) { 2215 return categoriesSettingsCookie[itm]; 2216 }); // IE compatibility 2217 2218 var categoriesSettingsCookie_count_of_enabled = 2219 categoriesSettingsCookie_arr_values.reduce(function (a, b) { 2220 return a + b; 2221 }, 0); 2222 2223 if (categoriesSettingsCookie_count_of_enabled > 1) { 2224 cpnb_setConsentCookie( 2225 'cpnb_cookiesSettings', 2226 categoriesSettingsCookie, 2227 expiration 2228 ); 2229 } 2230 2231 afterCategoriesSettingsCookie = categoriesSettingsCookie; 2232 afterExpirationCookies = expiration; 2233} 2234 2235function checkCookieCategoriesAfterDecline(expiration) { 2236 // after decline uncheck all checkboxes and keep the locked ones checked 2237 var cpnb_checkboxes = document.getElementsByClassName('cpnb-checkbox'); 2238 for (var i = 0, n = cpnb_checkboxes.length; i < n; i++) { 2239 cpnb_checkboxes[i].checked = false; 2240 } 2241 2242 for (var categoryID in cpnb_cookiesCategories) { 2243 if (cpnb_cookiesCategories[categoryID].cookie_category_status == 1) { 2244 var innerCookieCategory = 2245 cpnb_cookiesCategories[categoryID].cookie_category_id; 2246 if ( 2247 cpnb_cookiesCategories[categoryID] 2248 .cookie_category_checked_by_default == 2 2249 ) { 2250 categoriesSettingsCookie[innerCookieCategory] = 1; 2251 var lockedCheckbox = document.getElementById( 2252 'modalCheckBox_id_' + categoryID 2253 ); 2254 if (lockedCheckbox) { 2255 lockedCheckbox.checked = true; 2256 } 2257 } else { 2258 categoriesSettingsCookie[innerCookieCategory] = 0; 2259 } 2260 } 2261 } 2262 2263 cpnb_setConsentCookie( 2264 'cpnb_cookiesSettings', 2265 categoriesSettingsCookie, 2266 expiration 2267 ); 2268 2269 afterCategoriesSettingsCookie = categoriesSettingsCookie; 2270 afterExpirationCookies = expiration; 2271} 2272 2273function cpnb_warning_accept_button( 2274 w357_joomla_caching, 2275 confirmationAlert, 2276 confirmMsg, 2277 AcceptCookieName, 2278 link, 2279 expiration, 2280 base_url, 2281 type, 2282 reloadPageAfterAccept, 2283 overlayState 2284) { 2285 if (confirmationAlert != 1 || confirm(confirmMsg)) { 2286 checkCookieCategoriesAfterAccept(expiration); 2287 acceptFunction( 2288 w357_joomla_caching, 2289 confirmationAlert, 2290 confirmMsg, 2291 AcceptCookieName, 2292 link, 2293 expiration, 2294 base_url, 2295 type, 2296 reloadPageAfterAccept, 2297 overlayState 2298 ); 2299 } 2300 if (type == 'modal') { 2301 cpnb_m_closeModal(); 2302 cpnb_closeModalMoreInfo(); 2303 } 2304 cpnb_m_ensureFloatButton(); 2305 cpnb_closeNotificationBar(); 2306} 2307 2308// Decline Button 2309function cpnb_warning_decline_button( 2310 w357_joomla_caching, 2311 confirmationAlert, 2312 confirmMsg, 2313 cookieName, 2314 link, 2315 expiration, 2316 isModalWindow = false 2317) { 2318 var postData = { 2319 cpnb_method: 'cpnbCookiesDeclined', 2320 cpnb_btn_area: isModalWindow ? 'cookiesManager' : 'notificationBar', 2321 dt: w357_joomla_caching > 0 ? new Date().getTime() : undefined, 2322 }; 2323 2324 var declineAction = function () { 2325 checkCookieCategoriesAfterDecline(expiration); 2326 cpnb_setConsentCookie( 2327 cpnb_getDeclinedCookieName(), 2328 '1', 2329 expiration 2330 ); 2331 cpnb_eraseCookie(cookieName); 2332 cpnb_eraseCookie(cpnb_getCancelledCookieName()); 2333 cpnb_eraseCookie('cpnb_cookiesSettingsTemp'); 2334 2335 // Modal Manager 2336 var funCookieSettings = cpnb_getConsentCookieValue( 2337 'cpnb_cookiesSettings' 2338 ); 2339 for (var item in funCookieSettings) { 2340 var catId = categoriesSettingsCookieInner[item];
2341 var isLocked = 2342 catId && 2343 cpnb_cookiesCategories[catId] && 2344 cpnb_cookiesCategories[catId] 2345 .cookie_category_checked_by_default == 2; 2346 funCookieSettings[item] = isLocked ? 1 : 0; 2347 } 2348 cpnb_setConsentCookie( 2349 'cpnb_cookiesSettings', 2350 funCookieSettings, 2351 expiration 2352 ); 2353 2354 // decline 2355 cpnb_handleBlockCookieScripts(); 2356 sendPostRequest(link, postData); 2357 }; 2358 2359 if (confirmationAlert == 1) { 2360 if (confirm(confirmMsg)) { 2361 declineAction(); 2362 } 2363 } else { 2364 declineAction(); 2365 } 2366 if (isModalWindow) { 2367 cpnb_m_closeModal(); 2368 cpnb_closeModalMoreInfo(); 2369 } 2370 cpnb_m_ensureFloatButton(); 2371 cpnb_closeNotificationBar(); 2372} 2373 2374// Delete Button 2375function cpnb_warning_delete_button( 2376 w357_joomla_caching, 2377 confirmationAlert, 2378 confirmMsg, 2379 cookieName, 2380 link 2381) { 2382 var postData = { 2383 cpnb_method: 'cpnbCookiesDeleted', 2384 dt: w357_joomla_caching > 0 ? new Date().getTime() : undefined, 2385 }; 2386 2387 if (confirmationAlert == 1) { 2388 if (confirm(confirmMsg)) { 2389 cpnb_eraseCookie('cpnb_cookiesSettings'); 2390 cpnb_eraseCookie(cpnb_getDeclinedCookieName()); 2391 cpnb_eraseCookie(cookieName); 2392 cpnb_eraseCookie(cpnb_getCancelledCookieName()); 2393 sendPostRequest(link, postData); 2394 return; 2395 } 2396 } else { 2397 cpnb_eraseCookie('cpnb_cookiesSettings'); 2398 cpnb_eraseCookie(cpnb_getDeclinedCookieName()); 2399 cpnb_eraseCookie(cookieName); 2400 cpnb_eraseCookie(cpnb_getCancelledCookieName()); 2401 sendPostRequest(link, postData); 2402 return; 2403 } 2404} 2405 2406// Cancel Button 2407function cpnb_warning_cancel_button( 2408 cookieName, 2409 expiration, 2410 link, 2411 overlayState, 2412 isModalWindow = false 2413) { 2414 cpnb_setConsentCookie(cpnb_getCancelledCookieName(), '1', expiration); 2415 cpnb_eraseCookie(cookieName); 2416 cpnb_eraseCookie(cpnb_getDeclinedCookieName()); 2417 2418 // hide the notification bar 2419 var bar = document.getElementById('w357_cpnb_outer'); 2420 if (bar) { 2421 bar.classList.add('cpnb-warningBox-show-fade-out'); 2422 } 2423 if (overlayState == 1) { 2424 var overlay = document.getElementById('cpnb_warningBoxBgOverlay'); 2425 if (overlay) { 2426 overlay.style.display = 'none'; 2427 } 2428 } 2429 2430 setTimeout(function () { 2431 var bar = document.getElementById('w357_cpnb_outer'); 2432 if (bar) { 2433 bar.remove(); 2434 } 2435 }, 500); 2436 2437 cpnb_closeModalMoreInfo(); 2438} 2439 2440// Open POP UP 2441function w357_openPopUpWindowMoreInfo(url, title, w, h) { 2442 wLeft = window.screenLeft ? window.screenLeft : window.screenX; 2443 wTop = window.screenTop ? window.screenTop : window.screenY; 2444 2445 var left = wLeft + window.innerWidth / 2 - w / 2; 2446 var top = wTop + window.innerHeight / 2 - h / 2; 2447 window.open( 2448 url, 2449 title, 2450 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=' + 2451 w + 2452 ', height=' + 2453 h + 2454 ', top=' + 2455 top + 2456 ', left=' + 2457 left 2458 ); 2459} 2460 2461function cpnb_openModalMoreInfo() { 2462 var e = document.getElementById('cpnb_modal_wrap'); 2463 if (e) { 2464 e.classList.remove('cpnb-modal-show-fade-out'); 2465 e.classList.add('cpnb-modal-show-fade-in'); 2466 } 2467 2468 var ec = document.getElementById('modal_close_bg'); 2469 if (ec) { 2470 ec.classList.remove('cpnb-modal-show-fade-out'); 2471 ec.classList.add('cpnb-modal-show-fade-in'); 2472 } 2473} 2474 2475function cpnb_closeModalMoreInfo() { 2476 var e = document.getElementById('cpnb_modal_wrap'); 2477 if (e) { 2478 e.classList.remove('cpnb-modal-show-fade-in'); 2479 e.classList.add('cpnb-modal-show-fade-out'); 2480 } 2481 2482 var ec = document.getElementById('modal_close_bg'); 2483 if (ec) { 2484 ec.classList.remove('cpnb-modal-show-fade-in'); 2485 ec.classList.add('cpnb-modal-show-fade-out'); 2486 } 2487} 2488 2489function cpnb_createCookie(name, value, days) { 2490 var expires; 2491 var expValue = days; 2492 if (typeof expValue === 'string') { 2493 expValue = expValue.trim(); 2494 } 2495 if ( 2496 expValue && 2497 String(expValue).toUpperCase() !== 'SESSION' && 2498 !isNaN(expValue) 2499 ) { 2500 var date = new Date(); 2501 date.setTime(date.getTime() + expValue * 24 * 60 * 60 * 1000); 2502 expires = ';SameSite=Lax; expires=' + date.toGMTString(); 2503 } else { 2504 expires = ''; 2505 } 2506 // Get cookie domain from config (for sharing cookies across subdomains) 2507 var domainStr = ''; 2508 if (typeof cpnb_config !== 'undefined' && cpnb_config.w357_co
2508okie_domain) { 2509 domainStr = '; domain=' + cpnb_config.w357_cookie_domain; 2510 } 2511 document.cookie = 2512 encodeURIComponent(name) + 2513 '=' + 2514 encodeURIComponent(value) + 2515 expires + 2516 '; path=/' + 2517 domainStr; 2518} 2519 2520function cpnb_buildConsentPayload(value, exp) { 2521 return JSON.stringify({ v: value, exp: exp }); 2522} 2523 2524function cpnb_setConsentCookie(name, value, exp) { 2525 cpnb_createCookie(name, cpnb_buildConsentPayload(value, exp), exp); 2526} 2527 2528function cpnb_getDeclinedCookieName() { 2529 if ( 2530 typeof cpnb_config !== 'undefined' && 2531 cpnb_config.w357_cookie_name_declined 2532 ) { 2533 return cpnb_config.w357_cookie_name_declined; 2534 } 2535 return 'cpnbCookiesDeclined'; 2536} 2537 2538function cpnb_getCancelledCookieName() { 2539 if ( 2540 typeof cpnb_config !== 'undefined' && 2541 cpnb_config.w357_cookie_name_cancelled 2542 ) { 2543 return cpnb_config.w357_cookie_name_cancelled; 2544 } 2545 return 'cpnbCookiesCancelled'; 2546} 2547 2548function cpnb_getConsentCookiePayload(name) { 2549 var raw = cpnb_readCookie(name); 2550 if (!raw) { 2551 return null; 2552 } 2553 try { 2554 var payload = JSON.parse(raw); 2555 if (!payload || typeof payload !== 'object') { 2556 return null; 2557 } 2558 return payload; 2559 } catch (error) { 2560 return null; 2561 } 2562} 2563 2564function cpnb_getConsentCookieValue(name) { 2565 var payload = cpnb_getConsentCookiePayload(name); 2566 return payload ? payload.v : null; 2567} 2568 2569function cpnb_hasConsentCookie(name) { 2570 return cpnb_getConsentCookiePayload(name) !== null; 2571} 2572 2573/** 2574 * Whether a consent decision (Accept/Decline/Cancel) has been made, combining two signals: 2575 * - cfg.w357_has_consent_decision, computed server-side from $_COOKIE at page load - this 2576 * is what sees a decision made in an earlier session once its cookie is HttpOnly, which 2577 * document.cookie cannot. 2578 * - document.cookie, checked directly as a fallback for the instant after a click in *this* 2579 * page load - the client's own optimistic cookie write is still plain (not yet upgraded to 2580 * HttpOnly by the async server response) at that exact moment, so cfg.w357_has_consent_decision 2581 * (fixed at page load, before the click) would otherwise read as stale/false here. 2582 */ 2583function cpnb_hasAnyConsentDecision(cfg) { 2584 return ( 2585 !!cfg.w357_has_consent_decision ||
2586 cpnb_hasConsentCookie(cfg.w357_cookie_name) || 2587 cpnb_hasConsentCookie(cfg.w357_cookie_name_declined) || 2588 cpnb_hasConsentCookie(cfg.w357_cookie_name_cancelled) 2589 ); 2590} 2591 2592function cpnb_syncConsentCookieExpiration(name, exp) { 2593 var payload = cpnb_getConsentCookiePayload(name); 2594 if (!payload) { 2595 return; 2596 } 2597 var current = String(payload.exp).toUpperCase(); 2598 var expected = String(exp).toUpperCase(); 2599 if (current !== expected) { 2600 cpnb_setConsentCookie(name, payload.v, exp); 2601 } 2602} 2603 2604function cpnb_readCookie(name) { 2605 var nameEQ = encodeURIComponent(name) + '='; 2606 var ca = document.cookie.split(';'); 2607 for (var i = 0; i < ca.length; i++) { 2608 var c = ca[i]; 2609 while (c.charAt(0) === ' ') c = c.substring(1, c.length); 2610 if (c.indexOf(nameEQ) === 0) 2611 return decodeURIComponent(c.substring(nameEQ.length, c.length)); 2612 } 2613 return null; 2614} 2615 2616function cpnb_eraseCookie(name) { 2617 cpnb_createCookie(name, '', -1); 2618} 2619 2620function cpnb_decodeBlockCookiePayload(encodedPayload) { 2621 if (!encodedPayload) { 2622 return ''; 2623 } 2624 2625 try { 2626 return atob(encodedPayload); 2627 } catch (error) { 2628 console.error('CPNB: Failed to decode blocked script payload', error); 2629 return ''; 2630 } 2631} 2632 2633function cpnb_getDataAttribute(element, attributeName) { 2634 if (!element) { 2635 return ''; 2636 } 2637 var value = element.getAttribute(attributeName); 2638 return value === null ? '' : value; 2639} 2640 2641function cpnb_decodeDataAttribute(value) { 2642 if (!value) { 2643 return ''; 2644 } 2645 try { 2646 return decodeURIComponent(value); 2647 } catch (error) { 2648 return value; 2649 } 2650} 2651 2652function cpnb_handleActionButtonClick(event) { 2653 var target = event.target; 2654 if (!target || !target.closest) { 2655 return; 2656 } 2657 var actionButton = target.closest('[data-cpnb-action]'); 2658 if (!actionButton) { 2659 return; 2660 } 2661 2662 var action = cpnb_getDataAttribute(actionButton, 'data-cpnb-action'); 2663 if (!action) { 2664 return; 2665 } 2666 2667 switch (action) { 2668 case 'accept': 2669 cpnb_warning_accept_button( 2670 cpnb_getDataAttribute( 2671 actionButton, 2672 'data-cpnb-joomla-caching' 2673 ), 2674 cpnb_getDataAttribute( 2675 actionButton, 2676 'data-cpnb-enable-confirmation' 2677 ), 2678 cpnb_decodeDataAttribute( 2679 cpnb_getDataAttribute(actionButton, 'data-cpnb-message') 2680 ), 2681 cpnb_decodeDataAttribute( 2682 cpnb_getDataAttribute( 2683 actionButton, 2684 'data-cpnb-cookie-name' 2685 ) 2686 ), 2687 cpnb_decodeDataAttribute( 2688 cpnb_getDataAttribute(actionButton, 'data-cpnb-link') 2689 ), 2690 cpnb_getDataAttribute( 2691 actionButton, 2692 'data-cpnb-expiration' 2693 ), 2694 cpnb_decodeDataAttribute( 2695 cpnb_getDataAttribute( 2696 actionButton, 2697 'data-cpnb-base-ajax-url' 2698 ) 2699 ), 2700 cpnb_getDataAttribute(actionButton, 'data-cpnb-context'), 2701 cpnb_getDataAttribute(actionButton, 'data-cpnb-reload'), 2702 cpnb_getDataAttribute(actionButton, 'data-cpnb-overlay') 2703 ); 2704 break; 2705 case 'decline': 2706 cpnb_warning_decline_button( 2707 cpnb_getDataAttribute( 2708 actionButton, 2709 'data-cpnb-joomla-caching' 2710 ), 2711 cpnb_getDataAttribute( 2712 actionButton, 2713 'data-cpnb-enable-confirmation' 2714 ), 2715 cpnb_decodeDataAttribute( 2716 cpnb_getDataAttribute(actionButton, 'data-cpnb-message') 2717 ), 2718 cpnb_decodeDataAttribute( 2719 cpnb_getDataAttribute( 2720 actionButton, 2721 'data-cpnb-cookie-name' 2722 ) 2723 ), 2724 cpnb_decodeDataAttribute( 2725 cpnb_getDataAttribute(actionButton, 'data-cpnb-link') 2726 ), 2727 cpnb_getDataAttribute( 2728 actionButton, 2729 'data-cpnb-expiration' 2730 ), 2731 cpnb_getDataAttribute(actionButton, 'data-cpnb-is-modal') 2732 ); 2733 break; 2734 case 'save-settings': 2735 event.preventDefault(); 2736 cpnb_warning_save_settings_button( 2737 cpnb_decodeDataAttribute( 2738 cpnb_getDataAttribute(actionButton, 'data-cpnb-link') 2739 ), 2740 cpnb_getDataAttribute( 2741 actionButton, 2742 'data-cpnb-expiration' 2743 ), 2744 cpnb_decodeDataAttribute( 2745 cpnb_getDataAttribute(actionButton, 'data-cpnb-base-url') 2746 ), 2747 cpnb_decodeDataAttribute( 2748 cpnb_getDataAttribute( 2749 actionButton, 2750 'data-cpnb-cookie-name' 2751 ) 2752 ), 2753 cpnb_getDataAttribute( 2754 actionButton, 2755 'data-cpnb-accept-expiration' 2756 ), 2757 cpnb_getDataAttribute( 2758 actionButton, 2759 'data-cpnb-decline-expiration' 2760 ), 2761 cpnb_getDataAttribute( 2762 actionButton, 2763 'data-cpnb-joomla-caching' 2764 ), 2765 cpnb_getDataAttribute(actionButton, 'data-cpnb-reload') 2766 ); 2767 break; 2768 case 'delete': 2769 cpnb_warning_delete_button( 2770 cpnb_getDataAttribute( 2771 actionButton, 2772 'data-cpnb-joomla-caching' 2773 ), 2774 cpnb_getDataAttribute( 2775 actionButton, 2776 'data-cpnb-enable-confirmation' 2777 ), 2778 cpnb_decodeDataAttribute( 2779 cpnb_getDataAttribute(actionButton, 'data-cpnb-message') 2780 ), 2781 cpnb_decodeDataAttribute( 2782 cpnb_getDataAttribute( 2783 actionButton, 2784 'data-cpnb-cookie-name' 2785 ) 2786 ), 2787 cpnb_decodeDataAttribute( 2788 cpnb_getDataAttribute(actionButton, 'data-cpnb-link') 2789 ) 2790 ); 2791 if (cpnb_getDataAttribute(actionButton, 'data-cpnb-reload') == 1) { 2792 setTimeout(function () { 2793 window.location.reload(); 2794 }, 850); 2795 } 2796 break; 2797 default: 2798 break; 2799 } 2800} 2801 2802function cpnb_isBlockCookieCategoryEnabled(categoryId, loadState) { 2803 if (!categoryId) { 2804 return true; 2805 } 2806 2807 // Find category config by key or by inner category_id 2808 var categoryConfig = null; 2809 if (typeof cpnb_cookiesCategories !== 'undefined') { 2810 if (cpnb_cookiesCategories[categoryId]) { 2811 categoryConfig = cpnb_cookiesCategories[categoryId]; 2812 } else { 2813 for (var key in cpnb_cookiesCategories) { 2814 if ( 2815 cpnb_cookiesCategories[key].cookie_category_id === 2816 categoryId 2817 ) { 2818 categoryConfig = cpnb_cookiesCategories[key]; 2819 break; 2820 } 2821 } 2822 } 2823 } 2824 2825 var decisionMade = 2826 typeof cpnb_config !== 'undefined' && 2827 cpnb_hasAnyConsentDecision(cpnb_config); 2828 2829 var cookieSettingsRaw = 2830 cpnb_renderSettingsOverride || 2831 cpnb_getConsentCookieValue('cpnb_cookiesSettingsTemp') || 2832 cpnb_getConsentCookieValue('cpnb_cookiesSettings') || 2833 (typeof cpnb_config !== 'undefined' ? cpnb_config.w357_co
2833okie_settings_value : null); 2834 2835 // No decision stored yet: fall back to default config per loadState 2836 if (!decisionMade || !cookieSettingsRaw) { 2837 if (!categoryConfig) { 2838 return loadState === 'before' ? true : false; 2839 } 2840 2841 if (loadState === 'before') { 2842 return categoryConfig.cookie_category_checked_by_default == 0; 2843 } 2844 2845 if (loadState === 'after') { 2846 return categoryConfig.cookie_category_checked_by_default > 0; 2847 } 2848 2849 return loadState === 'before' ? true : false; 2850 } 2851 2852 try { 2853 var parsedSettings = cookieSettingsRaw; 2854 if (Object.prototype.hasOwnProperty.call(parsedSettings, categoryId)) { 2855 if (loadState === 'before') { 2856 return parsedSettings[categoryId] === 0; 2857 } 2858 if (loadState === 'after') { 2859 return parsedSettings[categoryId] === 1; 2860 } 2861 if (loadState === 'decline') { 2862 return parsedSettings[categoryId] === 0; 2863 } 2864 return parsedSettings[categoryId] === 1; 2865 } 2866 // If the specific categoryId is not in settings, fall back to defaults 2867 if (categoryConfig) { 2868 if (loadState === 'before') { 2869 return categoryConfig.cookie_category_checked_by_default == 0; 2870 } 2871 if (loadState === 'after') { 2872 return categoryConfig.cookie_category_checked_by_default > 0; 2873 } 2874 } 2875 } catch (error) { 2876 console.error('CPNB: Failed to parse cpnb_cookiesSettings', error); 2877 } 2878 2879 return loadState === 'before' ? false : true; 2880} 2881 2882function cpnb_insertUrlPlaceholders(categoryId) { 2883 // "Block elements" placeholders are now emitted server-side: when the mapped category is not 2884 // consented, the PHP plugin removes the matched element from the delivered HTML and replaces it 2885 // with a <div data-cpnb-placeholder-for> + an inert <template data-cpnb-blocked-for> copy. So 2886 // there is nothing to insert client-side â the blocked element never reached the browser. This 2887 // function is kept for call-site compatibility with cpnb_renderBlockCookieScripts(). 2888 return; 2889} 2890 2891function cpnb_removeUrlPlaceholders(categoryId) { 2892 // Consent was granted for this category: restore each blocked element from its inert <template> 2893 // copy and drop the placeholder. Inserting the template content into the live DOM lets iframes 2894 // load; <script> tags are recreated so they execute (cloned script nodes do not run otherwise). 2895 // Category ids can contain a double quote (admin-configurable), so escape it for the attribute 2896 // selector below - otherwise querySelectorAll() throws on an invalid selector and consent for 2897 // that category never restores anything. 2898 var escapedCategoryId = String(categoryId).replace(/(["\\])/g, '\\$1'); 2899 var placeholders = document.querySelectorAll('[data-cpnb-placeholder-for="' + escapedCategoryId + '"]'); 2900 2901 for (var i = 0; i < placeholders.length; i++) { 2902 var ph = placeholders[i]; 2903 var parent = ph.parentNode; 2904 if (!parent) continue; 2905 2906 // The inert original markup lives in the <template data-cpnb-blocked-for> right after the placeholder. 2907 var tpl = ph.nextElementSibling; 2908 var hasTemplate = tpl 2909 && tpl.tagName === 'TEMPLATE' 2910 && tpl.getAttribute('data-cpnb-blocked-for') === categoryId; 2911 2912 if (!hasTemplate) { 2913 // Nothing to restore (e.g. a legacy placeholder) â just remove it. 2914 parent.removeChild(ph); 2915 continue; 2916 } 2917 2918 try { 2919 var content = (tpl.content && tpl.content.cloneNode) 2920 ? tpl.content.cloneNode(true) 2921 : null; 2922 2923 if (content === null) { 2924 // <template> not supported: fall back to a reload so the server can render the element. 2925 window.location.reload(); 2926 return; 2927 } 2928 2929 // Recreate <script> elements so the browser executes them. 2930 var scripts = content.querySelectorAll ? content.querySelectorAll('script') : []; 2931 for (var s = 0; s < scripts.length; s++) { 2932 var oldScript = scripts[s]; 2933 var newScript = document.createElement('script'); 2934 for (var a = 0; a < oldScript.attributes.length; a++) { 2935 newScript.setAttribute(oldScript.attributes[a].name, oldScript.attributes[a].value); 2936 } 2937 newScript.text = oldScript.textContent; 2938 if (oldScript.parentNode) { 2939 oldScript.parentNode.replaceChild(newScript, oldScript); 2940 } 2941 } 2942 2943 parent.insertBefore(content, ph); 2944 parent.removeChild(ph); 2945 parent.removeChild(tpl); 2946 } catch (e) { 2947 // Restoration failed for this element â reload so the server renders it (now consented). 2948 window.location.reload(); 2949 return; 2950 } 2951 } 2952} 2953 2954function cpnb_renderBlockCookieScripts(loadState) { 2955 // Retrieve cookie settings and check if a decision was made 2956 var settingsObj = 2957 cpnb_getConsentCookieValue('cpnb_cookiesSettings') || 2958 (typeof cpnb_config !== 'undefined' ? cpnb_config.w357_co
2958okie_settings_value : null); 2959 2960 for (var catId in cpnb_cookiesCategories) { 2961 var category = cpnb_cookiesCategories[catId]; 2962 2963 // Skip if the category is disabled 2964 if (category.cookie_category_status != 1) continue; 2965 2966 var categoryId = category.cookie_category_id; 2967 var checkedByDefault = category.cookie_category_checked_by_default; 2968 2969 var shouldRender = false; 2970 2971 if (!settingsObj) { 2972 // Logic for when no decision has been made yet 2973 if (loadState === 'before') { 2974 // "Load Before Consent" only for "No (allow change by User)" (0) 2975 shouldRender = checkedByDefault == 0; 2976 } else if (loadState === 'after') { 2977 // "Load After Consent" for "Yes (allow change)" (1) and "Yes (locked)" (2) 2978 shouldRender = checkedByDefault == 1 || checkedByDefault == 2; 2979 } 2980 } else { 2981 // Logic for after a decision (Accept/Decline) has been made 2982 var isAccepted = 2983 (settingsObj && settingsObj[categoryId] == 1) || 2984 checkedByDefault == 2; 2985 2986 if (loadState === 'after') { 2987 // "Load After Consent" if the category is accepted or locked 2988 shouldRender = isAccepted; 2989 } else if (loadState === 'decline') { 2990 // "Load After Decline" if the category is declined and not locked 2991 shouldRender = !isAccepted && checkedByDefault != 2; 2992 } 2993 } 2994 2995 // Select all script placeholders for the current state and category 2996 var placeholders = document.querySelectorAll( 2997 '[data-cpnb-js][data-cpnb-load="' + 2998 loadState + 2999 '"][data-cpnb-category="' + 3000 categoryId + 3001 '"]' 3002 ); 3003 3004 for (var i = 0; i < placeholders.length; i++) { 3005 var placeholder = placeholders[i]; 3006 var isScriptPlaceholder = 3007 placeholder.tagName && 3008 placeholder.tagName.toLowerCase() === 'script'; 3009 3010 if (isScriptPlaceholder) { 3011 // Remove previously injected nodes for this placeholder 3012 if (placeholder._cpnbInjectedNodes) { 3013 for ( 3014 var r = 0; 3015 r < placeholder._cpnbInjectedNodes.length; 3016 r++ 3017 ) { 3018 var oldNode = placeholder._cpnbInjectedNodes[r]; 3019 if (oldNode && oldNode.parentNode) { 3020 oldNode.parentNode.removeChild(oldNode); 3021 } 3022 } 3023 } 3024 placeholder._cpnbInjectedNodes = []; 3025 } else { 3026 placeholder.innerHTML = ''; 3027 } 3028 3029 if (!shouldRender) continue; 3030 3031 var decoded = cpnb_decodeBlockCookiePayload( 3032 placeholder.getAttribute('data-cpnb-js') 3033 ); 3034 3035 if (!decoded) continue; 3036 3037 // Inject the scripts into the placeholder 3038 var template = document.createElement('template'); 3039 template.innerHTML = decoded; 3040 var fragment = document.createDocumentFragment(); 3041 var nodes = template.content.childNodes; 3042 3043 for (var n = 0; n < nodes.length; n++) { 3044 var node = nodes[n]; 3045 if ( 3046 node.nodeName && 3047 node.nodeName.toLowerCase() === 'script' 3048 ) { 3049 var script = document.createElement('script'); 3050 if (node.attributes) { 3051 for (var a = 0; a < node.attributes.length; a++) { 3052 script.setAttribute( 3053 node.attributes[a].name, 3054 node.attributes[a].value 3055 ); 3056 } 3057 } 3058 script.text = node.text || node.textContent || ''; 3059 fragment.appendChild(script); 3060 } else { 3061 fragment.appendChild(node.cloneNode(true)); 3062 } 3063 } 3064 3065 if (isScriptPlaceholder) { 3066 var parent = placeholder.parentNode; 3067 if (!parent) continue; 3068 3069 var injectedNodes = []; 3070 var childNodes = fragment.childNodes; 3071 for (var c = 0; c < childNodes.length; c++) { 3072 injectedNodes.push(childNodes[c]); 3073 } 3074 3075 parent.insertBefore(fragment, placeholder.nextSibling); 3076 placeholder._cpnbInjectedNodes = injectedNodes; 3077 placeholder._cpnbWasEverInjected = true; 3078 } else { 3079 placeholder.appendChild(fragment); 3080 } 3081 } 3082 3083 // Block elements: when consent for this category is now granted ('after' + shouldRender), 3084 // restore the server-blocked elements from their inert <template> copies. When still blocked, 3085 // there is nothing to do â the element was already removed server-side. 3086 if (loadState === 'after') { 3087 if (shouldRender) { 3088 cpnb_removeUrlPlaceholders(categoryId); 3089 } else { 3090 cpnb_insertUrlPlaceholders(categoryId); 3091 } 3092 } 3093 } 3094} 3095 3096function cpnb_handleBlockCookieScripts() { 3097 // Check if cpnb_cookiesSettings has been saved yet. NOTE: this must check 3098 // cpnb_cookiesSettings specifically, not the Accept/Decline cookie - the "Save Settings" 3099 // modal flow commits cpnb_cookiesSettings and calls this function *before* it determines 3100 // and writes the Accept/Decline cookie, so checking that cookie here would be stale. 3101 var decisionMade = 3102 cpnb_hasConsentCookie('cpnb_cookiesSettings') || 3103 (typeof cpnb_config !== 'undefined' && !!cpnb_config.w357_co
3103okie_settings_value); 3104 3105 if (!decisionMade) { 3106 // Initial run where no decision has been made yet 3107 cpnb_renderBlockCookieScripts('before'); 3108 cpnb_renderBlockCookieScripts('after'); 3109 } else { 3110 // After a decision (Accept/Decline) or on subsequent page loads 3111 cpnb_renderBlockCookieScripts('after'); 3112 cpnb_renderBlockCookieScripts('decline'); 3113 } 3114} 3115 3116// Accepts consent for exactly one category (an [accept] placeholder link), without touching any 3117// other category and without opening the cookie manager modal. Mirrors the single-category cookie 3118// write acceptFunction/cpnb_m_saveCategoryCookiesState already do, scoped down to one category. 3119function cpnb_acceptSingleCategoryConsent(categoryId) { 3120 var settings = cpnb_getConsentCookieValue('cpnb_cookiesSettings') || afterCategoriesSettingsCookie || {}; 3121 settings[categoryId] = 1; 3122 afterCategoriesSettingsCookie = settings; 3123 cpnb_setConsentCookie('cpnb_cookiesSettings', settings, afterExpirationCookies); 3124} 3125 3126// Delegated click handler for [accept]-rendered links (.cpnb-accept-link), shared by the <cpnb> tag 3127// and Block Elements placeholders. Bound once at plugin init. 3128function cpnb_bindAcceptLinks() { 3129 if (window.cpnb_accept_links_bound) { 3130 return; 3131 } 3132 window.cpnb_accept_links_bound = true; 3133 3134 document.addEventListener( 3135 'click', 3136 function (event) { 3137 var target = event.target; 3138 while (target && target !== document) { 3139 if (target.classList && target.classList.contains('cpnb-accept-link')) { 3140 // Only act inside the plugin's own placeholder, for a known category, with the 3141 // matching <template data-cpnb-blocked-for> sibling buildPlaceholder() always 3142 // pairs it with - article content can otherwise carry the same class/attribute. 3143 var categoryId = target.getAttribute('data-cpnb-accept-category'); 3144 var placeholderAncestor = target.closest('[data-cpnb-placeholder-for]'); 3145 var pairedTemplate = placeholderAncestor && placeholderAncestor.nextElementSibling; 3146 var isPluginRendered = placeholderAncestor 3147 && placeholderAncestor.getAttribute('data-cpnb-placeholder-for') === categoryId 3148 && pairedTemplate 3149 && pairedTemplate.tagName === 'TEMPLATE' 3150 && pairedTemplate.getAttribute('data-cpnb-blocked-for') === categoryId; 3151 // cpnb_cookiesCategories is keyed by group index, not category id - the id is 3152 // each entry's .cookie_category_id (same lookup cpnb_renderBlockCookieScripts uses). 3153 var isKnownCategory = false; 3154 if (categoryId && typeof cpnb_cookiesCategories !== 'undefined') { 3155 for (var knownCatKey in cpnb_cookiesCategories) { 3156 if (cpnb_cookiesCategories[knownCatKey] && cpnb_cookiesCategories[knownCatKey].cookie_category_id === categoryId) { 3157 isKnownCategory = true; 3158 break; 3159 } 3160 } 3161 } 3162 3163 if (isPluginRendered && isKnownCategory) { 3164 event.preventDefault(); 3165 cpnb_acceptSingleCategoryConsent(categoryId); 3166 cpnb_removeUrlPlaceholders(categoryId); 3167 cpnb_handleBlockCookieScripts(); 3168 } 3169 return; 3170 } 3171 target = target.parentNode; 3172 } 3173 }, 3174 false 3175 ); 3176} 3177 3178// Responsive left menu 3179function cpnb_toggle_responsive_menu(x) { 3180 x.classList.toggle('cpnb-toggle-menu-change'); 3181 3182 if ( 3183 document.getElementsByClassName('cpnb-manager-modal-left')[0].style 3184 .display == 'block' 3185 ) { 3186 document.getElementsByClassName( 3187 'cpnb-manager-modal-left' 3188 )[0].style.display = 'none'; 3189 } else { 3190 document.getElementsByClassName( 3191 'cpnb-manager-modal-left' 3192 )[0].style.display = 'block'; 3193 } 3194} 3195 3196function cpnb_toggle_responsive_menu_hide_menu() { 3197 if (window.innerWidth < 601) { 3198 document.getElementsByClassName( 3199 'cpnb-manager-modal-left' 3200 )[0].style.display = 'none'; 3201 } 3202} 3203
3204function cpnb_fetchCookiesInfoTable() { 3205 var container = document.getElementById('cpnb-cit-container'); 3206 if (!container || !container.getAttribute('data-cpnb-table-ajax')) { 3207 return; 3208 } 3209 3210 container.innerHTML = '<div class="cpnb-cit-spinner"></div>'; 3211 3212 var baseUrl = 3213 typeof cpnb_config !== 'undefined' && cpnb_config.w357_base_ajax_url 3214 ? cpnb_config.w357_base_ajax_url 3215 : ''; 3216 3217 var url = 3218 baseUrl + 3219 'index.php?option=com_ajax&plugin=cookiespolicynotificationbar&format=raw&method=getCookiesInfoTable&_=' + 3220 Date.now(); 3221 3222 fetch(url) 3223 .then(function (response) { 3224 if (!response.ok) { 3225 throw new Error('CPNB: getCookiesInfoTable responded with ' + response.status); 3226 } 3227 return response.text(); 3228 }) 3229 .then(function (html) { 3230 container.innerHTML = html; 3231 }) 3232 .catch(function (err) { 3233 console.error(err); 3234 }); 3235} 3236 3237/** 3238 * TRIGGER EVENTS 3239 */ 3240document.addEventListener('click', cpnb_handleActionButtonClick, false); 3241document.addEventListener('change', cpnb_handleLockedCheckboxChange, false); 3242document.addEventListener('change', cpnb_handleCategoryCheckboxChange, false); 3243document.addEventListener('DOMContentLoaded', cpnb_fetchCookiesInfoTable, false); 3244document.addEventListener('click', function (event) { 3245 var reloadBtn = event.target.closest('#cpnb-reload-btn-cit'); 3246 if (!reloadBtn) { 3247 return; 3248 } 3249 event.preventDefault(); 3250 cpnb_fetchCookiesInfoTable(); 3251}, false); 3252 3253function sendPostRequest(url, params) { 3254 // Params should be an object containing key-value pairs 3255 let formData = new URLSearchParams(params).toString(); 3256 3257 fetch(url, { 3258 method: 'POST', 3259 headers: { 3260 'Content-Type': 'application/x-www-form-urlencoded', 3261 }, 3262 body: formData, // Sending the URL-encoded string 3263 }) 3264 .then((response) => { 3265 if (!response.ok) { 3266 throw new Error('Network response was not ok'); 3267 } 3268 // Reload the page after successful POST 3269 //window.location.reload(); 3270 }) 3271 .catch((error) => { 3272 console.error('Failed to send POST request:', error); 3273 }); 3274}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.