+ Drupal.eu_cookie_compliance.execute = function () {
+ try {
+ if (!drupalSettings.eu_cookie_compliance.popup_enabled) {
+ return;
+ }
+
+ if (!Drupal.eu_cookie_compliance.cookiesEnabled()) {
+ return;
+ }
+
+ var status = Drupal.eu_cookie_compliance.getCurrentStatus();
+ if ((status === 0 && drupalSettings.eu_cookie_compliance.method === 'default') || status === null) {
+ if (!drupalSettings.eu_cookie_compliance.disagree_do_not_show_popup || status === null) {
+ // Detect mobile here and use mobile_popup_html_info, if we have a mobile device.
+ if (window.matchMedia('(max-width: ' + drupalSettings.eu_cookie_compliance.mobile_breakpoint + 'px)').matches && drupalSettings.eu_cookie_compliance.use_mobile_message) {
+ Drupal.eu_cookie_compliance.createPopup(drupalSettings.eu_cookie_compliance.mobile_popup_html_info);
+ } else {
+ Drupal.eu_cookie_compliance.createPopup(drupalSettings.eu_cookie_compliance.popup_html_info);
+ }
+
+ Drupal.eu_cookie_compliance.attachAgreeEvents();
+ }
+ } else if (status === 1 && drupalSettings.eu_cookie_compliance.popup_agreed_enabled) {
+ Drupal.eu_cookie_compliance.createPopup(drupalSettings.eu_cookie_compliance.popup_html_agreed);
+ Drupal.eu_cookie_compliance.attachHideEvents();
+ } else if (status === 2 && drupalSettings.eu_cookie_compliance.withdraw_enabled) {
+ Drupal.eu_cookie_compliance.createWithdrawBanner(drupalSettings.eu_cookie_compliance.withdraw_markup);
+ Drupal.eu_cookie_compliance.attachWithdrawEvents();
+ }
+ }
+ catch (e) {
+ }
+ };
+
+ Drupal.eu_cookie_compliance.createWithdrawBanner = function (html) {
+ var $html = $('<div></div>').html(html);
+ var $banner = $('.eu-cookie-withdraw-banner', $html);
+ $html.attr('id', 'sliding-popup');
+ $html.addClass('eu-cookie-withdraw-wrapper');
+
+ if (!drupalSettings.eu_cookie_compliance.popup_use_bare_css) {
+ $banner.height(drupalSettings.eu_cookie_compliance.popup_height)
+ .width(drupalSettings.eu_cookie_compliance.popup_width);
+ }
+ $html.hide();
+ var height = 0;
+ if (drupalSettings.eu_cookie_compliance.popup_position) {
+ $html.prependTo('body');
+ height = $html.outerHeight();
+
+ $html.show()
+ .addClass('sliding-popup-top')
+ .addClass('clearfix')
+ .css({ top: -1 * height });
+ // For some reason, the tab outerHeight is -10 if we don't use a timeout
+ // function to reveal the tab.
+ setTimeout(function () {
+ var height = $html.outerHeight();
+
+ $html.animate({ top: -1 * (height) }, drupalSettings.eu_cookie_compliance.popup_delay, null, function () {
+ $html.trigger('eu_cookie_compliance_popup_open');
+ });
+ }.bind($html), 0);
+ } else {
+ if (drupalSettings.eu_cookie_compliance.better_support_for_screen_readers) {
+ $html.prependTo('body');
+ } else {
+ $html.appendTo('body');
+ }
+ height = $html.outerHeight();
+ $html.show()
+ .addClass('sliding-popup-bottom')
+ .css({ bottom: -1 * height });
+ // For some reason, the tab outerHeight is -10 if we don't use a timeout
+ // function to reveal the tab.
+ setTimeout(function () {
+ var height = $html.outerHeight();
+
+ $html.animate({ bottom: -1 * (height) }, drupalSettings.eu_cookie_compliance.popup_delay, null, function () {
+ $html.trigger('eu_cookie_compliance_popup_open');
+ });
+ }.bind($html), 0);
+ }
+ };
+
+ Drupal.eu_cookie_compliance.toggleWithdrawBanner = function () {
+ var $wrapper = $('#sliding-popup');
+ var $tab = $('.eu-cookie-withdraw-tab');
+ var $bannerIsShowing = drupalSettings.eu_cookie_compliance.popup_position ? parseInt($wrapper.css('top')) === 0 : parseInt($wrapper.css('bottom')) === 0;
+ var height = $wrapper.outerHeight();
+ if (drupalSettings.eu_cookie_compliance.popup_position) {
+ if ($bannerIsShowing) {
+ $wrapper.animate({'top' : -1 * (height)}, drupalSettings.eu_cookie_compliance.popup_delay);
+ }
+ else {
+ $wrapper.animate({'top' : 0}, drupalSettings.eu_cookie_compliance.popup_delay);
+ }
+ }
+ else {
+ if ($bannerIsShowing) {
+ $wrapper.animate({'bottom' : -1 * (height)}, drupalSettings.eu_cookie_compliance.popup_delay);
+ }
+ else {
+ $wrapper.animate({'bottom' : 0}, drupalSettings.eu_cookie_compliance.popup_delay);
+ }
+ }
+ };
+