Update OOUI to v0.27.6
[lhc/web/wiklou.git] / resources / lib / oojs-ui / oojs-ui-windows.js
index 068f06b..e99d2f9 100644 (file)
@@ -1,12 +1,12 @@
 /*!
- * OOUI v0.27.3
+ * OOUI v0.27.6
  * 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-06-07T21:36:30Z
+ * Date: 2018-08-01T22:17:59Z
  */
 ( 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 */
@@ -1217,7 +1219,7 @@ OO.ui.WindowManager.prototype.getSetupDelay = function () {
  * @return {number} Milliseconds to wait
  */
 OO.ui.WindowManager.prototype.getReadyDelay = function () {
-       return 0;
+       return this.modal ? OO.ui.theme.getDialogTransitionDuration() : 0;
 };
 
 /**
@@ -1240,7 +1242,7 @@ OO.ui.WindowManager.prototype.getHoldDelay = function () {
  * @return {number} Milliseconds to wait
  */
 OO.ui.WindowManager.prototype.getTeardownDelay = function () {
-       return this.modal ? 250 : 0;
+       return this.modal ? OO.ui.theme.getDialogTransitionDuration() : 0;
 };
 
 /**
@@ -1374,7 +1376,6 @@ OO.ui.WindowManager.prototype.openWindow = function ( win, data, lifecycle, comp
                setTimeout( function () {
                        manager.compatOpened = $.Deferred();
                        win.setup( data ).then( function () {
-                               manager.updateWindowSize( win );
                                compatOpening.notify( { state: 'setup' } );
                                setTimeout( function () {
                                        win.ready( data ).then( function () {
@@ -2075,9 +2076,10 @@ OO.ui.Window.prototype.getDir = function () {
 /**
  * Get the 'setup' process.
  *
- * The setup process is used to set up a window for use in a particular context,
- * based on the `data` argument. This method is called during the opening phase of the window’s
- * lifecycle.
+ * The setup process is used to set up a window for use in a particular context, based on the `data`
+ * argument. This method is called during the opening phase of the window’s lifecycle (before the
+ * opening animation). You can add elements to the window in this process or set their default
+ * values.
  *
  * Override this method to add additional steps to the ‘setup’ process the parent method provides
  * using the {@link OO.ui.Process#first first} and {@link OO.ui.Process#next next} methods
@@ -2096,9 +2098,10 @@ OO.ui.Window.prototype.getSetupProcess = function () {
 /**
  * Get the ‘ready’ process.
  *
- * The ready process is used to ready a window for use in a particular
- * context, based on the `data` argument. This method is called during the opening phase of
- * the window’s lifecycle, after the window has been {@link #getSetupProcess setup}.
+ * The ready process is used to ready a window for use in a particular context, based on the `data`
+ * argument. This method is called during the opening phase of the window’s lifecycle, after the
+ * window has been {@link #getSetupProcess setup} (after the opening animation). You can focus
+ * elements in the window in this process, or open their dropdowns.
  *
  * Override this method to add additional steps to the ‘ready’ process the parent method
  * provides using the {@link OO.ui.Process#first first} and {@link OO.ui.Process#next next}
@@ -2114,9 +2117,10 @@ OO.ui.Window.prototype.getReadyProcess = function () {
 /**
  * Get the 'hold' process.
  *
- * The hold process is used to keep a window from being used in a particular context,
- * based on the `data` argument. This method is called during the closing phase of the window’s
- * lifecycle.
+ * The hold process is used to keep a window from being used in a particular context, based on the
+ * `data` argument. This method is called during the closing phase of the window’s lifecycle (before
+ * the closing animation). You can close dropdowns of elements in the window in this process, if
+ * they do not get closed automatically.
  *
  * Override this method to add additional steps to the 'hold' process the parent method provides
  * using the {@link OO.ui.Process#first first} and {@link OO.ui.Process#next next} methods
@@ -2132,9 +2136,10 @@ OO.ui.Window.prototype.getHoldProcess = function () {
 /**
  * Get the ‘teardown’ process.
  *
- * The teardown process is used to teardown a window after use. During teardown,
- * user interactions within the window are conveyed and the window is closed, based on the `data`
- * argument. This method is called during the closing phase of the window’s lifecycle.
+ * The teardown process is used to teardown a window after use. During teardown, user interactions
+ * within the window are conveyed and the window is closed, based on the `data` argument. This
+ * method is called during the closing phase of the window’s lifecycle (after the closing
+ * animation). You can remove elements in the window in this process or clear their values.
  *
  * Override this method to add additional steps to the ‘teardown’ process the parent method provides
  * using the {@link OO.ui.Process#first first} and {@link OO.ui.Process#next next} methods
@@ -2345,8 +2350,8 @@ OO.ui.Window.prototype.close = function ( data ) {
 /**
  * Setup window.
  *
- * This is called by OO.ui.WindowManager during window opening, and should not be called directly
- * by other systems.
+ * This is called by OO.ui.WindowManager during window opening (before the animation), and should
+ * not be called directly by other systems.
  *
  * @param {Object} [data] Window opening data
  * @return {jQuery.Promise} Promise resolved when window is setup
@@ -2360,6 +2365,7 @@ OO.ui.Window.prototype.setup = function ( data ) {
        this.$focusTraps.on( 'focus', this.focusTrapHandler );
 
        return this.getSetupProcess( data ).execute().then( function () {
+               win.updateSize();
                // Force redraw by asking the browser to measure the elements' widths
                win.$element.addClass( 'oo-ui-window-active oo-ui-window-setup' ).width();
                win.$content.addClass( 'oo-ui-window-content-setup' ).width();
@@ -2369,8 +2375,8 @@ OO.ui.Window.prototype.setup = function ( data ) {
 /**
  * Ready window.
  *
- * This is called by OO.ui.WindowManager during window opening, and should not be called directly
- * by other systems.
+ * This is called by OO.ui.WindowManager during window opening (after the animation), and should not
+ * be called directly by other systems.
  *
  * @param {Object} [data] Window opening data
  * @return {jQuery.Promise} Promise resolved when window is ready
@@ -2389,8 +2395,8 @@ OO.ui.Window.prototype.ready = function ( data ) {
 /**
  * Hold window.
  *
- * This is called by OO.ui.WindowManager during window closing, and should not be called directly
- * by other systems.
+ * This is called by OO.ui.WindowManager during window closing (before the animation), and should
+ * not be called directly by other systems.
  *
  * @param {Object} [data] Window closing data
  * @return {jQuery.Promise} Promise resolved when window is held
@@ -2408,15 +2414,15 @@ OO.ui.Window.prototype.hold = function ( data ) {
                }
 
                // Force redraw by asking the browser to measure the elements' widths
-               win.$element.removeClass( 'oo-ui-window-ready' ).width();
-               win.$content.removeClass( 'oo-ui-window-content-ready' ).width();
+               win.$element.removeClass( 'oo-ui-window-ready oo-ui-window-setup' ).width();
+               win.$content.removeClass( 'oo-ui-window-content-ready oo-ui-window-content-setup' ).width();
        } );
 };
 
 /**
  * Teardown window.
  *
- * This is called by OO.ui.WindowManager during window closing, and should not be called directly
+ * This is called by OO.ui.WindowManager during window closing (after the animation), and should not be called directly
  * by other systems.
  *
  * @param {Object} [data] Window closing data
@@ -2427,8 +2433,8 @@ OO.ui.Window.prototype.teardown = function ( data ) {
 
        return this.getTeardownProcess( data ).execute().then( function () {
                // Force redraw by asking the browser to measure the elements' widths
-               win.$element.removeClass( 'oo-ui-window-active oo-ui-window-setup' ).width();
-               win.$content.removeClass( 'oo-ui-window-content-setup' ).width();
+               win.$element.removeClass( 'oo-ui-window-active' ).width();
+
                win.$focusTraps.off( 'focus', win.focusTrapHandler );
                win.toggle( false );
        } );
@@ -2709,13 +2715,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.
  *
@@ -3023,11 +3051,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 );
@@ -3037,18 +3073,15 @@ OO.ui.MessageDialog.prototype.attachActions = function () {
 
        if ( special.safe ) {
                this.$actions.append( special.safe.$element );
-               special.safe.toggleFramed( false );
+               special.safe.toggleFramed( true );
        }
-       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 );
+               others[ i ].toggleFramed( true );
        }
        if ( special.primary ) {
                this.$actions.append( special.primary.$element );
-               special.primary.toggleFramed( false );
+               special.primary.toggleFramed( true );
        }
 };
 
@@ -3068,7 +3101,7 @@ OO.ui.MessageDialog.prototype.fitActions = function () {
        this.toggleVerticalActionLayout( false );
        for ( i = 0, len = actions.length; i < len; i++ ) {
                action = actions[ i ];
-               if ( action.$element.innerWidth() < action.$label.outerWidth( true ) ) {
+               if ( action.$element[ 0 ].scrollWidth > action.$element[ 0 ].clientWidth ) {
                        this.toggleVerticalActionLayout( true );
                        break;
                }
@@ -3239,26 +3272,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;
 };
 
 /**