Merge "Add block and unblock commands to WDIO"
[lhc/web/wiklou.git] / resources / lib / ooui / oojs-ui-windows.js
index 036cb6b..f86aee1 100644 (file)
@@ -1,12 +1,12 @@
 /*!
- * OOUI v0.29.3
+ * OOUI v0.30.2
  * https://www.mediawiki.org/wiki/OOUI
  *
- * Copyright 2011–2018 OOUI Team and other contributors.
+ * Copyright 2011–2019 OOUI Team and other contributors.
  * Released under the MIT license
  * http://oojs.mit-license.org
  *
- * Date: 2018-11-01T02:03:33Z
+ * Date: 2019-01-23T01:14:20Z
  */
 ( function ( OO ) {
 
@@ -159,7 +159,7 @@ OO.ui.ActionWidget.prototype.getModes = function () {
  *         return this.panel1.$element.outerHeight( true );
  *     };
  *     var windowManager = new OO.ui.WindowManager();
- *     $( 'body' ).append( windowManager.$element );
+ *     $( document.body ).append( windowManager.$element );
  *     var dialog = new MyProcessDialog( {
  *         size: 'medium'
  *     } );
@@ -381,6 +381,7 @@ OO.ui.ActionSet.prototype.getOthers = function () {
  * @param {string} mode The mode. Only actions configured to be available in the specified
  *  mode will be made visible.
  * @chainable
+ * @return {OO.ui.ActionSet} The widget, for chaining
  * @fires toggle
  * @fires change
  */
@@ -410,6 +411,7 @@ OO.ui.ActionSet.prototype.setMode = function ( mode ) {
  * @param {Object.<string,boolean>} actions A list keyed by action name with boolean
  *  values that indicate whether or not the action should be enabled.
  * @chainable
+ * @return {OO.ui.ActionSet} The widget, for chaining
  */
 OO.ui.ActionSet.prototype.setAbilities = function ( actions ) {
        var i, len, action, item;
@@ -435,6 +437,7 @@ OO.ui.ActionSet.prototype.setAbilities = function ( actions ) {
  * @param {Function} callback Callback to run for each action; callback is invoked with three
  *   arguments: the action, the action's index, the list of actions being iterated over
  * @chainable
+ * @return {OO.ui.ActionSet} The widget, for chaining
  */
 OO.ui.ActionSet.prototype.forEach = function ( filter, callback ) {
        this.changed = false;
@@ -453,6 +456,7 @@ OO.ui.ActionSet.prototype.forEach = function ( filter, callback ) {
  *
  * @param {OO.ui.ActionWidget[]} actions Action widgets to add
  * @chainable
+ * @return {OO.ui.ActionSet} The widget, for chaining
  * @fires add
  * @fires change
  */
@@ -483,6 +487,7 @@ OO.ui.ActionSet.prototype.add = function ( actions ) {
  *
  * @param {OO.ui.ActionWidget[]} actions Action widgets to remove
  * @chainable
+ * @return {OO.ui.ActionSet} The widget, for chaining
  * @fires remove
  * @fires change
  */
@@ -512,6 +517,7 @@ OO.ui.ActionSet.prototype.remove = function ( actions ) {
  * To remove only specified actions, use the {@link #method-remove remove} method instead.
  *
  * @chainable
+ * @return {OO.ui.ActionSet} The widget, for chaining
  * @fires remove
  * @fires change
  */
@@ -543,6 +549,7 @@ OO.ui.ActionSet.prototype.clear = function () {
  *
  * @private
  * @chainable
+ * @return {OO.ui.ActionSet} The widget, for chaining
  */
 OO.ui.ActionSet.prototype.organize = function () {
        var i, iLen, j, jLen, flag, action, category, list, item, special,
@@ -632,7 +639,7 @@ OO.ui.Error = function OoUiError( message, config ) {
        config = config || {};
 
        // Properties
-       this.message = message instanceof jQuery ? message : String( message );
+       this.message = message instanceof $ ? message : String( message );
        this.recoverable = config.recoverable === undefined || !!config.recoverable;
        this.warning = !!config.warning;
 };
@@ -671,7 +678,7 @@ OO.ui.Error.prototype.isWarning = function () {
  * @return {jQuery} Error message in DOM nodes
  */
 OO.ui.Error.prototype.getMessage = function () {
-       return this.message instanceof jQuery ?
+       return this.message instanceof $ ?
                this.message.clone() :
                $( '<div>' ).text( this.message ).contents();
 };
@@ -682,7 +689,7 @@ OO.ui.Error.prototype.getMessage = function () {
  * @return {string} Error message
  */
 OO.ui.Error.prototype.getMessageText = function () {
-       return this.message instanceof jQuery ? this.message.text() : this.message;
+       return this.message instanceof $ ? this.message.text() : this.message;
 };
 
 /**
@@ -769,7 +776,7 @@ OO.ui.Process.prototype.execute = function () {
                                return $.Deferred().reject( result ).promise();
                        }
                        // Duck-type the object to see if it can produce a promise
-                       if ( result && $.isFunction( result.promise ) ) {
+                       if ( result && typeof result.promise === 'function' ) {
                                // Use a promise generated from the result
                                return result.promise();
                        }
@@ -810,7 +817,7 @@ OO.ui.Process.prototype.execute = function () {
  * @return {Object} Step object, with `callback` and `context` properties
  */
 OO.ui.Process.prototype.createStep = function ( step, context ) {
-       if ( typeof step === 'number' || $.isFunction( step.promise ) ) {
+       if ( typeof step === 'number' || typeof step.promise === 'function' ) {
                return {
                        callback: function () {
                                return step;
@@ -818,7 +825,7 @@ OO.ui.Process.prototype.createStep = function ( step, context ) {
                        context: null
                };
        }
-       if ( $.isFunction( step ) ) {
+       if ( typeof step === 'function' ) {
                return {
                        callback: step,
                        context: context
@@ -1294,6 +1301,7 @@ OO.ui.WindowManager.prototype.getCurrentWindow = function () {
        return this.currentWindow;
 };
 
+/* eslint-disable valid-jsdoc */
 /**
  * Open a window.
  *
@@ -1308,6 +1316,7 @@ OO.ui.WindowManager.prototype.getCurrentWindow = function () {
  * @fires opening
  */
 OO.ui.WindowManager.prototype.openWindow = function ( win, data, lifecycle, compatOpening ) {
+       /* eslint-enable valid-jsdoc */
        var error,
                manager = this;
        data = data || {};
@@ -1527,7 +1536,7 @@ OO.ui.WindowManager.prototype.closeWindow = function ( win, data ) {
  * Example:
  *
  *     var windowManager = new OO.ui.WindowManager();
- *     $( 'body' ).append( windowManager.$element );
+ *     $( document.body ).append( windowManager.$element );
  *
  *     // Add a window under the default name: see OO.ui.MessageDialog.static.name
  *     windowManager.addWindows( [ new OO.ui.MessageDialog() ] );
@@ -1624,6 +1633,7 @@ OO.ui.WindowManager.prototype.clearWindows = function () {
  *
  * @param {OO.ui.Window} win Window to update, should be the current window
  * @chainable
+ * @return {OO.ui.WindowManager} The manager, for chaining
  */
 OO.ui.WindowManager.prototype.updateWindowSize = function ( win ) {
        var isFullscreen;
@@ -1650,6 +1660,7 @@ OO.ui.WindowManager.prototype.updateWindowSize = function ( win ) {
  * @private
  * @param {boolean} [on] Bind global events
  * @chainable
+ * @return {OO.ui.WindowManager} The manager, for chaining
  */
 OO.ui.WindowManager.prototype.toggleGlobalEvents = function ( on ) {
        var scrollWidth, bodyMargin,
@@ -1669,10 +1680,8 @@ OO.ui.WindowManager.prototype.toggleGlobalEvents = function ( on ) {
                        if ( stackDepth === 0 ) {
                                scrollWidth = window.innerWidth - document.documentElement.clientWidth;
                                bodyMargin = parseFloat( $body.css( 'margin-right' ) ) || 0;
-                               $body.css( {
-                                       overflow: 'hidden',
-                                       'margin-right': bodyMargin + scrollWidth
-                               } );
+                               $body.addClass( 'oo-ui-windowManager-modal-active' );
+                               $body.css( 'margin-right', bodyMargin + scrollWidth );
                        }
                        stackDepth++;
                        this.globalEvents = true;
@@ -1684,10 +1693,8 @@ OO.ui.WindowManager.prototype.toggleGlobalEvents = function ( on ) {
                } );
                stackDepth--;
                if ( stackDepth === 0 ) {
-                       $body.css( {
-                               overflow: '',
-                               'margin-right': ''
-                       } );
+                       $body.removeClass( 'oo-ui-windowManager-modal-active' );
+                       $body.css( 'margin-right', '' );
                }
                this.globalEvents = false;
        }
@@ -1702,6 +1709,7 @@ OO.ui.WindowManager.prototype.toggleGlobalEvents = function ( on ) {
  * @private
  * @param {boolean} [isolate] Make only the window manager visible to screen readers
  * @chainable
+ * @return {OO.ui.WindowManager} The manager, for chaining
  */
 OO.ui.WindowManager.prototype.toggleAriaIsolation = function ( isolate ) {
        var $topLevelElement;
@@ -1718,7 +1726,7 @@ OO.ui.WindowManager.prototype.toggleAriaIsolation = function ( isolate ) {
                        this.$element.removeAttr( 'aria-hidden' );
 
                        // Hide everything other than the window manager from screen readers
-                       this.$ariaHidden = $( 'body' )
+                       this.$ariaHidden = $( document.body )
                                .children()
                                .not( 'script' )
                                .not( $topLevelElement )
@@ -1881,6 +1889,7 @@ OO.ui.Window.static.size = 'medium';
  *
  * @private
  * @param {jQuery.Event} e Mouse down event
+ * @return {OO.ui.Window} The window, for chaining
  */
 OO.ui.Window.prototype.onMouseDown = function ( e ) {
        // Prevent clicking on the click-block from stealing focus
@@ -2160,6 +2169,7 @@ OO.ui.Window.prototype.getTeardownProcess = function () {
  * @param {OO.ui.WindowManager} manager Manager for this window
  * @throws {Error} An error is thrown if the method is called more than once
  * @chainable
+ * @return {OO.ui.Window} The window, for chaining
  */
 OO.ui.Window.prototype.setManager = function ( manager ) {
        if ( this.manager ) {
@@ -2178,6 +2188,7 @@ OO.ui.Window.prototype.setManager = function ( manager ) {
  * @param {string} size Symbolic name of size: `small`, `medium`, `large`, `larger` or
  *  `full`
  * @chainable
+ * @return {OO.ui.Window} The window, for chaining
  */
 OO.ui.Window.prototype.setSize = function ( size ) {
        this.size = size;
@@ -2190,6 +2201,7 @@ OO.ui.Window.prototype.setSize = function ( size ) {
  *
  * @throws {Error} An error is thrown if the window is not attached to a window manager
  * @chainable
+ * @return {OO.ui.Window} The window, for chaining
  */
 OO.ui.Window.prototype.updateSize = function () {
        if ( !this.manager ) {
@@ -2215,6 +2227,7 @@ OO.ui.Window.prototype.updateSize = function () {
  * @param {string|number} [dim.minHeight] Minimum height
  * @param {string|number} [dim.maxHeight] Maximum height
  * @chainable
+ * @return {OO.ui.Window} The window, for chaining
  */
 OO.ui.Window.prototype.setDimensions = function ( dim ) {
        var height,
@@ -2255,6 +2268,7 @@ OO.ui.Window.prototype.setDimensions = function ( dim ) {
  *
  * @throws {Error} An error is thrown if the window is not attached to a window manager
  * @chainable
+ * @return {OO.ui.Window} The window, for chaining
  */
 OO.ui.Window.prototype.initialize = function () {
        if ( !this.manager ) {
@@ -2407,6 +2421,7 @@ OO.ui.Window.prototype.hold = function ( data ) {
 
                // Blur the focused element
                if ( $focus.length ) {
+                       // eslint-disable-next-line jquery/no-event-shorthand
                        $focus[ 0 ].blur();
                }
 
@@ -2465,7 +2480,7 @@ OO.ui.Window.prototype.teardown = function ( data ) {
  *     } );
  *     // Create and append a window manager, which opens and closes the window.
  *     var windowManager = new OO.ui.WindowManager();
- *     $( 'body' ).append( windowManager.$element );
+ *     $( document.body ).append( windowManager.$element );
  *     windowManager.addWindows( [ myDialog ] );
  *     // Open the window!
  *     windowManager.openWindow( myDialog );
@@ -2756,6 +2771,7 @@ OO.ui.Dialog.prototype.attachActions = function () {
  *
  * @protected
  * @chainable
+ * @return {OO.ui.Dialog} The dialog, for chaining
  */
 OO.ui.Dialog.prototype.detachActions = function () {
        var i, len;
@@ -2765,6 +2781,8 @@ OO.ui.Dialog.prototype.detachActions = function () {
                this.attachedActions[ i ].$element.detach();
        }
        this.attachedActions = [];
+
+       return this;
 };
 
 /**
@@ -2805,7 +2823,7 @@ OO.ui.Dialog.prototype.executeAction = function ( action ) {
  *
  *     // Create and append a window manager.
  *     var windowManager = new OO.ui.WindowManager();
- *     $( 'body' ).append( windowManager.$element );
+ *     $( document.body ).append( windowManager.$element );
  *     windowManager.addWindows( [ messageDialog ] );
  *     // Open the window.
  *     windowManager.openWindow( messageDialog, {
@@ -2892,6 +2910,7 @@ OO.ui.MessageDialog.static.actions = [
  * @private
  * @param {boolean} [value] Layout actions vertically, omit to toggle
  * @chainable
+ * @return {OO.ui.MessageDialog} The dialog, for chaining
  */
 OO.ui.MessageDialog.prototype.toggleVerticalActionLayout = function ( value ) {
        value = value === undefined ? !this.verticalActionLayout : !!value;
@@ -3159,7 +3178,7 @@ OO.ui.MessageDialog.prototype.fitActions = function () {
  *     };
  *
  *     var windowManager = new OO.ui.WindowManager();
- *     $( 'body' ).append( windowManager.$element );
+ *     $( document.body ).append( windowManager.$element );
  *
  *     var dialog = new MyProcessDialog();
  *     windowManager.addWindows( [ dialog ] );
@@ -3237,6 +3256,7 @@ OO.ui.ProcessDialog.prototype.initialize = function () {
        // Events
        this.dismissButton.connect( this, { click: 'onDismissErrorButtonClick' } );
        this.retryButton.connect( this, { click: 'onRetryButtonClick' } );
+       this.title.connect( this, { labelChange: 'fitLabel' } );
 
        // Initialization
        this.title.$element.addClass( 'oo-ui-processDialog-title' );
@@ -3347,6 +3367,7 @@ OO.ui.ProcessDialog.prototype.setDimensions = function () {
  *
  * @private
  * @chainable
+ * @return {OO.ui.MessageDialog} The dialog, for chaining
  */
 OO.ui.ProcessDialog.prototype.fitLabel = function () {
        var safeWidth, primaryWidth, biggerWidth, labelWidth, navigationWidth, leftWidth, rightWidth,
@@ -3486,7 +3507,7 @@ OO.ui.ProcessDialog.prototype.getTeardownProcess = function ( data ) {
 OO.ui.getWindowManager = function () {
        if ( !OO.ui.windowManager ) {
                OO.ui.windowManager = new OO.ui.WindowManager();
-               $( 'body' ).append( OO.ui.windowManager.$element );
+               $( document.body ).append( OO.ui.windowManager.$element );
                OO.ui.windowManager.addWindows( [ new OO.ui.MessageDialog() ] );
        }
        return OO.ui.windowManager;