/* * Copyright 2016, CMCC Technologies Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ (function(a){if(typeof define==="function"&&define.amd){define("pym",[],a)}else{if(typeof module!=="undefined"&&module.exports){module.exports=a()}else{window.pym=a.call(this)}}window.pym=a.call(this)})(function(){var a="xPYMx";function e(){var k,i;if(window.innerHeight&&window.scrollMaxY){k=window.innerWidth+window.scrollMaxX;i=window.innerHeight+window.scrollMaxY}else{if(document.body.scrollHeight>document.body.offsetHeight){k=document.body.scrollWidth;i=document.body.scrollHeight}else{k=document.body.offsetWidth;i=document.body.offsetHeight}}var j,l;if(self.innerHeight){if(document.documentElement.clientWidth){j=document.documentElement.clientWidth}else{j=self.innerWidth}l=self.innerHeight}else{if(document.documentElement&&document.documentElement.clientHeight){j=document.documentElement.clientWidth;l=document.documentElement.clientHeight}else{if(document.body){j=document.body.clientWidth;l=document.body.clientHeight}}}if(i-1){q=this.url.substring(n,this.url.length);this.url=this.url.substring(0,n)}if(this.url.indexOf("?")<0){this.url+="?"}else{this.url+="&"}this.iframe.src=this.url.trim().indexOf("javascript:")>=0?"":this.url+"initialWidth="+o+"&childId="+this.id;"&parentUrl="+encodeURIComponent(window.location.href)+q;this.iframe.setAttribute("width","100%");this.iframe.setAttribute("scrolling","no");this.iframe.setAttribute("marginheight","0");this.iframe.setAttribute("frameborder","0");this.el.appendChild(this.iframe);var p=this;window.addEventListener("resize",this._onResize)};this._onResize=function(){this.sendWidth()}.bind(this);this._fire=function(o,p){if(o in this.messageHandlers){for(var n=0;n0&&this.childpageType==="isc"){console.log("parent window detect that the child iframe page loaded smartclient,the iframe height will ignore the child's Height change message;");if(this.minHeightheight){m=l.oldHeight-height}else{m=height-l.oldHeight}if(m<=70){return}if(l.oldHeight!=height){l.oldHeight=height;console.log("child iframe id="+l.id+" sedHeight:"+height);l.sendMessage("height",height)}}.bind(this);this.scrollParentTo=function(m){this.sendMessage("navigateTo","#"+m)};this.navigateParentTo=function(m){this.sendMessage("navigateTo",m)};this.id=c("childId")||i.id;this.messageRegex=new RegExp("^pym"+a+this.id+a+"(\\S+)"+a+"(.+)$");var k=parseInt(c("initialWidth"));this.parentUrl=c("parentUrl");this.onMessage("width",this._onWidthMessage);for(var j in i){this.settings[j]=i[j]}var l=this;window.addEventListener("message",this._processMessage,false);if(this.settings.renderCallback){this.settings.renderCallback(k)}this.sendHeight();if(this.settings.polling){window.setInterval(this.sendHeight,this.settings.polling)}return this};d();return g});