1/** 2 * @file 3 * bootstrap.js 4 * 5 * Provides general enhancements and fixes to Bootstrap's JS files. 6 */ 7 8var Drupal = Drupal || {}; 9 10(function($, Drupal){ 11 "use strict"; 12 13 var $document = $(document); 14 15 Drupal.behaviors.bootstrap = { 16 attach: function(context) { 17 // Provide some Bootstrap tab/Drupal integration. 18 $(context).find('.tabbable').once('bootstrap-tabs', function () { 19 var $wrapper = $(this); 20 var $tabs = $wrapper.find('.nav-tabs'); 21 var $content = $wrapper.find('.tab-content'); 22 var borderRadius = parseInt($content.css('borderBottomRightRadius'), 10); 23 var bootstrapTabResize = function() { 24 if ($wrapper.hasClass('tabs-left') || $wrapper.hasClass('tabs-right')) { 25 $content.css('min-height', $tabs.outerHeight()); 26 } 27 }; 28 // Add min-height on content for left and right tabs. 29 bootstrapTabResize(); 30 // Detect tab switch. 31 if ($wrapper.hasClass('tabs-left') || $wrapper.hasClass('tabs-right')) { 32 $tabs.on('shown.bs.tab', 'a[data-toggle="tab"]', function (e) { 33 bootstrapTabResize(); 34 if ($wrapper.hasClass('tabs-left')) { 35 if ($(e.target).parent().is(':first-child')) { 36 $content.css('borderTopLeftRadius', '0'); 37 } 38 else { 39 $content.css('borderTopLeftRadius', borderRadius + 'px'); 40 } 41 } 42 else { 43 if ($(e.target).parent().is(':first-child')) { 44 $content.css('borderTopRightRadius', '0'); 45 } 46 else { 47 $content.css('borderTopRightRadius', borderRadius + 'px'); 48 } 49 } 50 }); 51 } 52 }); 53 } 54 }; 55 56 /** 57 * Behavior for . 58 */ 59 Drupal.behaviors.bootstrapFormHasError = { 60 attach: function (context, settings) { 61 if (settings.bootstrap && settings.bootstrap.formHasError) { 62 var $context = $(context); 63 $context.find('.form-item.has-error:not(.form-type-password.has-feedback)').once('error', function () { 64 var $formItem = $(this); 65 var $input = $formItem.find(':input'); 66 $input.on('keyup focus blur', function () { 67 var value = $input.val() || false; 68 $formItem[value ? 'removeClass' : 'addClass']('has-error'); 69 $input[value ? 'removeClass' : 'addClass']('error'); 70 }); 71 }); 72 } 73 } 74 }; 75 76 /** 77 * Bootstrap Popovers. 78 */ 79 Drupal.behaviors.bootstrapPopovers = { 80 attach: function (context, settings) { 81 // Immediately return if popovers are not available. 82 if (!settings.bootstrap || !settings.bootstrap.popoverEnabled || !$.fn.popover) { 83 return; 84 } 85 86 // Popover autoclose. 87 if (settings.bootstrap.popoverOptions.triggerAutoclose) { 88 var $currentPopover = null; 89 $document 90 .on('show.bs.popover', '[data-toggle=popover]', function () { 91 var $trigger = $(this); 92 var popover = $trigger.data('bs.popover'); 93 94 // Only keep track of clicked triggers that we're manually handling. 95 if (popover.options.originalTrigger === 'click') { 96 if ($currentPopover && !$currentPopover.is($trigger)) { 97 $currentPopover.popover('hide'); 98 } 99 $currentPopover = $trigger; 100 } 101 }) 102 .on('click', function (e) { 103 var $target = $(e.target); 104 var popover = $target.is('[data-toggle=popover]') && $target.data('bs.popover'); 105 if ($currentPopover && !$target.is('[data-toggle=popover]') && !$target.closest('.popover.in')[0]) { 106 $currentPopover.popover('hide'); 107 $currentPopover = null; 108 } 109 }) 110 ; 111 } 112 113 var elements = $(context).find('[data-toggle=popover]').toArray(); 114 for (var i = 0; i < elements.length; i++) { 115 var $element = $(elements[i]); 116 var options = $.extend({}, $.fn.popover.Constructor.DEFAULTS, settings.bootstrap.popoverOptions, $element.data()); 117 118 // Store the original trigger. 119 options.originalTrigger = options.trigger; 120 121 // If the trigger is "click", then we'll handle it manually here. 122 if (options.trigger === 'click') { 123 options.trigger = 'manual'; 124 } 125 126 // Retrieve content from a target element. 127 var target = options.target || $element.is('a[href^="#"]') && $element.attr('href'); 128 var $target = $document.find(target).clone(); 129 if (!options.content && $target[0]) { 130 $target.removeClass('element-invisible hidden').removeAttr('aria-hidden'); 131 options.content = $target.wrap('<div/>').parent()[options.html ? 'html' : 'text']() || ''; 132 } 133 134 // Initialize the popover. 135 $element.popover(options); 136 137 // Handle clicks manually. 138 if (options.originalTrigger === 'click') { 139 // To ensure the element is bound multiple times, remove any 140 // previously set event handler before adding another one. 141 $element 142 .off('click.drupal.bootstrap.popover') 143 .on('click.drupal.bootstrap.popover', function (e) { 144 $(this).popover('toggle'); 145 e.preventDefault(); 146 e.stopPropagation(); 147 }) 148 ; 149 } 150 } 151 }, 152 detach: function (context, settings) { 153 // Immediately return if popovers are not available.
154 if (!settings.bootstrap || !settings.bootstrap.popoverEnabled || !$.fn.popover) { 155 return; 156 } 157 158 // Destroy all popovers. 159 $(context).find('[data-toggle="popover"]') 160 .off('click.drupal.bootstrap.popover') 161 .popover('destroy') 162 ; 163 } 164 }; 165 166 /** 167 * Bootstrap Tooltips. 168 */ 169 Drupal.behaviors.bootstrapTooltips = { 170 attach: function (context, settings) { 171 if (settings.bootstrap && settings.bootstrap.tooltipEnabled) { 172 var elements = $(context).find('[data-toggle="tooltip"]').toArray(); 173 for (var i = 0; i < elements.length; i++) { 174 var $element = $(elements[i]); 175 var options = $.extend({}, settings.bootstrap.tooltipOptions, $element.data()); 176 $element.tooltip(options); 177 } 178 } 179 } 180 }; 181 182 /** 183 * Anchor fixes. 184 */ 185 var $scrollableElement = $(); 186 Drupal.behaviors.bootstrapAnchors = { 187 attach: function(context, settings) { 188 var i, elements = ['html', 'body']; 189 if (!$scrollableElement.length) { 190 for (i = 0; i < elements.length; i++) { 191 var $element = $(elements[i]); 192 if ($element.scrollTop() > 0) { 193 $scrollableElement = $element; 194 break; 195 } 196 else { 197 $element.scrollTop(1); 198 if ($element.scrollTop() > 0) { 199 $element.scrollTop(0); 200 $scrollableElement = $element; 201 break; 202 } 203 } 204 } 205 } 206 if (!settings.bootstrap || settings.bootstrap.anchorsFix !== '1') { 207 return; 208 } 209 var anchors = $(context).find('a').toArray(); 210 for (i = 0; i < anchors.length; i++) { 211 if (!anchors[i].scrollTo) { 212 this.bootstrapAnchor(anchors[i]); 213 } 214 } 215 $scrollableElement.once('bootstrap-anchors', function () { 216 $scrollableElement.on('click.bootstrap-anchors', 'a[href*="#"]:not([data-toggle],[data-target],[data-slide])', function(e) { 217 if (this.scrollTo) { 218 this.scrollTo(e); 219 } 220 }); 221 }); 222 }, 223 bootstrapAnchor: function (element) { 224 element.validAnchor = element.nodeName === 'A' && (location.hostname === element.hostname || !element.hostname) && (element.hash.replace(/#/,'').length > 0); 225 element.scrollTo = function(event) { 226 var attr = 'id'; 227 var $target = $(element.hash); 228 // Check for anchors that use the name attribute instead. 229 if (!$target.length) { 230 attr = 'name'; 231 $target = $('[name="' + element.hash.replace('#', '') + '"]'); 232 } 233 // Immediately stop if no anchors are found. 234 if (!this.validAnchor && !$target.length) { 235 return; 236 } 237 // Anchor is valid, continue if there is an offset. 238 var offset = $target.offset().top - parseInt($scrollableElement.css('paddingTop'), 10) - parseInt($scrollableElement.css('marginTop'), 10); 239 if (offset > 0) { 240 if (event) { 241 event.preventDefault(); 242 } 243 var $fakeAnchor = $('<div/>') 244 .addClass('element-invisible') 245 .attr(attr, $target.attr(attr)) 246 .css({ 247 position: 'absolute', 248 top: offset + 'px', 249 zIndex: -1000 250 }) 251 .appendTo($scrollableElement); 252 $target.removeAttr(attr); 253 var complete = function () { 254 location.hash = element.hash; 255 $fakeAnchor.remove(); 256 $target.attr(attr, element.hash.replace('#', '')); 257 }; 258 if (Drupal.settings.bootstrap.anchorsSmoothScrolling) { 259 $scrollableElement.animate({ scrollTop: offset, avoidTransforms: true }, 400, complete); 260 } 261 else { 262 $scrollableElement.scrollTop(offset); 263 complete(); 264 } 265 } 266 }; 267 } 268 }; 269 270 /** 271 * Tabledrag theming elements. 272 */ 273 Drupal.theme.tableDragChangedMarker = function () { 274 return '<span class="tabledrag-changed glyphicon glyphicon-warning-sign text-warning"></span>'; 275 }; 276 277 Drupal.theme.tableDragChangedWarning = function () { 278 return '<div class="tabledrag-changed-warning alert alert-warning messages warning">' + Drupal.theme('tableDragChangedMarker') + ' ' + Drupal.t('Changes made in this table will not be saved until the form is submitted.') + '</div>'; 279 }; 280 281})(jQuery, Drupal); 282; 283/** 284 * @file 285 * Cookie Compliance Javascript. 286 */ 287 288(function ($) { 289 'use strict'; 290 var euCookieComplianceBlockCookies; 291 292 Drupal.behaviors.eu_cookie_compliance_popup = { 293 attach: function (context, settings) { 294 $('body', context).once('eu-cookie-compliance', function () { 295 // If configured, check JSON callback to determine if in EU. 296 if (Drupal.settings.eu_cookie_compliance.popup_eu_only_js) { 297 if (Drupal.eu_cookie_compliance.showBanner()) { 298 var url = Drupal.settings.basePath + Drupal.settings.pathPrefix + 'eu-cookie-compliance-check'; 299 var data = {}; 300 $.getJSON(url, data, function (data) { 301 // If in the EU, show the compliance banner. 302 if (data.in_eu) { 303 Drupal.eu_cookie_compliance.execute(); 304 } 305 306 // If not in EU, set an agreed cookie automatically. 307 else { 308 Drupal.eu_cookie_compliance.setStatus(2); 309 } 310 }); 311 } 312 } 313 314 // Otherwise, fallback to standard behavior which is to render the banner. 315 else { 316 Drupal.eu_cookie_compliance.execute(); 317 } 318 }); 319 } 320 }; 321 322 Drupal.eu_cookie_compliance = {}; 323 324 Drupal.eu_cookie_compliance.execute = function () { 325 try { 326 if (!Drupal.settings.eu_cookie_compliance.popup_enabled) { 327 return; 328 } 329 330 if (!Drupal.eu_cookie_compliance.cookiesEnabled()) { 331 return; 332 } 333 334 Drupal.eu_cookie_compliance.updateCheck(); 335 var status = Drupal.eu_cookie_compliance.getCurrentStatus(); 336 if ((status === 0 && Drupal.settings.eu_cookie_compliance.method === 'default') || status === null) { 337 if (!Drupal.settings.eu_cookie_compliance.disagree_do_not_show_popup || status === null) { 338 // Detect mobile here and use mobile_popup_html_info, if we have a mobile device. 339 if (window.matchMedia('(max-width: ' + Drupal.settings.eu_cookie_compliance.mobile_breakpoint + 'px)').matches && Drupal.settings.eu_cookie_compliance.use_mobile_message) { 340 Drupal.eu_cookie_compliance.createPopup(Drupal.settings.eu_cookie_compliance.mobile_popup_html_info); 341 } 342 else { 343 Drupal.eu_cookie_compliance.createPopup(Drupal.settings.eu_cookie_compliance.popup_html_info); 344 } 345 346 Drupal.eu_cookie_compliance.attachAgreeEvents(); 347 } 348 } 349 else if (status === 1 && Drupal.settings.eu_cookie_compliance.popup_agreed_enabled) { 350 Drupal.eu_cookie_compliance.createPopup(Drupal.settings.eu_cookie_compliance.popup_html_agreed); 351 Drupal.eu_cookie_compliance.attachHideEvents(); 352 } 353 else if (status === 2 && Drupal.settings.eu_cookie_compliance.withdraw_enabled) { 354 Drupal.eu_cookie_compliance.createWithdrawBanner(Drupal.settings.eu_cookie_compliance.withdraw_markup); 355 Drupal.eu_cookie_compliance.attachWithdrawEvents(); 356 } 357 } 358 catch (e) { 359 } 360 }; 361 362 Drupal.eu_cookie_compliance.createWithdrawBanner = function (html) { 363 var $html = $('<div></div>').html(html); 364 var $banner = $('.eu-cookie-withdraw-banner', $html); 365 $html.attr('id', 'sliding-popup'); 366 $html.addClass('eu-cookie-withdraw-wrapper'); 367 368 if (!Drupal.settings.eu_cookie_compliance.popup_use_bare_css) { 369 $banner.height(Drupal.settings.eu_cookie_compliance.popup_height) 370 .width(Drupal.settings.eu_cookie_compliance.popup_width); 371 } 372 $html.hide(); 373 var height = 0; 374 if (Drupal.settings.eu_cookie_compliance.popup_position) { 375 $html.prependTo('body'); 376 height = $html.outerHeight(); 377 378 $html.show() 379 .addClass('sliding-popup-top') 380 .addClass('clearfix') 381 .css({ top: -1 * height }); 382 // For some reason, the tab outerHeight is -10 if we don't use a timeout 383 // function to reveal the tab. 384 setTimeout(function () { 385 $html.animate({ top: -1 * height }, Drupal.settings.eu_cookie_compliance.popup_delay, null, function () { 386 $html.trigger('eu_cookie_compliance_popup_open'); 387 }); 388 }.bind($html, height), 0); 389 } 390 else { 391 if (Drupal.settings.eu_cookie_compliance.better_support_for_screen_readers) { 392 $html.prependTo('body'); 393 } 394 else { 395 $html.appendTo('body'); 396 } 397 height = $html.outerHeight(); 398 $html.show() 399 .addClass('sliding-popup-bottom') 400 .css({ bottom: -1 * height }); 401 // For some reason, the tab outerHeight is -10 if we don't use a timeout 402 // function to reveal the tab. 403 setTimeout(function () { 404 $html.animate({ bottom: -1 * height }, Drupal.settings.eu_cookie_compliance.popup_delay, null, function () { 405 $html.trigger('eu_cookie_compliance_popup_open'); 406 }); 407 }.bind($html, height), 0); 408 } 409 }; 410 411 Drupal.eu_cookie_compliance.toggleWithdrawBanner = function () { 412 var $wrapper = $('#sliding-popup'); 413 var $tab = $('.eu-cookie-withdraw-tab'); 414 var $bannerIsShowing = Drupal.settings.eu_cookie_compliance.popup_position ? parseInt($wrapper.css('top')) === 0 : parseInt($wrapper.css('bottom')) === 0; 415 var topBottom = (Drupal.settings.eu_cookie_compliance.popup_position ? 'top' : 'bottom'); 416 var height = $wrapper.outerHeight(); 417 if (Drupal.settings.eu_cookie_compliance.popup_position) { 418 if ($bannerIsShowing) { 419 $wrapper.animate({'top' : -1 * height}, Drupal.settings.eu_cookie_compliance.popup_delay); 420 } 421 else { 422 $wrapper.animate({'top' : 0}, Drupal.settings.eu_cookie_compliance.popup_delay); 423 } 424 } 425 else { 426 if ($bannerIsShowing) { 427 $wrapper.animate({'bottom' : -1 * height}, Drupal.settings.eu_cookie_compliance.popup_delay); 428 } 429 else { 430 $wrapper.animate({'bottom' : 0}, Drupal.settings.eu_cookie_compliance.popup_delay); 431 } 432 } 433 }; 434 435 Drupal.eu_cookie_compliance.createPopup = function (html) { 436 // This fixes a problem with jQuery 1.9. 437 var $popup = $('<div></div>').html(html); 438 $popup.attr('id', 'sliding-popup'); 439 if (!Drupal.settings.eu_cookie_compliance.popup_use_bare_css) { 440 $popup.height(Drupal.settings.eu_cookie_compliance.popup_height) 441 .width(Drupal.settings.eu_cookie_compliance.popup_width); 442 } 443 444 $popup.hide(); 445 var height = 0; 446 if (Drupal.settings.eu_cookie_compliance.popup_position) { 447 $popup.prependTo('body'); 448 height = $popup.outerHeight(); 449 $popup.show() 450 .attr({ 'class': 'sliding-popup-top clearfix' }) 451 .css({ top: -1 * height }) 452 .animate({ top: 0 }, Drupal.settings.eu_cookie_compliance.popup_delay, null, function () { 453 $popup.trigger('eu_cookie_compliance_popup_open'); 454 }); 455 } 456 else { 457 if (Drupal.settings.eu_cookie_compliance.better_support_for_screen_readers) { 458 $popup.prependTo('body'); 459 } 460 else { 461 $popup.appendTo('body'); 462 } 463 464 height = $popup.outerHeight(); 465 $popup.show() 466 .attr({ 'class': 'sliding-popup-bottom' }) 467 .css({ bottom: -1 * height }) 468 .animate({ bottom: 0 }, Drupal.settings.eu_cookie_compliance.popup_delay, null, function () { 469 $popup.trigger('eu_cookie_compliance_popup_open'); 470 }); 471 } 472 }; 473 474 Drupal.eu_cookie_compliance.attachAgreeEvents = function () { 475 var clickingConfirms = Drupal.settings.eu_cookie_compliance.popup_clicking_confirmation; 476 var scrollConfirms = Drupal.settings.eu_cookie_compliance.popup_scrolling_confirmation; 477 478 $('.agree-button').click(Drupal.eu_cookie_compliance.acceptAction); 479 $('.decline-button').click(Drupal.eu_cookie_compliance.declineAction); 480 481 if (clickingConfirms) { 482 $('a, input[type=submit], button[type=submit]').not('.popup-content *').bind('click.euCookieCompliance', Drupal.eu_cookie_compliance.acceptAction); 483 } 484 485 if (scrollConfirms) { 486 var alreadyScrolled = false;
487 var scrollHandler = function () { 488 if (alreadyScrolled) { 489 Drupal.eu_cookie_compliance.acceptAction(); 490 $(window).off('scroll', scrollHandler); 491 } 492 else { 493 alreadyScrolled = true; 494 } 495 }; 496 497 $(window).bind('scroll', scrollHandler); 498 } 499 500 $('.find-more-button').not('.find-more-button-processed').addClass('find-more-button-processed').click(Drupal.eu_cookie_compliance.moreInfoAction); 501 }; 502 503 Drupal.eu_cookie_compliance.attachHideEvents = function () { 504 var popupHideAgreed = Drupal.settings.eu_cookie_compliance.popup_hide_agreed; 505 var clickingConfirms = Drupal.settings.eu_cookie_compliance.popup_clicking_confirmation; 506 $('.hide-popup-button').click(function () { 507 Drupal.eu_cookie_compliance.changeStatus(2); 508 } 509 ); 510 if (clickingConfirms) { 511 $('a, input[type=submit], button[type=submit]').unbind('click.euCookieCompliance'); 512 } 513 514 if (popupHideAgreed) { 515 $('a, input[type=submit], button[type=submit]').bind('click.euCookieComplianceHideAgreed', function () { 516 Drupal.eu_cookie_compliance.changeStatus(2); 517 }); 518 } 519 520 $('.find-more-button').not('.find-more-button-processed').addClass('find-more-button-processed').click(Drupal.eu_cookie_compliance.moreInfoAction); 521 }; 522 523 Drupal.eu_cookie_compliance.attachWithdrawEvents = function () { 524 $('.eu-cookie-withdraw-button').click(Drupal.eu_cookie_compliance.withdrawAction); 525 $('.eu-cookie-withdraw-tab').click(Drupal.eu_cookie_compliance.toggleWithdrawBanner); 526 }; 527 528 Drupal.eu_cookie_compliance.acceptAction = function () { 529 var agreedEnabled = Drupal.settings.eu_cookie_compliance.popup_agreed_enabled; 530 var nextStatus = 1; 531 if (!agreedEnabled) { 532 Drupal.eu_cookie_compliance.setStatus(1); 533 nextStatus = 2; 534 } 535 536 if (!euCookieComplianceHasLoadedScripts) { 537 euCookieComplianceLoadScripts(); 538 } 539 540 if (typeof euCookieComplianceBlockCookies !== 'undefined') { 541 clearInterval(euCookieComplianceBlockCookies); 542 } 543 544 Drupal.eu_cookie_compliance.changeStatus(nextStatus); 545 }; 546 547 Drupal.eu_cookie_compliance.declineAction = function () { 548 Drupal.eu_cookie_compliance.setStatus(0); 549 var popup = $('#sliding-popup'); 550 if (popup.hasClass('sliding-popup-top')) { 551 popup.animate({ top: popup.outerHeight() * -1 }).trigger('eu_cookie_compliance_popup_close'); 552 } 553 else { 554 popup.animate({ bottom: popup.outerHeight() * -1 }).trigger('eu_cookie_compliance_popup_close'); 555 } 556 }; 557 558 Drupal.eu_cookie_compliance.withdrawAction = function () { 559 Drupal.eu_cookie_compliance.setStatus(0); 560 561 location.reload(); 562 }; 563 564 Drupal.eu_cookie_compliance.moreInfoAction = function () { 565 if (Drupal.settings.eu_cookie_compliance.disagree_do_not_show_popup) { 566 Drupal.eu_cookie_compliance.setStatus(0); 567 $('#sliding-popup').trigger('eu_cookie_compliance_popup_close').remove(); 568 } 569 else { 570 if (Drupal.settings.eu_cookie_compliance.popup_link_new_window) { 571 window.open(Drupal.settings.eu_cookie_compliance.popup_link); 572 } 573 else { 574 window.location.href = Drupal.settings.eu_cookie_compliance.popup_link; 575 } 576 } 577 }; 578 579 Drupal.eu_cookie_compliance.getCurrentStatus = function () { 580 var cookieName = (typeof eu_cookie_compliance_cookie_name === 'undefined' || eu_cookie_compliance_cookie_name === '') ? 'cookie-agreed' : eu_cookie_compliance_cookie_name; 581 var value = $.cookie(cookieName); 582 value = parseInt(value); 583 if (isNaN(value)) { 584 value = null; 585 } 586 587 return value; 588 }; 589 590 Drupal.eu_cookie_compliance.changeStatus = function (value) { 591 var status = Drupal.eu_cookie_compliance.getCurrentStatus(); 592 var reloadPage = Drupal.settings.eu_cookie_compliance.reload_page; 593 if (status === value) { 594 return; 595 } 596 597 if (Drupal.settings.eu_cookie_compliance.popup_position) { 598 $('.sliding-popup-top').animate({ top: $('#sliding-popup').outerHeight() * -1 }, Drupal.settings.eu_cookie_compliance.popup_delay, function () { 599 if (status === null && !reloadPage) { 600 $('#sliding-popup').html(Drupal.settings.eu_cookie_compliance.popup_html_agreed).animate({ top: 0 }, Drupal.settings.eu_cookie_compliance.popup_delay); 601 Drupal.eu_cookie_compliance.attachHideEvents(); 602 } 603 else if (status === 1) { 604 $('#sliding-popup').trigger('eu_cookie_compliance_popup_close').remove(); 605 } 606 }); 607 } 608 else { 609 $('.sliding-popup-bottom').animate({ bottom: $('#sliding-popup').outerHeight() * -1 }, Drupal.settings.eu_cookie_compliance.popup_delay, function () { 610 if (status === null && !reloadPage) { 611 $('#sliding-popup').html(Drupal.settings.eu_cookie_compliance.popup_html_agreed).animate({ bottom: 0 }, Drupal.settings.eu_cookie_compliance.popup_delay); 612 Drupal.eu_cookie_compliance.attachHideEvents(); 613 } 614 else if (status === 1) { 615 $('#sliding-popup').trigger('eu_cookie_compliance_popup_close').remove(); 616 } 617 }); 618 } 619 620 if (reloadPage) { 621 location.reload(); 622 } 623 624 if (value === 2 && Drupal.settings.eu_cookie_compliance.withdraw_enabled) { 625 Drupal.eu_cookie_compliance.createWithdrawBanner(Drupal.settings.eu_cookie_compliance.withdraw_markup); 626 Drupal.eu_cookie_compliance.attachWithdrawEvents(); 627 } 628 629 Drupal.eu_cookie_compliance.setStatus(value); 630 }; 631 632 Drupal.eu_cookie_compliance.setStatus = function (status) { 633 var date = new Date(); 634 var domain = Drupal.settings.eu_cookie_compliance.domain ? Drupal.settings.eu_cookie_compliance.domain : ''; 635 var path = Drupal.settings.basePath; 636 var cookieName = (typeof eu_cookie_compliance_cookie_name === 'undefined' || eu_cookie_compliance_cookie_name === '') ? 'cookie-agreed' : eu_cookie_compliance_cookie_name; 637 if (path.length > 1) { 638 var pathEnd = path.length - 1; 639 if (path.lastIndexOf('/') === pathEnd) { 640 path = path.substring(0, pathEnd); 641 } 642 } 643 644 var cookieSession = parseInt(Drupal.settings.eu_cookie_compliance.cookie_session); 645 if (cookieSession) { 646 $.cookie(cookieName, status, { path: path, domain: domain }); 647 } 648 else { 649 var lifetime = parseInt(Drupal.settings.eu_cookie_compliance.cookie_lifetime); 650 date.setDate(date.getDate() + lifetime); 651 $.cookie(cookieName, status, { expires: date, path: path, domain: domain }); 652 } 653 $(document).trigger('eu_cookie_compliance.changeStatus', [status]); 654 655 // Store consent if applicable. 656 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))) { 657 var url = Drupal.settings.basePath + Drupal.settings.pathPrefix + 'eu-cookie-compliance/store_consent/banner'; 658 $.post(url, {}, function (data) { }); 659 } 660 }; 661 662 Drupal.eu_cookie_compliance.hasAgreed = function () { 663 var status = Drupal.eu_cookie_compliance.getCurrentStatus(); 664 return (status === 1 || status === 2); 665 }; 666 667 Drupal.eu_cookie_compliance.showBanner = function () { 668 var showBanner = false;
669 var status = Drupal.eu_cookie_compliance.getCurrentStatus(); 670 if ((status === 0 && Drupal.settings.eu_cookie_compliance.method === 'default') || status === null) { 671 if (!Drupal.settings.eu_cookie_compliance.disagree_do_not_show_popup || status === null) { 672 showBanner = true; 673 } 674 } 675 else if (status === 1 && Drupal.settings.eu_cookie_compliance.popup_agreed_enabled) { 676 showBanner = true; 677 } 678 679 return showBanner; 680 }; 681 682 Drupal.eu_cookie_compliance.cookiesEnabled = function () { 683 var cookieEnabled = navigator.cookieEnabled; 684 if (typeof navigator.cookieEnabled === 'undefined' && !cookieEnabled) { 685 document.cookie = 'testCookie'; 686 cookieEnabled = (document.cookie.indexOf('testCookie') !== -1); 687 } 688 689 return cookieEnabled; 690 }; 691 692 // This code upgrades the cookie agreed status when upgrading for an old version. 693 Drupal.eu_cookie_compliance.updateCheck = function () { 694 var legacyCookie = 'cookie-agreed-' + Drupal.settings.eu_cookie_compliance.popup_language; 695 var domain = Drupal.settings.eu_cookie_compliance.domain ? Drupal.settings.eu_cookie_compliance.domain : ''; 696 var path = Drupal.settings.basePath; 697 var cookie = $.cookie(legacyCookie); 698 var date = new Date(); 699 var cookieName = (typeof eu_cookie_compliance_cookie_name === 'undefined' || eu_cookie_compliance_cookie_name === '') ? 'cookie-agreed' : eu_cookie_compliance_cookie_name; 700 701 // jQuery.cookie 1.0 (bundled with Drupal) returns null, 702 // jQuery.cookie 1.4.1 (bundled with some themes) returns undefined. 703 // We had a 1.4.1 related bug where the value was set to 'null' (string). 704 if (cookie !== undefined && cookie !== null && cookie !== 'null') { 705 date.setDate(date.getDate() + parseInt(Drupal.settings.eu_cookie_compliance.cookie_lifetime)); 706 $.cookie(cookieName, cookie, { expires: date, path: path, domain: domain }); 707 708 // Use removeCookie if the function exists. 709 if (typeof $.removeCookie !== 'undefined') { 710 $.removeCookie(legacyCookie); 711 } 712 else { 713 $.cookie(legacyCookie, null, { path: path, domain: domain }); 714 } 715 } 716 }; 717 718 // Load blocked scripts if the user has agreed to being tracked. 719 var euCookieComplianceHasLoadedScripts = false; 720 $(function () { 721 if (Drupal.eu_cookie_compliance.hasAgreed() 722 || (Drupal.eu_cookie_compliance.getCurrentStatus() === null && Drupal.settings.eu_cookie_compliance.method !== 'opt_in') 723 ) { 724 euCookieComplianceLoadScripts(); 725 euCookieComplianceHasLoadedScripts = true; 726 } 727 }); 728 729 // Block cookies when the user hasn't agreed. 730 Drupal.behaviors.eu_cookie_compliance_popup_block_cookies = { 731 initialized: false, 732 attach: function (context, settings) { 733 if (!Drupal.behaviors.eu_cookie_compliance_popup_block_cookies.initialized && settings.eu_cookie_compliance) { 734 Drupal.behaviors.eu_cookie_compliance_popup_block_cookies.initialized = true; 735 if ((settings.eu_cookie_compliance.method === 'opt_in' && (Drupal.eu_cookie_compliance.getCurrentStatus() === null || !Drupal.eu_cookie_compliance.hasAgreed())) 736 || (settings.eu_cookie_compliance.method === 'opt_out' && !Drupal.eu_cookie_compliance.hasAgreed() && Drupal.eu_cookie_compliance.getCurrentStatus() !== null) 737 ) { 738 // Split the white-listed cookies. 739 var euCookieComplianceWhitelist = settings.eu_cookie_compliance.whitelisted_cookies.split(/\r\n|\n|\r/g); 740 741 // Add the EU Cookie Compliance cookie. 742 euCookieComplianceWhitelist.push((typeof settings.eu_cookie_compliance.cookie_name === 'undefined' || settings.eu_cookie_compliance.cookie_name === '') ? 'cookie-agreed' : settings.eu_cookie_compliance.cookie_name); 743 euCookieComplianceBlockCookies = setInterval(function () { 744 // Load all cookies from jQuery. 745 var cookies = $.cookie(); 746 747 // Check each cookie and try to remove it if it's not white-listed. 748 for (var i in cookies) { 749 var remove = true; 750 var hostname = window.location.hostname; 751 var cookieRemoved = false;
752 var index = 0; 753 754 // Skip the PHP session cookie. 755 if (i.indexOf('SESS') === 0 || i.indexOf('SSESS') === 0) { 756 remove = false; 757 } 758 759 // Check if the cookie is white-listed. 760 for (var item in euCookieComplianceWhitelist) { 761 if (i === euCookieComplianceWhitelist[item]) { 762 remove = false; 763 } 764 } 765 766 // Remove the cookie if it's not white-listed. 767 if (remove) { 768 while (!cookieRemoved && hostname !== '') { 769 // Attempt to remove. 770 cookieRemoved = $.removeCookie(i, { domain: '.' + hostname, path: '/' }); 771 if (!cookieRemoved) { 772 cookieRemoved = $.removeCookie(i, { domain: hostname, path: '/' }); 773 } 774 775 index = hostname.indexOf('.'); 776 777 // We can be on a sub-domain, so keep checking the main domain as well. 778 hostname = (index === -1) ? '' : hostname.substring(index + 1); 779 } 780 } 781 } 782 }, 5000); 783 } 784 } 785 } 786 } 787 788})(jQuery); 789;
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.