PageSourceSearch

https://baheyeldin.com/sites/baheyeldin.com/files/js/js_geiSPEA8NhNFdEARwB55jjJR7jaTRU8R_J8EDRwQc3w.js

js baheyeldin.com collected 2026-09-24 18:16:45 UTC 20,748 bytes, 508 lines download raw bytes

1/**
2 * @file
3 * Cookie Compliance Javascript.
4 */
5
6(function ($) {
7  'use strict';
8  var euCookieComplianceBlockCookies;
9
10  Backdrop.behaviors.eu_cookie_compliance_popup = {
11    attach: function (context, settings) {
12      $('body', context).once('eu-cookie-compliance', function () {
13        // If configured, check JSON callback to determine if in EU.
14        if (Backdrop.settings.eu_cookie_compliance.popup_eu_only_js) {
15          if (Backdrop.eu_cookie_compliance.showBanner()) {
16            var url = Backdrop.settings.basePath + Backdrop.settings.pathPrefix + 'eu-cookie-compliance-check';
17            var data = {};
18            $.getJSON(url, data, function (data) {
19              // If in the EU, show the compliance banner.
20              if (data.in_eu) {
21                Backdrop.eu_cookie_compliance.execute();
22              }
23
24              // If not in EU, set an agreed cookie automatically.
25              else {
26                Backdrop.eu_cookie_compliance.setStatus(2);
27              }
28            });
29          }
30        }
31
32        // Otherwise, fallback to standard behavior which is to render the banner.
33        else {
34          Backdrop.eu_cookie_compliance.execute();
35        }
36      });
37    }
38  };
39
40  Backdrop.eu_cookie_compliance = {};
41
42  Backdrop.eu_cookie_compliance.execute = function () {
43    try {
44      if (!Backdrop.settings.eu_cookie_compliance.popup_enabled) {
45        return;
46      }
47
48      if (!Backdrop.eu_cookie_compliance.cookiesEnabled()) {
49        return;
50      }
51
52      Backdrop.eu_cookie_compliance.updateCheck();
53      var status = Backdrop.eu_cookie_compliance.getCurrentStatus();
54      if ((status === 0 && Backdrop.settings.eu_cookie_compliance.method === 'default') || status === null) {
55        if (!Backdrop.settings.eu_cookie_compliance.disagree_do_not_show_popup || status === null) {
56          // Detect mobile here and use mobile_popup_html_info, if we have a mobile device.
57          if (window.matchMedia('(max-width: ' + Backdrop.settings.eu_cookie_compliance.mobile_breakpoint + 'px)').matches && Backdrop.settings.eu_cookie_compliance.use_mobile_message) {
58            Backdrop.eu_cookie_compliance.createPopup(Backdrop.settings.eu_cookie_compliance.mobile_popup_html_info);
59          }
60          else {
61            Backdrop.eu_cookie_compliance.createPopup(Backdrop.settings.eu_cookie_compliance.popup_html_info);
62          }
63
64          Backdrop.eu_cookie_compliance.attachAgreeEvents();
65        }
66      }
67      else if (status === 1 && Backdrop.settings.eu_cookie_compliance.popup_agreed_enabled) {
68        Backdrop.eu_cookie_compliance.createPopup(Backdrop.settings.eu_cookie_compliance.popup_html_agreed);
69        Backdrop.eu_cookie_compliance.attachHideEvents();
70      }
71      else if (status === 2 && Backdrop.settings.eu_cookie_compliance.withdraw_enabled) {
72        Backdrop.eu_cookie_compliance.createWithdrawBanner(Backdrop.settings.eu_cookie_compliance.withdraw_markup);
73        Backdrop.eu_cookie_compliance.attachWithdrawEvents();
74      }
75    }
76    catch (e) {
77    }
78  };
79
80  Backdrop.eu_cookie_compliance.createWithdrawBanner = function (html) {
81    var $html = $('<div></div>').html(html);
82    var $banner = $('.eu-cookie-withdraw-banner', $html);
83    $html.attr('id', 'sliding-popup');
84    $html.addClass('eu-cookie-withdraw-wrapper');
85
86    if (!Backdrop.settings.eu_cookie_compliance.popup_use_bare_css) {
87      $banner.height(Backdrop.settings.eu_cookie_compliance.popup_height)
88          .width(Backdrop.settings.eu_cookie_compliance.popup_width);
89    }
90    $html.hide();
91    var height = 0;
92    if (Backdrop.settings.eu_cookie_compliance.popup_position) {
93      $html.prependTo('body');
94      height = $html.outerHeight();
95
96      $html.show()
97          .addClass('sliding-popup-top')
98          .addClass('clearfix')
99          .css({ top: -1 * height });
100      // For some reason, the tab outerHeight is -10 if we don't use a timeout
101      // function to reveal the tab.
102      setTimeout(function () {
103        $html.animate({ top: -1 * height }, Backdrop.settings.eu_cookie_compliance.popup_delay, null, function () {
104          $html.trigger('eu_cookie_compliance_popup_open');
105        });
106      }.bind($html, height), 0);
107    }
108    else {
109      if (Backdrop.settings.eu_cookie_compliance.better_support_for_screen_readers) {
110        $html.prependTo('body');
111      }
112      else {
113        $html.appendTo('body');
114      }
115      height = $html.outerHeight();
116      $html.show()
117          .addClass('sliding-popup-bottom')
118          .css({ bottom: -1 * height });
119      // For some reason, the tab outerHeight is -10 if we don't use a timeout
120      // function to reveal the tab.
121      setTimeout(function () {
122        $html.animate({ bottom: -1 * height }, Backdrop.settings.eu_cookie_compliance.popup_delay, null, function () {
123          $html.trigger('eu_cookie_compliance_popup_open');
124        });
125      }.bind($html, height), 0);
126    }
127  };
128
129  Backdrop.eu_cookie_compliance.toggleWithdrawBanner = function () {
130    var $wrapper = $('#sliding-popup');
131    var $tab = $('.eu-cookie-withdraw-tab');
132    var $bannerIsShowing = Backdrop.settings.eu_cookie_compliance.popup_position ? parseInt($wrapper.css('top')) === 0 : parseInt($wrapper.css('bottom')) === 0;
133    var topBottom = (Backdrop.settings.eu_cookie_compliance.popup_position ? 'top' : 'bottom');
134    var height = $wrapper.outerHeight();
135    if (Backdrop.settings.eu_cookie_compliance.popup_position) {
136      if ($bannerIsShowing) {
137        $wrapper.animate({'top' : -1 * height}, Backdrop.settings.eu_cookie_compliance.popup_delay);
138      }
139      else {
140        $wrapper.animate({'top' : 0}, Backdrop.settings.eu_cookie_compliance.popup_delay);
141      }
142    }
143    else {
144      if ($bannerIsShowing) {
145        $wrapper.animate({'bottom' : -1 * height}, Backdrop.settings.eu_cookie_compliance.popup_delay);
146      }
147      else {
148        $wrapper.animate({'bottom' : 0}, Backdrop.settings.eu_cookie_compliance.popup_delay);
149      }
150    }
151  };
152
153  Backdrop.eu_cookie_compliance.createPopup = function (html) {
154
155    // This fixes a problem with jQuery 1.9.
156    var $popup = $('<div></div>').html(html);
157    $popup.attr('id', 'sliding-popup');
158    if (!Backdrop.settings.eu_cookie_compliance.popup_use_bare_css) {
159      $popup.height(Backdrop.settings.eu_cookie_compliance.popup_height)
160          .width(Backdrop.settings.eu_cookie_compliance.popup_width);
161    }
162
163    $popup.hide();
164    var height = 0;
165    if (Backdrop.settings.eu_cookie_compliance.popup_position) {
166      $popup.prependTo('body');
167      height = $popup.outerHeight();
168      $popup.show()
169        .attr({ 'class': 'sliding-popup-top clearfix' })
170        .css({ top: -1 * height })
171        .animate({ top: 0 }, Backdrop.settings.eu_cookie_compliance.popup_delay, null, function () {
172          $popup.trigger('eu_cookie_compliance_popup_open');
173        });
174    }
175    else {
176      if (Backdrop.settings.eu_cookie_compliance.better_support_for_screen_readers) {
177        $popup.prependTo('body');
178      }
179      else {
180        $popup.appendTo('body');
181      }
182
183      height = $popup.outerHeight();
184      $popup.show()
185        .attr({ 'class': 'sliding-popup-bottom' })
186        .css({ bottom: -1 * height })
187        .animate({ bottom: 0 }, Backdrop.settings.eu_cookie_compliance.popup_delay, null, function () {
188          $popup.trigger('eu_cookie_compliance_popup_open');
189        });
190    }
191  };
192
193  Backdrop.eu_cookie_compliance.attachAgreeEvents = function () {
194    var clickingConfirms = Backdrop.settings.eu_cookie_compliance.popup_clicking_confirmation;
195    var scrollConfirms = Backdrop.settings.eu_cookie_compliance.popup_scrolling_confirmation;
196
197    $('.agree-button').click(Backdrop.eu_cookie_compliance.acceptAction);
198    $('.decline-button').click(Backdrop.eu_cookie_compliance.declineAction);
199
200    if (clickingConfirms) {
201      $('a, input[type=submit], button[type=submit]').not('.popup-content *').bind('click.euCookieCompliance', Backdrop.eu_cookie_compliance.acceptAction);
202    }
203
204    if (scrollConfirms) {
205      var alreadyScrolled = false;
206      var scrollHandler = function () {
207        if (alreadyScrolled) {
208          Backdrop.eu_cookie_compliance.acceptAction();
209          $(window).off('scroll', scrollHandler);
210        }
211        else {
212          alreadyScrolled = true;
213        }
214      };
215
216      $(window).bind('scroll', scrollHandler);
217    }
218
219    $('.find-more-button').not('.find-more-button-processed').addClass('find-more-button-processed').click(Backdrop.eu_cookie_compliance.moreInfoAction);
220  };
221
222  Backdrop.eu_cookie_compliance.attachHideEvents = function () {
223    var popupHideAgreed = Backdrop.settings.eu_cookie_compliance.popup_hide_agreed;
224    var clickingConfirms = Backdrop.settings.eu_cookie_compliance.popup_clicking_confirmation;
225    $('.hide-popup-button').click(function () {
226      Backdrop.eu_cookie_compliance.changeStatus(2);
227    }
228    );
229    if (clickingConfirms) {
230      $('a, input[type=submit], button[type=submit]').unbind('click.euCookieCompliance');
231    }
232
233    if (popupHideAgreed) {
234      $('a, input[type=submit], button[type=submit]').bind('click.euCookieComplianceHideAgreed', function () {
235        Backdrop.eu_cookie_compliance.changeStatus(2);
236      });
237    }
238
239    $('.find-more-button').not('.find-more-button-processed').addClass('find-more-button-processed').click(Backdrop.eu_cookie_compliance.moreInfoAction);
240  };
241
242  Backdrop.eu_cookie_compliance.attachWithdrawEvents = function () {
243    $('.eu-cookie-withdraw-button').click(Backdrop.eu_cookie_compliance.withdrawAction);
244    $('.eu-cookie-withdraw-tab').click(Backdrop.eu_cookie_compliance.toggleWithdrawBanner);
245  };
246
247  Backdrop.eu_cookie_compliance.acceptAction = function () {
248    var agreedEnabled = Backdrop.settings.eu_cookie_compliance.popup_agreed_enabled;
249    var nextStatus = 1;
250    if (!agreedEnabled) {
251      Backdrop.eu_cookie_compliance.setStatus(1);
252      nextStatus = 2;
253    }
254
255    if (!euCookieComplianceHasLoadedScripts) {
256      euCookieComplianceLoadScripts();
257    }
258
259    if (typeof euCookieComplianceBlockCookies !== 'undefined') {
260      clearInterval(euCookieComplianceBlockCookies);
261    }
262
263    Backdrop.eu_cookie_compliance.changeStatus(nextStatus);
264  };
265
266  Backdrop.eu_cookie_compliance.declineAction = function () {
267    Backdrop.eu_cookie_compliance.setStatus(0);
268    var popup = $('#sliding-popup');
269    if (popup.hasClass('sliding-popup-top')) {
270      popup.animate({ top: popup.outerHeight() * -1 }).trigger('eu_cookie_compliance_popup_close');
271    }
272    else {
273      popup.animate({ bottom: popup.outerHeight() * -1 }).trigger('eu_cookie_compliance_popup_close');
274    }
275  };
276
277  Backdrop.eu_cookie_compliance.withdrawAction = function () {
278    Backdrop.eu_cookie_compliance.setStatus(0);
279
280    location.reload();
281  };
282
283  Backdrop.eu_cookie_compliance.moreInfoAction = function () {
284    if (Backdrop.settings.eu_cookie_compliance.disagree_do_not_show_popup) {
285      Backdrop.eu_cookie_compliance.setStatus(0);
286      $('#sliding-popup').trigger('eu_cookie_compliance_popup_close').remove();
287    }
288    else {
289      if (Backdrop.settings.eu_cookie_compliance.popup_link_new_window) {
290        window.open(Backdrop.settings.eu_cookie_compliance.popup_link);
291      }
292      else {
293        window.location.href = Backdrop.settings.eu_cookie_compliance.popup_link;
294      }
295    }
296  };
297
298  Backdrop.eu_cookie_compliance.getCurrentStatus = function () {
299    var cookieName = (typeof eu_cookie_compliance_cookie_name === 'undefined' || eu_cookie_compliance_cookie_name === '') ? 'cookie-agreed' : eu_cookie_compliance_cookie_name;
300    var value = $.cookie(cookieName);
301    value = parseInt(value);
302    if (isNaN(value)) {
303      value = null;
304    }
305
306    return value;
307  };
308
309  Backdrop.eu_cookie_compliance.changeStatus = function (value) {
310    var status = Backdrop.eu_cookie_compliance.getCurrentStatus();
311    var reloadPage = Backdrop.settings.eu_cookie_compliance.reload_page;
312    if (status === value) {
313      return;
314    }
315
316    if (Backdrop.settings.eu_cookie_compliance.popup_position) {
317      $('.sliding-popup-top').animate({ top: $('#sliding-popup').outerHeight() * -1 }, Backdrop.settings.eu_cookie_compliance.popup_delay, function () {
318        if (status === null && !reloadPage) {
319          $('#sliding-popup').html(Backdrop.settings.eu_cookie_compliance.popup_html_agreed).animate({ top: 0 }, Backdrop.settings.eu_cookie_compliance.popup_delay);
320          Backdrop.eu_cookie_compliance.attachHideEvents();
321        }
322        else if (status === 1) {
323          $('#sliding-popup').trigger('eu_cookie_compliance_popup_close').remove();
324        }
325      });
326    }
327    else {
328      $('.sliding-popup-bottom').animate({ bottom: $('#sliding-popup').outerHeight() * -1 }, Backdrop.settings.eu_cookie_compliance.popup_delay, function () {
329        if (status === null && !reloadPage) {
330          $('#sliding-popup').html(Backdrop.settings.eu_cookie_compliance.popup_html_agreed).animate({ bottom: 0 }, Backdrop.settings.eu_cookie_compliance.popup_delay);
331          Backdrop.eu_cookie_compliance.attachHideEvents();
332        }
333        else if (status === 1) {
334          $('#sliding-popup').trigger('eu_cookie_compliance_popup_close').remove();
335        }
336      });
337    }
338
339    if (reloadPage) {
340      location.reload();
341    }
342
343    if (value === 2 && Backdrop.settings.eu_cookie_compliance.withdraw_enabled) {
344      Backdrop.eu_cookie_compliance.createWithdrawBanner(Backdrop.settings.eu_cookie_compliance.withdraw_markup);
345      Backdrop.eu_cookie_compliance.attachWithdrawEvents();
346    }
347
348    Backdrop.eu_cookie_compliance.setStatus(value);
349  };
350
351  Backdrop.eu_cookie_compliance.setStatus = function (status) {
352    var date = new Date();
353    var domain = Backdrop.settings.eu_cookie_compliance.domain ? Backdrop.settings.eu_cookie_compliance.domain : '';
354    var path = Backdrop.settings.basePath;
355    var cookieName = (typeof eu_cookie_compliance_cookie_name === 'undefined' || eu_cookie_compliance_cookie_name === '') ? 'cookie-agreed' : eu_cookie_compliance_cookie_name;
356    if (path.length > 1) {
357      var pathEnd = path.length - 1;
358      if (path.lastIndexOf('/') === pathEnd) {
359        path = path.substring(0, pathEnd);
360      }
361    }
362
363    var cookieSession = parseInt(Backdrop.settings.eu_cookie_compliance.cookie_session);
364    if (cookieSession) {
365      $.cookie(cookieName, status, { path: path, domain: domain });
366    }
367    else {
368      var lifetime = parseInt(Backdrop.settings.eu_cookie_compliance.cookie_lifetime);
369      date.setDate(date.getDate() + lifetime);
370      $.cookie(cookieName, status, { expires: date, path: path, domain: domain });
371    }
372    $(document).trigger('eu_cookie_compliance.changeStatus', [status]);
373
374    // Store consent if applicable.
375    if (Backdrop.settings.eu_cookie_compliance.store_consent && ((status === 1 && Backdrop.settings.eu_cookie_compliance.popup_agreed_enabled) || (status === 2  && !Backdrop.settings.eu_cookie_compliance.popup_agreed_enabled))) {
376      var url = Backdrop.settings.basePath + Backdrop.settings.pathPrefix + 'eu-cookie-compliance/store_consent/banner';
377      $.post(url, {}, function (data) { });
378    }
379  };
380
381  Backdrop.eu_cookie_compliance.hasAgreed = function () {
382    var status = Backdrop.eu_cookie_compliance.getCurrentStatus();
383    return (status === 1 || status === 2);
384  };
385
386  Backdrop.eu_cookie_compliance.showBanner = function () {
387    var showBanner = false;
388    var status = Backdrop.eu_cookie_compliance.getCurrentStatus();
389    if ((status === 0 && Backdrop.settings.eu_cookie_compliance.method === 'default') || status === null) {
390      if (!Backdrop.settings.eu_cookie_compliance.disagree_do_not_show_popup || status === null) {
391        showBanner = true;
392      }
393    }
394    else if (status === 1 && Backdrop.settings.eu_cookie_compliance.popup_agreed_enabled) {
395      showBanner = true;
396    }
397
398    return showBanner;
399  };
400
401  Backdrop.eu_cookie_compliance.cookiesEnabled = function () {
402    var cookieEnabled = navigator.cookieEnabled;
403    if (typeof navigator.cookieEnabled === 'undefined' && !cookieEnabled) {
404      document.cookie = 'testCookie';
405      cookieEnabled = (document.cookie.indexOf('testCookie') !== -1);
406    }
407
408    return cookieEnabled;
409  };
410
411  // This code upgrades the cookie agreed status when upgrading for an old version.
412  Backdrop.eu_cookie_compliance.updateCheck = function () {
413    var legacyCookie = 'cookie-agreed-' + Backdrop.settings.eu_cookie_compliance.popup_language;
414    var domain = Backdrop.settings.eu_cookie_compliance.domain ? Backdrop.settings.eu_cookie_compliance.domain : '';
415    var path = Backdrop.settings.basePath;
416    var cookie = $.cookie(legacyCookie);
417    var date = new Date();
418    var cookieName = (typeof eu_cookie_compliance_cookie_name === 'undefined' || eu_cookie_compliance_cookie_name === '') ? 'cookie-agreed' : eu_cookie_compliance_cookie_name;
419
420    // jQuery.cookie 1.0 (bundled with Backdrop) returns null,
421    // jQuery.cookie 1.4.1 (bundled with some themes) returns undefined.
422    // We had a 1.4.1 related bug where the value was set to 'null' (string).
423    if (cookie !== undefined && cookie !== null && cookie !== 'null') {
424      date.setDate(date.getDate() + parseInt(Backdrop.settings.eu_cookie_compliance.cookie_lifetime));
425      $.cookie(cookieName, cookie, { expires: date, path:  path, domain: domain });
426
427      // Use removeCookie if the function exists.
428      if (typeof $.removeCookie !== 'undefined') {
429        $.removeCookie(legacyCookie);
430      }
431      else {
432        $.cookie(legacyCookie, null, { path: path, domain: domain });
433      }
434    }
435  };
436
437  // Load blocked scripts if the user has agreed to being tracked.
438  var euCookieComplianceHasLoadedScripts = false;
439  $(function () {
440    if (Backdrop.eu_cookie_compliance.hasAgreed()
441        || (Backdrop.eu_cookie_compliance.getCurrentStatus() === null && Backdrop.settings.eu_cookie_compliance.method !== 'opt_in')
442    ) {
443      euCookieComplianceLoadScripts();
444      euCookieComplianceHasLoadedScripts = true;
445    }
446  });
447
448  // Block cookies when the user hasn't agreed.
449  Backdrop.behaviors.eu_cookie_compliance_popup_block_cookies = {
450    initialized: false,
451    attach: function (context, settings) {
452      if (!Backdrop.behaviors.eu_cookie_compliance_popup_block_cookies.initialized && settings.eu_cookie_compliance) {
453        Backdrop.behaviors.eu_cookie_compliance_popup_block_cookies.initialized = true;
454        if ((settings.eu_cookie_compliance.method === 'opt_in' && (Backdrop.eu_cookie_compliance.getCurrentStatus() === null || !Backdrop.eu_cookie_compliance.hasAgreed()))
455          || (settings.eu_cookie_compliance.method === 'opt_out' && !Backdrop.eu_cookie_compliance.hasAgreed() && Backdrop.eu_cookie_compliance.getCurrentStatus() !== null)
456        ) {
457          // Split the white-listed cookies.
458          var euCookieComplianceWhitelist = settings.eu_cookie_compliance.whitelisted_cookies.split(/\r\n|\n|\r/g);
459
460          // Add the EU Cookie Compliance cookie.
461          euCookieComplianceWhitelist.push((typeof settings.eu_cookie_compliance.cookie_name === 'undefined' || settings.eu_cookie_compliance.cookie_name === '') ? 'cookie-agreed' : settings.eu_cookie_compliance.cookie_name);
462          euCookieComplianceBlockCookies = setInterval(function () {
463            // Load all cookies from jQuery.
464            var cookies = $.cookie();
465
466            // Check each cookie and try to remove it if it's not white-listed.
467            for (var i in cookies) {
468              var remove = true;
469              var hostname = window.location.hostname;
470              var cookieRemoved = false;
471              var index = 0;
472
473              // Skip the PHP session cookie.
474              if (i.indexOf('SESS') === 0 || i.indexOf('SSESS') === 0) {
475                remove = false;
476              }
477
478              // Check if the cookie is white-listed.
479              for (var item in euCookieComplianceWhitelist) {
480                if (i === euCookieComplianceWhitelist[item]) {
481                  remove = false;
482                }
483              }
484
485              // Remove the cookie if it's not white-listed.
486              if (remove) {
487                while (!cookieRemoved && hostname !== '') {
488                  // Attempt to remove.
489                  cookieRemoved = $.removeCookie(i, { domain: '.' + hostname, path: '/' });
490                  if (!cookieRemoved) {
491                    cookieRemoved = $.removeCookie(i, { domain: hostname, path: '/' });
492                  }
493
494                  index = hostname.indexOf('.');
495
496                  // We can be on a sub-domain, so keep checking the main domain as well.
497                  hostname = (index === -1) ? '' : hostname.substring(index + 1);
498                }
499              }
500            }
501          }, 5000);
502        }
503      }
504    }
505  }
506
507})(jQuery);
508;

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.