Merge "Fix 'Tags' padding to keep it farther from the edge and document the source...
[lhc/web/wiklou.git] / resources / lib / oojs-ui / oojs-ui-windows.js
index bc11e8c..0880906 100644 (file)
@@ -1,12 +1,12 @@
 /*!
- * OOUI v0.26.5
+ * OOUI v0.27.4
  * https://www.mediawiki.org/wiki/OOUI
  *
  * Copyright 2011–2018 OOUI Team and other contributors.
  * Released under the MIT license
  * http://oojs.mit-license.org
  *
- * Date: 2018-04-24T23:29:01Z
+ * Date: 2018-06-27T17:25:08Z
  */
 ( function ( OO ) {
 
@@ -1034,8 +1034,10 @@ OO.ui.WindowManager = function OoUiWindowManager( config ) {
        // Initialization
        this.$element
                .addClass( 'oo-ui-windowManager' )
-               .attr( 'aria-hidden', true )
                .toggleClass( 'oo-ui-windowManager-modal', this.modal );
+       if ( this.modal ) {
+               this.$element.attr( 'aria-hidden', true );
+       }
 };
 
 /* Setup */
@@ -2607,6 +2609,10 @@ OO.ui.Dialog.prototype.onActionsChange = function () {
        this.detachActions();
        if ( !this.isClosing() ) {
                this.attachActions();
+               if ( !this.isOpening() ) {
+                       // If the dialog is currently opening, this will be called automatically soon.
+                       this.updateSize();
+               }
        }
 };
 
@@ -2705,13 +2711,35 @@ OO.ui.Dialog.prototype.initialize = function () {
 OO.ui.Dialog.prototype.getActionWidgets = function ( actions ) {
        var i, len, widgets = [];
        for ( i = 0, len = actions.length; i < len; i++ ) {
-               widgets.push(
-                       new OO.ui.ActionWidget( actions[ i ] )
-               );
+               widgets.push( this.getActionWidget( actions[ i ] ) );
        }
        return widgets;
 };
 
+/**
+ * Get action widget from config
+ *
+ * Override this method to change the action widget class used.
+ *
+ * @param {Object} config Action widget config
+ * @return {OO.ui.ActionWidget} Action widget
+ */
+OO.ui.Dialog.prototype.getActionWidget = function ( config ) {
+       return new OO.ui.ActionWidget( this.getActionWidgetConfig( config ) );
+};
+
+/**
+ * Get action widget config
+ *
+ * Override this method to modify the action widget config
+ *
+ * @param {Object} config Initial action widget config
+ * @return {Object} Action widget config
+ */
+OO.ui.Dialog.prototype.getActionWidgetConfig = function ( config ) {
+       return config;
+};
+
 /**
  * Attach action actions.
  *
@@ -2857,34 +2885,6 @@ OO.ui.MessageDialog.static.actions = [
 
 /* Methods */
 
-/**
- * @inheritdoc
- */
-OO.ui.MessageDialog.prototype.setManager = function ( manager ) {
-       OO.ui.MessageDialog.parent.prototype.setManager.call( this, manager );
-
-       // Events
-       this.manager.connect( this, {
-               resize: 'onResize'
-       } );
-
-       return this;
-};
-
-/**
- * Handle window resized events.
- *
- * @private
- */
-OO.ui.MessageDialog.prototype.onResize = function () {
-       var dialog = this;
-       dialog.fitActions();
-       // Wait for CSS transition to finish and do it again :(
-       setTimeout( function () {
-               dialog.fitActions();
-       }, 300 );
-};
-
 /**
  * Toggle action layout between vertical and horizontal.
  *
@@ -2985,7 +2985,9 @@ OO.ui.MessageDialog.prototype.getBodyHeight = function () {
  * @inheritdoc
  */
 OO.ui.MessageDialog.prototype.setDimensions = function ( dim ) {
-       var $scrollable = this.container.$element;
+       var
+               dialog = this,
+               $scrollable = this.container.$element;
        OO.ui.MessageDialog.parent.prototype.setDimensions.call( this, dim );
 
        // Twiddle the overflow property, otherwise an unnecessary scrollbar will be produced.
@@ -3007,6 +3009,12 @@ OO.ui.MessageDialog.prototype.setDimensions = function ( dim ) {
                $scrollable[ 0 ].style.overflow = oldOverflow;
        }, 300 );
 
+       dialog.fitActions();
+       // Wait for CSS transition to finish and do it again :(
+       setTimeout( function () {
+               dialog.fitActions();
+       }, 300 );
+
        return this;
 };
 
@@ -3039,11 +3047,19 @@ OO.ui.MessageDialog.prototype.initialize = function () {
        this.$foot.append( this.$actions );
 };
 
+/**
+ * @inheritdoc
+ */
+OO.ui.MessageDialog.prototype.getActionWidgetConfig = function ( config ) {
+       // Force unframed
+       return $.extend( {}, config, { framed: false } );
+};
+
 /**
  * @inheritdoc
  */
 OO.ui.MessageDialog.prototype.attachActions = function () {
-       var i, len, other, special, others;
+       var i, len, special, others;
 
        // Parent method
        OO.ui.MessageDialog.parent.prototype.attachActions.call( this );
@@ -3053,24 +3069,12 @@ OO.ui.MessageDialog.prototype.attachActions = function () {
 
        if ( special.safe ) {
                this.$actions.append( special.safe.$element );
-               special.safe.toggleFramed( false );
        }
-       if ( others.length ) {
-               for ( i = 0, len = others.length; i < len; i++ ) {
-                       other = others[ i ];
-                       this.$actions.append( other.$element );
-                       other.toggleFramed( false );
-               }
+       for ( i = 0, len = others.length; i < len; i++ ) {
+               this.$actions.append( others[ i ].$element );
        }
        if ( special.primary ) {
                this.$actions.append( special.primary.$element );
-               special.primary.toggleFramed( false );
-       }
-
-       if ( !this.isOpening() ) {
-               // If the dialog is currently opening, this will be called automatically soon.
-               // This also calls #fitActions.
-               this.updateSize();
        }
 };
 
@@ -3261,26 +3265,23 @@ OO.ui.ProcessDialog.prototype.initialize = function () {
 /**
  * @inheritdoc
  */
-OO.ui.ProcessDialog.prototype.getActionWidgets = function ( actions ) {
-       var i, len, config,
-               isMobile = OO.ui.isMobile(),
-               widgets = [];
-
-       for ( i = 0, len = actions.length; i < len; i++ ) {
-               config = $.extend( { framed: !OO.ui.isMobile() }, actions[ i ] );
-               if ( isMobile &&
-                       ( config.flags === 'back' || ( Array.isArray( config.flags ) && config.flags.indexOf( 'back' ) !== -1 ) )
-               ) {
-                       $.extend( config, {
-                               icon: 'previous',
-                               label: ''
-                       } );
-               }
-               widgets.push(
-                       new OO.ui.ActionWidget( config )
-               );
+OO.ui.ProcessDialog.prototype.getActionWidgetConfig = function ( config ) {
+       var isMobile = OO.ui.isMobile();
+
+       // Default to unframed on mobile
+       config = $.extend( { framed: !isMobile }, config );
+       // Change back buttons to icon only on mobile
+       if (
+               isMobile &&
+               ( config.flags === 'back' || ( Array.isArray( config.flags ) && config.flags.indexOf( 'back' ) !== -1 ) )
+       ) {
+               $.extend( config, {
+                       icon: 'previous',
+                       label: ''
+               } );
        }
-       return widgets;
+
+       return config;
 };
 
 /**
@@ -3304,9 +3305,6 @@ OO.ui.ProcessDialog.prototype.attachActions = function () {
        if ( special.safe ) {
                this.$safeActions.append( special.safe.$element );
        }
-
-       this.fitLabel();
-       this.$body.css( 'bottom', this.$foot.outerHeight( true ) );
 };
 
 /**
@@ -3324,10 +3322,20 @@ OO.ui.ProcessDialog.prototype.executeAction = function ( action ) {
  * @inheritdoc
  */
 OO.ui.ProcessDialog.prototype.setDimensions = function () {
+       var dialog = this;
+
        // Parent method
        OO.ui.ProcessDialog.parent.prototype.setDimensions.apply( this, arguments );
 
        this.fitLabel();
+
+       // If there are many actions, they might be shown on multiple lines. Their layout can change when
+       // resizing the dialog and when changing the actions. Adjust the height of the footer to fit them.
+       dialog.$body.css( 'bottom', dialog.$foot.outerHeight( true ) );
+       // Wait for CSS transition to finish and do it again :(
+       setTimeout( function () {
+               dialog.$body.css( 'bottom', dialog.$foot.outerHeight( true ) );
+       }, 300 );
 };
 
 /**
@@ -3590,4 +3598,4 @@ OO.ui.prompt = function ( text, options ) {
 
 }( OO ) );
 
-//# sourceMappingURL=oojs-ui-windows.js.map
\ No newline at end of file
+//# sourceMappingURL=oojs-ui-windows.js.map.json
\ No newline at end of file