summaryrefslogtreecommitdiff
blob: 6e6404281e5a352ca9b96ed69c03f9aa8ddffec5 (plain)
1
var wmpAppBanner=wmpAppBanner||{};wmpAppBanner.WIDGET=wmpAppBanner.WIDGET||{},wmpAppBanner.WIDGET.appUrl=wmpAppBanner.WIDGET.appUrl||"",wmpAppBanner.WIDGET.appIcon=wmpAppBanner.WIDGET.appIcon||"",wmpAppBanner.WIDGET.appName=wmpAppBanner.WIDGET.appName||"",wmpAppBanner.WIDGET.ref=wmpAppBanner.WIDGET.ref||"",wmpAppBanner.WIDGET.trustedDevice=wmpAppBanner.WIDGET.trustedDevice||0,wmpAppBanner.WIDGET.iframeUrl=wmpAppBanner.WIDGET.iframeUrl||"",wmpAppBanner.WIDGET.cssPath=wmpAppBanner.WIDGET.cssPath||"",wmpAppBanner.WIDGET.openAppButton=wmpAppBanner.WIDGET.openAppButton||"OPEN",function(){var e=function(){this.initialize()},n=e.prototype;n.initialize=function(){},n.get=function(e){var n,t,i,o=document.cookie.split(";");for(n=0;n<o.length;n++)if(t=o[n].substr(0,o[n].indexOf("=")),i=o[n].substr(o[n].indexOf("=")+1),t=t.replace(/^\s+|\s+$/g,""),t==e)return decodeURIComponent(i)},n.set=function(e,n,t){var i=new Date;i.setDate(i.getDate()+t);var o=encodeURIComponent(n)+(null==t?"":"; expires="+i.toUTCString())+"; path=/;";document.cookie=e+"="+o},wmpAppBanner.Cookie=e}(),function(){var e=function(e){this.initialize(e)},n=e.prototype;n.htmlElement=null,n.iframe=null,n.iframeUrl=null,n.initialize=function(e){var n=this;if(this.createWrapper(e),"onorientationchange"in window)this.orientationchangeFn=function(){setTimeout(function(){n.resize()},250)},window.addEventListener("orientationchange",this.orientationchangeFn,!1);else{var t=window.matchMedia("(orientation: portrait)");t.addListener(function(e){e.matches?n.resize("portrait"):n.resize("landscape")},!1)}this.touchendFn=function(){clearTimeout(window.resizeEvt),window.resizeEvt=setTimeout(function(){n.resize()},300)},window.resizeEvt,window.addEventListener("touchleave",this.touchendFn,!1),window.addEventListener("touchcancel",this.touchendFn,!1),window.addEventListener("touchmove",this.touchendFn,!1),window.addEventListener("touchend",this.touchendFn,!1)},n.createWrapper=function(e){var n=document.createElement("appticles-wrapper");this.htmlElement=n;var t=Math.round(this.getHeight()),i=Math.round(.1*t);n.style.position="fixed",n.style.width="100%",n.style.height="0px",n.style.top="0px",n.style.left="0px",n.style.boxSizing="border-box",n.style.zIndex=1e6,n.style.display="block",n.style.height=t+i+"px",document.body.appendChild(n);var o=e.appName||"",r=e.appUrl||"",a=e.appIcon||"",p=e.cssPath||"",c=this.iframeUrl=e.iframeUrl||"",h=window.location.href,s=e.openAppButton||"",d=(new Date).getTime(),l="cssPath="+p+"?_dc"+d;l+="&amp;height="+t,l+="&amp;appName="+encodeURIComponent(o),l+="&amp;appUrl="+encodeURIComponent(r),l+="&amp;appIcon="+a,l+="&amp;originUrl="+encodeURIComponent(h),l+="&amp;openText="+encodeURIComponent(s);var m=['<iframe id="appticles-iframe-bar" width="100%" height="'+(t+i)+'px" src="'+c+"#"+l+'" frameborder="0" allowtransparency="true" scrolling="no" style="position:relative;"></iframe>'].join("");n.innerHTML=m,this.iframe=document.getElementById("appticles-iframe-bar")},n.resize=function(e){var n=this.htmlElement;if(null!=n){var t=Math.round(this.getHeight()),i=Math.round(.1*t);n.style.height=t+i+"px";var o="height="+t;this.iframe.style.height=t+i+"px",this.iframe.src=this.iframeUrl+"#"+o}},n.getHeight=function(e){e=e||this.getOrientation();var n,t,i,o;return"portrait"==e?(n=Math.min(screen.width,screen.height),t=Math.max(screen.width,screen.height),i=window.innerWidth,o=90*(i/n)):"landscape"==e?(n=Math.max(screen.width,screen.height),t=Math.min(screen.width,screen.height),i=window.innerWidth,o=90*(i/t)*(t/n)):void 0},n.destroy=function(){var e=this.htmlElement;e.parentNode.removeChild(e),this.htmlElement=null,"onorientationchange"in window&&window.removeEventListener("orientationchange",this.orientationchangeFn),window.removeEventListener("touchleave",this.touchendFn),window.removeEventListener("touchcancel",this.touchendFn),window.removeEventListener("touchmove",this.touchendFn),window.removeEventListener("touchend",this.touchendFn),window[this]=null,delete this},n.getOrientation=function(){return window.matchMedia("(orientation: portrait)").matches?"portrait":window.matchMedia("(orientation: landscape)").matches?"landscape":void 0},wmpAppBanner.Bar=e}(),wmpAppBanner=wmpAppBanner||{},function(){var e=function(e){this.WIDGET=e,this.initialize(e)},n=e.prototype;n.cookie=null,n.WIDGET=null,n.bar=null,n.initialize=function(){this.cookie=new wmpAppBanner.Cookie},n.detectDevice=function(){var e=this;return 1==e.WIDGET.trustedDevice?void e.redirectFn(1):void e.redirectFn(0)},n.redirectFn=function(e){var n=this.WIDGET,t=this.cookie;t.set(n.cookiePrefix+"mobile_device",e,7),Boolean(Number(String(e)))&&this.createBar()},n.createBar=function(){var e=this,n=setInterval(function(){document.body&&0!=document.body.clientWidth&&(clearInterval(n),e.bar=new wmpAppBanner.Bar({appIcon:e.WIDGET.appIcon,appName:e.WIDGET.appName,appUrl:e.WIDGET.appUrl,cssPath:e.WIDGET.cssPath,iframeUrl:e.WIDGET.iframeUrl,openAppButton:e.WIDGET.openAppButton}))},10)},n.openApp=function(){var e=this.WIDGET,n=e.ref;document.cookie=e.cookiePrefix+"redirect=; expires=Thu, 01 Jan 1970 00:00:01 GMT; path=/;",n&&n.length>0&&(window.location.href=n)},wmpAppBanner.Stage=e}(),function(){function e(){t=i=new wmpAppBanner.Stage(wmpAppBanner.WIDGET);var e=i.cookie,o=e.get(wmpAppBanner.WIDGET.cookiePrefix+"mobile_device"),r=e.get(wmpAppBanner.WIDGET.cookiePrefix+"redirect"),a=e.get(wmpAppBanner.WIDGET.cookiePrefix+"closed"),p=wmpAppBanner.WIDGET.appUrl;if(o&&1==Boolean(Number(String(o)))&&p&&p.length>1){r=null!=r?Boolean(Number(String(r))):!0;var c=window.location.href.split("?");return c.length>1&&(-1!=c[c.length-1].indexOf("redirect=false")?(e.set(wmpAppBanner.WIDGET.cookiePrefix+"redirect",0,7),r=!1):-1!=c[c.length-1].indexOf("redirect=true")&&(e.set(wmpAppBanner.WIDGET.cookiePrefix+"redirect",1,7),r=!0)),void(r&&!a&&(window.onhashchange=n,i.createBar()))}o&&0==Boolean(Number(String(o)))||-1==window.location.href.indexOf("redirect=false")&&(window.onhashchange=n,i.detectDevice())}function n(){var e=window.location.hash.split("#")[1];if(e&&(e=e.split("="),"app_action"==e[0]))switch(e[1]){case"closebar":t.cookie.set(wmpAppBanner.WIDGET.cookiePrefix+"closed",1,7),setTimeout(function(){t.bar.destroy(),t=null},300),window.onhashchange=null,window.location.hash="";break;case"openapp":window.onhashchange=null,window.location.hash="",t.openApp()}}var t,i,o=setInterval(function(){/loading|loaded|complete/i.test(document.readyState)&&(clearInterval(o),e())},10)}();