PageSourceSearch

https://ecpparkbuddy.com/_templates/ECP/js/smartbanner.js

js ecpparkbuddy.com collected 2026-10-08 03:29:33 UTC 18,544 bytes, 531 lines download raw bytes

1/*!
2 * smartbanner.js v1.5.0 <https://github.com/ain/smartbanner.js>
3 * Copyright © 2017 Ain Tohvri, contributors. Licensed under GPL-3.0.
4 */
5(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
6'use strict';
7
8Object.defineProperty(exports, "__esModule", {
9  value: true
10});
11
12var _createClass = function () { function 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); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
13
14function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
15
16var Bakery = function () {
17  function Bakery() {
18    _classCallCheck(this, Bakery);
19  }
20
21  _createClass(Bakery, null, [{
22    key: 'bake',
23    value: function bake() {
24      document.cookie = 'smartbanner_exited=1';
25    }
26  }, {
27    key: 'unbake',
28    value: function unbake() {
29      document.cookie = 'smartbanner_exited=; expires=Thu, 01 Jan 1970 00:00:01 GMT;';
30    }
31  }, {
32    key: 'baked',
33    get: function get() {
34      var value = document.cookie.replace(/(?:(?:^|.*;\s*)smartbanner_exited\s*\=\s*([^;]*).*$)|^.*$/, '$1');
35      return value === '1';
36    }
37  }]);
38
39  return Bakery;
40}();
41
42exports.default = Bakery;
43
44},{}],2:[function(require,module,exports){
45(function (global){
46'use strict';
47
48Object.defineProperty(exports, "__esModule", {
49  value: true
50});
51
52var _createClass = function () { function 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); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
53
54function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
55
56var Detector = function () {
57  function Detector() {
58    _classCallCheck(this, Detector);
59  }
60
61  _createClass(Detector, null, [{
62    key: 'platform',
63    value: function platform() {
64      if (/iPhone|iPad|iPod/i.test(window.navigator.userAgent)) {
65        return 'ios';
66      } else if (/Android/i.test(window.navigator.userAgent)) {
67        return 'android';
68      }
69    }
70  }, {
71    key: 'userAgentMatchesRegex',
72    value: function userAgentMatchesRegex(regexString) {
73      return new RegExp(regexString).test(window.navigator.userAgent);
74    }
75  }, {
76    key: 'jQueryMobilePage',
77    value: function jQueryMobilePage() {
78      return typeof global.$ !== 'undefined' && global.$.mobile !== 'undefined' && document.querySelector('.ui-page') !== null;
79    }
80  }, {
81    key: 'wrapperElement',
82    value: function wrapperElement() {
83      var selector = Detector.jQueryMobilePage() ? '.ui-page' : 'html';
84      return document.querySelectorAll(selector);
85    }
86  }]);
87
88  return Detector;
89}();
90
91exports.default = Detector;
92
93}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
94},{}],3:[function(require,module,exports){
95'use strict';
96
97var _smartbanner = require('./smartbanner.js');
98
99var _smartbanner2 = _interopRequireDefault(_smartbanner);
100
101function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
102
103var smartbanner = void 0;
104
105window.addEventListener('load', function () {
106  smartbanner = new _smartbanner2.default();
107  smartbanner.publish();
108});
109
110},{"./smartbanner.js":7}],4:[function(require,module,exports){
111'use strict';
112
113Object.defineProperty(exports, "__esModule", {
114  value: true
115});
116
117var _createClass = function () { function 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); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
118
119require('./polyfills/array/from.js');
120
121require('./polyfills/array/includes.js');
122
123function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
124
125function valid(name) {
126  // TODO: validate against options dictionary
127  return name.indexOf('smartbanner:') !== -1 && name.split(':')[1].length > 0;
128}
129
130function convertToCamelCase(name) {
131  var parts = name.split('-');
132  parts.map(function (part, index) {
133    if (index > 0) {
134      parts[index] = part.charAt(0).toUpperCase() + part.substring(1);
135    }
136  });
137  return parts.join('');
138}
139
140var OptionParser = function () {
141  function OptionParser() {
142    _classCallCheck(this, OptionParser);
143  }
144
145  _createClass(OptionParser, [{
146    key: 'parse',
147    value: function parse() {
148      var metas = document.getElementsByTagName('meta');
149      var options = {};
150      var optionName = null;
151      Array.from(metas).forEach(function (meta) {
152        var name = meta.getAttribute('name');
153        var content = meta.getAttribute('content');
154        if (name && content && valid(name) && content.length > 0) {
155          optionName = name.split(':')[1];
156          if (Array.from(optionName).includes('-')) {
157            optionName = convertToCamelCase(optionName);
158          }
159          options[optionName] = content;
160        }
161      });
162      return options;
163    }
164  }]);
165
166  return OptionParser;
167}();
168
169exports.default = OptionParser;
170
171},{"./polyfills/array/from.js":5,"./polyfills/array/includes.js":6}],5:[function(require,module,exports){
172'use strict';
173
174// Production steps of ECMA-262, Edition 6, 22.1.2.1
175// Reference: https://people.mozilla.org/~jorendorff/es6-draft.html#sec-array.from
176if (!Array.from) {
177  Array.from = function () {
178    var toStr = Object.prototype.toString;
179    var isCallable = function isCallable(fn) {
180      return typeof fn === 'function' || toStr.call(fn) === '[object Function]';
181    };
182    var toInteger = function toInteger(value) {
183      var number = Number(value);
184      if (isNaN(number)) {
185        return 0;
186      }
187      if (number === 0 || !isFinite(number)) {
188        return number;
189      }
190      return (number > 0 ? 1 : -1) * Math.floor(Math.abs(number));
191    };
192    var maxSafeInteger = Math.pow(2, 53) - 1;
193    var toLength = function toLength(value) {
194      var len = toInteger(value);
195      return Math.min(Math.max(len, 0), maxSafeInteger);
196    };
197
198    // The length property of the from method is 1.
199    return function from(arrayLike /*, mapFn, thisArg */) {
200      // 1. Let C be the this value.
201      var C = this;
202
203      // 2. Let items be ToObject(arrayLike).
204      var items = Object(arrayLike);
205
206      // 3. ReturnIfAbrupt(items).
207      if (arrayLike == null) {
208        throw new TypeError("Array.from requires an array-like object - not null or undefined");
209      }
210
211      // 4. If mapfn is undefined, then let mapping be false.
212      var mapFn = arguments.length > 1 ? arguments[1] : void undefined;
213      var T;
214      if (typeof mapFn !== 'undefined') {
215        // 5. else
216        // 5. a If IsCallable(mapfn) is false, throw a TypeError exception.
217        if (!isCallable(mapFn)) {
218          throw new TypeError('Array.from: when provided, the second argument must be a function');
219        }
220
221        // 5. b. If thisArg was supplied, let T be thisArg; else let T be undefined.
222        if (arguments.length > 2) {
223          T = arguments[2];
224        }
225      }
226
227      // 10. Let lenValue be Get(items, "length").
228      // 11. Let len be ToLength(lenValue).
229      var len = toLength(items.length);
230
231      // 13. If IsConstructor(C) is true, then
232      // 13. a. Let A be the result of calling the [[Construct]] internal method of C with an argument list containing the single item len.
233      // 14. a. Else, Let A be ArrayCreate(len).
234      var A = isCallable(C) ? Object(new C(len)) : new Array(len);
235
236      // 16. Let k be 0.
237      var k = 0;
238      // 17. Repeat, while k < len… (also steps a - h)
239      var kValue;
240      while (k < len) {
241        kValue = items[k];
242        if (mapFn) {
243          A[k] = typeof T === 'undefined' ? mapFn(kValue, k) : mapFn.call(T, kValue, k);
244        } else {
245          A[k] = kValue;
246        }
247        k += 1;
248      }
249      // 18. Let putStatus be Put(A, "length", len, true).
250      A.length = len;
251      // 20. Return A.
252      return A;
253    };
254  }();
255}
256
257},{}],6:[function(require,module,exports){
258'use strict';
259
260if (!Array.prototype.includes) {
261  Array.prototype.includes = function (searchElement /*, fromIndex*/) {
262    'use strict';
263
264    if (this == null) {
265      throw new TypeError('Array.prototype.includes called on null or undefined');
266    }
267
268    var O = Object(this);
269    var len = parseInt(O.length, 10) || 0;
270    if (len === 0) {
271      return false;
272    }
273    var n = parseInt(arguments[1], 10) || 0;
274    var k;
275    if (n >= 0) {
276      k = n;
277    } else {
278      k = len + n;
279      if (k < 0) {
280        k = 0;
281      }
282    }
283    var currentElement;
284    while (k < len) {
285      currentElement = O[k];
286      if (searchElement === currentElement || searchElement !== searchElement && currentElement !== currentElement) {
287        // NaN !== NaN
288        return true;
289      }
290      k++;
291    }
292    return false;
293  };
294}
295
296},{}],7:[function(require,module,exports){
297'use strict';
298
299Object.defineProperty(exports, "__esModule", {
300  value: true
301});
302
303var _createClass = function () { function 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); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
304
305var _optionparser = require('./optionparser.js');
306
307var _optionparser2 = _interopRequireDefault(_optionparser);
308
309var _detector = require('./detector.js');
310
311var _detector2 = _interopRequireDefault(_detector);
312
313var _bakery = require('./bakery.js');
314
315var _bakery2 = _interopRequireDefault(_bakery);
316
317function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
318
319function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
320
321var DEFAULT_PLATFORMS = 'android,ios';
322
323var datas = {
324  originalTop: 'data-smartbanner-original-top',
325  originalMarginTop: 'data-smartbanner-original-margin-top'
326};
327
328function handleExitClick(event, self) {
329  self.exit();
330  event.preventDefault();
331}
332
333function handleJQueryMobilePageLoad(event) {
334  if (!this.positioningDisabled) {
335    setContentPosition(event.data.height);
336  }
337}
338
339function addEventListeners(self) {
340  var closeIcon = document.querySelector('.js_smartbanner__exit');
341  closeIcon.addEventListener('click', function (event) {
342    return handleExitClick(event, self);
343  });
344  if (_detector2.default.jQueryMobilePage()) {
345    $(document).on('pagebeforeshow', self, handleJQueryMobilePageLoad);
346  }
347}
348
349function removeEventListeners() {
350  if (_detector2.default.jQueryMobilePage()) {
351    $(document).off('pagebeforeshow', handleJQueryMobilePageLoad);
352  }
353}
354
355function setContentPosition(value) {
356  var wrappers = _detector2.default.wrapperElement();
357  for (var i = 0, l = wrappers.length, wrapper; i < l; i++) {
358    wrapper = wrappers[i];
359    if (_detector2.default.jQueryMobilePage()) {
360      if (wrapper.getAttribute(datas.originalTop)) {
361        continue;
362      }
363      var top = parseFloat(getComputedStyle(wrapper).top);
364      wrapper.setAttribute(datas.originalTop, isNaN(top) ? 0 : top);
365      wrapper.style.top = value + 'px';
366    } else {
367      if (wrapper.getAttribute(datas.originalMarginTop)) {
368        continue;
369      }
370      var margin = parseFloat(getComputedStyle(wrapper).marginTop);
371      wrapper.setAttribute(datas.originalMarginTop, isNaN(margin) ? 0 : margin);
372      wrapper.style.marginTop = value + 'px';
373    }
374  }
375}
376
377function restoreContentPosition() {
378  var wrappers = _detector2.default.wrapperElement();
379  for (var i = 0, l = wrappers.length, wrapper; i < l; i++) {
380    wrapper = wrappers[i];
381    if (_detector2.default.jQueryMobilePage() && wrapper.getAttribute(datas.originalTop)) {
382      wrapper.style.top = wrapper.getAttribute(datas.originalTop) + 'px';
383    } else if (wrapper.getAttribute(datas.originalMarginTop)) {
384      wrapper.style.marginTop = wrapper.getAttribute(datas.originalMarginTop) + 'px';
385    }
386  }
387}
388
389var SmartBanner = function () {
390  function SmartBanner() {
391    _classCallCheck(this, SmartBanner);
392
393    var parser = new _optionparser2.default();
394    this.options = parser.parse();
395    this.platform = _detector2.default.platform();
396  }
397
398  // DEPRECATED. Will be removed.
399
400
401  _createClass(SmartBanner, [{
402    key: 'publish',
403    value: function publish() {
404      if (Object.keys(this.options).length === 0) {
405        throw new Error('No options detected. Please consult documentation.');
406      }
407
408      if (_bakery2.default.baked) {
409        return false;
410      }
411
412      // User Agent was explicetely excluded by defined excludeUserAgentRegex
413      if (this.userAgentExcluded) {
414        return false;
415      }
416
417      // User agent was neither included by platformEnabled,
418      // nor by defined includeUserAgentRegex
419      if (!(this.platformEnabled || this.userAgentIncluded)) {
420        return false;
421      }
422
423      var bannerDiv = document.createElement('div');
424      document.querySelector('body').appendChild(bannerDiv);
425      bannerDiv.outerHTML = this.html;
426      if (!this.positioningDisabled) {
427        setContentPosition(this.height);
428      }
429      addEventListeners(this);
430    }
431  }, {
432    key: 'exit',
433    value: function exit() {
434      removeEventListeners();
435      if (!this.positioningDisabled) {
436        restoreContentPosition();
437      }
438      var banner = document.querySelector('.js_smartbanner');
439      document.querySelector('body').removeChild(banner);
440      _bakery2.default.bake();
441    }
442  }, {
443    key: 'originalTop',
444    get: function get() {
445      var wrapper = _detector2.default.wrapperElement()[0];
446      return parseFloat(wrapper.getAttribute(datas.originalTop));
447    }
448
449    // DEPRECATED. Will be removed.
450
451  }, {
452    key: 'originalTopMargin',
453    get: function get() {
454      var wrapper = _detector2.default.wrapperElement()[0];
455      return parseFloat(wrapper.getAttribute(datas.originalMarginTop));
456    }
457  }, {
458    key: 'priceSuffix',
459    get: function get() {
460      if (this.platform === 'ios') {
461        return this.options.priceSuffixApple;
462      } else if (this.platform === 'android') {
463        return this.options.priceSuffixGoogle;
464      }
465      return '';
466    }
467  }, {
468    key: 'icon',
469    get: function get() {
470      if (this.platform === 'android') {
471        return this.options.iconGoogle;
472      } else {
473        return this.options.iconApple;
474      }
475    }
476  }, {
477    key: 'buttonUrl',
478    get: function get() {
479      if (this.platform === 'android') {
480        return this.options.buttonUrlGoogle;
481      } else if (this.platform === 'ios') {
482        return this.options.buttonUrlApple;
483      }
484      return '#';
485    }
486  }, {
487    key: 'html',
488    get: function get() {
489      return '<div class="smartbanner smartbanner--' + this.platform + ' js_smartbanner">\n      <a href="javascript:void();" class="smartbanner__exit js_smartbanner__exit"></a>\n      <div class="smartbanner__icon" style="background-image: url(' + this.icon + ');"></div>\n      <div class="smartbanner__info">\n        <div>\n          <div class="smartbanner__info__title">' + this.options.title + '</div>\n          <div class="smartbanner__info__author">' + this.options.author + '</div>\n          <div class="smartbanner__info__price">' + this.options.price + this.priceSuffix + '</div>\n        </div>\n      </div>\n      <a href="' + this.buttonUrl + '" target="_blank" class="smartbanner__button"><span class="smartbanner__button__label">' + this.options.button + '</span></a>\n    </div>';
490    }
491  }, {
492    key: 'height',
493    get: function get() {
494      var height = document.querySelector('.js_smartbanner').offsetHeight;
495      return height !== undefined ? height : 0;
496    }
497  }, {
498    key: 'platformEnabled',
499    get: function get() {
500      var enabledPlatforms = this.options.enabledPlatforms || DEFAULT_PLATFORMS;
501      return enabledPlatforms && enabledPlatforms.replace(/\s+/g, '').split(',').indexOf(this.platform) !== -1;
502    }
503  }, {
504    key: 'positioningDisabled',
505    get: function get() {
506      return this.options.disablePositioning === 'true';
507    }
508  }, {
509    key: 'userAgentExcluded',
510    get: function get() {
511      if (!this.options.excludeUserAgentRegex) {
512        return false;
513      }
514      return _detector2.default.userAgentMatchesRegex(this.options.excludeUserAgentRegex);
515    }
516  }, {
517    key: 'userAgentIncluded',
518    get: function get() {
519      if (!this.options.includeUserAgentRegex) {
520        return false;
521      }
522      return _detector2.default.userAgentMatchesRegex(this.options.includeUserAgentRegex);
523    }
524  }]);
525
526  return SmartBanner;
527}();
528
529exports.default = SmartBanner;
530
531},{"./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.