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