diff --git a/dist/smartbanner.css b/dist/smartbanner.css index 1a6c6542..88c6e307 100644 --- a/dist/smartbanner.css +++ b/dist/smartbanner.css @@ -1,5 +1,5 @@ /*! - * smartbanner.js v1.20.0 + * smartbanner.js v1.21.0 * Copyright © 2023 Ain Tohvri, contributors. Licensed under GPL-3.0. */ .smartbanner { diff --git a/dist/smartbanner.js b/dist/smartbanner.js index 887f26d6..38588533 100644 --- a/dist/smartbanner.js +++ b/dist/smartbanner.js @@ -1,5 +1,5 @@ /*! - * smartbanner.js v1.20.0 + * smartbanner.js v1.21.0 * Copyright © 2023 Ain Tohvri, contributors. Licensed under GPL-3.0. */ (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\n \n
\n
\n
\n
").concat(this.options.title, "
\n
").concat(this.options.author, "
\n
").concat(this.options.price).concat(this.priceSuffix, "
\n
\n
\n ").concat(this.options.button, "\n "); + return "
\n \n
\n
\n
\n
").concat(this.options.title, "
\n
").concat(this.options.author, "
\n
").concat(this.price).concat(this.priceSuffix, "
\n
\n
\n ").concat(this.options.button, "\n
"); } }, { key: "height", diff --git a/dist/smartbanner.min.css b/dist/smartbanner.min.css index ed8caff6..4556a191 100644 --- a/dist/smartbanner.min.css +++ b/dist/smartbanner.min.css @@ -1,5 +1,5 @@ /*! - * smartbanner.js v1.20.0 + * smartbanner.js v1.21.0 * Copyright © 2023 Ain Tohvri, contributors. Licensed under GPL-3.0. */ .smartbanner{position:absolute;top:0;left:0;overflow-x:hidden;width:100%;height:84px;background:#f3f3f3;font-family:Helvetica,sans,sans-serif}.smartbanner__exit{position:absolute;top:calc(50% - 6px);left:9px;display:block;margin:0;width:12px;height:12px;border:0;text-align:center}.smartbanner__exit::before,.smartbanner__exit::after{position:absolute;width:1px;height:12px;background:#767676;content:" "}.smartbanner__exit::before{transform:rotate(45deg)}.smartbanner__exit::after{transform:rotate(-45deg)}.smartbanner__icon{position:absolute;top:10px;left:30px;width:64px;height:64px;border-radius:15px;background-size:64px 64px}.smartbanner__info{position:absolute;top:10px;left:104px;display:flex;overflow-y:hidden;width:60%;height:64px;align-items:center;color:#000}.smartbanner__info__title{font-size:14px}.smartbanner__info__author,.smartbanner__info__price{font-size:12px}.smartbanner__button{position:absolute;top:32px;right:10px;z-index:1;display:block;padding:0 10px;min-width:10%;border-radius:5px;background:#f3f3f3;color:#1474fc;font-size:18px;text-align:center;text-decoration:none}.smartbanner__button__label{text-align:center}.smartbanner.smartbanner--android{background:#3d3d3d url("data:image/gif;base64,R0lGODlhCAAIAIABAFVVVf///yH5BAEHAAEALAAAAAAIAAgAAAINRG4XudroGJBRsYcxKAA7");box-shadow:inset 0 4px 0 #88b131}.smartbanner.smartbanner--android .smartbanner__exit{left:6px;margin-right:7px;width:17px;height:17px;border-radius:14px;background:#1c1e21;box-shadow:0 1px 2px rgba(0,0,0,.8) inset,0 1px 1px rgba(255,255,255,.3);color:#b1b1b3;font-family:"ArialRoundedMTBold",Arial;font-size:20px;line-height:17px;text-shadow:0 1px 1px #000}.smartbanner.smartbanner--android .smartbanner__exit::before,.smartbanner.smartbanner--android .smartbanner__exit::after{top:3px;left:8px;width:2px;height:11px;background:#b1b1b3}.smartbanner.smartbanner--android .smartbanner__exit:active,.smartbanner.smartbanner--android .smartbanner__exit:hover{color:#eee}.smartbanner.smartbanner--android .smartbanner__icon{background-color:rgba(0,0,0,0);box-shadow:none}.smartbanner.smartbanner--android .smartbanner__info{color:#ccc;text-shadow:0 1px 2px #000}.smartbanner.smartbanner--android .smartbanner__info__title{color:#fff;font-weight:bold}.smartbanner.smartbanner--android .smartbanner__button{top:30px;right:20px;padding:0;min-width:12%;border-radius:0;background:none;box-shadow:0 0 0 1px #333,0 0 0 2px #dddcdc;color:#d1d1d1;font-size:14px;font-weight:bold}.smartbanner.smartbanner--android .smartbanner__button:active,.smartbanner.smartbanner--android .smartbanner__button:hover{background:none}.smartbanner.smartbanner--android .smartbanner__button__label{display:block;padding:0 10px;background:#42b6c9;background:linear-gradient(to bottom, #42b6c9, #39a9bb);box-shadow:none;line-height:24px;text-align:center;text-shadow:none;text-transform:none}.smartbanner.smartbanner--android .smartbanner__button__label:active,.smartbanner.smartbanner--android .smartbanner__button__label:hover{background:#2ac7e1}/*# sourceMappingURL=smartbanner.min.css.map */ diff --git a/dist/smartbanner.min.js b/dist/smartbanner.min.js index a2abe46e..42b33b75 100644 --- a/dist/smartbanner.min.js +++ b/dist/smartbanner.min.js @@ -1,5 +1,5 @@ /*! - * smartbanner.js v1.20.0 + * smartbanner.js v1.21.0 * Copyright © 2023 Ain Tohvri, contributors. Licensed under GPL-3.0. */ -(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;i0||/iPhone|iPad|iPod/i.test(userAgent)){return"ios"}}},{key:"userAgentMatchesRegex",value:function userAgentMatchesRegex(regexString){return new RegExp(regexString).test(window.navigator.userAgent)}},{key:"jQueryMobilePage",value:function jQueryMobilePage(){return typeof global.$!=="undefined"&&global.$.mobile!=="undefined"&&document.querySelector(".ui-page")!==null}},{key:"wrapperElement",value:function wrapperElement(){var selector=Detector.jQueryMobilePage()?".ui-page":"html";return document.querySelectorAll(selector)}}]);return Detector}()}).call(this)}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{}],3:[function(require,module,exports){"use strict";var _smartbanner=_interopRequireDefault(require("./smartbanner.js"));function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}var smartbanner;window.addEventListener("load",function(){smartbanner=new _smartbanner["default"];if(smartbanner.apiEnabled){window.smartbanner=smartbanner}else{smartbanner.publish()}})},{"./smartbanner.js":5}],4:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports["default"]=void 0;function _typeof(o){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(o){return typeof o}:function(o){return o&&"function"==typeof Symbol&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o},_typeof(o)}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}function _defineProperties(target,props){for(var i=0;i0}function convertToCamelCase(name){var parts=name.split("-");parts.map(function(part,index){if(index>0){parts[index]=part.charAt(0).toUpperCase()+part.substring(1)}});return parts.join("")}var OptionParser=exports["default"]=function(){function OptionParser(){_classCallCheck(this,OptionParser)}_createClass(OptionParser,[{key:"parse",value:function parse(){var metas=document.getElementsByTagName("meta");var options={};Array.apply(null,metas).forEach(function(meta){var optionName=null;var name=meta.getAttribute("name");var content=meta.getAttribute("content");if(name&&content&&valid(name)&&content.length>0){optionName=name.split(":")[1];if(optionName.indexOf("-")!==-1){optionName=convertToCamelCase(optionName)}options[optionName]=content}});return options}}]);return OptionParser}()},{}],5:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports["default"]=void 0;var _optionparser=_interopRequireDefault(require("./optionparser.js"));var _detector=_interopRequireDefault(require("./detector.js"));var _bakery=_interopRequireDefault(require("./bakery.js"));function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _typeof(o){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(o){return typeof o}:function(o){return o&&"function"==typeof Symbol&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o},_typeof(o)}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}function _defineProperties(target,props){for(var i=0;i\n \n
\n
\n
\n
').concat(this.options.title,'
\n
').concat(this.options.author,'
\n
').concat(this.options.price).concat(this.priceSuffix,'
\n
\n
\n ').concat(this.options.button,"\n ")}},{key:"height",get:function get(){try{return document.querySelector(".js_smartbanner").offsetHeight}catch(error){return 0}}},{key:"platformEnabled",get:function get(){var enabledPlatforms=this.options.enabledPlatforms||DEFAULT_PLATFORMS;return enabledPlatforms&&enabledPlatforms.replace(/\s+/g,"").split(",").indexOf(this.platform)!==-1}},{key:"positioningDisabled",get:function get(){return this.options.disablePositioning==="true"}},{key:"apiEnabled",get:function get(){return this.options.api==="true"}},{key:"userAgentExcluded",get:function get(){if(!this.options.excludeUserAgentRegex){return false}return _detector["default"].userAgentMatchesRegex(this.options.excludeUserAgentRegex)}},{key:"userAgentIncluded",get:function get(){if(!this.options.includeUserAgentRegex){return false}return _detector["default"].userAgentMatchesRegex(this.options.includeUserAgentRegex)}},{key:"hideTtl",get:function get(){return this.options.hideTtl?parseInt(this.options.hideTtl):false}},{key:"hidePath",get:function get(){return this.options.hidePath?this.options.hidePath:"/"}},{key:"publish",value:function publish(){if(Object.keys(this.options).length===0){throw new Error("No options detected. Please consult documentation.")}if(_bakery["default"].baked){return false}if(this.userAgentExcluded){return false}if(!(this.platformEnabled||this.userAgentIncluded)){return false}var bannerDiv=document.createElement("div");document.querySelector("body").prepend(bannerDiv);bannerDiv.outerHTML=this.html;var event=new Event("smartbanner.view");document.dispatchEvent(event);if(!this.positioningDisabled){setContentPosition(this.height)}addEventListeners(this)}},{key:"exit",value:function exit(){removeEventListeners();if(!this.positioningDisabled){restoreContentPosition()}var banner=document.querySelector(".js_smartbanner");document.querySelector("body").removeChild(banner);var event=new Event("smartbanner.exit");document.dispatchEvent(event);_bakery["default"].bake(this.hideTtl,this.hidePath)}},{key:"clickout",value:function clickout(){var event=new Event("smartbanner.clickout");document.dispatchEvent(event)}}]);return SmartBanner}()},{"./bakery.js":1,"./detector.js":2,"./optionparser.js":4}]},{},[3]); \ No newline at end of file +(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;i0||/iPhone|iPad|iPod/i.test(userAgent)){return"ios"}}},{key:"userAgentMatchesRegex",value:function userAgentMatchesRegex(regexString){return new RegExp(regexString).test(window.navigator.userAgent)}},{key:"jQueryMobilePage",value:function jQueryMobilePage(){return typeof global.$!=="undefined"&&global.$.mobile!=="undefined"&&document.querySelector(".ui-page")!==null}},{key:"wrapperElement",value:function wrapperElement(){var selector=Detector.jQueryMobilePage()?".ui-page":"html";return document.querySelectorAll(selector)}}]);return Detector}()}).call(this)}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{}],3:[function(require,module,exports){"use strict";var _smartbanner=_interopRequireDefault(require("./smartbanner.js"));function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}var smartbanner;window.addEventListener("load",function(){smartbanner=new _smartbanner["default"];if(smartbanner.apiEnabled){window.smartbanner=smartbanner}else{smartbanner.publish()}})},{"./smartbanner.js":5}],4:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports["default"]=void 0;function _typeof(o){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(o){return typeof o}:function(o){return o&&"function"==typeof Symbol&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o},_typeof(o)}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}function _defineProperties(target,props){for(var i=0;i0}function convertToCamelCase(name){var parts=name.split("-");parts.map(function(part,index){if(index>0){parts[index]=part.charAt(0).toUpperCase()+part.substring(1)}});return parts.join("")}var OptionParser=exports["default"]=function(){function OptionParser(){_classCallCheck(this,OptionParser)}_createClass(OptionParser,[{key:"parse",value:function parse(){var metas=document.getElementsByTagName("meta");var options={};Array.apply(null,metas).forEach(function(meta){var optionName=null;var name=meta.getAttribute("name");var content=meta.getAttribute("content");if(name&&content&&valid(name)&&content.length>0){optionName=name.split(":")[1];if(optionName.indexOf("-")!==-1){optionName=convertToCamelCase(optionName)}options[optionName]=content}});return options}}]);return OptionParser}()},{}],5:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports["default"]=void 0;var _optionparser=_interopRequireDefault(require("./optionparser.js"));var _detector=_interopRequireDefault(require("./detector.js"));var _bakery=_interopRequireDefault(require("./bakery.js"));function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _typeof(o){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(o){return typeof o}:function(o){return o&&"function"==typeof Symbol&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o},_typeof(o)}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}function _defineProperties(target,props){for(var i=0;i\n \n
\n
\n
\n
').concat(this.options.title,'
\n
').concat(this.options.author,'
\n
').concat(this.price).concat(this.priceSuffix,'
\n
\n
\n ').concat(this.options.button,"\n ")}},{key:"height",get:function get(){try{return document.querySelector(".js_smartbanner").offsetHeight}catch(error){return 0}}},{key:"platformEnabled",get:function get(){var enabledPlatforms=this.options.enabledPlatforms||DEFAULT_PLATFORMS;return enabledPlatforms&&enabledPlatforms.replace(/\s+/g,"").split(",").indexOf(this.platform)!==-1}},{key:"positioningDisabled",get:function get(){return this.options.disablePositioning==="true"}},{key:"apiEnabled",get:function get(){return this.options.api==="true"}},{key:"userAgentExcluded",get:function get(){if(!this.options.excludeUserAgentRegex){return false}return _detector["default"].userAgentMatchesRegex(this.options.excludeUserAgentRegex)}},{key:"userAgentIncluded",get:function get(){if(!this.options.includeUserAgentRegex){return false}return _detector["default"].userAgentMatchesRegex(this.options.includeUserAgentRegex)}},{key:"hideTtl",get:function get(){return this.options.hideTtl?parseInt(this.options.hideTtl):false}},{key:"hidePath",get:function get(){return this.options.hidePath?this.options.hidePath:"/"}},{key:"publish",value:function publish(){if(Object.keys(this.options).length===0){throw new Error("No options detected. Please consult documentation.")}if(_bakery["default"].baked){return false}if(this.userAgentExcluded){return false}if(!(this.platformEnabled||this.userAgentIncluded)){return false}var bannerDiv=document.createElement("div");document.querySelector("body").prepend(bannerDiv);bannerDiv.outerHTML=this.html;var event=new Event("smartbanner.view");document.dispatchEvent(event);if(!this.positioningDisabled){setContentPosition(this.height)}addEventListeners(this)}},{key:"exit",value:function exit(){removeEventListeners();if(!this.positioningDisabled){restoreContentPosition()}var banner=document.querySelector(".js_smartbanner");document.querySelector("body").removeChild(banner);var event=new Event("smartbanner.exit");document.dispatchEvent(event);_bakery["default"].bake(this.hideTtl,this.hidePath)}},{key:"clickout",value:function clickout(){var event=new Event("smartbanner.clickout");document.dispatchEvent(event)}}]);return SmartBanner}()},{"./bakery.js":1,"./detector.js":2,"./optionparser.js":4}]},{},[3]); \ No newline at end of file diff --git a/package.json b/package.json index 55fd2184..32163927 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "smartbanner.js", - "version": "1.20.0", + "version": "1.21.0", "description": "Customisable smart app banner for iOS and Android", "homepage": "https://github.com/ain/smartbanner.js#readme", "author": {