Merge "Handle missing namespace prefix in XML dumps more gracefully"
[lhc/web/wiklou.git] / resources / lib / oojs-ui / oojs-ui-windows.js
index ab83a55..586efb0 100644 (file)
@@ -1,12 +1,12 @@
 /*!
- * OOjs UI v0.18.4-fix (d4045dee45)
+ * OOjs UI v0.19.5
  * 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-01-19T20:22:26Z
+ * Date: 2017-03-07T22:57:01Z
  */
 ( function ( OO ) {
 
@@ -203,6 +203,7 @@ OO.ui.ActionWidget.prototype.toggle = function () {
  *     }
  *     OO.inheritClass( MyProcessDialog, OO.ui.ProcessDialog );
  *     MyProcessDialog.static.title = 'An action set in a process dialog';
+ *     MyProcessDialog.static.name = 'myProcessDialog';
  *     // An action set that uses modes ('edit' and 'help' mode, in this example).
  *     MyProcessDialog.static.actions = [
  *         { action: 'continue', modes: 'edit', label: 'Continue', flags: [ 'primary', 'constructive' ] },
@@ -1442,6 +1443,41 @@ OO.ui.WindowManager.prototype.closeWindow = function ( win, data ) {
  * See the [OOjs ui documentation on MediaWiki] [2] for examples.
  * [2]: https://www.mediawiki.org/wiki/OOjs_UI/Windows/Window_managers
  *
+ * This function can be called in two manners:
+ *
+ * 1. `.addWindows( [ windowA, windowB, ... ] )` (where `windowA`, `windowB` are OO.ui.Window objects)
+ *
+ *    This syntax registers windows under the symbolic names defined in their `.static.name`
+ *    properties. For example, if `windowA.constructor.static.name` is `'nameA'`, calling
+ *    `.openWindow( 'nameA' )` afterwards will open the window `windowA`. This syntax requires the
+ *    static name to be set, otherwise an exception will be thrown.
+ *
+ *    This is the recommended way, as it allows for an easier switch to using a window factory.
+ *
+ * 2. `.addWindows( { nameA: windowA, nameB: windowB, ... } )`
+ *
+ *    This syntax registers windows under the explicitly given symbolic names. In this example,
+ *    calling `.openWindow( 'nameA' )` afterwards will open the window `windowA`, regardless of what
+ *    its `.static.name` is set to. The static name is not required to be set.
+ *
+ *    This should only be used if you need to override the default symbolic names.
+ *
+ * Example:
+ *
+ *     var windowManager = new OO.ui.WindowManager();
+ *     $( 'body' ).append( windowManager.$element );
+ *
+ *     // Add a window under the default name: see OO.ui.MessageDialog.static.name
+ *     windowManager.addWindows( [ new OO.ui.MessageDialog() ] );
+ *     // Add a window under an explicit name
+ *     windowManager.addWindows( { myMessageDialog: new OO.ui.MessageDialog() } );
+ *
+ *     // Open window by default name
+ *     windowManager.openWindow( 'message' );
+ *     // Open window by explicitly given name
+ *     windowManager.openWindow( 'myMessageDialog' );
+ *
+ *
  * @param {Object.<string,OO.ui.Window>|OO.ui.Window[]} windows An array of window objects specified
  *  by reference, symbolic name, or explicitly defined symbolic names.
  * @throws {Error} An error is thrown if a window is added by symbolic name, but has neither an
@@ -1455,11 +1491,8 @@ OO.ui.WindowManager.prototype.addWindows = function ( windows ) {
                list = {};
                for ( i = 0, len = windows.length; i < len; i++ ) {
                        name = windows[ i ].constructor.static.name;
-                       if ( typeof name !== 'string' ) {
-                               throw new Error( 'Cannot add window' );
-                       }
                        if ( !name ) {
-                               OO.ui.warnDeprecation( 'OO.ui.WindowManager#addWindows: Windows must have a `name` static property defined.' );
+                               throw new Error( 'Windows must have a `name` static property defined.' );
                        }
                        list[ name ] = windows[ i ];
                }
@@ -2320,6 +2353,7 @@ OO.ui.Window.prototype.teardown = function ( data ) {
  *         MyDialog.parent.call( this, config );
  *     }
  *     OO.inheritClass( MyDialog, OO.ui.Dialog );
+ *     MyDialog.static.name = 'myDialog';
  *     MyDialog.prototype.initialize = function () {
  *         MyDialog.parent.prototype.initialize.call( this );
  *         this.content = new OO.ui.PanelLayout( { padded: true, expanded: false } );
@@ -2365,7 +2399,6 @@ OO.ui.Dialog = function OoUiDialog( config ) {
        // Events
        this.actions.connect( this, {
                click: 'onActionClick',
-               resize: 'onActionResize',
                change: 'onActionsChange'
        } );
 
@@ -2449,7 +2482,7 @@ OO.ui.Dialog.prototype.onDialogKeyDown = function ( e ) {
                this.executeAction( '' );
                e.preventDefault();
                e.stopPropagation();
-       } else if ( e.which === OO.ui.Keys.ENTER && e.ctrlKey ) {
+       } else if ( e.which === OO.ui.Keys.ENTER && ( e.ctrlKey || e.metaKey ) ) {
                actions = this.actions.get( { flags: 'primary', visible: true, disabled: false } );
                if ( actions.length > 0 ) {
                        this.executeAction( actions[ 0 ].getAction() );
@@ -2459,16 +2492,6 @@ OO.ui.Dialog.prototype.onDialogKeyDown = function ( e ) {
        }
 };
 
-/**
- * Handle action resized events.
- *
- * @private
- * @param {OO.ui.ActionWidget} action Action that was resized
- */
-OO.ui.Dialog.prototype.onActionResize = function () {
-       // Override in subclass
-};
-
 /**
  * Handle action click events.
  *
@@ -2698,11 +2721,22 @@ OO.inheritClass( OO.ui.MessageDialog, OO.ui.Dialog );
 
 /* Static Properties */
 
+/**
+ * @static
+ * @inheritdoc
+ */
 OO.ui.MessageDialog.static.name = 'message';
 
+/**
+ * @static
+ * @inheritdoc
+ */
 OO.ui.MessageDialog.static.size = 'small';
 
-// @deprecated since v0.18.4 as default; TODO: Remove
+/**
+ * @static
+ * @deprecated since v0.18.4 as default; TODO: Remove
+ */
 OO.ui.MessageDialog.static.verbose = true;
 
 /**
@@ -2729,8 +2763,12 @@ OO.ui.MessageDialog.static.title = null;
  */
 OO.ui.MessageDialog.static.message = null;
 
-// Note that OO.ui.alert() and OO.ui.confirm() rely on these.
+/**
+ * @static
+ * @inheritdoc
+ */
 OO.ui.MessageDialog.static.actions = [
+       // Note that OO.ui.alert() and OO.ui.confirm() rely on these.
        { action: 'accept', label: OO.ui.deferMsg( 'ooui-dialog-message-accept' ), flags: 'primary' },
        { action: 'reject', label: OO.ui.deferMsg( 'ooui-dialog-message-reject' ), flags: 'safe' }
 ];
@@ -2751,14 +2789,6 @@ OO.ui.MessageDialog.prototype.setManager = function ( manager ) {
        return this;
 };
 
-/**
- * @inheritdoc
- */
-OO.ui.MessageDialog.prototype.onActionResize = function ( action ) {
-       this.fitActions();
-       return OO.ui.MessageDialog.parent.prototype.onActionResize.call( this, action );
-};
-
 /**
  * Handle window resized events.
  *
@@ -3018,6 +3048,7 @@ OO.ui.MessageDialog.prototype.fitActions = function () {
  *     }
  *     OO.inheritClass( MyProcessDialog, OO.ui.ProcessDialog );
  *
+ *     MyProcessDialog.static.name = 'myProcessDialog';
  *     MyProcessDialog.static.title = 'Process dialog';
  *     MyProcessDialog.static.actions = [
  *         { action: 'save', label: 'Done', flags: 'primary' },
@@ -3096,16 +3127,6 @@ OO.ui.ProcessDialog.prototype.onRetryButtonClick = function () {
        this.executeAction( this.currentAction );
 };
 
-/**
- * @inheritdoc
- */
-OO.ui.ProcessDialog.prototype.onActionResize = function ( action ) {
-       if ( this.actions.isSpecial( action ) ) {
-               this.fitLabel();
-       }
-       return OO.ui.ProcessDialog.parent.prototype.onActionResize.call( this, action );
-};
-
 /**
  * @inheritdoc
  */
@@ -3374,9 +3395,7 @@ OO.ui.getWindowManager = function () {
        if ( !OO.ui.windowManager ) {
                OO.ui.windowManager = new OO.ui.WindowManager();
                $( 'body' ).append( OO.ui.windowManager.$element );
-               OO.ui.windowManager.addWindows( {
-                       messageDialog: new OO.ui.MessageDialog()
-               } );
+               OO.ui.windowManager.addWindows( [ new OO.ui.MessageDialog() ] );
        }
        return OO.ui.windowManager;
 };
@@ -3398,7 +3417,7 @@ OO.ui.getWindowManager = function () {
  * @return {jQuery.Promise} Promise resolved when the user closes the dialog
  */
 OO.ui.alert = function ( text, options ) {
-       return OO.ui.getWindowManager().openWindow( 'messageDialog', $.extend( {
+       return OO.ui.getWindowManager().openWindow( 'message', $.extend( {
                message: text,
                actions: [ OO.ui.MessageDialog.static.actions[ 0 ] ]
        }, options ) ).then( function ( opened ) {
@@ -3434,7 +3453,7 @@ OO.ui.alert = function ( text, options ) {
  *  `false`.
  */
 OO.ui.confirm = function ( text, options ) {
-       return OO.ui.getWindowManager().openWindow( 'messageDialog', $.extend( {
+       return OO.ui.getWindowManager().openWindow( 'message', $.extend( {
                message: text
        }, options ) ).then( function ( opened ) {
                return opened.then( function ( closing ) {
@@ -3464,7 +3483,7 @@ OO.ui.confirm = function ( text, options ) {
  *
  * @param {jQuery|string} text Message text to display
  * @param {Object} [options] Additional options, see OO.ui.MessageDialog#getSetupProcess
- * @cfg {Object} [textInput] Additional options for text input widget, see OO.ui.TextInputWidget
+ * @param {Object} [options.textInput] Additional options for text input widget, see OO.ui.TextInputWidget
  * @return {jQuery.Promise} Promise resolved when the user closes the dialog. If the user chose to
  *  confirm, the promise will resolve with the value of the text input widget; otherwise, it will
  *  resolve to `null`.
@@ -3479,7 +3498,7 @@ OO.ui.prompt = function ( text, options ) {
 
        // TODO: This is a little hacky, and could be done by extending MessageDialog instead.
 
-       return manager.openWindow( 'messageDialog', $.extend( {
+       return manager.openWindow( 'message', $.extend( {
                message: textField.$element
        }, options ) ).then( function ( opened ) {
                // After ready
@@ -3496,5 +3515,3 @@ OO.ui.prompt = function ( text, options ) {
 };
 
 }( OO ) );
-
-//# sourceMappingURL=oojs-ui-windows.js.map
\ No newline at end of file