X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=resources%2Flib%2Foojs-ui%2Foojs-ui-windows.js;h=97e63266d36de722ef98758fe89dfe01ee4cdca5;hb=1f2c768a9df46909932b44443f733d2185517435;hp=23db06aa3addf199b4e9ca04b704b35c024e5a30;hpb=a2254d32bf816c28f2a3fb4088b5e4356cff4c48;p=lhc%2Fweb%2Fwiklou.git diff --git a/resources/lib/oojs-ui/oojs-ui-windows.js b/resources/lib/oojs-ui/oojs-ui-windows.js index 23db06aa3a..97e63266d3 100644 --- a/resources/lib/oojs-ui/oojs-ui-windows.js +++ b/resources/lib/oojs-ui/oojs-ui-windows.js @@ -1,12 +1,12 @@ /*! - * OOjs UI v0.22.1 + * OOjs UI v0.22.4 * https://www.mediawiki.org/wiki/OOjs_UI * * Copyright 2011–2017 OOjs UI Team and other contributors. * Released under the MIT license * http://oojs.mit-license.org * - * Date: 2017-05-31T19:07:36Z + * Date: 2017-08-01T23:45:14Z */ ( function ( OO ) { @@ -912,6 +912,44 @@ OO.ui.WindowInstance = function OOuiWindowInstance() { OO.initClass( OO.ui.WindowInstance ); +/** + * Check if window is opening. + * + * @return {boolean} Window is opening + */ +OO.ui.WindowInstance.prototype.isOpening = function () { + return this.deferreds.opened.state() === 'pending'; +}; + +/** + * Check if window is opened. + * + * @return {boolean} Window is opened + */ +OO.ui.WindowInstance.prototype.isOpened = function () { + return this.deferreds.opened.state() === 'resolved' && + this.deferreds.closing.state() === 'pending'; +}; + +/** + * Check if window is closing. + * + * @return {boolean} Window is closing + */ +OO.ui.WindowInstance.prototype.isClosing = function () { + return this.deferreds.closing.state() === 'resolved' && + this.deferreds.closed.state() === 'pending'; +}; + +/** + * Check if window is closed. + * + * @return {boolean} Window is closed + */ +OO.ui.WindowInstance.prototype.isClosed = function () { + return this.deferreds.closed.state() === 'resolved'; +}; + /** * Window managers are used to open and close {@link OO.ui.Window windows} and control their presentation. * Managed windows are mutually exclusive. If a new window is opened while a current window is opening @@ -1108,7 +1146,7 @@ OO.ui.WindowManager.prototype.afterWindowResize = function () { */ OO.ui.WindowManager.prototype.isOpening = function ( win ) { return win === this.currentWindow && !!this.lifecycle && - this.lifecycle.opened.state() === 'pending'; + this.lifecycle.isOpening(); }; /** @@ -1119,8 +1157,7 @@ OO.ui.WindowManager.prototype.isOpening = function ( win ) { */ OO.ui.WindowManager.prototype.isClosing = function ( win ) { return win === this.currentWindow && !!this.lifecycle && - this.lifecycle.closing.state() === 'resolved' && - this.lifecycle.closed.state() === 'pending'; + this.lifecycle.isClosing(); }; /** @@ -1131,8 +1168,7 @@ OO.ui.WindowManager.prototype.isClosing = function ( win ) { */ OO.ui.WindowManager.prototype.isOpened = function ( win ) { return win === this.currentWindow && !!this.lifecycle && - this.lifecycle.opened.state() === 'resolved' && - this.lifecycle.closing.state() === 'pending'; + this.lifecycle.isOpened(); }; /** @@ -1261,7 +1297,8 @@ OO.ui.WindowManager.prototype.getCurrentWindow = function () { * @fires opening */ OO.ui.WindowManager.prototype.openWindow = function ( win, data, lifecycle, compatOpening ) { - var manager = this; + var error, + manager = this; data = data || {}; // Internal parameter 'lifecycle' allows this method to always return @@ -1298,21 +1335,16 @@ OO.ui.WindowManager.prototype.openWindow = function ( win, data, lifecycle, comp // Error handling if ( !this.hasWindow( win ) ) { - compatOpening.reject( new OO.ui.Error( - 'Cannot open window: window is not attached to manager' - ) ); - lifecycle.deferreds.opening.reject( new OO.ui.Error( - 'Cannot open window: window is not attached to manager' - ) ); - return lifecycle; + error = 'Cannot open window: window is not attached to manager'; + } else if ( this.lifecycle && this.lifecycle.isOpened() ) { + error = 'Cannot open window: another window is open'; + } else if ( this.preparingToOpen || ( this.lifecycle && this.lifecycle.isOpening() ) ) { + error = 'Cannot open window: another window is opening'; } - if ( this.preparingToOpen || ( this.lifecycle && this.lifecycle.closing.state() !== 'resolved' ) ) { - compatOpening.reject( new OO.ui.Error( - 'Cannot open window: another window is opening or open' - ) ); - lifecycle.deferreds.opening.reject( new OO.ui.Error( - 'Cannot open window: another window is opening or open' - ) ); + + if ( error ) { + compatOpening.reject( new OO.ui.Error( error ) ); + lifecycle.deferreds.opening.reject( new OO.ui.Error( error ) ); return lifecycle; } @@ -1386,9 +1418,9 @@ OO.ui.WindowManager.prototype.closeWindow = function ( win, data ) { error = 'Cannot close window: no window is currently open'; } else if ( !win ) { error = 'Cannot close window: window is not attached to manager'; - } else if ( win !== this.currentWindow ) { + } else if ( win !== this.currentWindow || this.lifecycle.isClosed() ) { error = 'Cannot close window: window already closed with different data'; - } else if ( this.preparingToClose || lifecycle.closing.state() === 'resolved' ) { + } else if ( this.preparingToClose || this.lifecycle.isClosing() ) { error = 'Cannot close window: window already closing with different data'; }