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