PageSourceSearch

https://www.luxor.cz/smartbanner.js/dist/smartbanner.js

js luxor.cz collected 2026-09-24 20:25:24 UTC 21,157 bytes, 427 lines download raw bytes

1/*!
2 * smartbanner.js v1.19.3 <https://github.com/ain/smartbanner.js#readme>
3 * Copyright © 2023 Ain Tohvri, contributors. Licensed under GPL-3.0.
4 */
5(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
6"use strict";
7
8Object.defineProperty(exports, "__esModule", {
9  value: true
10});
11exports["default"] = void 0;
12function _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); }
13function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
14function _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, _toPropertyKey(descriptor.key), descriptor); } }
15function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
16function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
17function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
18var Bakery = /*#__PURE__*/function () {
19  function Bakery() {
20    _classCallCheck(this, Bakery);
21  }
22  _createClass(Bakery, null, [{
23    key: "getCookieExpiresString",
24    value: function getCookieExpiresString(hideTtl) {
25      var now = new Date();
26      var expireTime = new Date(now.getTime() + hideTtl);
27      return "expires=".concat(expireTime.toGMTString(), ";");
28    }
29  }, {
30    key: "bake",
31    value: function bake(hideTtl, hidePath) {
32      document.cookie = "smartbanner_exited=1; ".concat(hideTtl ? Bakery.getCookieExpiresString(hideTtl) : '', " path=").concat(hidePath);
33    }
34  }, {
35    key: "unbake",
36    value: function unbake() {
37      document.cookie = 'smartbanner_exited=; expires=Thu, 01 Jan 1970 00:00:01 GMT;';
38    }
39  }, {
40    key: "baked",
41    get: function get() {
42      var value = document.cookie.replace(/(?:(?:^|.*;\s*)smartbanner_exited\s*=\s*([^;]*).*$)|^.*$/, '$1');
43      return value === '1';
44    }
45  }]);
46  return Bakery;
47}();
48exports["default"] = Bakery;
49
50},{}],2:[function(require,module,exports){
51(function (global){(function (){
52"use strict";
53
54Object.defineProperty(exports, "__esModule", {
55  value: true
56});
57exports["default"] = void 0;
58function _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); }
59function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
60function _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, _toPropertyKey(descriptor.key), descriptor); } }
61function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
62function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string");
62 return _typeof(key) === "symbol" ? key : String(key); }
63function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
64var Detector = /*#__PURE__*/function () {
65  function Detector() {
66    _classCallCheck(this, Detector);
67  }
68  _createClass(Detector, null, [{
69    key: "platform",
70    value: function platform() {
71      var maxTouchPoints = window.navigator.maxTouchPoints;
72      var userAgent = window.navigator.userAgent;
73      if (/Android/i.test(userAgent)) {
74        return 'android';
75        // maxTouchPoints is the only effective method to detect iPad iOS 13+
76        // FMI https://developer.apple.com/forums/thread/119186
77      } else if (!window.MSStream && !/X11|Linux/i.test(userAgent) && maxTouchPoints && maxTouchPoints > 0 || /iPhone|iPad|iPod/i.test(userAgent)) {
78        return 'ios';
79      }
80    }
81  }, {
82    key: "userAgentMatchesRegex",
83    value: function userAgentMatchesRegex(regexString) {
84      return new RegExp(regexString).test(window.navigator.userAgent);
85    }
86  }, {
87    key: "jQueryMobilePage",
88    value: function jQueryMobilePage() {
89      return typeof global.$ !== 'undefined' && global.$.mobile !== 'undefined' && document.querySelector('.ui-page') !== null;
90    }
91  }, {
92    key: "wrapperElement",
93    value: function wrapperElement() {
94      var selector = Detector.jQueryMobilePage() ? '.ui-page' : 'html';
95      return document.querySelectorAll(selector);
96    }
97  }]);
98  return Detector;
99}();
100exports["default"] = Detector;
101
102}).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
103},{}],3:[function(require,module,exports){
104"use strict";
105
106var _smartbanner = _interopRequireDefault(require("./smartbanner.js"));
107function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
108var smartbanner;
109window.addEventListener('load', function () {
110  smartbanner = new _smartbanner["default"]();
111  if (smartbanner.apiEnabled) {
112    window.smartbanner = smartbanner;
113  } else {
114    smartbanner.publish();
115  }
116});
117
118},{"./smartbanner.js":5}],4:[function(require,module,exports){
119"use strict";
120
121Object.defineProperty(exports, "__esModule", {
122  value: true
123});
124exports["default"] = void 0;
125function _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); }
126function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
127function _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, _toPropertyKey(descriptor.key), descriptor); } }
128function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
129function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
130function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
131function valid(name) {
132  // TODO: validate against options dictionary
133  return name.indexOf('smartbanner:') !== -1 && name.split(':')[1].length > 0;
134}
135function convertToCamelCase(name) {
136  var parts = name.split('-');
137  parts.map(function (part, index) {
138    if (index > 0) {
139      parts[index] = part.charAt(0).toUpperCase() + part.substring(1);
140    }
141  });
142  return parts.join('');
143}
144var OptionParser = /*#__PURE__*/function () {
145  function OptionParser() {
146    _classCallCheck(this, OptionParser);
147  }
148  _createClass(OptionParser, [{
149    key: "parse",
150    value: function parse() {
151      var metas = document.getElementsByTagName('meta');
152      var options = {};
153      Array.apply(null, metas).forEach(function (meta) {
154        var optionName = null;
155        var name = meta.getAttribute('name');
156        var content = meta.getAttribute('content');
157        if (name && content && valid(name) && content.length > 0) {
158          optionName = name.split(':')[1];
159          if (optionName.indexOf('-') !== -1) {
160            optionName = convertToCamelCase(optionName);
161          }
162          options[optionName] = content;
163        }
164      });
165      return options;
166    }
167  }]);
168  return OptionParser;
169}();
170exports["default"] = OptionParser;
171
172},{}],5:[function(require,module,exports){
173"use strict";
174
175Object.defineProperty(exports, "__esModule", {
176  value: true
177});
178exports["default"] = void 0;
179var _optionparser = _interopRequireDefault(require("./optionparser.js"));
180var _detector = _interopRequireDefault(require("./detector.js"));
181var _bakery = _interopRequireDefault(require("./bakery.js"));
182function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
183function _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); }
184function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
185function _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, _toPropertyKey(descriptor.key), descriptor); } }
186function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
187function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
188function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
189var DEFAULT_PLATFORMS = 'android,ios';
190var DEFAULT_CLOSE_LABEL = 'Close';
191var datas = {
192  originalTop: 'data-smartbanner-original-top',
193  originalMarginTop: 'data-smartbanner-original-margin-top'
194};
195function handleExitClick(event, self) {
196  self.exit();
197  event.preventDefault();
198}
199function handleClickout(event, self) {
200  self.clickout();
201}
202function handleJQueryMobilePageLoad(event) {
203  if (!this.positioningDisabled) {
204    setContentPosition(event.data.height);
205  }
206}
207function addEventListeners(self) {
208  var closeIcon = document.querySelector('.js_smartbanner__exit');
209  closeIcon.addEventListener('click', function (event) {
210    return handleExitClick(event, self);
211  });
212  var button = document.querySelector('.js_smartbanner__button');
213  button.addEventListener('click', function (event) {
214    return handleClickout(event, self);
215  });
216  if (_detector["default"].jQueryMobilePage()) {
217    $(document).on('pagebeforeshow', self, handleJQueryMobilePageLoad);
218  }
219}
220function removeEventListeners() {
221  if (_detector["default"].jQueryMobilePage()) {
222    $(document).off('pagebeforeshow', handleJQueryMobilePageLoad);
223  }
224}
225function setContentPosition(value) {
226  var wrappers = _detector["default"].wrapperElement();
227  for (var i = 0, l = wrappers.length, wrapper; i < l; i++) {
228    wrapper = wrappers[i];
229    if (_detector["default"].jQueryMobilePage()) {
230      if (wrapper.getAttribute(datas.originalTop)) {
231        continue;
232      }
233      var top = parseFloat(getComputedStyle(wrapper).top);
234      wrapper.setAttribute(datas.originalTop, isNaN(top) ? 0 : top);
235      wrapper.style.top = value + 'px';
236    } else {
237      if (wrapper.getAttribute(datas.originalMarginTop)) {
238        continue;
239      }
240      var margin = parseFloat(getComputedStyle(wrapper).marginTop);
241      wrapper.setAttribute(datas.originalMarginTop, isNaN(margin) ? 0 : margin);
242      wrapper.style.marginTop = value + 'px';
243    }
244  }
245}
246function restoreContentPosition() {
247  var wrappers = _detector["default"].wrapperElement();
248  for (var i = 0, l = wrappers.length, wrapper; i < l; i++) {
249    wrapper = wrappers[i];
250    if (_detector["default"].jQueryMobilePage() && wrapper.getAttribute(datas.originalTop)) {
251      wrapper.style.top = wrapper.getAttribute(datas.originalTop) + 'px';
252    } else if (wrapper.getAttribute(datas.originalMarginTop)) {
253      wrapper.style.marginTop = wrapper.getAttribute(datas.originalMarginTop) + 'px';
254    }
255  }
256}
257var SmartBanner = /*#__PURE__*/function () {
258  function SmartBanner() {
259    _classCallCheck(this, SmartBanner);
260    var parser = new _optionparser["default"]();
261    this.options = parser.parse();
262    this.platform = _detector["default"].platform();
263    var event = new Event('smartbanner.init');
264    document.dispatchEvent(event);
265  }
266
267  // DEPRECATED. Will be removed.
268  _createClass(SmartBanner, [{
269    key: "originalTop",
270    get: function get() {
271      var wrapper = _detector["default"].wrapperElement()[0];
272      return parseFloat(wrapper.getAttribute(datas.originalTop));
273    }
274
275    // DEPRECATED. Will be removed.
276  }, {
277    key: "originalTopMargin",
278    get: function get() {
279      var wrapper = _detector["default"].wrapperElement()[0];
280      return parseFloat(wrapper.getAttribute(datas.originalMarginTop));
281    }
282  }, {
283    key: "priceSuffix",
284    get: function get() {
285      if (this.platform === 'ios' && this.options.priceSuffixApple) {
286        return this.options.priceSuffixApple;
287      } else if (this.platform === 'android' && this.options.priceSuffixGoogle) {
288        return this.options.priceSuffixGoogle;
289      }
290      return '';
291    }
292  }, {
293    key: "icon",
294    get: function get() {
295      if (this.platform === 'android') {
296        return this.options.iconGoogle;
297      } else {
298        return this.options.iconApple;
299      }
300    }
301  }, {
302    key: "buttonUrl",
303    get: function get() {
304      if (this.platform === 'android') {
305        return this.options.buttonUrlGoogle;
306      } else if (this.platform === 'ios') {
307        return this.options.buttonUrlApple;
308      }
309      return '#';
310    }
311  }, {
312    key: "closeLabel",
313    get: function get() {
314      return this.options.closeLabel !== undefined ? this.options.closeLabel : DEFAULT_CLOSE_LABEL;
315    }
316  }, {
317    key: "html",
318    get: function get() {
319      var modifier = !this.options.customDesignModifier ? this.platform : this.options.customDesignModifier;
320      return "<div class=\"smartbanner smartbanner--".concat(modifier, " js_smartbanner\">\n      <a href=\"javascript:void(0);\" class=\"smartbanner__exit js_smartbanner__exit\" aria-label=\"").concat(this.closeLabel, "\"></a>\n      <div class=\"smartbanner__icon\" style=\"background-image: url(").concat(this.icon, ");\"></div>\n      <div class=\"smartbanner__info\">\n        <div>\n          <div class=\"smartbanner__info__title\">").concat(this.options.title, "</div>\n          <div class=\"smartbanner__info__author\">").concat(this.options.author, "</div>\n          <div class=\"smartbanner__info__price\">").concat(this.options.price).concat(this.priceSuffix, "</div>\n        </div>\n      </div>\n      <a href=\"").concat(this.buttonUrl, "\" target=\"_blank\" class=\"smartbanner__button js_smartbanner__button\" rel=\"noopener\" aria-label=\"").concat(this.options.button, "\"><span class=\"smartbanner__button__label\">").concat(this.options.button, "</span></a>\n    </div>");
321    }
322  }, {
323    key: "height",
324    get: function get() {
325      try {
326        return document.querySelector('.js_smartbanner').offsetHeight;
327      } catch (error) {
328        return 0;
329      }
330    }
331  }, {
332    key: "platformEnabled",
333    get: function get() {
334      var enabledPlatforms = this.options.enabledPlatforms || DEFAULT_PLATFORMS;
335      return enabledPlatforms && enabledPlatforms.replace(/\s+/g, '').split(',').indexOf(this.platform) !== -1;
336    }
337  }, {
338    key: "positioningDisabled",
339    get: function get() {
340      return this.options.disablePositioning === 'true';
341    }
342  }, {
343    key: "apiEnabled",
344    get: function get() {
345      return this.options.api === 'true';
346    }
347  }, {
348    key: "userAgentExcluded",
349    get: function get() {
350      if (!this.options.excludeUserAgentRegex) {
351        return false;
352      }
353      return _detector["default"].userAgentMatchesRegex(this.options.excludeUserAgentRegex);
354    }
355  }, {
356    key: "userAgentIncluded",
357    get: function get() {
358      if (!this.options.includeUserAgentRegex) {
359        return false;
360      }
361      return _detector["default"].userAgentMatchesRegex(this.options.includeUserAgentRegex);
362    }
363  }, {
364    key: "hideTtl",
365    get: function get() {
366      return this.options.hideTtl ? parseInt(this.options.hideTtl) : false;
367    }
368  }, {
369    key: "hidePath",
370    get: function get() {
371      return this.options.hidePath ? this.options.hidePath : '/';
372    }
373  }, {
374    key: "publish",
375    value: function publish() {
376      if (Object.keys(this.options).length === 0) {
377        throw new Error('No options detected. Please consult documentation.');
378      }
379      if (_bakery["default"].baked) {
380        return false;
381      }
382
383      // User Agent was explicetely excluded by defined excludeUserAgentRegex
384      if (this.userAgentExcluded) {
385        return false;
386      }
387
388      // User agent was neither included by platformEnabled,
389      // nor by defined includeUserAgentRegex
390      if (!(this.platformEnabled || this.userAgentIncluded)) {
391        return false;
392      }
393      var bannerDiv = document.createElement('div');
394      document.querySelector('body').appendChild(bannerDiv);
395      bannerDiv.outerHTML = this.html;
396      var event = new Event('smartbanner.view');
397      document.dispatchEvent(event);
398      if (!this.positioningDisabled) {
399        setContentPosition(this.height);
400      }
401      addEventListeners(this);
402    }
403  }, {
404    key: "exit",
405    value: function exit() {
406      removeEventListeners();
407      if (!this.positioningDisabled) {
408        restoreContentPosition();
409      }
410      var banner = document.querySelector('.js_smartbanner');
411      document.querySelector('body').removeChild(banner);
412      var event = new Event('smartbanner.exit');
413      document.dispatchEvent(event);
414      _bakery["default"].bake(this.hideTtl, this.hidePath);
415    }
416  }, {
417    key: "clickout",
418    value: function clickout() {
419      var event = new Event('smartbanner.clickout');
420      document.dispatchEvent(event);
421    }
422  }]);
423  return SmartBanner;
424}();
425exports["default"] = SmartBanner;
426
427},{"./bakery.js":1,"./detector.js":2,"./optionparser.js":4}]},{},[3]);

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.