Merge "Show redirect fragments on Special:BrokenRedirects"
[lhc/web/wiklou.git] / resources / lib / oojs-ui / oojs-ui-widgets.js
index 3c5d16c..18695bf 100644 (file)
@@ -1,12 +1,12 @@
 /*!
- * OOjs UI v0.21.4
+ * OOjs UI v0.22.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-05-16T22:31:39Z
+ * Date: 2017-08-03T19:36:51Z
  */
 ( function ( OO ) {
 
@@ -277,7 +277,6 @@ OO.ui.mixin.DraggableGroupElement = function OoUiMixinDraggableGroupElement( con
        }
        this.$element
                .addClass( 'oo-ui-draggableGroupElement' )
-               .attr( 'role', 'listbox' )
                .append( this.$status )
                .toggleClass( 'oo-ui-draggableGroupElement-horizontal', this.orientation === 'horizontal' );
 };
@@ -1976,10 +1975,19 @@ OO.ui.BookletLayout.prototype.isOutlineVisible = function () {
  * @chainable
  */
 OO.ui.BookletLayout.prototype.toggleOutline = function ( show ) {
+       var booklet = this;
+
        if ( this.outlined ) {
                show = show === undefined ? !this.outlineVisible : !!show;
                this.outlineVisible = show;
                this.toggleMenu( show );
+               if ( show && this.editable ) {
+                       // HACK: When the sidebar stops animating, kill dumb scrollbars (T161798). Only necessary when
+                       // outline controls are present, The delay matches transition on `.oo-ui-menuLayout-menu`.
+                       setTimeout( function () {
+                               OO.ui.Element.static.reconsiderScrollbars( booklet.outlinePanel.$element[ 0 ] );
+                       }, 200 );
+               }
        }
 
        return this;
@@ -3136,6 +3144,16 @@ OO.ui.ToggleSwitchWidget.prototype.setValue = function ( value ) {
        return this;
 };
 
+/**
+ * @inheritdoc
+ */
+OO.ui.ToggleSwitchWidget.prototype.simulateLabelClick = function () {
+       if ( !this.isDisabled() ) {
+               this.setValue( !this.value );
+       }
+       this.focus();
+};
+
 /**
  * OutlineControlsWidget is a set of controls for an {@link OO.ui.OutlineSelectWidget outline select widget}.
  * Controls include moving items up and down, removing items, and adding different kinds of items.
@@ -3186,7 +3204,7 @@ OO.ui.OutlineControlsWidget = function OoUiOutlineControlsWidget( outline, confi
        } );
        this.removeButton = new OO.ui.ButtonWidget( {
                framed: false,
-               icon: 'remove',
+               icon: 'trash',
                title: OO.ui.msg( 'ooui-outline-control-remove' )
        } );
        this.abilities = { move: true, remove: true };
@@ -3732,7 +3750,7 @@ OO.ui.CapsuleItemWidget = function OoUiCapsuleItemWidget( config ) {
        // Events
        this.closeButton = new OO.ui.ButtonWidget( {
                framed: false,
-               indicator: 'clear',
+               icon: 'close',
                tabIndex: -1
        } ).on( 'click', this.onCloseClick.bind( this ) );
 
@@ -4654,7 +4672,7 @@ OO.ui.TagItemWidget = function OoUiTagItemWidget( config ) {
 
        this.closeButton = new OO.ui.ButtonWidget( {
                framed: false,
-               indicator: 'clear',
+               icon: 'close',
                tabIndex: -1
        } );
        this.closeButton.setDisabled( this.isDisabled() );
@@ -5526,6 +5544,12 @@ OO.ui.TagMultiselectWidget.prototype.getPreviousItem = function ( item ) {
 OO.ui.TagMultiselectWidget.prototype.updateInputSize = function () {
        var $lastItem, direction, contentWidth, currentWidth, bestWidth;
        if ( this.inputPosition === 'inline' && !this.isDisabled() ) {
+               if ( this.input.$input[ 0 ].scrollWidth === 0 ) {
+                       // Input appears to be attached but not visible.
+                       // Don't attempt to adjust its size, because our measurements
+                       // are going to fail anyway.
+                       return;
+               }
                this.input.$input.css( 'width', '1em' );
                $lastItem = this.$group.children().last();
                direction = OO.ui.Element.static.getDir( this.$handle );
@@ -5863,6 +5887,11 @@ OO.ui.MenuTagMultiselectWidget = function OoUiMenuTagMultiselectWidget( config )
                .append( this.menu.$element );
        this.$element
                .addClass( 'oo-ui-menuTagMultiselectWidget' );
+       // TagMultiselectWidget already does this, but it doesn't work right because this.menu is not yet
+       // set up while the parent constructor runs, and #getAllowedValues rejects everything.
+       if ( config.selected ) {
+               this.setValue( config.selected );
+       }
 };
 
 /* Initialization */
@@ -5939,6 +5968,7 @@ OO.ui.MenuTagMultiselectWidget.prototype.onTagSelect = function ( tagItem ) {
  */
 OO.ui.MenuTagMultiselectWidget.prototype.addTagFromInput = function () {
        var inputValue = this.input.getValue(),
+               validated = false,
                highlightedItem = this.menu.getHighlightedItem(),
                item = this.menu.getItemFromData( inputValue );
 
@@ -5947,14 +5977,19 @@ OO.ui.MenuTagMultiselectWidget.prototype.addTagFromInput = function () {
 
        // Look for a highlighted item first
        if ( highlightedItem ) {
-               this.addTag( highlightedItem.getData(), highlightedItem.getLabel() );
+               validated = this.addTag( highlightedItem.getData(), highlightedItem.getLabel() );
        } else if ( item ) {
                // Look for the element that fits the data
-               this.addTag( item.getData(), item.getLabel() );
+               validated = this.addTag( item.getData(), item.getLabel() );
        } else {
                // Otherwise, add the tag - the method will only add if the
                // tag is valid or if invalid tags are allowed
-               this.addTag( inputValue );
+               validated = this.addTag( inputValue );
+       }
+
+       if ( validated ) {
+               this.clearInput();
+               this.focus();
        }
 };
 
@@ -6025,9 +6060,13 @@ OO.ui.MenuTagMultiselectWidget.prototype.getMenu = function () {
  * @return {string[]} Allowed data values
  */
 OO.ui.MenuTagMultiselectWidget.prototype.getAllowedValues = function () {
-       var menuDatas = this.menu.getItems().map( function ( menuItem ) {
-               return menuItem.getData();
-       } );
+       var menuDatas = [];
+       if ( this.menu ) {
+               // If the parent constructor is calling us, we're not ready yet, this.menu is not set up.
+               menuDatas = this.menu.getItems().map( function ( menuItem ) {
+                       return menuItem.getData();
+               } );
+       }
        return this.allowedValues.concat( menuDatas );
 };
 
@@ -6243,6 +6282,13 @@ OO.ui.SelectFileWidget.prototype.blur = function () {
        return this;
 };
 
+/**
+ * @inheritdoc
+ */
+OO.ui.SelectFileWidget.prototype.simulateLabelClick = function () {
+       this.focus();
+};
+
 /**
  * Update the user interface when a file is selected or unselected
  *
@@ -6734,7 +6780,7 @@ OO.ui.NumberInputWidget = function OoUiNumberInputWidget( config ) {
                                disabled: this.isDisabled(),
                                tabIndex: -1,
                                classes: [ 'oo-ui-numberInputWidget-minusButton' ],
-                               label: '−'
+                               icon: 'subtract'
                        },
                        config.minusButton
                ) );
@@ -6743,7 +6789,7 @@ OO.ui.NumberInputWidget = function OoUiNumberInputWidget( config ) {
                                disabled: this.isDisabled(),
                                tabIndex: -1,
                                classes: [ 'oo-ui-numberInputWidget-plusButton' ],
-                               label: '+'
+                               icon: 'add'
                        },
                        config.plusButton
                ) );