rotate-device
Version:
Plugin rotateDevice has been made to ask the users to rotate device/expand browser window to enjoy your site/app fully!
1 lines • 16.6 kB
JavaScript
!function(t,i){"object"==typeof exports&&"object"==typeof module?module.exports=i():"function"==typeof define&&define.amd?define([],i):"object"==typeof exports?exports.rotateDevice=i():t.rotateDevice=i()}(this,function(){return(n={},o.m=e=[function(t,i,e){"use strict";e.r(i);e(1);var n=e(5),o=e.n(n),r=e(7),s=e.n(r);i.default={createDesktopNotification:o(),createTouchDeviceNotification:s()}},function(t,i,e){var n=e(2);"string"==typeof n&&(n=[[t.i,n,""]]);var o={hmr:!0,transform:void 0,insertInto:void 0};e(3)(n,o);n.locals&&(t.exports=n.locals)},function(t,i,e){},function(t,i,n){var e,o,r,c={},f=(e=function(){return window&&document&&document.all&&!window.atob},function(){return void 0===o&&(o=e.apply(this,arguments)),o}),s=(r={},function(t,i){if("function"==typeof t)return t();if(void 0===r[t]){var e=function(t,i){return i?i.querySelector(t):document.querySelector(t)}.call(this,t,i);if(window.HTMLIFrameElement&&e instanceof window.HTMLIFrameElement)try{e=e.contentDocument.head}catch(t){e=null}r[t]=e}return r[t]}),l=null,h=0,a=[],p=n(4);function d(t,i){for(var e=0;e<t.length;e++){var n=t[e],o=c[n.id];if(o){o.refs++;for(var r=0;r<o.parts.length;r++)o.parts[r](n.parts[r]);for(;r<n.parts.length;r++)o.parts.push(g(n.parts[r],i))}else{var s=[];for(r=0;r<n.parts.length;r++)s.push(g(n.parts[r],i));c[n.id]={id:n.id,refs:1,parts:s}}}}function u(t,i){for(var e=[],n={},o=0;o<t.length;o++){var r=t[o],s=i.base?r[0]+i.base:r[0],a={css:r[1],media:r[2],sourceMap:r[3]};n[s]?n[s].parts.push(a):e.push(n[s]={id:s,parts:[a]})}return e}function v(t,i){var e=s(t.insertInto);if(!e)throw new Error("Couldn't find a style target. This probably means that the value for the 'insertInto' parameter is invalid.");var n=a[a.length-1];if("top"===t.insertAt)n?n.nextSibling?e.insertBefore(i,n.nextSibling):e.appendChild(i):e.insertBefore(i,e.firstChild),a.push(i);else if("bottom"===t.insertAt)e.appendChild(i);else{if("object"!=typeof t.insertAt||!t.insertAt.before)throw new Error("[Style Loader]\n\n Invalid value for parameter 'insertAt' ('options.insertAt') found.\n Must be 'top', 'bottom', or Object.\n (https://github.com/webpack-contrib/style-loader#insertat)\n");var o=s(t.insertAt.before,e);e.insertBefore(i,o)}}function m(t){if(null!==t.parentNode){t.parentNode.removeChild(t);var i=a.indexOf(t);0<=i&&a.splice(i,1)}}function y(t){var i=document.createElement("style");if(void 0===t.attrs.type&&(t.attrs.type="text/css"),void 0===t.attrs.nonce){var e=function(){0;return n.nc}();e&&(t.attrs.nonce=e)}return w(i,t.attrs),v(t,i),i}function w(i,e){Object.keys(e).forEach(function(t){i.setAttribute(t,e[t])})}function g(i,t){var e,n,o,r,s,a;if(t.transform&&i.css){if(!(r="function"==typeof t.transform?t.transform(i.css):t.transform.default(i.css)))return function(){};i.css=r}if(t.singleton){var c=h++;e=l=l||y(t),n=x.bind(null,e,c,!1),o=x.bind(null,e,c,!0)}else o=i.sourceMap&&"function"==typeof URL&&"function"==typeof URL.createObjectURL&&"function"==typeof URL.revokeObjectURL&&"function"==typeof Blob&&"function"==typeof btoa?(s=t,a=document.createElement("link"),void 0===s.attrs.type&&(s.attrs.type="text/css"),s.attrs.rel="stylesheet",w(a,s.attrs),v(s,a),n=function(t,i,e){var n=e.css,o=e.sourceMap,r=void 0===i.convertToAbsoluteUrls&&o;(i.convertToAbsoluteUrls||r)&&(n=p(n));o&&(n+="\n/*# sourceMappingURL=data:application/json;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(o))))+" */");var s=new Blob([n],{type:"text/css"}),a=t.href;t.href=URL.createObjectURL(s),a&&URL.revokeObjectURL(a)}.bind(null,e=a,t),function(){m(e),e.href&&URL.revokeObjectURL(e.href)}):(e=y(t),n=function(t,i){var e=i.css,n=i.media;n&&t.setAttribute("media",n);if(t.styleSheet)t.styleSheet.cssText=e;else{for(;t.firstChild;)t.removeChild(t.firstChild);t.appendChild(document.createTextNode(e))}}.bind(null,e),function(){m(e)});return n(i),function(t){if(t){if(t.css===i.css&&t.media===i.media&&t.sourceMap===i.sourceMap)return;n(i=t)}else o()}}t.exports=function(t,s){if("undefined"!=typeof DEBUG&&DEBUG&&"object"!=typeof document)throw new Error("The style-loader cannot be used in a non-browser environment");(s=s||{}).attrs="object"==typeof s.attrs?s.attrs:{},s.singleton||"boolean"==typeof s.singleton||(s.singleton=f()),s.insertInto||(s.insertInto="head"),s.insertAt||(s.insertAt="bottom");var a=u(t,s);return d(a,s),function(t){for(var i=[],e=0;e<a.length;e++){var n=a[e];(o=c[n.id]).refs--,i.push(o)}t&&d(u(t,s),s);for(e=0;e<i.length;e++){var o;if(0===(o=i[e]).refs){for(var r=0;r<o.parts.length;r++)o.parts[r]();delete c[o.id]}}}};var b,C=(b=[],function(t,i){return b[t]=i,b.filter(Boolean).join("\n")});function x(t,i,e,n){var o=e?"":n.css;if(t.styleSheet)t.styleSheet.cssText=C(i,o);else{var r=document.createTextNode(o),s=t.childNodes;s[i]&&t.removeChild(s[i]),s.length?t.insertBefore(r,s[i]):t.appendChild(r)}}},function(t,i){t.exports=function(t){var i="undefined"!=typeof window&&window.location;if(!i)throw new Error("fixUrls requires window.location");if(!t||"string"!=typeof t)return t;var o=i.protocol+"//"+i.host,r=o+i.pathname.replace(/\/[^\/]*$/,"/");return t.replace(/url\s*\(((?:[^)(]|\((?:[^)(]+|\([^)(]*\))*\))*)\)/gi,function(t,i){var e,n=i.trim().replace(/^"(.*)"$/,function(t,i){return i}).replace(/^'(.*)'$/,function(t,i){return i});return/^(#|data:|http:\/\/|https:\/\/|file:\/\/\/|\s*$)/i.test(n)?t:(e=0===n.indexOf("//")?n:0===n.indexOf("/")?o+n:r+n.replace(/^\.\//,""),"url("+JSON.stringify(e)+")")})}},function(t,i,e){"use strict";var n,o=this&&this.__extends||(n=function(t,i){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,i){t.__proto__=i}||function(t,i){for(var e in i)i.hasOwnProperty(e)&&(t[e]=i[e])})(t,i)},function(t,i){function e(){this.constructor=t}n(t,i),t.prototype=null===i?Object.create(i):(e.prototype=i.prototype,new e)}),r=this&&this.__assign||function(){return(r=Object.assign||function(t){for(var i,e=1,n=arguments.length;e<n;e++)for(var o in i=arguments[e])Object.prototype.hasOwnProperty.call(i,o)&&(t[o]=i[o]);return t}).apply(this,arguments)};Object.defineProperty(i,"__esModule",{value:!0});var s,a=e(6),c={allowContentShow:!0,mainMessage:"Please expand your browser window",extraMessage:"or click to continue",desktopHeightBreak:350,desktopWidthBreak:400,showClass:"show",notificationClassPrefix:"desktop",iconPath:'<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"\nviewBox="0 0 206 160" style="enable-background:new 0 0 206 160;" xml:space="preserve">\n<g>\n<g>\n <path d="M181.64,160H24.36C10.93,160,0,149.07,0,135.64V24.36C0,10.93,10.93,0,24.36,0h157.28C195.07,0,206,10.93,206,24.36\n v111.28C206,149.07,195.07,160,181.64,160z M24.36,6C14.24,6,6,14.24,6,24.36v111.28C6,145.76,14.24,154,24.36,154h157.28\n c10.12,0,18.36-8.24,18.36-18.36V24.36C200,14.24,191.76,6,181.64,6H24.36z"/>\n</g>\n<g>\n <rect x="3" y="33.77" width="200" height="6"/>\n</g>\n<g>\n <circle cx="28.5" cy="21.5" r="4.5"/>\n</g>\n<g>\n <circle cx="41.5" cy="21.5" r="4.5"/>\n</g>\n<g>\n <circle cx="54.5" cy="21.5" r="4.5"/>\n</g>\n<g>\n <path d="M59.7,125.19c-0.99,0-1.96-0.49-2.53-1.38c-0.89-1.39-0.49-3.25,0.91-4.14L151,60.09c1.4-0.89,3.25-0.49,4.14,0.91\n c0.89,1.39,0.49,3.25-0.91,4.14l-92.92,59.58C60.82,125.04,60.26,125.19,59.7,125.19z"/>\n</g>\n<g>\n <path d="M76.78,129.81c-0.22,0-0.45-0.02-0.67-0.08l-17.92-4.09c-0.78-0.18-1.45-0.65-1.87-1.33c-0.42-0.67-0.56-1.49-0.38-2.26\n l4.4-19.3c0.37-1.62,1.98-2.63,3.59-2.26c1.62,0.37,2.63,1.98,2.26,3.59l-3.74,16.38l15,3.42c1.62,0.37,2.63,1.98,2.26,3.59\n C79.38,128.87,78.15,129.81,76.78,129.81z"/>\n</g>\n<g>\n <path d="M148.75,84.58c-0.22,0-0.45-0.02-0.67-0.08c-1.62-0.37-2.63-1.98-2.26-3.59l3.74-16.38l-15-3.42\n c-1.62-0.37-2.63-1.98-2.26-3.59c0.37-1.62,1.98-2.63,3.59-2.26l17.92,4.09c0.78,0.18,1.45,0.65,1.87,1.33\n c0.42,0.67,0.56,1.49,0.38,2.26l-4.4,19.3C151.35,83.64,150.11,84.58,148.75,84.58z"/>\n</g>\n</g>\n</svg>',appearAnimation:"",hideAnimation:"",hideAnimationDuration:0,type:"desktop",customHTML:!1,backgroundColor:"#ffffff"},f=(s=a.NotificationClass,o(l,s),l.prototype.startNotification=function(){this.getWindowHeight()<this.desktopHeightBreak||this.getWindowWidth()<this.desktopWidthBreak?this.showNotification():this.hideNotification()},l);function l(t){var i=s.call(this,t)||this;return i.desktopWidthBreak=t.desktopWidthBreak,i.desktopHeightBreak=t.desktopHeightBreak,i}i.default=function(t){var i=r(r({},c),t);return new f(i)}},function(t,i,e){"use strict";Object.defineProperty(i,"__esModule",{value:!0});var n=document.body,o=(r.prototype.deviceType=function(){return/Mobile|webOS|BlackBerry|IEMobile|MeeGo|mini|Fennec|Windows Phone|Android|iP(ad|od|hone)/i.test(navigator.userAgent)?"touchDevice":"desktop"},r.prototype.getWindowWidth=function(){return window.innerWidth},r.prototype.getWindowHeight=function(){return window.innerHeight},r.prototype.buildNotificationHtml=function(){var t=document.createElement("div");if(t.style.backgroundColor=this.backgroundColor,t.classList.add(this.notificationClassPrefix+"-notification-wrapper"),"boolean"==typeof this.customHTML){"<"!==this.iconPath[0]&&(this.iconPath='<img src="'+this.iconPath+'" alt="icon">');var i=void 0;i=this.extraMessage?'<p class="'+this.notificationClassPrefix+'-notification-extra-message">'+this.extraMessage+"</p>":"",t.innerHTML='<div class="'+this.notificationClassPrefix+'-notification-block">\n <p class="'+this.notificationClassPrefix+'-notification-main-message">'+this.mainMessage+'</p> <div class="'+this.notificationClassPrefix+"-notification-img-wrapper "+this.notificationClassPrefix+'-default-icon">'+this.iconPath+"</div> "+i+"\n </div>"}else t.innerHTML=this.customHTML;n.insertAdjacentElement("afterbegin",t),this.notificationWrapper=t,this.appearAnimationArr=this.getAnimationClasses(this.appearAnimation),this.hideAnimationArr=this.getAnimationClasses(this.hideAnimation)},r.prototype.getAnimationClasses=function(t){return 0<t.length?t.split(" "):[]},r.prototype.setAnimationClasses=function(i,t){0<t.length&&t.forEach(function(t){i.classList.add(t)})},r.prototype.removeAnimationClasses=function(i,t){0<t.length&&t.forEach(function(t){i.classList.remove(t)})},r.prototype.showNotification=function(){this.removeAnimationClasses(this.notificationWrapper,this.hideAnimationArr),this.setAnimationClasses(this.notificationWrapper,this.appearAnimationArr),this.notificationWrapper.classList.add(this.showClass),n.style.overflow="hidden",this.notificationState=!0,this.allowContentShow&&this.hideNotificationOnClick()},r.prototype.hideNotification=function(){var t=this;this.removeAnimationClasses(this.notificationWrapper,this.appearAnimationArr),this.setAnimationClasses(this.notificationWrapper,this.hideAnimationArr),this.notificationState=!1,setTimeout(function(){t.notificationWrapper.classList.remove(t.showClass),n.style.overflow="",t.removeAnimationClasses(t.notificationWrapper,t.hideAnimationArr)},this.hideAnimationDuration)},r.prototype.hideNotificationOnClick=function(){var t=this;window.addEventListener("click",function(){t.hideNotification()}),window.addEventListener("touchstart",function(){t.hideNotification()},!1)},r.prototype.initialization=function(){var i=this;this.type===this.deviceType()&&(this.notificationWrapper||(this.buildNotificationHtml(),this.startNotification(),this.initialized=!0),"touchDevice"===this.type?this.mql.addListener(function(t){i.isPortrait=t.matches,i.startNotification()}):window.addEventListener("resize",this.startNotification))},r.prototype.init=function(){var t=this;this.initialization(),window.addEventListener("resize",function(){t.deviceType()!==t.type||t.initialized?t.deviceType()!==t.type&&t.initialized&&t.destroy():t.initialization()})},r.prototype.destroy=function(){this.initialized&&("touchDevice"===this.type?window.removeEventListener("orientationchange",this.startNotification):window.removeEventListener("resize",this.startNotification),this.notificationState=!1,n.style.overflow="",this.initialized=!1,n.removeChild(this.notificationWrapper),this.notificationWrapper=null)},r);function r(t){this.type=t.type,this.mainMessage=t.mainMessage,this.extraMessage=t.allowContentShow?t.extraMessage:"",this.allowContentShow=t.allowContentShow,this.showClass="show",this.notificationClassPrefix=t.notificationClassPrefix,this.iconPath=t.iconPath,this.appearAnimation=t.appearAnimation,this.hideAnimation=t.hideAnimation,this.hideAnimationDuration=0===t.hideAnimationDuration&&""!==t.hideAnimation?400:t.hideAnimationDuration,this.notificationState=!1,this.customHTML=t.customHTML,this.initialized=!1,this.startNotification=this.startNotification.bind(this),this.mql=t.mql,this.isPortrait=t.isPortrait,this.backgroundColor=t.backgroundColor}i.NotificationClass=o},function(t,i,e){"use strict";var n,o=this&&this.__extends||(n=function(t,i){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,i){t.__proto__=i}||function(t,i){for(var e in i)i.hasOwnProperty(e)&&(t[e]=i[e])})(t,i)},function(t,i){function e(){this.constructor=t}n(t,i),t.prototype=null===i?Object.create(i):(e.prototype=i.prototype,new e)}),r=this&&this.__assign||function(){return(r=Object.assign||function(t){for(var i,e=1,n=arguments.length;e<n;e++)for(var o in i=arguments[e])Object.prototype.hasOwnProperty.call(i,o)&&(t[o]=i[o]);return t}).apply(this,arguments)};Object.defineProperty(i,"__esModule",{value:!0});var s,a=e(6),c={blockedOrientation:"landscape",allowContentShow:!0,mainMessage:"Please turn your device",extraMessage:"or tap the screen to continue",responsivePortraitBreak:767,responsiveLandscapeBreak:850,showClass:"show",notificationClassPrefix:"touch-device",iconPath:'<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"\nviewBox="0 0 184.02 312.02" style="enable-background:new 0 0 184.02 312.02;" xml:space="preserve">\n<style type="text/css">\n.st0{fill:#FFFFFF;}\n</style>\n<g>\n<path d="M163.52,312H20.48C9.17,312,0,302.83,0,291.52V20.54C0,9.23,9.17,0.06,20.48,0.06h143.04c11.31,0,20.48,9.17,20.48,20.48\n v270.98C184,302.83,174.83,312,163.52,312z"/>\n<path class="st0" d="M156.34,304.09H27.66c-10.91,0-19.75-8.84-19.75-19.75V25.56c0-10.91,8.84-19.75,19.75-19.75h128.69\n c10.91,0,19.75,8.84,19.75,19.75v258.78C176.09,295.25,167.25,304.09,156.34,304.09z"/>\n<circle cx="92" cy="282.53" r="12.22"/>\n<path d="M113.46,14.44H70.54c-7.5,0-14.3-4.4-17.37-11.23l-1.41-3.14h80.5l-1.41,3.14C127.76,10.04,120.96,14.44,113.46,14.44z"/>\n</g>\n</svg>',appearAnimation:"",hideAnimation:"",hideAnimationDuration:0,type:"touchDevice",customHTML:!1,mql:window.matchMedia("(orientation: portrait)"),backgroundColor:"#ffffff"},f=(s=a.NotificationClass,o(l,s),l.prototype.isDeviceInBlockedPortrait=function(){return window.screen.availWidth<this.responsivePortraitBreak},l.prototype.isDeviceInBlockedLandscape=function(){return window.screen.availWidth<this.responsiveLandscapeBreak},l.prototype.startNotification=function(){switch(this.blockedOrientation){case"portrait":!this.notificationState&&this.isPortrait?this.isDeviceInBlockedPortrait()&&this.showNotification():this.notificationState&&!this.isPortrait&&this.hideNotification();break;case"landscape":this.isPortrait||this.notificationState?this.isPortrait&&this.notificationState&&this.hideNotification():this.isDeviceInBlockedLandscape()&&this.showNotification()}},l);function l(t){var i=s.call(this,t)||this;return i.blockedOrientation=t.blockedOrientation,i.responsiveLandscapeBreak=t.responsiveLandscapeBreak,i.responsivePortraitBreak=t.responsivePortraitBreak,i.isPortrait=i.mql.matches,i}i.default=function(t){var i=r(r({},c),t);return new f(i)}}],o.c=n,o.d=function(t,i,e){o.o(t,i)||Object.defineProperty(t,i,{enumerable:!0,get:e})},o.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},o.t=function(i,t){if(1&t&&(i=o(i)),8&t)return i;if(4&t&&"object"==typeof i&&i&&i.__esModule)return i;var e=Object.create(null);if(o.r(e),Object.defineProperty(e,"default",{enumerable:!0,value:i}),2&t&&"string"!=typeof i)for(var n in i)o.d(e,n,function(t){return i[t]}.bind(null,n));return e},o.n=function(t){var i=t&&t.__esModule?function(){return t.default}:function(){return t};return o.d(i,"a",i),i},o.o=function(t,i){return Object.prototype.hasOwnProperty.call(t,i)},o.p="",o(o.s=0)).default;function o(t){if(n[t])return n[t].exports;var i=n[t]={i:t,l:!1,exports:{}};return e[t].call(i.exports,i,i.exports,o),i.l=!0,i.exports}var e,n});