Update OOjs UI to v0.21.4
[lhc/web/wiklou.git] / resources / lib / oojs-ui / oojs-ui-windows.js
index ab78a4a..3a697e1 100644 (file)
@@ -1,12 +1,12 @@
 /*!
- * OOjs UI v0.20.0
+ * OOjs UI v0.21.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-03-15T17:06:24Z
+ * Date: 2017-05-16T22:31:39Z
  */
 ( function ( OO ) {
 
@@ -60,14 +60,6 @@ OO.ui.ActionWidget = function OoUiActionWidget( config ) {
 OO.inheritClass( OO.ui.ActionWidget, OO.ui.ButtonWidget );
 OO.mixinClass( OO.ui.ActionWidget, OO.ui.mixin.PendingElement );
 
-/* Events */
-
-/**
- * A resize event is emitted when the size of the widget changes.
- *
- * @event resize
- */
-
 /* Methods */
 
 /**
@@ -102,90 +94,6 @@ OO.ui.ActionWidget.prototype.getModes = function () {
        return this.modes.slice();
 };
 
-/**
- * Emit a resize event if the size has changed.
- *
- * @private
- * @chainable
- */
-OO.ui.ActionWidget.prototype.propagateResize = function () {
-       var width, height;
-
-       if ( this.isElementAttached() ) {
-               width = this.$element.width();
-               height = this.$element.height();
-
-               if ( width !== this.width || height !== this.height ) {
-                       this.width = width;
-                       this.height = height;
-                       this.emit( 'resizePrivate' );
-                       if ( this.emit( 'resize' ) ) {
-                               OO.ui.warnDeprecation( 'ActionWidget: resize event is deprecated. See T129162.' );
-                       }
-               }
-       }
-
-       return this;
-};
-
-/**
- * @inheritdoc
- */
-OO.ui.ActionWidget.prototype.setIcon = function () {
-       // Mixin method
-       OO.ui.mixin.IconElement.prototype.setIcon.apply( this, arguments );
-       this.propagateResize();
-
-       return this;
-};
-
-/**
- * @inheritdoc
- */
-OO.ui.ActionWidget.prototype.setLabel = function () {
-       // Mixin method
-       OO.ui.mixin.LabelElement.prototype.setLabel.apply( this, arguments );
-       this.propagateResize();
-
-       return this;
-};
-
-/**
- * @inheritdoc
- */
-OO.ui.ActionWidget.prototype.setFlags = function () {
-       // Mixin method
-       OO.ui.mixin.FlaggedElement.prototype.setFlags.apply( this, arguments );
-       this.propagateResize();
-
-       return this;
-};
-
-/**
- * @inheritdoc
- */
-OO.ui.ActionWidget.prototype.clearFlags = function () {
-       // Mixin method
-       OO.ui.mixin.FlaggedElement.prototype.clearFlags.apply( this, arguments );
-       this.propagateResize();
-
-       return this;
-};
-
-/**
- * Toggle the visibility of the action button.
- *
- * @param {boolean} [show] Show button, omit to toggle visibility
- * @chainable
- */
-OO.ui.ActionWidget.prototype.toggle = function () {
-       // Parent method
-       OO.ui.ActionWidget.parent.prototype.toggle.apply( this, arguments );
-       this.propagateResize();
-
-       return this;
-};
-
 /* eslint-disable no-unused-vars */
 /**
  * ActionSets manage the behavior of the {@link OO.ui.ActionWidget action widgets} that comprise them.
@@ -320,14 +228,6 @@ OO.ui.ActionSet.static.specialFlags = [ 'safe', 'primary' ];
  * @param {OO.ui.ActionWidget} action Action that was clicked
  */
 
-/**
- * @event resize
- *
- * A 'resize' event is emitted when an action widget is resized.
- *
- * @param {OO.ui.ActionWidget} action Action that was resized
- */
-
 /**
  * @event add
  *
@@ -566,11 +466,6 @@ OO.ui.ActionSet.prototype.add = function ( actions ) {
                        click: [ 'emit', 'click', action ],
                        toggle: [ 'onActionChange' ]
                } );
-               action.on( 'resizePrivate', function ( action ) {
-                       if ( this.emit( 'resize', action ) ) {
-                               OO.ui.warnDeprecation( 'ActionSet: resize event is deprecated. See T129162.' );
-                       }
-               }, [ action ], this );
                this.list.push( action );
        }
        this.organized = false;
@@ -1333,7 +1228,7 @@ OO.ui.WindowManager.prototype.openWindow = function ( win, data ) {
                                manager.toggleGlobalEvents( true );
                                manager.toggleAriaIsolation( true );
                        }
-                       manager.$returnFocusTo = data.$returnFocusTo || $( document.activeElement );
+                       manager.$returnFocusTo = data.$returnFocusTo !== undefined ? data.$returnFocusTo : $( document.activeElement );
                        manager.currentWindow = win;
                        manager.opening = opening;
                        manager.preparingToOpen = null;
@@ -1741,6 +1636,26 @@ OO.ui.Window = function OoUiWindow( config ) {
        this.manager = null;
        this.size = config.size || this.constructor.static.size;
        this.$frame = $( '<div>' );
+       /**
+        * Overlay element to use for the `$overlay` configuration option of widgets that support it.
+        * Things put inside of it are overlaid on top of the window and are not bound to its dimensions.
+        * See <https://www.mediawiki.org/wiki/OOjs_UI/Concepts#Overlays>.
+        *
+        *     MyDialog.prototype.initialize = function () {
+        *       ...
+        *       var popupButton = new OO.ui.PopupButtonWidget( {
+        *         $overlay: this.$overlay,
+        *         label: 'Popup button',
+        *         popup: {
+        *           $content: $( '<p>Popup contents.</p><p>Popup contents.</p><p>Popup contents.</p>' ),
+        *           padded: true
+        *         }
+        *       } );
+        *       ...
+        *     };
+        *
+        * @property {jQuery}
+        */
        this.$overlay = $( '<div>' );
        this.$content = $( '<div>' );
 
@@ -2597,21 +2512,15 @@ OO.ui.Dialog.prototype.getTeardownProcess = function ( data ) {
  * @inheritdoc
  */
 OO.ui.Dialog.prototype.initialize = function () {
-       var titleId;
-
        // Parent method
        OO.ui.Dialog.parent.prototype.initialize.call( this );
 
-       titleId = OO.ui.generateElementId();
-
        // Properties
-       this.title = new OO.ui.LabelWidget( {
-               id: titleId
-       } );
+       this.title = new OO.ui.LabelWidget();
 
        // Initialization
        this.$content.addClass( 'oo-ui-dialog-content' );
-       this.$element.attr( 'aria-labelledby', titleId );
+       this.$element.attr( 'aria-labelledby', this.title.getElementId() );
        this.setPendingElement( this.$head );
 };
 
@@ -2842,6 +2751,7 @@ OO.ui.MessageDialog.prototype.getActionProcess = function ( action ) {
  * @param {Object} [data] Dialog opening data
  * @param {jQuery|string|Function|null} [data.title] Description of the action being confirmed
  * @param {jQuery|string|Function|null} [data.message] Description of the action's consequence
+ * @param {string} [data.size] Symbolic name of the dialog size, see OO.ui.Window
  * @param {Object[]} [data.actions] List of OO.ui.ActionOptionWidget configuration options for each
  *   action item
  */
@@ -2857,6 +2767,7 @@ OO.ui.MessageDialog.prototype.getSetupProcess = function ( data ) {
                        this.message.setLabel(
                                data.message !== undefined ? data.message : this.constructor.static.message
                        );
+                       this.size = data.size !== undefined ? data.size : this.constructor.static.size;
                }, this );
 };
 
@@ -2875,7 +2786,7 @@ OO.ui.MessageDialog.prototype.getReadyProcess = function ( data ) {
                                return action.getFlags().indexOf( 'primary' ) > -1;
                        } );
                        if ( actions.length > 0 ) {
-                               actions[ 0 ].$button.focus();
+                               actions[ 0 ].focus();
                        }
                }, this );
 };
@@ -3408,6 +3319,8 @@ OO.ui.getWindowManager = function () {
  *         console.log( 'User closed the dialog.' );
  *     } );
  *
+ *     OO.ui.alert( 'Something larger happened!', { size: 'large' } );
+ *
  * @param {jQuery|string} text Message text to display
  * @param {Object} [options] Additional options, see OO.ui.MessageDialog#getSetupProcess
  * @return {jQuery.Promise} Promise resolved when the user closes the dialog
@@ -3511,3 +3424,5 @@ OO.ui.prompt = function ( text, options ) {
 };
 
 }( OO ) );
+
+//# sourceMappingURL=oojs-ui-windows.js.map
\ No newline at end of file