[Qooxdoo-commit] qooxdoo/source/script/gui QxNativeWindow.js,1.1.2.17,1.1.2.18
Brought to you by:
ecker,
martinwittemann
|
From: Sebastian W. <wp...@us...> - 2006-01-24 12:21:50
|
Update of /cvsroot/qooxdoo/qooxdoo/source/script/gui In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15560/source/script/gui Modified Files: Tag: renderer QxNativeWindow.js Log Message: Fixed modal handling, many improvements Index: QxNativeWindow.js =================================================================== RCS file: /cvsroot/qooxdoo/qooxdoo/source/script/gui/Attic/QxNativeWindow.js,v retrieving revision 1.1.2.17 retrieving revision 1.1.2.18 diff -u -d -r1.1.2.17 -r1.1.2.18 --- QxNativeWindow.js 24 Jan 2006 08:39:21 -0000 1.1.2.17 +++ QxNativeWindow.js 24 Jan 2006 12:21:40 -0000 1.1.2.18 @@ -33,7 +33,20 @@ function QxNativeWindow(vUrl, vName) { QxTarget.call(this); + + + // ************************************************************************ + // TIMER + // ************************************************************************ + + this._timer = new QxTimer(100); + this._timer.addEventListener(QxConst.EVENT_TYPE_INTERVAL, this._oninterval, this); + + // ************************************************************************ + // INITIAL PROPERTIES + // ************************************************************************ + if (QxUtil.isValidString(vUrl)) { this.setUrl(vUrl); }; @@ -46,6 +59,11 @@ QxNativeWindow.extend(QxTarget, "QxNativeWindow"); /*! + If the window is open or closed +*/ +QxNativeWindow.addProperty({ name : "open", type : QxConst.TYPEOF_BOOLEAN, defaultValue : false }); + +/*! The outer width of the window. */ QxNativeWindow.addProperty({ name : "width", defaultValue : 400 }); @@ -165,6 +183,11 @@ return true; }; +proto._modifyOpen = function(propValue, propOldValue, propData) +{ + propValue ? this._open() : this._close(); + return true; +}; @@ -214,28 +237,26 @@ --------------------------------------------------------------------------- */ -proto._isOpened = false; - proto.isClosed = function() { var vClosed = true; - try + if (this._window) { - if (this._window) { + try { vClosed = this._window.closed; - }; - } - catch(ex) {}; + } catch(ex) {}; + }; return vClosed; }; -proto.close = function() -{ - if (!this.isClosed()) { - this._window.close(); - }; +proto.open = function() { + this.setOpen(true); +}; + +proto.close = function() { + this.setOpen(false); }; @@ -252,8 +273,8 @@ --------------------------------------------------------------------------- */ -proto.open = function() -{ +proto._open = function() +{ /* ------------------------------------------------------------------------------ PRE CONFIGURE WINDOW @@ -312,28 +333,6 @@ conf += "modal=" + (this.getModal() ? "yes" : "no") + ","; - /* - ------------------------------------------------------------------------------ - TIMER - ------------------------------------------------------------------------------ - */ - - this._isOpened = false; - this._isLoaded = false; - this._readyState = 0; - - - /* - ------------------------------------------------------------------------------ - BLOCKER - ------------------------------------------------------------------------------ - */ - - if (this.getModal()) { - window.application.getClientWindow().getClientDocument().block(this); - }; - - /* @@ -348,21 +347,57 @@ this._window = window.open(this.getUrl(), this.getName(), conf); - if (!this._window) + if (this.isClosed()) { - this.debug("Window could not be opened. It seems there is a popup blocker active!"); + this.error("Window could not be opened. It seems, there is a popup blocker active!", "_open"); + } + else + { + // start timer for close detection + this._timer.start(); + + // block original document + if (this.getModal()) + { + var vClientWindow = window.application.getClientWindow(); + + if (vClientWindow) { + vClientWindow.getClientDocument().block(this); + }; + }; + }; +}; - // release window again - if (this.getModal()) { - window.application.getClientWindow().getClientDocument().release(this); - }; +proto._close = function() +{ + if (!this._window) { + return; }; + + // stop timer for close detection + this._timer.stop(); + + // release window again + if (this.getModal()) + { + var vClientWindow = window.application.getClientWindow(); + + if (vClientWindow) { + vClientWindow.getClientDocument().release(this); + }; + }; + + // finally close window + if (!this.isClosed()) { + this._window.close(); + }; }; + /* --------------------------------------------------------------------------- CENTER SUPPORT @@ -383,10 +418,6 @@ proto._centerHelper = function(l, t) { - // to force the move of the window - this.forceLeft(0); - this.forceTop(0); - // set new values this.setLeft(l); this.setTop(t); @@ -427,6 +458,25 @@ + +/* +--------------------------------------------------------------------------- + EVENT HANDLING +--------------------------------------------------------------------------- +*/ + +proto._oninterval = function(e) +{ + if (this.isClosed()) { + this.setOpen(false); + }; +}; + + + + + + /* --------------------------------------------------------------------------- DISPOSER @@ -439,7 +489,7 @@ return; }; - if (this._window) + if (!this.isClosed()) { this.close(); this._window = null; |