1/** 2 * @file 3 * Cookie Compliance Javascript. 4 * 5 * Statuses: 6 * null: not yet agreed (or withdrawn), show popup 7 * 0: Disagreed 8 * 1: Agreed, show thank you banner 9 * 2: Agreed. 10 */ 11 12(function ($) { 13 'use strict'; 14 var euCookieComplianceBlockCookies; 15 16 Drupal.behaviors.eu_cookie_compliance_popup = { 17 attach: function (context, settings) { 18 $(Drupal.settings.eu_cookie_compliance.containing_element, context).once('eu-cookie-compliance', function () { 19 20 // Initialize internal variables. 21 _euccCurrentStatus = self.getCurrentStatus(); 22 _euccSelectedCategories = self.getAcceptedCategories(); 23 24 // If configured, check JSON callback to determine if in EU. 25 if (Drupal.settings.eu_cookie_compliance.popup_eu_only_js) { 26 if (Drupal.eu_cookie_compliance.showBanner()) { 27 var url = Drupal.settings.basePath + Drupal.settings.pathPrefix + 'eu-cookie-compliance-check'; 28 var data = {}; 29 $.getJSON(url, data, function (data) { 30 // If in the EU, show the compliance banner. 31 if (data.in_eu) { 32 Drupal.eu_cookie_compliance.execute(); 33 } 34 35 // If not in EU, set an agreed cookie automatically. 36 else { 37 Drupal.eu_cookie_compliance.setStatus(2); 38 } 39 }); 40 } 41 } 42 43 // Otherwise, fallback to standard behavior which is to render the banner. 44 else { 45 Drupal.eu_cookie_compliance.execute(); 46 } 47 }).addClass('eu-cookie-compliance-status-' + Drupal.eu_cookie_compliance.getCurrentStatus()); 48 } 49 }; 50 51 // Sep up the namespace as a function to store list of arguments in a queue. 52 Drupal.eu_cookie_compliance = Drupal.eu_cookie_compliance || function () { 53 (Drupal.eu_cookie_compliance.queue = Drupal.eu_cookie_compliance.queue || []).push(arguments) 54 }; 55 // Initialize the object with some data. 56 Drupal.eu_cookie_compliance.a = +new Date; 57 // A shorter name to use when accessing the namespace. 58 var self = Drupal.eu_cookie_compliance; 59 // Save our cookie preferences locally only. 60 // Used by external scripts to modify data before it is used. 61 var _euccSelectedCategories = []; 62 var _euccCurrentStatus = null; 63 self.updateSelectedCategories = function (categories) { 64 _euccSelectedCategories = categories; 65 } 66 self.updateCurrentStatus = function (status) { 67 _euccCurrentStatus = status; 68 } 69 70 Drupal.eu_cookie_compliance.execute = function () { 71 try { 72 if (!Drupal.settings.eu_cookie_compliance.popup_enabled) { 73 return; 74 } 75 76 if (!Drupal.eu_cookie_compliance.cookiesEnabled()) { 77 return; 78 } 79 80 if (typeof Drupal.eu_cookie_compliance.getVersion() === 'undefined') { 81 // If version doesn't exist as a cookie, set it to the current one. 82 // For modules that update to this, it prevents needless retriggering 83 // For first time runs, it makes no difference as the other IF statements 84 // below will still cause the popup to trigger 85 // For incrementing the version, it also makes no difference as either it's 86 // a returning user and will have a version set, or it's a new user and 87 // the other checks will trigger it. 88 Drupal.eu_cookie_compliance.setVersion(); 89 } 90 91 Drupal.eu_cookie_compliance.updateCheck(); 92 var versionChanged = Drupal.eu_cookie_compliance.getVersion() !== Drupal.settings.eu_cookie_compliance.cookie_policy_version; 93 // Closed if status has a value and the version hasn't changed. 94 var closed = _euccCurrentStatus !== null && !versionChanged; 95 if ((_euccCurrentStatus === 0 && Drupal.settings.eu_cookie_compliance.method === 'default') || _euccCurrentStatus === null || (Drupal.settings.eu_cookie_compliance.withdraw_enabled && Drupal.settings.eu_cookie_compliance.withdraw_button_on_info_popup) || versionChanged) { 96 if (Drupal.settings.eu_cookie_compliance.withdraw_enabled || !Drupal.settings.eu_cookie_compliance.disagree_do_not_show_popup || _euccCurrentStatus === null || versionChanged) { 97 // Detect mobile here and use mobile_popup_html_info, if we have a mobile device. 98 if (window.matchMedia('(max-width: ' + Drupal.settings.eu_cookie_compliance.mobile_breakpoint + 'px)').matches && Drupal.settings.eu_cookie_compliance.use_mobile_message) { 99 Drupal.eu_cookie_compliance.createPopup(Drupal.settings.eu_cookie_compliance.mobile_popup_html_info, closed); 100 } 101 else { 102 Drupal.eu_cookie_compliance.createPopup(Drupal.settings.eu_cookie_compliance.popup_html_info, closed); 103 } 104 105 Drupal.eu_cookie_compliance.initPopup(); 106 Drupal.eu_cookie_compliance.resizeListener(); 107 } 108 } 109 if (_euccCurrentStatus === 1 && Drupal.settings.eu_cookie_compliance.popup_agreed_enabled) { 110 // Thank you banner. 111 Drupal.eu_cookie_compliance.createPopup(Drupal.settings.eu_cookie_compliance.popup_html_agreed); 112 Drupal.eu_cookie_compliance.attachHideEvents(); 113 } 114 else if (_euccCurrentStatus === 2 && Drupal.settings.eu_cookie_compliance.withdraw_enabled) { 115 if (!Drupal.settings.eu_cookie_compliance.withdraw_button_on_info_popup) { 116 Drupal.eu_cookie_compliance.createWithdrawBanner(Drupal.settings.eu_cookie_compliance.withdraw_markup); 117 Drupal.eu_cookie_compliance.resizeListener(); 118 } 119 Drupal.eu_cookie_compliance.attachWithdrawEvents(); 120 } 121 } 122 catch (e) { 123 } 124 }; 125 126 Drupal.eu_cookie_compliance.initPopup = function () { 127 Drupal.eu_cookie_compliance.attachAgreeEvents(); 128 129 if (Drupal.settings.eu_cookie_compliance.method === 'categories') { 130 Drupal.eu_cookie_compliance.setPreferenceCheckboxes(_euccSelectedCategories); 131 Drupal.eu_cookie_compliance.attachSavePreferencesEvents(); 132 } 133 134 if (Drupal.settings.eu_cookie_compliance.withdraw_enabled && Drupal.settings.eu_cookie_compliance.withdraw_button_on_info_popup) { 135 Drupal.eu_cookie_compliance.attachWithdrawEvents(); 136 if (_euccCurrentStatus === 1 || _euccCurrentStatus === 2) { 137 $('.eu-cookie-withdraw-button').show(); 138 } 139 } 140 } 141 142 Drupal.eu_cookie_compliance.positionTab = function () { 143 if (Drupal.settings.eu_cookie_compliance.popup_position) { 144 var totalHeight = $('.eu-cookie-withdraw-tab').outerHeight() + $('.eu-cookie-compliance-banner').outerHeight(); 145 $('.eu-cookie-withdraw-tab').css('margin-top', totalHeight + 'px'); 146 } 147 }; 148 149 Drupal.eu_cookie_compliance.createWithdrawBanner = function (html) { 150 var $html = $('<div></div>').html(html); 151 var $banner = $('.eu-cookie-withdraw-banner', $html); 152 $html.attr('id', 'sliding-popup'); 153 $html.addClass('eu-cookie-withdraw-wrapper'); 154 155 if (!Drupal.settings.eu_cookie_compliance.popup_use_bare_css) { 156 $banner.height(Drupal.settings.eu_cookie_compliance.popup_height) 157 .width(Drupal.settings.eu_cookie_compliance.popup_width); 158 } 159 $html.hide(); 160 var height = 0; 161 if (Drupal.settings.eu_cookie_compliance.popup_position) { 162 $html.prependTo(Drupal.settings.eu_cookie_compliance.containing_element); 163 height = $html.outerHeight(); 164 165 $html.show() 166 .addClass('sliding-popup-top') 167 .addClass('clearfix') 168 .css({ top: !Drupal.settings.eu_cookie_compliance.fixed_top_position ? -(parseInt($(Drupal.settings.eu_cookie_compliance.containing_element).css('padding-top')) + parseInt($(Drupal.settings.eu_cookie_compliance.containing_element).css('margin-top')) + height) : -1 * height }); 169 // For some reason, the tab outerHeight is -10 if we don't use a timeout 170 // function to reveal the tab. 171 setTimeout(function () { 172 $html.animate({ top: !Drupal.settings.eu_cookie_compliance.fixed_top_position ? -(parseInt($(Drupal.settings.eu_cookie_compliance.containing_element).css('padding-top')) + parseInt($(Drupal.settings.eu_cookie_compliance.containing_element).css('margin-top')) + height) : -1 * height }, Drupal.settings.eu_cookie_compliance.popup_delay, null, function () { 173 $html.trigger('eu_cookie_compliance_popup_open'); 174 $('body').addClass('eu-cookie-compliance-popup-open'); 175 Drupal.eu_cookie_compliance.positionTab(); 176 }); 177 }.bind($html, height), 0); 178 } 179 else { 180 if (Drupal.settings.eu_cookie_compliance.better_support_for_screen_readers) { 181 $html.prependTo(Drupal.settings.eu_cookie_compliance.containing_element); 182 } 183 else { 184 $html.appendTo(Drupal.settings.eu_cookie_compliance.containing_element); 185 } 186 height = $html.outerHeight(); 187 $html.show() 188 .addClass('sliding-popup-bottom') 189 .css({ bottom: -1 * height }); 190 // For some reason, the tab outerHeight is -10 if we don't use a timeout 191 // function to reveal the tab. 192 setTimeout(function () { 193 $html.animate({ bottom: -1 * height }, Drupal.settings.eu_cookie_compliance.popup_delay, null, function () { 194 $html.trigger('eu_cookie_compliance_popup_open'); 195 $('body').addClass('eu-cookie-compliance-popup-open'); 196 }); 197 }.bind($html, height), 0); 198 } 199 }; 200 201 Drupal.eu_cookie_compliance.toggleWithdrawBanner = function () { 202 var $wrapper = $('#sliding-popup'); 203 var height = $wrapper.outerHeight(); 204 var $bannerIsShowing = ($wrapper.find('.eu-cookie-compliance-banner, .eu-cookie-withdraw-banner').is(':visible')); 205 if ($bannerIsShowing) { 206 $bannerIsShowing = Drupal.settings.eu_cookie_compliance.popup_position ? parseInt($wrapper.css('top')) === (!Drupal.settings.eu_cookie_compliance.fixed_top_position ? -(parseInt($(Drupal.settings.eu_cookie_compliance.containing_element).css('padding-top')) + parseInt($(Drupal.settings.eu_cookie_compliance.containing_element).css('margin-top'))) : 0) : parseInt($wrapper.css('bottom')) === 0; 207 } 208 if (Drupal.settings.eu_cookie_compliance.popup_position) { 209 if ($bannerIsShowing) { 210 $wrapper.animate({ top: !Drupal.settings.eu_cookie_compliance.fixed_top_position ? -(parseInt($(Drupal.settings.eu_cookie_compliance.containing_element).css('padding-top')) + parseInt($(Drupal.settings.eu_cookie_compliance.containing_element).css('margin-top')) + height) : -1 * height }, Drupal.settings.eu_cookie_compliance.popup_delay).trigger('eu_cookie_compliance_popup_close'); 211 $('body').removeClass('eu-cookie-compliance-popup-open'); 212 } 213 else { 214 // If "Do not show cookie policy when the user clicks the Cookie policy button." is 215 // selected, the inner banner may be hidden. 216 $wrapper.find('.eu-cookie-compliance-banner').show(); 217 $wrapper.animate({ top: !Drupal.settings.eu_cookie_compliance.fixed_top_position ? -(parseInt($(Drupal.settings.eu_cookie_compliance.containing_element).css('padding-top')) + parseInt($(Drupal.settings.eu_cookie_compliance.containing_element).css('margin-top'))) : 0 }, Drupal.settings.eu_cookie_compliance.popup_delay).trigger('eu_cookie_compliance_popup_open'); 218 $('body').addClass('eu-cookie-compliance-popup-open'); 219 } 220 } 221 else { 222 if ($bannerIsShowing) { 223 $wrapper.animate({ 'bottom': -1 * height }, Drupal.settings.eu_cookie_compliance.popup_delay).trigger('eu_cookie_compliance_popup_close'); 224 $('body').removeClass('eu-cookie-compliance-popup-open'); 225 } 226 else { 227 // If "Do not show cookie policy when the user clicks the Cookie policy button." is 228 // selected, the inner banner may be hidden. 229 $wrapper.find('.eu-cookie-compliance-banner').show(); 230 $wrapper.animate({ 'bottom': 0 }, Drupal.settings.eu_cookie_compliance.popup_delay).trigger('eu_cookie_compliance_popup_open'); 231 $('body').addClass('eu-cookie-compliance-popup-open'); 232 } 233 } 234 }; 235 236 Drupal.eu_cookie_compliance.resizeListener = function () { 237 var $wrapper = $('#sliding-popup'); 238 239 const debounce = function (func, wait ) { 240 var timeout; 241
242 return function executedFunction() { 243 var later = function () { 244 clearTimeout(timeout); 245 func(); 246 }; 247 248 clearTimeout(timeout); 249 timeout = setTimeout(later, wait); 250 }; 251 }; 252 253 var checkIfPopupIsClosed = debounce(function () { 254 var wrapperHeight = $wrapper.outerHeight(); 255 if (Drupal.settings.eu_cookie_compliance.popup_position) { 256 var wrapperTopProperty = parseFloat($wrapper.css('bottom')); 257 if (wrapperTopProperty !== 0) { 258 $wrapper.css('top', wrapperHeight * -1); 259 } 260 } 261 else { 262 var wrapperBottomProperty = parseFloat($wrapper.css('bottom')); 263 if (wrapperBottomProperty !== 0) { 264 $wrapper.css('bottom', wrapperHeight * -1); 265 } 266 } 267 }, 50); 268 269 setTimeout(function () { 270 checkIfPopupIsClosed(); 271 }); 272 273 window.addEventListener('resize', checkIfPopupIsClosed); 274 275 }; 276 277 Drupal.eu_cookie_compliance.createPopup = function (html, closed) { 278 // This fixes a problem with jQuery 1.9. 279 var $popup = $('<div></div>').html(html); 280 $popup.attr('id', 'sliding-popup'); 281 if (!Drupal.settings.eu_cookie_compliance.popup_use_bare_css) { 282 $popup.height(Drupal.settings.eu_cookie_compliance.popup_height) 283 .width(Drupal.settings.eu_cookie_compliance.popup_width); 284 } 285 286 $popup.hide(); 287 var height = 0; 288 if (Drupal.settings.eu_cookie_compliance.popup_position) { 289 $popup.prependTo(Drupal.settings.eu_cookie_compliance.containing_element); 290 height = $popup.outerHeight(); 291 $popup.show() 292 .attr({ 'class': 'sliding-popup-top clearfix' }) 293 .css({ top: !Drupal.settings.eu_cookie_compliance.fixed_top_position ? -(parseInt($(Drupal.settings.eu_cookie_compliance.containing_element).css('padding-top')) + parseInt($(Drupal.settings.eu_cookie_compliance.containing_element).css('margin-top')) + height) : -1 * height }); 294 if (closed !== true) { 295 $popup.animate({ top: !Drupal.settings.eu_cookie_compliance.fixed_top_position ? -(parseInt($(Drupal.settings.eu_cookie_compliance.containing_element).css('padding-top')) + parseInt($(Drupal.settings.eu_cookie_compliance.containing_element).css('margin-top'))) : 0 }, Drupal.settings.eu_cookie_compliance.popup_delay, null, function () { 296 $popup.trigger('eu_cookie_compliance_popup_open'); 297 $('body').addClass('eu-cookie-compliance-popup-open'); 298 Drupal.eu_cookie_compliance.positionTab(); 299 }); 300 } 301 else { 302 setTimeout(function () { 303 Drupal.eu_cookie_compliance.positionTab(); 304 }, 0); 305 } 306 } 307 else { 308 if (Drupal.settings.eu_cookie_compliance.better_support_for_screen_readers) { 309 $popup.prependTo(Drupal.settings.eu_cookie_compliance.containing_element); 310 } 311 else { 312 $popup.appendTo(Drupal.settings.eu_cookie_compliance.containing_element); 313 } 314 315 height = $popup.outerHeight(); 316 $popup.show() 317 .attr({ 'class': 'sliding-popup-bottom' }) 318 .css({ bottom: -1 * height }); 319 if (closed !== true) { 320 $popup.animate({bottom: 0}, Drupal.settings.eu_cookie_compliance.popup_delay, null, function () { 321 $popup.trigger('eu_cookie_compliance_popup_open'); 322 $('body').addClass('eu-cookie-compliance-popup-open'); 323 }); 324 } 325 } 326 }; 327 328 Drupal.eu_cookie_compliance.attachAgreeEvents = function () { 329 var clickingConfirms = Drupal.settings.eu_cookie_compliance.popup_clicking_confirmation; 330 var scrollConfirms = Drupal.settings.eu_cookie_compliance.popup_scrolling_confirmation; 331 332 if (Drupal.settings.eu_cookie_compliance.method === 'categories' && Drupal.settings.eu_cookie_compliance.enable_save_preferences_button) { 333 // The agree button becomes an agree to all categories button when the 'save preferences' button is present. 334 $('.agree-button').click(Drupal.eu_cookie_compliance.acceptAllAction); 335 } 336 else { 337 $('.agree-button').click(Drupal.eu_cookie_compliance.acceptAction); 338 } 339 $('.decline-button').click(Drupal.eu_cookie_compliance.declineAction); 340 341 if (clickingConfirms) { 342 $('a, input[type=submit], button[type=submit]').not('.popup-content *').bind('click.euCookieCompliance', Drupal.eu_cookie_compliance.acceptAction); 343 } 344 345 if (scrollConfirms) { 346 var alreadyScrolled = false;
347 var scrollHandler = function () { 348 if (alreadyScrolled) { 349 Drupal.eu_cookie_compliance.acceptAction(); 350 $(window).off('scroll', scrollHandler); 351 } 352 else { 353 alreadyScrolled = true; 354 } 355 }; 356 357 $(window).bind('scroll', scrollHandler); 358 } 359 360 $('.find-more-button').not('.find-more-button-processed').addClass('find-more-button-processed').click(Drupal.eu_cookie_compliance.moreInfoAction); 361 }; 362 363 Drupal.eu_cookie_compliance.attachSavePreferencesEvents = function () { 364 $('.eu-cookie-compliance-save-preferences-button').click(Drupal.eu_cookie_compliance.savePreferencesAction); 365 }; 366 367 Drupal.eu_cookie_compliance.attachHideEvents = function () { 368 var popupHideAgreed = Drupal.settings.eu_cookie_compliance.popup_hide_agreed; 369 var clickingConfirms = Drupal.settings.eu_cookie_compliance.popup_clicking_confirmation; 370 $('.hide-popup-button').click(function () { 371 Drupal.eu_cookie_compliance.changeStatus(2); 372 } 373 ); 374 if (clickingConfirms) { 375 $('a, input[type=submit], button[type=submit]').unbind('click.euCookieCompliance'); 376 } 377 378 if (popupHideAgreed) { 379 $('a, input[type=submit], button[type=submit]').bind('click.euCookieComplianceHideAgreed', function () { 380 Drupal.eu_cookie_compliance.changeStatus(2); 381 }); 382 } 383 384 $('.find-more-button').not('.find-more-button-processed').addClass('find-more-button-processed').click(Drupal.eu_cookie_compliance.moreInfoAction); 385 }; 386 387 Drupal.eu_cookie_compliance.attachWithdrawEvents = function () { 388 $('.eu-cookie-withdraw-button').click(Drupal.eu_cookie_compliance.withdrawAction); 389 $('.eu-cookie-withdraw-tab').click(Drupal.eu_cookie_compliance.toggleWithdrawBanner); 390 }; 391 392 Drupal.eu_cookie_compliance.acceptAction = function () { 393 var agreedEnabled = Drupal.settings.eu_cookie_compliance.popup_agreed_enabled; 394 var nextStatus = 1; 395 if (!agreedEnabled) { 396 Drupal.eu_cookie_compliance.setStatus(1); 397 nextStatus = 2; 398 } 399 400 if (!euCookieComplianceHasLoadedScripts && typeof euCookieComplianceLoadScripts === "function") { 401 euCookieComplianceLoadScripts(); 402 } 403 404 if (typeof euCookieComplianceBlockCookies !== 'undefined') { 405 clearInterval(euCookieComplianceBlockCookies); 406 } 407 408 if (Drupal.settings.eu_cookie_compliance.method === 'categories') { 409 // Select Checked categories. 410 var categories = $("#eu-cookie-compliance-categories input:checkbox:checked").map(function () { 411 return $(this).val(); 412 }).get(); 413 Drupal.eu_cookie_compliance.setAcceptedCategories(categories); 414 // Load scripts for all categories. If no categories selected, none 415 // will be loaded. 416 Drupal.eu_cookie_compliance.loadCategoryScripts(categories); 417 if (!categories.length) { 418 // No categories selected is the same as declining all cookies. 419 nextStatus = 0; 420 } 421 } 422 423 Drupal.eu_cookie_compliance.changeStatus(nextStatus); 424 425 if (Drupal.settings.eu_cookie_compliance.withdraw_enabled && Drupal.settings.eu_cookie_compliance.withdraw_button_on_info_popup) { 426 Drupal.eu_cookie_compliance.attachWithdrawEvents(); 427 if (_euccCurrentStatus === 1 || _euccCurrentStatus === 2) { 428 $('.eu-cookie-withdraw-button').show(); 429 } 430 } 431 }; 432 433 Drupal.eu_cookie_compliance.acceptAllAction = function () { 434 var allCategories = Drupal.settings.eu_cookie_compliance.cookie_categories; 435 Drupal.eu_cookie_compliance.setPreferenceCheckboxes(allCategories); 436 Drupal.eu_cookie_compliance.acceptAction(); 437 } 438 439 Drupal.eu_cookie_compliance.savePreferencesAction = function () { 440 var categories = $("#eu-cookie-compliance-categories input:checkbox:checked").map(function () { 441 return $(this).val(); 442 }).get(); 443 var agreedEnabled = Drupal.settings.eu_cookie_compliance.popup_agreed_enabled; 444 var nextStatus = 1; 445 if (!agreedEnabled) { 446 Drupal.eu_cookie_compliance.setStatus(1); 447 nextStatus = 2; 448 } 449 450 Drupal.eu_cookie_compliance.setAcceptedCategories(categories); 451 // Load scripts for all categories. If no categories selected, none 452 // will be loaded. 453 Drupal.eu_cookie_compliance.loadCategoryScripts(categories); 454 if (!categories.length) { 455 // No categories selected is the same as declining all cookies. 456 nextStatus = 0; 457 } 458 Drupal.eu_cookie_compliance.changeStatus(nextStatus); 459 }; 460 461 Drupal.eu_cookie_compliance.loadCategoryScripts = function (categories) { 462 for (var cat in categories) { 463 if (euCookieComplianceHasLoadedScriptsForCategory[cat] !== true && typeof euCookieComplianceLoadScripts === "function") { 464 euCookieComplianceLoadScripts(categories[cat]); 465 euCookieComplianceHasLoadedScriptsForCategory[cat] = true; 466 } 467 } 468 } 469 470 Drupal.eu_cookie_compliance.declineAction = function () { 471 Drupal.eu_cookie_compliance.setStatus(0); 472 var popup = $('#sliding-popup'); 473 if (popup.hasClass('sliding-popup-top')) { 474 popup.animate({ top: !Drupal.settings.eu_cookie_compliance.fixed_top_position ? -(parseInt($(Drupal.settings.eu_cookie_compliance.containing_element).css('padding-top')) + parseInt($(Drupal.settings.eu_cookie_compliance.containing_element).css('margin-top')) + popup.outerHeight()) : popup.outerHeight() * -1 }, Drupal.settings.eu_cookie_compliance.popup_delay, null, function () { 475 popup.hide(); 476 }).trigger('eu_cookie_compliance_popup_close'); 477 $('body').removeClass('eu-cookie-compliance-popup-open'); 478 } 479 else { 480 popup.animate({ bottom: popup.outerHeight() * -1 }, Drupal.settings.eu_cookie_compliance.popup_delay, null, function () { 481 popup.hide(); 482 }).trigger('eu_cookie_compliance_popup_close'); 483 $('body').removeClass('eu-cookie-compliance-popup-open'); 484 } 485 }; 486 487 Drupal.eu_cookie_compliance.withdrawAction = function () { 488 Drupal.eu_cookie_compliance.setStatus(null); 489 Drupal.eu_cookie_compliance.setAcceptedCategories([]); 490 location.reload(); 491 }; 492 493 Drupal.eu_cookie_compliance.moreInfoAction = function () { 494 if (Drupal.settings.eu_cookie_compliance.disagree_do_not_show_popup) { 495 Drupal.eu_cookie_compliance.setStatus(0); 496 if (Drupal.settings.eu_cookie_compliance.withdraw_enabled && Drupal.settings.eu_cookie_compliance.withdraw_button_on_info_popup) { 497 $('#sliding-popup .eu-cookie-compliance-banner').trigger('eu_cookie_compliance_popup_close').hide(); 498 $('body').removeClass('eu-cookie-compliance-popup-open'); 499 } 500 else { 501 $('#sliding-popup').trigger('eu_cookie_compliance_popup_close').remove(); 502 $('body').removeClass('eu-cookie-compliance-popup-open'); 503 } 504 } 505 else { 506 if (Drupal.settings.eu_cookie_compliance.popup_link_new_window) { 507 window.open(Drupal.settings.eu_cookie_compliance.popup_link); 508 } 509 else { 510 window.location.href = Drupal.settings.eu_cookie_compliance.popup_link; 511 } 512 } 513 }; 514 515 Drupal.eu_cookie_compliance.getCurrentStatus = function () { 516 // Make a new observer & fire it to allow other scripts to hook in. 517 var preStatusLoadObject = new PreStatusLoad(); 518 self.handleEvent('preStatusLoad', preStatusLoadObject); 519 520 var cookieName = (typeof eu_cookie_compliance_cookie_name === 'undefined' || eu_cookie_compliance_cookie_name === '') ? 'cookie-agreed' : eu_cookie_compliance_cookie_name; 521 var storedStatus = $.cookie(cookieName); 522 _euccCurrentStatus = parseInt(storedStatus); 523 if (isNaN(_euccCurrentStatus)) { 524 _euccCurrentStatus = null; 525 } 526 527 // Make a new observer & fire it to allow other scripts to hook in. 528 var postStatusLoadObject = new PostStatusLoad(); 529 self.handleEvent('postStatusLoad', postStatusLoadObject); 530 531 return _euccCurrentStatus; 532 }; 533 534 Drupal.eu_cookie_compliance.setPreferenceCheckboxes = function (categories) { 535 for (var i in categories) { 536 $("#eu-cookie-compliance-categories input:checkbox[value='" + categories[i] + "']").attr("checked", "checked"); 537 } 538 } 539 540 Drupal.eu_cookie_compliance.getAcceptedCategories = function () { 541 // Make a new observer & fire it to allow other scripts to hook in. 542 var prePreferencesLoadObject = new PrePreferencesLoad(); 543 self.handleEvent('prePreferencesLoad', prePreferencesLoadObject); 544 545 var cookieName = (typeof eu_cookie_compliance_cookie_name === 'undefined' || eu_cookie_compliance_cookie_name === '') ? 'cookie-agreed-categories' : Drupal.settings.eu_cookie_compliance.cookie_name + '-categories'; 546 var storedCategories = $.cookie(cookieName); 547 548 if (storedCategories !== null && typeof storedCategories !== 'undefined') { 549 _euccSelectedCategories = JSON.parse(storedCategories); 550 } 551 else { 552 _euccSelectedCategories = []; 553 } 554 555 // Merge in required categories if not already present. Mimics old 556 // logic where "fix first category" changed logic in 557 // .hasAgreedWithCategory and this function. 558 for (var _categoryName in Drupal.settings.eu_cookie_compliance.cookie_categories_details) { 559 var _category = Drupal.settings.eu_cookie_compliance.cookie_categories_details[_categoryName]; 560 if (_category.checkbox_default_state === 'required' && $.inArray(_category.machine_name, _euccSelectedCategories) === -1) { 561 _euccSelectedCategories.push(_category.machine_name); 562 } 563 } 564 565 // Make a new observer & fire it to allow other scripts to hook in. 566 var postPreferencesLoadObject = new PostPreferencesLoad(); 567 self.handleEvent('postPreferencesLoad', postPreferencesLoadObject); 568 569 return _euccSelectedCategories; 570 }; 571 572 Drupal.eu_cookie_compliance.changeStatus = function (value) { 573 var reloadPage = Drupal.settings.eu_cookie_compliance.reload_page; 574 var previousState = _euccCurrentStatus; 575 if (_euccCurrentStatus === value) { 576 return; 577 } 578 579 if (Drupal.settings.eu_cookie_compliance.popup_position) { 580 $('.sliding-popup-top').animate({ top: !Drupal.settings.eu_cookie_compliance.fixed_top_position ? -(parseInt($(Drupal.settings.eu_cookie_compliance.containing_element).css('padding-top')) + parseInt($(Drupal.settings.eu_cookie_compliance.containing_element).css('margin-top')) + $('#sliding-popup').outerHeight()) : $('#sliding-popup').outerHeight() * -1 }, Drupal.settings.eu_cookie_compliance.popup_delay, function () { 581 if (value === 1 && previousState === null && !reloadPage) { 582 $('.sliding-popup-top').not('.eu-cookie-withdraw-wrapper').html(Drupal.settings.eu_cookie_compliance.popup_html_agreed).animate({ top: !Drupal.settings.eu_cookie_compliance.fixed_top_position ? -(parseInt($(Drupal.settings.eu_cookie_compliance.containing_element).css('padding-top')) + parseInt($(Drupal.settings.eu_cookie_compliance.containing_element).css('margin-top'))) : 0 }, Drupal.settings.eu_cookie_compliance.popup_delay); 583 Drupal.eu_cookie_compliance.attachHideEvents(); 584 } 585 else if (previousState === 1) { 586 if (Drupal.settings.eu_cookie_compliance.withdraw_enabled && Drupal.settings.eu_cookie_compliance.withdraw_button_on_info_popup) { 587 // Restore popup content. 588 if (window.matchMedia('(max-width: ' + Drupal.settings.eu_cookie_compliance.mobile_breakpoint + 'px)').matches && Drupal.settings.eu_cookie_compliance.use_mobile_message) { 589 $('.sliding-popup-top').not('.eu-cookie-withdraw-wrapper').html(Drupal.settings.eu_cookie_compliance.mobile_popup_html_info); 590 } 591 else { 592 $('.sliding-popup-top').not('.eu-cookie-withdraw-wrapper').html(Drupal.settings.eu_cookie_compliance.popup_html_info); 593 } 594 Drupal.eu_cookie_compliance.initPopup(); 595 Drupal.eu_cookie_compliance.resizeListener(); 596 } 597 else { 598 $('.sliding-popup-top').not('.eu-cookie-withdraw-wrapper').trigger('eu_cookie_compliance_popup_close').remove(); 599 $('body').removeClass('eu-cookie-compliance-popup-open'); 600 } 601 } 602 if (Drupal.settings.eu_cookie_compliance.withdraw_enabled) { 603 Drupal.eu_cookie_compliance.showWithdrawBanner(value); 604 } 605 }); 606 } 607 else { 608 $('.sliding-popup-bottom').animate({ bottom: $('#sliding-popup').outerHeight() * -1 }, Drupal.settings.eu_cookie_compliance.popup_delay, function () { 609 if (value === 1 && previousState === null && !reloadPage) { 610 $('.sliding-popup-bottom').not('.eu-cookie-withdraw-wrapper').html(Drupal.settings.eu_cookie_compliance.popup_html_agreed).animate({ bottom: 0 }, Drupal.settings.eu_cookie_compliance.popup_delay); 611 Drupal.eu_cookie_compliance.attachHideEvents(); 612 } 613 else if (previousState === 1) { 614 if (Drupal.settings.eu_cookie_compliance.withdraw_enabled && Drupal.settings.eu_cookie_compliance.withdraw_button_on_info_popup) { 615 // Restore popup content. 616 if (window.matchMedia('(max-width: ' + Drupal.settings.eu_cookie_compliance.mobile_breakpoint + 'px)').matches && Drupal.settings.eu_cookie_compliance.use_mobile_message) { 617 $('.sliding-popup-bottom').not('.eu-cookie-withdraw-wrapper').html(Drupal.settings.eu_cookie_compliance.mobile_popup_html_info); 618 } 619 else { 620 $('.sliding-popup-bottom').not('.eu-cookie-withdraw-wrapper').html(Drupal.settings.eu_cookie_compliance.popup_html_info); 621 } 622 Drupal.eu_cookie_compliance.initPopup(); 623 Drupal.eu_cookie_compliance.resizeListener(); 624 } 625 else { 626 $('.sliding-popup-bottom').not('.eu-cookie-withdraw-wrapper').trigger('eu_cookie_compliance_popup_close').remove(); 627 $('body').removeClass('eu-cookie-compliance-popup-open'); 628 } 629 } 630 if (Drupal.settings.eu_cookie_compliance.withdraw_enabled) { 631 Drupal.eu_cookie_compliance.showWithdrawBanner(value); 632 } 633 }); 634 } 635 636 if (reloadPage) { 637 location.reload(); 638 } 639 640 Drupal.eu_cookie_compliance.setStatus(value); 641 }; 642 643 Drupal.eu_cookie_compliance.showWithdrawBanner = function (value) { 644 if (value === 2 && Drupal.settings.eu_cookie_compliance.withdraw_enabled) { 645 if (!Drupal.settings.eu_cookie_compliance.withdraw_button_on_info_popup) { 646 Drupal.eu_cookie_compliance.createWithdrawBanner(Drupal.settings.eu_cookie_compliance.withdraw_markup); 647 Drupal.eu_cookie_compliance.resizeListener(); 648 } 649 Drupal.eu_cookie_compliance.attachWithdrawEvents(); 650 Drupal.eu_cookie_compliance.positionTab(); 651 } 652 }; 653 654 Drupal.eu_cookie_compliance.setStatus = function (status) { 655 656 // Make a new observer & fire it to allow other scripts to hook in. 657 var preStatusSaveObject = new PreStatusSave(); 658 self.handleEvent('preStatusSave', preStatusSaveObject); 659 660 var date = new Date(); 661 var domain = Drupal.settings.eu_cookie_compliance.domain ? Drupal.settings.eu_cookie_compliance.domain : ''; 662 var path = Drupal.settings.eu_cookie_compliance.domain_all_sites ? '/' : Drupal.settings.basePath; 663 var cookieName = (typeof eu_cookie_compliance_cookie_name === 'undefined' || eu_cookie_compliance_cookie_name === '') ? 'cookie-agreed' : eu_cookie_compliance_cookie_name; 664 if (path.length > 1) { 665 var pathEnd = path.length - 1; 666 if (path.lastIndexOf('/') === pathEnd) { 667 path = path.substring(0, pathEnd); 668 } 669 } 670 671 var cookieSession = parseInt(Drupal.settings.eu_cookie_compliance.cookie_session); 672 if (cookieSession) { 673 $.cookie(cookieName, status, { path: path, domain: domain }); 674 } 675 else { 676 var lifetime = parseInt(Drupal.settings.eu_cookie_compliance.cookie_lifetime); 677 date.setDate(date.getDate() + lifetime); 678 $.cookie(cookieName, status, { expires: date, path: path, domain: domain }); 679 } 680 _euccCurrentStatus = status; 681 $(document).trigger('eu_cookie_compliance.changeStatus', [status]); 682 // Status set means something happened, update the version. 683 Drupal.eu_cookie_compliance.setVersion(); 684 685 // Store consent if applicable. 686 if (Drupal.settings.eu_cookie_compliance.store_consent && ((status === 1 && Drupal.settings.eu_cookie_compliance.popup_agreed_enabled) || (status === 2 && !Drupal.settings.eu_cookie_compliance.popup_agreed_enabled))) { 687 var url = Drupal.settings.basePath + Drupal.settings.pathPrefix + 'eu-cookie-compliance/store_consent/ban
687ner'; 688 $.post(url, {}, function (data) { }); 689 } 690 691 // Make a new observer & fire it to allow other scripts to hook in. 692 var postStatusSaveObject = new PostStatusSave(); 693 self.handleEvent('postStatusSave', postStatusSaveObject); 694 695 if (status === 0 && Drupal.settings.eu_cookie_compliance.method === 'opt_out') { 696 euCookieComplianceBlockCookies = setInterval(Drupal.eu_cookie_compliance.BlockCookies, 5000); 697 } 698 }; 699 700 Drupal.eu_cookie_compliance.setAcceptedCategories = function (categories) { 701 702 // Make a new observer & fire it to allow other scripts to hook in. 703 var prePreferencesSaveObject = new PrePreferencesSave(); 704 self.handleEvent('prePreferencesSave', prePreferencesSaveObject); 705 706 var date = new Date(); 707 var domain = Drupal.settings.eu_cookie_compliance.domain ? Drupal.settings.eu_cookie_compliance.domain : ''; 708 var path = Drupal.settings.eu_cookie_compliance.domain_all_sites ? '/' : Drupal.settings.basePath; 709 var cookieName = (typeof eu_cookie_compliance_cookie_name === 'undefined' || eu_cookie_compliance_cookie_name === '') ? 'cookie-agreed-categories' : Drupal.settings.eu_cookie_compliance.cookie_name + '-categories'; 710 if (path.length > 1) { 711 var pathEnd = path.length - 1; 712 if (path.lastIndexOf('/') === pathEnd) { 713 path = path.substring(0, pathEnd); 714 } 715 } 716 var categoriesString = JSON.stringify(categories); 717 var cookie_session = parseInt(Drupal.settings.eu_cookie_compliance.cookie_session); 718 if (cookie_session) { 719 $.cookie(cookieName, categoriesString, { path: path, domain: domain }); 720 } 721 else { 722 var lifetime = parseInt(Drupal.settings.eu_cookie_compliance.cookie_lifetime); 723 date.setDate(date.getDate() + lifetime); 724 $.cookie(cookieName, categoriesString, { expires: date, path: path, domain: domain }); 725 } 726 _euccSelectedCategories = categories; 727 $(document).trigger('eu_cookie_compliance.changePreferences', [categories]); 728 729 // TODO: Store categories with consent if applicable? 730 // Make a new observer & fire it to allow other scripts to hook in. 731 var postPreferencesSaveObject = new PostPreferencesSave(); 732 self.handleEvent('postPreferencesSave', postPreferencesSaveObject); 733 }; 734 735 Drupal.eu_cookie_compliance.hasAgreed = function (category) { 736 var agreed = (_euccCurrentStatus === 1 || _euccCurrentStatus === 2); 737 738 if (category !== undefined && agreed) { 739 agreed = Drupal.eu_cookie_compliance.hasAgreedWithCategory(category); 740 } 741 742 return agreed; 743 }; 744 745 Drupal.eu_cookie_compliance.hasAgreedWithCategory = function (category) { 746 return $.inArray(category, _euccSelectedCategories) !== -1; 747 }; 748 749 Drupal.eu_cookie_compliance.showBanner = function () { 750 var showBanner = false; 751 if ((_euccCurrentStatus === 0 && Drupal.settings.eu_cookie_compliance.method === 'default') || _euccCurrentStatus === null) { 752 if (!Drupal.settings.eu_cookie_compliance.disagree_do_not_show_popup || _euccCurrentStatus === null) { 753 showBanner = true; 754 } 755 } 756 else if (_euccCurrentStatus === 1 && Drupal.settings.eu_cookie_compliance.popup_agreed_enabled) { 757 showBanner = true; 758 } 759 760 return showBanner; 761 }; 762 763 Drupal.eu_cookie_compliance.cookiesEnabled = function () { 764 var cookieEnabled = navigator.cookieEnabled; 765 if (typeof navigator.cookieEnabled === 'undefined' && !cookieEnabled) { 766 document.cookie = 'testCookie'; 767 cookieEnabled = (document.cookie.indexOf('testCookie') !== -1); 768 } 769 770 return cookieEnabled; 771 }; 772 773 Drupal.eu_cookie_compliance.cookieMatches = function (cookieName, pattern) { 774 if (cookieName === pattern) { 775 return true; 776 } 777 if (pattern.indexOf('*') < 0) { 778 return false; 779 } 780 try { 781 var regexp = new RegExp('^' + pattern.replace(/\./g, '\\.').replace(/\*/g, '.+') + '$', 'g'); 782 return regexp.test(cookieName); 783 } 784 catch (err) { 785 return false; 786 } 787 }; 788 789 Drupal.eu_cookie_compliance.isAllowed = function (cookieName) { 790 // Skip the PHP session cookie. 791 if (cookieName.indexOf('SESS') === 0 || cookieName.indexOf('SSESS') === 0) { 792 return true; 793 } 794 // Split the allowed cookies. 795 var euCookieComplianceAllowlist = Drupal.settings.eu_cookie_compliance.allowed_cookies.split(/\r\n|\n|\r/g); 796 797 // Add the EU Cookie Compliance cookie. 798 euCookieComplianceAllowlist.push((typeof Drupal.settings.eu_cookie_compliance.cookie_name === 'undefined' || Drupal.settings.eu_cookie_compliance.cookie_name === '') ? 'cookie-agreed' : Drupal.settings.eu_cookie_compliance.cookie_name); 799 euCookieComplianceAllowlist.push((typeof Drupal.settings.eu_cookie_compliance.cookie_name === 'undefined' || Drupal.settings.eu_cookie_compliance.cookie_name === '') ? 'cookie-agreed-categories' : Drupal.settings.eu_cookie_compliance.cookie_name + '-categories'); 800 euCookieComplianceAllowlist.push((typeof Drupal.settings.eu_cookie_compliance.cookie_name === 'undefined' || Drupal.settings.eu_cookie_compliance.cookie_name === '') ? 'cookie-agreed-version' : Drupal.settings.eu_cookie_compliance.cookie_name + '-version'); 801 802 // Check if the cookie is allowed. 803 for (var item in euCookieComplianceAllowlist) { 804 if (Drupal.eu_cookie_compliance.cookieMatches(cookieName, euCookieComplianceAllowlist[item])) { 805 return true; 806 } 807 // Handle cookie names that are prefixed with a category. 808 if (Drupal.settings.eu_cookie_compliance.method === 'categories') { 809 var separatorPos = euCookieComplianceAllowlist[item].indexOf(":"); 810 if (separatorPos !== -1) { 811 var category = euCookieComplianceAllowlist[item].substr(0, separatorPos); 812 var wlCookieName = euCookieComplianceAllowlist[item].substr(separatorPos + 1); 813 814 if (Drupal.eu_cookie_compliance.cookieMatches(cookieName, wlCookieName) && Drupal.eu_cookie_compliance.hasAgreedWithCategory(category)) { 815 return true; 816 } 817 } 818 } 819 } 820 821 return false;
822 } 823 824 // This code upgrades the cookie agreed status when upgrading for an old version. 825 Drupal.eu_cookie_compliance.updateCheck = function () { 826 var legacyCookie = 'cookie-agreed-' + Drupal.settings.eu_cookie_compliance.popup_language; 827 var domain = Drupal.settings.eu_cookie_compliance.domain ? Drupal.settings.eu_cookie_compliance.domain : ''; 828 var path = Drupal.settings.eu_cookie_compliance.domain_all_sites ? '/' : Drupal.settings.basePath; 829 var cookie = $.cookie(legacyCookie); 830 var date = new Date(); 831 var cookieName = (typeof eu_cookie_compliance_cookie_name === 'undefined' || eu_cookie_compliance_cookie_name === '') ? 'cookie-agreed' : eu_cookie_compliance_cookie_name; 832 833 // jQuery.cookie 1.0 (bundled with Drupal) returns null, 834 // jQuery.cookie 1.4.1 (bundled with some themes) returns undefined. 835 // We had a 1.4.1 related bug where the value was set to 'null' (string). 836 if (cookie !== undefined && cookie !== null && cookie !== 'null') { 837 date.setDate(date.getDate() + parseInt(Drupal.settings.eu_cookie_compliance.cookie_lifetime)); 838 $.cookie(cookieName, cookie, { expires: date, path: path, domain: domain }); 839 840 // Use removeCookie if the function exists. 841 if (typeof $.removeCookie !== 'undefined') { 842 $.removeCookie(legacyCookie); 843 } 844 else { 845 $.cookie(legacyCookie, null, { path: path, domain: domain }); 846 } 847 } 848 }; 849 850 Drupal.eu_cookie_compliance.getVersion = function () { 851 var cookieName = (typeof Drupal.settings.eu_cookie_compliance.cookie_name === 'undefined' || Drupal.settings.eu_cookie_compliance.cookie_name === '') ? 'cookie-agreed-version' : Drupal.settings.eu_cookie_compliance.cookie_name + '-version'; 852 return $.cookie(cookieName); 853 }; 854 855 Drupal.eu_cookie_compliance.setVersion = function () { 856 var date = new Date(); 857 var domain = Drupal.settings.eu_cookie_compliance.domain ? Drupal.settings.eu_cookie_compliance.domain : ''; 858 var path = Drupal.settings.eu_cookie_compliance.domain_all_sites ? '/' : Drupal.settings.basePath; 859 var cookieName = (typeof Drupal.settings.eu_cookie_compliance.cookie_name === 'undefined' || Drupal.settings.eu_cookie_compliance.cookie_name === '') ? 'cookie-agreed-version' : Drupal.settings.eu_cookie_compliance.cookie_name + '-version'; 860 861 if (path.length > 1) { 862 var pathEnd = path.length - 1; 863 if (path.lastIndexOf('/') === pathEnd) { 864 path = path.substring(0, pathEnd); 865 } 866 } 867 var eucc_version = Drupal.settings.eu_cookie_compliance.cookie_policy_version; 868 var cookie_session = parseInt(Drupal.settings.eu_cookie_compliance.cookie_session); 869 if (cookie_session) { 870 $.cookie(cookieName, eucc_version, { path: path, domain: domain }); 871 } 872 else { 873 var lifetime = parseInt(Drupal.settings.eu_cookie_compliance.cookie_lifetime); 874 date.setDate(date.getDate() + lifetime); 875 $.cookie(cookieName, eucc_version, { expires: date, path: path, domain: domain }); 876 } 877 }; 878 879 // Load blocked scripts if the user has agreed to being tracked. 880 var euCookieComplianceHasLoadedScripts = false; 881 var euCookieComplianceHasLoadedScriptsForCategory = []; 882 $(function () { 883 if (Drupal.eu_cookie_compliance.hasAgreed() 884 || (_euccCurrentStatus === null && Drupal.settings.eu_cookie_compliance.method !== 'opt_in' && Drupal.settings.eu_cookie_compliance.method !== 'categories') 885 ) { 886 if (typeof euCookieComplianceLoadScripts === "function") { 887 euCookieComplianceLoadScripts(); 888 } 889 euCookieComplianceHasLoadedScripts = true; 890 891 if (Drupal.settings.eu_cookie_compliance.method === 'categories') { 892 Drupal.eu_cookie_compliance.loadCategoryScripts(_euccSelectedCategories); 893 } 894 } 895 }); 896 897 // Block cookies when the user hasn't agreed. 898 Drupal.behaviors.eu_cookie_compliance_popup_block_cookies = { 899 initialized: false, 900 attach: function (context, settings) { 901 if (!Drupal.behaviors.eu_cookie_compliance_popup_block_cookies.initialized && settings.eu_cookie_compliance) { 902 Drupal.behaviors.eu_cookie_compliance_popup_block_cookies.initialized = true; 903 if (settings.eu_cookie_compliance.automatic_cookies_removal && 904 ((settings.eu_cookie_compliance.method === 'opt_in' && (_euccCurrentStatus === null || !Drupal.eu_cookie_compliance.hasAgreed()))
905 || (settings.eu_cookie_compliance.method === 'opt_out' && !Drupal.eu_cookie_compliance.hasAgreed() && _euccCurrentStatus !== null) 906 || (Drupal.settings.eu_cookie_compliance.method === 'categories')) 907 ) { 908 // Split the allowed cookies. 909 var euCookieComplianceAllowlist = settings.eu_cookie_compliance.allowed_cookies.split(/\r\n|\n|\r/g); 910 911 // Add the EU Cookie Compliance cookie. 912 var cookieName = (typeof eu_cookie_compliance_cookie_name === 'undefined' || eu_cookie_compliance_cookie_name === '') ? 'cookie-agreed' : eu_cookie_compliance_cookie_name; 913 euCookieComplianceAllowlist.push(cookieName); 914 915 euCookieComplianceBlockCookies = setInterval(Drupal.eu_cookie_compliance.BlockCookies, 5000); 916 } 917 } 918 } 919 } 920 921 Drupal.eu_cookie_compliance.BlockCookies = function () { 922 // Load all cookies from jQuery. 923 var cookies = $.cookie(); 924 925 // Check each cookie and try to remove it if it's not allowed. 926 for (var i in cookies) { 927 var remove = true; 928 var hostname = window.location.hostname; 929 var cookieRemoved = false; 930 var index = 0; 931 932 remove = !Drupal.eu_cookie_compliance.isAllowed(i); 933 934 // Remove the cookie if it's not allowed. 935 if (remove) { 936 while (!cookieRemoved && hostname !== '') { 937 // Attempt to remove. 938 cookieRemoved = $.removeCookie(i, { domain: '.' + hostname, path: '/' }); 939 if (!cookieRemoved) { 940 cookieRemoved = $.removeCookie(i, { domain: hostname, path: '/' }); 941 } 942 943 index = hostname.indexOf('.'); 944 945 // We can be on a sub-domain, so keep checking the main domain as well. 946 hostname = (index === -1) ? '' : hostname.substring(index + 1); 947 } 948 949 // Some jQuery Cookie versions don't remove cookies well. Try again
950 // using plain js. 951 if (!cookieRemoved) { 952 document.cookie = i + '=; expires=Thu, 01 Jan 1970 00:00:01 GMT; path=/;'; 953 } 954 } 955 } 956 } 957 958 /** 959 * Filter the event listeners by event name and return the list of handlers. 960 * 961 * @param forEventName 962 * 963 * @returns {[]} 964 */ 965 var filterQueue = function (forEventName) { 966 var handlers = []; 967 if (typeof Drupal.eu_cookie_compliance !== 'undefined' && 968 typeof Drupal.eu_cookie_compliance.queue !== 'undefined' && 969 Drupal.eu_cookie_compliance.queue.length) { 970 // Loop over the list of arguments (objects) pushed into the queue. 971 for (var i = 0; i < Drupal.eu_cookie_compliance.queue.length; i++) { 972 if (Drupal.eu_cookie_compliance.queue[i].length) { 973 var queueItem = Drupal.eu_cookie_compliance.queue[i]; 974 var eventName = queueItem[0]; 975 var eventHandler = queueItem[1]; 976 // If the first element is a string and the second is a function. 977 if (typeof eventName === 'string' && typeof eventHandler === 'function') { 978 // And the string matches the event name. 979 if (eventName === forEventName) { 980 // Return the functions so they can be executed. 981 handlers.push(eventHandler); 982 } 983 } 984 } 985 } 986 } 987 return handlers; 988 } 989 990 /** 991 * Handle event by finding and executing handlers pushed to the queue. 992 */ 993 self.handleEvent = function (eventName, observer) { 994 var handlers = filterQueue(eventName); 995 for (var i = 0; i < handlers.length; i++) { 996 if (typeof handlers[i] !== 'undefined') { 997 observer.subscribe(handlers[i]); 998 observer.fire({ 999 currentStatus: _euccCurrentStatus, 1000 currentCategories: _euccSelectedCategories 1001 }); 1002 observer.unsubscribe(handlers[i]); 1003 } 1004 } 1005 }; 1006 1007 /** 1008 * Observer: triggered before status gets read from cookie. 1009 */ 1010 var PreStatusLoad = (function () { 1011 // Constructor. 1012 var PreStatusLoad = function () { 1013 // Observers. 1014 this.handlers = []; 1015 }; 1016 // Convenience var for the prototype. 1017 var prototype = PreStatusLoad.prototype; 1018 prototype.subscribe = function (fn) { 1019 this.handlers.push(fn); 1020 }; 1021 prototype.unsubscribe = function (fn) { 1022 this.handlers = this.handlers.filter( 1023 function (item) { 1024 if (item !== fn) { 1025 return item; 1026 } 1027 } 1028 ); 1029 }; 1030 prototype.fire = function (o, thisObj) { 1031 var scope = thisObj || window; 1032 this.handlers.forEach(function (item) { 1033 item.call(scope, o); 1034 }); 1035 }; 1036 return PreStatusLoad; 1037 })(); 1038 1039 /** 1040 * Observer: triggered after status was read from cookie and stored in private variable. 1041 */ 1042 var PostStatusLoad = (function () { 1043 // Constructor. 1044 var PostStatusLoad = function () { 1045 // Observers. 1046 this.handlers = []; 1047 }; 1048 // Convenience var for the prototype. 1049 var prototype = PostStatusLoad.prototype; 1050 prototype.subscribe = function (fn) { 1051 this.handlers.push(fn); 1052 }; 1053 prototype.unsubscribe = function (fn) { 1054 this.handlers = this.handlers.filter( 1055 function (item) { 1056 if (item !== fn) { 1057 return item; 1058 } 1059 } 1060 ); 1061 }; 1062 prototype.fire = function (o, thisObj) { 1063 var scope = thisObj || window; 1064 this.handlers.forEach(function (item) { 1065 item.call(scope, o); 1066 }); 1067 }; 1068 return PostStatusLoad; 1069 })(); 1070 1071 /** 1072 * Observer: triggered before status gets saved into cookie. 1073 */ 1074 var PreStatusSave = (function () { 1075 // Constructor. 1076 var PreStatusSave = function () { 1077 // Observers. 1078 this.handlers = []; 1079 }; 1080 // Convenience var for the prototype. 1081 var prototype = PreStatusSave.prototype; 1082 prototype.subscribe = function (fn) { 1083 this.handlers.push(fn); 1084 }; 1085 prototype.unsubscribe = function (fn) { 1086 this.handlers = this.handlers.filter( 1087 function (item) { 1088 if (item !== fn) { 1089 return item; 1090 } 1091 } 1092 ); 1093 }; 1094 prototype.fire = function (o, thisObj) { 1095 var scope = thisObj || window;
1096 this.handlers.forEach(function (item) { 1097 item.call(scope, o); 1098 }); 1099 }; 1100 return PreStatusSave; 1101 })(); 1102 1103 /** 1104 * Observer: triggered after status was saved into cookie. 1105 */ 1106 var PostStatusSave = (function () { 1107 // Constructor. 1108 var PostStatusSave = function () { 1109 // Observers. 1110 this.handlers = []; 1111 }; 1112 // Convenience var for the prototype. 1113 var prototype = PostStatusSave.prototype; 1114 prototype.subscribe = function (fn) { 1115 this.handlers.push(fn); 1116 }; 1117 prototype.unsubscribe = function (fn) { 1118 this.handlers = this.handlers.filter( 1119 function (item) { 1120 if (item !== fn) { 1121 return item; 1122 } 1123 } 1124 ); 1125 }; 1126 prototype.fire = function (o, thisObj) { 1127 var scope = thisObj || window; 1128 this.handlers.forEach(function (item) { 1129 item.call(scope, o); 1130 }); 1131 }; 1132 return PostStatusSave; 1133 })(); 1134 1135 /** 1136 * Observer: triggered before categories are read from cookie. 1137 */ 1138 var PrePreferencesLoad = (function () { 1139 // Constructor. 1140 var prePreferencesLoad = function () { 1141 // Observers. 1142 this.handlers = []; 1143 }; 1144 // Convenience var for the prototype. 1145 var prototype = prePreferencesLoad.prototype; 1146 prototype.subscribe = function (fn) { 1147 this.handlers.push(fn); 1148 }; 1149 prototype.unsubscribe = function (fn) { 1150 this.handlers = this.handlers.filter( 1151 function (item) { 1152 if (item !== fn) { 1153 return item; 1154 } 1155 } 1156 ); 1157 }; 1158 prototype.fire = function (o, thisObj) { 1159 var scope = thisObj || window; 1160 this.handlers.forEach(function (item) { 1161 item.call(scope, o); 1162 }); 1163 }; 1164 return prePreferencesLoad; 1165 })(); 1166 1167 /** 1168 * Observer: triggered after categories were read from cookie. 1169 */ 1170 var PostPreferencesLoad = (function () { 1171 // Constructor. 1172 var postPreferencesLoad = function () { 1173 // Observers. 1174 this.handlers = []; 1175 }; 1176 // Convenience var for the prototype. 1177 var prototype = postPreferencesLoad.prototype; 1178 prototype.subscribe = function (fn) { 1179 this.handlers.push(fn); 1180 }; 1181 prototype.unsubscribe = function (fn) { 1182 this.handlers = this.handlers.filter( 1183 function (item) { 1184 if (item !== fn) { 1185 return item; 1186 } 1187 } 1188 ); 1189 }; 1190 prototype.fire = function (o, thisObj) { 1191 var scope = thisObj || window; 1192 this.handlers.forEach(function (item) { 1193 item.call(scope, o); 1194 }); 1195 }; 1196 return postPreferencesLoad; 1197 })(); 1198 1199 /** 1200 * Observer: triggered before categories are being saved to cookie. 1201 */ 1202 var PrePreferencesSave = (function () { 1203 // Constructor. 1204 var prePreferencesSave = function () { 1205 // Observers. 1206 this.handlers = []; 1207 }; 1208 // Convenience var for the prototype. 1209 var prototype = prePreferencesSave.prototype; 1210 prototype.subscribe = function (fn) { 1211 this.handlers.push(fn); 1212 }; 1213 prototype.unsubscribe = function (fn) { 1214 this.handlers = this.handlers.filter( 1215 function (item) { 1216 if (item !== fn) { 1217 return item; 1218 } 1219 } 1220 ); 1221 }; 1222 prototype.fire = function (o, thisObj) { 1223 var scope = thisObj || window; 1224 this.handlers.forEach(function (item) { 1225 item.call(scope, o); 1226 }); 1227 }; 1228 return prePreferencesSave; 1229 })(); 1230 1231 /** 1232 * Observer: triggered after categories were saved to cookie. 1233 */ 1234 var PostPreferencesSave = (function () { 1235 // Constructor. 1236 var postPreferencesSave = function () { 1237 // Observers. 1238 this.handlers = []; 1239 }; 1240 // Convenience var for the prototype. 1241 var prototype = postPreferencesSave.prototype; 1242 prototype.subscribe = function (fn) { 1243 this.handlers.push(fn); 1244 }; 1245 prototype.unsubscribe = function (fn) { 1246 this.handlers = this.handlers.filter( 1247 function (item) { 1248 if (item !== fn) { 1249 return item; 1250 } 1251 } 1252 ); 1253 }; 1254 prototype.fire = function (o, thisObj) { 1255 var scope = thisObj || window;
1256 this.handlers.forEach(function (item) { 1257 item.call(scope, o); 1258 }); 1259 }; 1260 return postPreferencesSave; 1261 })(); 1262 1263})(jQuery); 1264; 1265(function ($) { 1266 $(document).ready(function() { 1267 $.ajax({ 1268 type: "POST", 1269 cache: false, 1270 url: Drupal.settings.statistics.url, 1271 data: Drupal.settings.statistics.data 1272 }); 1273 }); 1274})(jQuery); 1275;
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.