📄 window.js
字号:
/* * Copyright (c) 2001-2007, TIBCO Software Inc. * Use, modification, and distribution subject to terms of license. */jsx3.require("jsx3.gui.Block");jsx3.Class.defineClass("jsx3.gui.Window",jsx3.app.Model,null,function(a,n){var Y=jsx3.Exception;var cb=jsx3.util.Logger;var Rb=cb.getLogger(a.jsxclass.getName());a.xm=new jsx3.net.URI("jsx3.gui.window.html");a.hs=new jsx3.net.URI("jsx3.gui.window.xhtml");if(jsx3.CLASS_LOADER.IE){a.Is="screenLeft";a.Hv="screenTop";}else{a.Is="screenX";a.Hv="screenY";}a.DID_OPEN="didOpen";a.WILL_CLOSE="willClose";a.DID_FOCUS="didFocus";a.DID_RESIZE="didResize";a.PARENT_DID_CLOSE="parentDidClose";n.jsxwidth=400;n.jsxheight=300;n.jsxresizable=jsx3.Boolean.FALSE;n.jsxscrollable=jsx3.Boolean.FALSE;n.jsxdependent=jsx3.Boolean.TRUE;n.jsxtitle="";n._jsxwindow=null;n._jsxXc=null;n.init=function(p){this.jsxsuper(p);};n.open=function(){if(this._jsxwindow!=null&&!this._jsxwindow.closed){throw new Y("Window "+this+" already open.");}else{var jc=jsx3.util.strEndsWith(jsx3.app.Browser.getLocation().getPath().toLowerCase(),".xhtml")?a.hs:a.xm;var J=window.open(jc.toString(),this.getId().replace(/\./g,""),"directories=no,location=no,menubar=no,status=yes,personalbar=no,titlebar=yes,toolbar=no,width="+this.getWidth()+","+"height="+this.getHeight()+","+"resizable="+(this.isResizable()?"yes":"no")+","+"scrollbars="+(this.isScrollable()?"yes":"no"));if(J!=null){J["_jsxwindow"]=this;this._jsxwindow=J;this._jsxXc=window;return true;}else{return false;}}};n.close=function(){if(this._jsxwindow!=null&&!this._jsxwindow.closed){this._jsxwindow.close();return true;}else{throw new Y("Window "+this+" not open.");}};n.focus=function(){if(this._jsxwindow!=null&&!this._jsxwindow.closed){this._jsxwindow.focus();}else{throw new Y("Window "+this+" not open.");}};n.isOpen=function(){return this._jsxwindow!=null&&!this._jsxwindow.closed;};n.isParentOpen=function(){return this._jsxXc!=null&&!this._jsxXc.closed;};n.moveTo=function(c,g){if(this._jsxwindow!=null&&!this._jsxwindow.closed){if(this._jsxXc!=null&&!this._jsxXc.closed)this._jsxwindow.moveBy(c-this._jsxwindow[a.Is]+this._jsxXc[a.Is],g-this._jsxwindow[a.Hv]+this._jsxXc[a.Hv]);else this._jsxwindow.moveBy(c-this._jsxwindow[a.Is],g-this._jsxwindow[a.Hv]);}else{throw new Y("Window "+this+" not open.");}};n.constrainToScreen=function(){if(this._jsxwindow!=null&&!this._jsxwindow.closed){var Gc=this._jsxwindow;if(Gc[a.Is]<0||Gc[a.Is]>window.screen.width||Gc[a.Hv]<0||Gc[a.Hv]>window.screen.height)Gc.moveTo(0,0);}};n.getOffsetLeft=function(){if(this._jsxwindow!=null&&!this._jsxwindow.closed){if(this._jsxXc!=null&&!this._jsxXc.closed)return this._jsxwindow[a.Is]-this._jsxXc[a.Is];else return this._jsxwindow[a.Is];}else{throw new Y("Window "+this+" not open.");}};n.getOffsetTop=function(){if(this._jsxwindow!=null&&!this._jsxwindow.closed){if(this._jsxXc!=null&&!this._jsxXc.closed)return this._jsxwindow[a.Hv]-this._jsxXc[a.Hv];else return this._jsxwindow[a.Hv];}else{throw new Y("Window "+this+" not open.");}};n.onLoad=function(s){if(Rb.isLoggable(cb.DEBUG))Rb.debug("onLoad "+this.getName());var Z=s.document;var I=s.opener;var V=Z.getElementsByTagName("body")[0];var tc=Z.getElementsByTagName("head")[0];var Kc=this.getServer().getRootDocument();var pb=Kc.getElementsByTagName("link");for(var y=0;y<pb.length;y++){var zb=pb[y];if(zb.rel=="stylesheet"){var Yb=zb.getAttribute("href");if(Rb.isLoggable(cb.TRACE))Rb.trace("appending stylesheet "+Yb+" to window "+this.getName());var tb=Z.createElement("link");tb.setAttribute("id",zb.getAttribute("id"));tb.setAttribute("href",Yb);tb.setAttribute("rel",zb.getAttribute("rel"));tb.setAttribute("type",zb.getAttribute("type"));tc.appendChild(tb);}}V.innerHTML=this.getRootBlock().paint();s["jsx3"]=I.jsx3;this._jsxwindow=s;this._jsxXc=I;this.setTitle(this.getTitle());this.publish({subject:a.DID_OPEN});};n.onFocus=function(){if(Rb.isLoggable(cb.DEBUG))Rb.debug("onFocus "+this.getName());this.publish({subject:a.DID_FOCUS});};n.onBeforeUnload=function(){if(Rb.isLoggable(cb.DEBUG))Rb.debug("onBeforeUnload "+this.getName());if(this._jsxwindow!=null){jsx3.gui.Event._deregisterWindow(this._jsxwindow);for(var Mc in this._jsxwindow){try{this._jsxwindow[Mc]=null;}catch(Kc){}}}if(this._jsxXc!=null&&!this._jsxXc.closed)this._jsxXc.focus();this._jsxwindow=null;this._jsxXc=null;this.publish({subject:a.WILL_CLOSE});};n.onResize=function(){if(Rb.isLoggable(cb.TRACE))Rb.trace("onResize "+this.getName());this.jsxwidth=this._jsxwindow.document.body.clientWidth;this.jsxheight=this._jsxwindow.document.body.clientHeight;if(this._jsxmq!=null)this._jsxwindow.clearTimeout(this._jsxmq);var fc=this;this._jsxmq=this._jsxwindow.setTimeout(function(){fc._jsxmq=null;jsx3.gui.Painted.Queue.enableChunking(false);fc.getRootBlock().nW({parentwidth:fc.getWidth(),parentheight:fc.getHeight()},true);jsx3.gui.Painted.Queue.enableChunking(true);},250);this.publish({subject:a.DID_RESIZE});};n.onParentUnload=function(){if(Rb.isLoggable(cb.DEBUG))Rb.debug("onParentUnload");this.publish({subject:a.DID_PARENT_CLOSE});};n.getRootBlock=function(){var gc=this.getChild(0);if(gc==null){gc=new jsx3.gui.Block(this.getName()+"_JSXROOT",0,0,"100%","100%","");gc.setDynamicProperty("jsxbgcolor","@Solid Light");gc.setRelativePosition(jsx3.gui.Block.ABSOLUTE);gc.setOverflow(jsx3.gui.Block.OVERFLOWHIDDEN);gc.setIndex(0);this.setChild(gc);}return gc;};n.getWindow=function(){if(this._jsxwindow!=null&&!this._jsxwindow.closed)return this._jsxwindow;return null;};n.getParentWindow=function(){if(this._jsxXc!=null&&!this._jsxXc.closed)return this._jsxXc;return null;};n.getDocument=function(){if(this._jsxwindow!=null&&!this._jsxwindow.closed)return this._jsxwindow.document;return null;};n.IO=function(){return {parentwidth:this.getWidth(),parentheight:this.getHeight()};};n.repaint=function(){return this.getRootBlock().repaint();};n.getWidth=function(){return this.jsxwidth;};n.setWidth=function(i){if(this._jsxwindow!=null&&!this._jsxwindow.closed){this._jsxwindow.resizeBy(i-this.jsxwidth,0);}this.jsxwidth=i;};n.getHeight=function(){return this.jsxheight;};n.setHeight=function(e){if(this._jsxwindow!=null&&!this._jsxwindow.closed){this._jsxwindow.resizeBy(0,e-this.jsxheight);}this.jsxheight=e;};n.isResizable=function(){return this.jsxresizable;};n.setResizable=function(j){this.jsxresizable=jsx3.Boolean.valueOf(j);};n.isScrollable=function(){return this.jsxscrollable;};n.setScrollable=function(h){this.jsxscrollable=jsx3.Boolean.valueOf(h);};n.isDependent=function(){return this.jsxdependent;};n.setDependent=function(e){this.jsxdependent=jsx3.Boolean.valueOf(e);};n.getTitle=function(){return this.jsxtitle;};n.setTitle=function(m){this.jsxtitle=m;if(this._jsxwindow!=null&&!this._jsxwindow.closed)this._jsxwindow.document.title=m;};n.toString=function(g){return this.jsxsuper()+" "+this.getName();};});
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -