PageSourceSearch

https://turismoburgos.org/wp-content/plugins/hurrytimer/assets/js/hurrytimer.js?ver=2.14.3

js turismoburgos.org collected 2026-10-02 08:06:25 UTC 31,155 bytes, 884 lines download raw bytes

1'use strict';
2
3function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
4
5function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
6
7function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
8
9function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
10
11function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
12
13function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
14
15var HurrytimerAction = /*#__PURE__*/function () {
16  function HurrytimerAction(elementRef, config) {
17    _classCallCheck(this, HurrytimerAction);
18
19    this.elementRef = elementRef;
20    this.config = config;
21  }
22
23  _createClass(HurrytimerAction, [{
24    key: "hasMessageAction",
25    value: function hasMessageAction() {
26      var _iterator = _createForOfIteratorHelper(this.config.actions),
27          _step;
28
29      try {
30        for (_iterator.s(); !(_step = _iterator.n()).done;) {
31          var action = _step.value;
32
33          if (action['id'] == hurrytimer_ajax_object.actionsOptions.displayMessage) {
34            return true;
35          }
36        }
37      } catch (err) {
38        _iterator.e(err);
39      } finally {
40        _iterator.f();
41      }
42
43      return false;
44    }
45    /**
46     * Hide campaign.
47     */
48
49  }, {
50    key: "hide",
51    value: function hide() {
52      // We don't hide campaign if there is a message to display.
53      if (this.hasMessageAction()) {
54        return;
55      }
56
57      var stickyBar = this.elementRef.closest('.hurrytimer-sticky');
58
59      if (stickyBar.length) {
60        stickyBar.addClass('hurryt-loading');
61      } else {
62        this.elementRef.addClass('hurryt-loading');
63      }
64    }
65    /**
66     * Redirect to the given url.
67     * @param url
68     */
69
70  }, {
71    key: "hideAddToCartButton",
72    value:
73    /**
74     * Hide "Add to cart" button.
75     * @return void
76     */
77    function hideAddToCartButton() {
78      var $addToCartForm = jQuery('.single_add_to_cart_button').closest('form.cart');
79
80      if ($addToCartForm.length) {
81        $addToCartForm.remove();
82      }
83    }
84    /**
85     * Display message by replacing campaign content with the given message.
86     * @param message
87     */
88
89  }, {
90    key: "displayMessage",
91    value: function displayMessage(message) {
92      var messageHtml = "<div class=\"hurrytimer-campaign-message\" data-id=\"".concat(this.config.id, "\">").concat(message, "</div>");
93      this.elementRef.find('.hurrytimer-campaign-message').remove();
94      var stickyBar = this.elementRef.closest('.hurrytimer-sticky');
95
96      if (stickyBar.length) {
97        this.elementRef.addClass('hurryt-loading');
98        stickyBar.find('.hurrytimer-sticky-inner').append(messageHtml);
99      } else {
100        this.elementRef.addClass('hurryt-loading');
101        this.elementRef.after(messageHtml);
102      }
103    }
104  }, {
105    key: "expireCoupon",
106    value: function expireCoupon(code, message) {
107      // Remove coupon if applied but expired and the checkout form has not been placed yet.
108      jQuery('form.checkout').on('checkout_place_order', function (event) {
109        validate_expired_coupon_checkout(event);
110      });
111      document.addEventListener("DOMContentLoaded", function () {
112        validate_expired_coupon_checkout();
113      });
114
115      function validate_expired_coupon_checkout(event) {
116        // Get applied coupons
117        var appliedCoupons = jQuery('.woocommerce-checkout-review-order-table').find('.cart-discount');
118        var isCouponExpired = false;
119        appliedCoupons.each(function () {
120          var couponCode = jQuery(this).find('.woocommerce-remove-coupon').data('coupon');
121
122          if (couponCode && typeof couponCode === 'string' && couponCode.trim().toLowerCase() === code.trim().toLowerCase()) {
123            isCouponExpired = true;
124            return false;
125          }
126        });
127
128        if (isCouponExpired) {
129          var errorHtml = '<ul class="woocommerce-error" role="alert"><li>' + message + '</li></ul>';
130          var noticeGroup = jQuery('.woocommerce-NoticeGroup-checkout');
131
132          if (noticeGroup.length) {
133            noticeGroup.html(errorHtml);
134          } else {
135            var noticeGroupHtml = "<div class=\"woocommerce-NoticeGroup woocommerce-NoticeGroup-checkout\">".concat(errorHtml, "</div>");
136            jQuery('form.checkout').before(noticeGroupHtml);
137            jQuery('html, body').animate({
138              scrollTop: jQuery('.woocommerce-NoticeGroup-checkout').offset().top - 100
139            });
140          }
141
142          var container = jQuery('.woocommerce-checkout-review-order');
143          container.addClass('processing').block({
144            message: null,
145            overlayCSS: {
146              background: '#fff',
147              opacity: 0.6
148            }
149          });
150          jQuery.ajax({
151            type: 'POST',
152            url: wc_checkout_params.wc_ajax_url.toString().replace('%%endpoint%%', 'remove_coupon'),
153            data: {
154              security: wc_checkout_params.remove_coupon_nonce,
155              coupon: code
156            },
157            success: function success(response) {
158              container.removeClass('processing').unblock();
159
160              if (response) {
161                jQuery(document.body).trigger('removed_coupon_in_checkout', [code]);
162                jQuery(document.body).trigger('update_checkout', {
163                  update_shipping_method: false
164                });
165              }
166            },
167            error: function error(jqXHR) {
168              if (wc_checkout_params.debug_mode) {
169                console.log(jqXHR.responseText);
170              }
171            }
172          });
173
174          if (event) {
175            event.preventDefault();
176          }
177
178          return false;
179        }
180      } // WC 7.5.x
181
182
183      var originalFetch = window.fetch;
184
185      window.fetch = function (url, options) {
186        if (url.indexOf('wc-ajax=apply_coupon') !== -1) {
187          var body = options.body;
188          var searchParams = new URLSearchParams(body);
189          var couponCode = searchParams.get('coupon_code');
190
191          if (typeof couponCode === 'string' && couponCode.trim().toLowerCase() === code.trim().toLowerCase()) {
192            jQuery('.woocommerce-error').remove();
193            var $target = jQuery('.woocommerce-notices-wrapper:first') || jQuery('.cart
193-empty').closest('.woocommerce') || jQuery('.woocommerce-cart-form');
194            $target.prepend("<ul class=\"woocommerce-error\" role=\"alert\"><li>".concat(message, "</li></ul>"));
195            jQuery('.checkout_coupon').removeClass('processing').unblock();
196            jQuery('.woocommerce-cart-form').removeClass('processing').unblock();
197            return Promise.reject(new Error(message));
198          }
199        } else if (url.indexOf('/wc/store/v1/batch') !== -1) {
200          var body = options.body;
201          var requests = JSON.parse(body).requests || [];
202          var abortController = new AbortController();
203          options.signal = abortController.signal;
204          requests.forEach(function (req) {
205            if (req.path === '/wc/store/v1/cart/apply-coupon') {
206              var couponCode = req.body.code;
207
208              if (couponCode && typeof couponCode === 'string' && couponCode.trim().toLowerCase() === code.trim().toLowerCase()) {
209                abortController.abort();
210                throw new Error(message);
211              }
212            }
213          });
214        }
215
216        return originalFetch.apply(this, [url, options]);
217      }; // WC 7.4.x
218
219
220      jQuery.ajaxPrefilter(function (opts, originOpts, jqXHR) {
221        if (opts.url.indexOf('wc-ajax=apply_coupon') === -1) return;
222        if (!originOpts.data.coupon_code || typeof originOpts.data.coupon_code !== 'string' || typeof code !== 'string' || originOpts.data.coupon_code.trim().toLowerCase() !== code.trim().toLowerCase()) return;
223        jqXHR.abort();
224        jQuery('.woocommerce-error').remove();
225        var $target = jQuery('.woocommerce-notices-wrapper:first') || jQuery('.cart
225-empty').closest('.woocommerce') || jQuery('.woocommerce-cart-form');
226        $target.prepend("<ul class=\"woocommerce-error\" role=\"alert\"><li>".concat(message, "</li></ul>"));
227        jQuery('.checkout_coupon').removeClass('processing').unblock();
228        jQuery('.woocommerce-cart-form').removeClass('processing').unblock();
229      });
230    }
231  }], [{
232    key: "redirect",
233    value: function redirect(url) {
234      document.body.style.opacity = '0';
235      document.body.style.display = 'none';
236
237      if (url.trim().length === 0) {
238        return;
239      }
240
241      if (hurrytimer_ajax_object.redirect_no_back) {
242        window.location.replace(url);
243      } else {
244        window.location.href = url;
245      }
246    }
247  }]);
248
249  return HurrytimerAction;
250}();
251"use strict";
252
253function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
254
255function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
256
257function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
258
259function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
260
261function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
262
263function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
264
265function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
266
267function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
268
269function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
270
271function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
272
273function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
274
275/*
276 * global hurrytimer_ajax_object
277 */
278var HurrytimerCampaign = /*#__PURE__*/function () {
279  function HurrytimerCampaign(elementRef, config, state) {
280    _classCallCheck(this, HurrytimerCampaign);
281
282    this.config = config;
283    this.elementRef = elementRef;
284    this.actionsOptions = hurrytimer_ajax_object.actionsOptions;
285    this.restartOptions = hurrytimer_ajax_object.restartOptions;
286    this.recurTimeoutId = -1;
287    this.recurIntervalId = -1;
288    this.retryCount = 0;
289    this.startEventDispatched = false;
290    this.state = state;
291    this.restartIntervalId = -1;
292    this.currentEndDate = null;
293  }
294  /**
295   * @param endDateInMS
296   * @return void
297   */
298
299
300  _createClass(HurrytimerCampaign, [{
301    key: "setCookie",
302    value: function setCookie(endDateInMS) {
303      var options = {
304        expires: 365
305      };
306
307      if (hurrytimer_ajax_object.COOKIEPATH) {
308        options.path = hurrytimer_ajax_object.COOKIEPATH;
309      }
310
311      if (hurrytimer_ajax_object.COOKIE_DOMAIN) {
312        options.domain = hurrytimer_ajax_object.COOKIE_DOMAIN;
313      }
314
315      Cookies.set(this.config.cookieName, endDateInMS, options);
316
317      if (this.config.reset_token) {
318        Cookies.set("".concat(this.config.cookieName, "_reset_token"), this.config.reset_token, {
319          expires: 365
320        });
321      }
322    }
323    /**
324     * Returns end date for the given duration.
325     * @return {Date}
326     */
327
328  }, {
329    key: "getEndDate",
330    value: function getEndDate() {
331      // Evergreen or recurring
332      if (this.config.isRegular) {
333        return new Date(this.config.endDate);
334      }
335
336      var date = new Date(parseInt(this.config.endDate));
337
338      if (!this.isValidDate(date) || !this.config.endDate || this.should_reset() || this.allowRestart() || this.config.reload_reset) {
339        if (_typeof(date) === 'object' && date.setTime != undefined) {
340          this.unDismissStickyBar();
341          date.setTime(this.calculateDate().getTime());
342        }
343      }
344
345      this.setCookie(date.getTime());
346      this.updateTimestamp(date.getTime());
347      this.currentEndDate = date;
348      return date;
349    }
350    /**
351     * Check if the given date is valid.
352     * @param {*} d
353     */
354
355  }, {
356    key: "isValidDate",
357    value: function isValidDate(d) {
358      return Object.prototype.toString.call(d) === '[object Date]' && !isNaN(d.getTime());
359    }
360    /**
361     * This is useful to force timestamp update when the page is cached.
362     */
363
364  }, {
365    key: "updateTimestamp",
366    value: function updateTimestamp(endDateTimeTS) {
367      if (jQuery.ajax === undefined) return;
368      var args = {
369        url: hurrytimer_ajax_object.ajax_url,
370        async: true,
371        type: 'POST',
372        data: {
373          nonce: hurrytimer_ajax_object.ajax_nonce,
374          timestamp: endDateTimeTS,
375          cid: this.config.id,
376          action: 'hurryt/update_timestamp'
377        }
378      };
379      jQuery.ajax(args);
380    }
381    /**
382     * Returns true if the campaign should reset.
383     *
384     * @return {number}
385     */
386
387  }, {
388    key: "should_reset",
389    value: function should_reset() {
390      return this.config.should_reset;
391    }
392    /**
393     * Remove sticky bar dismiss if available for current given campaign.
394     */
395
396  }, {
397    key: "unDismissStickyBar",
398    value: function unDismissStickyBar() {
399      Cookies.remove("_ht_CDT-".concat(this.config.id, "_dismissed"));
400    }
401    /**
402     * Returns true if the campaign will restart.
403     * @return {boolean}
404     */
405
406  }, {
407    key: "allowRestart",
408    value: function allowRestart() {
409      if (this.config.isRegular) return false;
410      return this.isExpired() && (this.allowRestartImmediately() || this.allowRestartAfterReload() || this.durationSinceExpiryIsOver());
411    }
412    /**
413     * Campaign expired.
414     */
415
416  }, {
417    key: "isExpired",
418    value: function isExpired() {
419      var today = new Date();
420      return this.config.endDate < today;
421    }
422  }, {
423    key: "duratinSinceExpiration",
424    value: function duratinSinceExpiration() {
425      var endDate = this.currentEndDate || this.config.endDate;
426
427      if (!endDate) {
428        return 0;
429      }
430
431      var now = new Date();
432      var diff = now.getTime() - endDate;
433      return diff / 1000;
434    }
435  }, {
436    key: "durationSinceExpiryIsOver",
437    value: function durationSinceExpiryIsOver() {
438      return this.shouldRestartAfterDuration() && this.duratinSinceExpiration() >= this.config.restart_duration;
439    }
440    /**
441     * Restart on refresh.
442     *
443     * @returns {boolean}
444     */
445
446  }, {
447    key: "allowRestartAfterReload",
448    value: function allowRestartAfterReload() {
449      return parseInt(this.config.restart) === parseInt(this.restartOptions.afterReload);
450    }
451    /**
452     * Restart immediatly.
453     *
454     * @returns {boolean}
455     */
456
457  }, {
458    key: "allowRestartImmediately",
459    value: function allowRestartImmediately() {
460      return parseInt(this.config.restart) === parseInt(this.restartOptions.immediately);
461    }
462  }, {
463    key: "shouldRestartAfterDuration",
464    value: function shouldRestartAfterDuration() {
465      return this.config.restart == this.restartOptions.after_duration;
466    }
467    /**
468     * Returns true if the campaign has an action.
469     */
470
471  }, {
472    key: "hasAction",
473    value: function hasAction() {
474      return this.config.actions.length;
475    }
476    /**
477     * Calculate date based on the given duration.
478     * @return {Date}
479     */
480
481  }, {
482    key: "calculateDate",
483    value: function calculateDate() {
484      var date = new Date(); // Fallback to original duration-based calculation
485
486
487      date.setSeconds(date.getSeconds() + this.config.duration);
488      return date;
489    }
490    /**
491     * Run registered actions.
492     */
493
494  }, {
495    key: "executeActions",
496    value: function executeActions() {
497      if (parseInt(hurrytimer_ajax_object.disable_actions) === 1) {
498        return false;
499      } // No action, abort.
500
501
502      if (this.hasAction()) {
503        var _iterator = _createForOfIteratorHelper(this.config.actions),
504            _step;
505
506        try {
507          for (_iterator.s(); !(_step = _iterator.n()).done;) {
508            var action = _step.value;
509            var actionManager = new HurrytimerAction(this.elementRef, this.config);
510
511            if (this.config.run_in_background) {
512              if (action['id'] == this.actionsOptions.expire_coupon) {
513                actionManager.expireCoupon(action['coupon'], hurrytimer_ajax_object.expire_coupon_message.replace('%s', action['coupon']));
514              }
515            } else {
516              switch (action['id']) {
517                case this.actionsOptions.redirect:
518                  HurrytimerAction.redirect(action['redirectUrl']);
519                  break;
520
521                case this.actionsOptions.displayMessage:
522                  actionManager.displayMessage(action['message']);
523                  break;
524
525                case this.actionsOptions.hideAddToCartButton:
526                  actionManager.hideAddToCartButton();
527                  break;
528
529                case this.actionsOptions.hide:
530                  actionManager.hide();
531                  break;
532              }
533            }
534          }
535        } catch (err) {
536          _iterator.e(err);
537        } finally {
538          _iterator.f();
539        }
540      }
541    }
542  }, {
543    key: "maybeShowCampaign",
544    value: function maybeShowCampaign() {
545      if (this.elementRef.length && !this.config.run_in_background) {
546        // Remove message tag if present.
547        var $message = this.elementRef.parent().find(".hurrytimer-campaign-message[data-id=\"".concat(this.config.id, "\"]"));
548
549        if ($message.length) {
550          $message.remove();
551        }
552
553        this.elementRef.removeClass('hurryt-loading');
554      }
555
556      var stickyBar = this.elementRef.closest('.hurrytimer-sticky');
557
558      if (stickyBar.length) {
559        // Remove message tag if present.
560        var _$message = this.elementRef.find('.hurrytimer-campaign-message');
561
562        if (_$message.length) {
563          _$message.remove();
564        }
565
566        stickyBar.removeClass('hurryt-loading');
567      }
568    }
569    /**
570     * Maybe run countdown timer.
571     */
572
573  }, {
574    key: "waitThenRun",
575    value: function waitThenRun() {
576      var _this = this;
577
578      this.restartIntervalId = setInterval(function () {
579        if (_this.durationSinceExpiryIsOver()) {
580          clearInterval(_this.restartIntervalId);
581
582          _this.run();
583        }
584      }, 1000);
585    }
586  }, {
587    key: "run",
588    value: function run() {
589      var _this2 = this;
590
591      this.triggerInitEvent();
592      this.elementRef.countdown(this.getEndDate(), function (e) {
593        return _this2.onCountdownUpdate(e);
594      });
595      var stickyBar = this.elementRef.closest('.hurrytimer-sticky');
596      this.handleStickyBar(stickyBar);
597    }
598    /**
599     * Handle sticky bar visibility.
600     * @param {*} stickyBar
601     */
602
603  }, {
604    key: "handleStickyBar",
605    value: function handleStickyBar(stickyBar) {
606      var _this3 = this;
607
608      if (stickyBar.length === 0) return;
609      var dismissCookie = Cookies.get("_ht_CDT-".concat(this.config.id, "_dismissed")); // Stick bar hasn't been dismissed.
610
611      if (dismissCookie == undefined) {
612        stickyBar.on('click', '.hurrytimer-sticky-close', function () {
613          return _this3.onStickyBarDismiss(stickyBar);
614        });
615      } else {
616        this.hideStickyBar(stickyBar);
617      }
618    }
619    /**
620     * Hide Sticky Bar
621     * @param {*} stickyBar
622     */
623
624  }, {
625    key: "hideStickyBar",
626    value: function hideStickyBar(stickyBar) {
627      if (stickyBar.length === 0) return;
628      var isTopPinned = stickyBar.css('top') === '0px';
629      stickyBar.remove();
630
631      if (isTopPinned) {
632        jQuery('body').css('margin-top', 0);
633      } else {
634        jQuery('body').css('margin-bottom', 0);
635      }
636    }
637    /**
638     * Handle sticky bar dismiss.
639     */
640
641  }, {
642    key: "onStickyBarDismiss",
643    value: function onStickyBarDismiss(stickyBar) {
644      this.hideStickyBar(stickyBar);
645      Cookies.set("_ht_CDT-".concat(this.config.id, "_dismissed"), '1', {
646        expires: +this.config.sticky_bar_hide_timeout
647      });
648    }
649    /**
650     * Countdown timer start callback.
651     * @param event
652     */
653
654  }, {
655    key: "onCountdownUpdate",
656    value: function onCountdownUpdate(event) {
657      this.render(event);
658      this.maybeShowCampaign();
659
660      if (event.elapsed && event.type === 'finish') {
661        this.executeActions();
662        this.triggerFinishEvent();
663        this.maybeRecur();
664
665        if (this.allowRestartImmediately()) {
666          this.run();
667        }
668
669        if (this.shouldRestartAfterDuration()) {
670          this.waitThenRun();
671        }
672      }
673    }
674  }, {
675    key: "triggerFinishEvent",
676    value: function triggerFinishEvent() {
677      var params = {
678        id: this.config.id,
679        mode: this.config.mode,
680        endAt: this.config.endDate
681      };
682      this.elementRef.trigger('hurryt:finished', params);
683    }
684  }, {
685    key: "triggerInitEvent",
686    value: function triggerInitEvent() {
687      var params = {
688        id: this.config.id,
689        mode: this.config.mode,
690        endAt: this.config.endDate
691      };
692      jQuery('.hurrytimer-campaign').trigger('hurryt:init', params);
693    }
694  }, {
695    key: "triggerStartEvent",
696    value: function triggerStartEvent() {
697      if (!this.startEventDispatched) {
698        var params = {
699          id: this.config.id,
700          mode: this.config.mode,
701          endAt: this.config.endDate
702        };
703        this.elementRef.trigger('hurryt:started', params);
704        this.startEventDispatched = true;
705      }
706    }
707    /**
708     * Render countdown timer.
709     * @param event
710     */
711
712  }, {
713    key: "render",
714    value: function render(event) {
715      if (hurrytimer_ajax_object.run_in_background) {
716        this.elementRef.html('');
717      } else {
718        this.elementRef.find('.hurrytimer-timer').html(event.strftime(this.config.template));
719      }
720
721      this.triggerStartEvent();
722    }
723    /**
724     * Calculate the remaining time until the next recurrence.
725     * 
726     * @return int
727     */
728
729  }, {
730    key: "willRecurNow",
731    value: function willRecurNow() {
732      var now = new Date();
733      var prev_recurrence_time = this.getEndDate().getTime() + this.config.timeToNextRecurrence * 1000;
734      return now.getTime() >= prev_recurrence_time;
735    }
736    /**
737     * Run the next recurrence if available.
738     */
739
740  }, {
741    key: "maybeRecur",
742    value: function maybeRecur() {
743      var _this4 = this;
744
745      // Not a recurring campaign.
746      if (!this.config.recurr) return; // the jQuery ajax function is required to fetch the next recurrence.
747
748      if (jQuery.ajax === undefined) return;
749      clearTimeout(this.recurTimeoutId);
750      clearInterval(this.recurIntervalId);
751      this.recurIntervalId = setInterval(function () {
752        if (!_this4.willRecurNow()) {
753          return;
754        }
755
756        clearInterval(_this4.recurIntervalId);
757        jQuery.ajax({
758          url: hurrytimer_ajax_object.ajax_url,
759          data: {
760            action: 'next_recurrence',
761            nonce: hurrytimer_ajax_object.ajax_nonce,
762            id: _this4.config.id
763          },
764          error: function error() {
765            if (_this4.retryCount === 10) return;
766            _this4.retryCount++;
767            setTimeout(function () {
768              _this4.maybeRecur();
769            }, 1000);
770          },
771          success: function success(_ref) {
772            var data = _ref.data;
773            _this4.retryCount = 0;
774            if (!data) return;
775
776            if (isNaN(data.endTimestamp)) {
777              return;
778            }
779
780            _this4.config.endDate = data.endTimestamp; // TODO: Handle lateness:
781            // retry for one minute if the received end date is still expired.
782
783            _this4.run();
784          }
785        });
786      }, 1000);
787    }
788  }]);
789
790  return HurrytimerCampaign;
791}();
792'use strict';
793
794function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
795
796(function ($) {
797  // TODO: delete `state`.
798  var state = {
799    reseting: []
800  };
801  var $body = $('body');
802
803  function onElementInserted(containerSelector, elementSelector, callback) {
804    var onMutationsObserved = function onMutationsObserved(mutations) {
805      mutations.forEach(function (mutation) {
806        if (mutation.addedNodes.length) {
807          var elements = $(mutation.addedNodes).find(elementSelector);
808
809          for (var i = 0, len = elements.length; i < len; i++) {
810            callback(elements[i]);
811          }
812        }
813      });
814    };
815
816    var target = $(containerSelector)[0];
817    var config = {
818      childList: true,
819      subtree: true
820    };
821    var MutationObserver = window.MutationObserver || window.WebKitMutationObserver;
822    var observer = new MutationObserver(onMutationsObserved);
823    observer.observe(target, config);
824  }
825
826  document.addEventListener('DOMContentLoaded', function () {
827    var initialElements = document.querySelectorAll('.hurrytimer-campaign');
828    initialElements.forEach(initCallback);
829    onElementInserted('body', '.hurrytimer-campaign', initCallback);
830  });
831
832  function initCallback(e) {
833    if ($(e).parents('div[data-elementor-type=popup]').length === 0) {
834      runCampaign($(e));
835    }
836  }
837
838  $(document).on('elementor/popup/show', function (event, id) {
839    // Run only campaigns within a Elementor popup.
840    $(".elementor-".concat(id, " .hurrytimer-campaign")).each(function () {
841      runCampaign($(this));
842    });
843  });
844  /**
845   *
846   * @param $campaign jQuery
847   */
848
849  function runCampaign($campaign) {
850    // TODO: Inject config object in the <head> tag or inline.
851    var config = $campaign.data('config');
852    if (config === undefined) return; // Check if the config object is corrupt.
853
854    if (_typeof(config) !== 'object') {
855      config = JSON.parse(config.replace(/\s+/g, " "));
856    }
857
858    $campaign.removeAttr('data-config');
859    $campaign.trigger('hurryt:pre-init', {
860      id: config.id,
861      mode: config.mode,
862      endAt: config.endAt
863    });
864    var $sticky = $campaign.closest('.hurrytimer-sticky'); // Display sticky bar if present.
865
866    if ($sticky.length) {
867      $body.append($sticky);
868      $(window).resize(function () {
869        if ($sticky.css('top') === '0px') {
870          // Pin at the top.
871          $body.css('margin-top', $sticky.outerHeight());
872        } else {
873          // Pin at the bottom.
874          $body.css('margin-bottom', $sticky.outerHeight());
875        }
876      });
877      setTimeout(function () {
878        $(window).trigger('resize');
879      });
880    }
881
882    new HurrytimerCampaign($campaign, config, state).run();
883  }
884})(jQuery);

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.