Merge "Remove @param comments that literally repeat what the code says"
[lhc/web/wiklou.git] / resources / lib / oojs-ui / oojs-ui-widgets.js
index c84d940..bf282e6 100644 (file)
@@ -1,12 +1,12 @@
 /*!
- * OOjs UI v0.24.0
+ * OOjs UI v0.25.0
  * https://www.mediawiki.org/wiki/OOjs_UI
  *
- * Copyright 2011–2017 OOjs UI Team and other contributors.
+ * Copyright 2011–2018 OOjs UI Team and other contributors.
  * Released under the MIT license
  * http://oojs.mit-license.org
  *
- * Date: 2017-10-17T23:18:51Z
+ * Date: 2018-01-10T00:26:02Z
  */
 ( function ( OO ) {
 
@@ -279,7 +279,6 @@ OO.ui.mixin.DraggableGroupElement = function OoUiMixinDraggableGroupElement( con
        }
        this.$element
                .addClass( 'oo-ui-draggableGroupElement' )
-               .append( this.$status )
                .toggleClass( 'oo-ui-draggableGroupElement-horizontal', this.orientation === 'horizontal' );
 };
 
@@ -645,7 +644,7 @@ OO.ui.mixin.LookupElement = function OoUiMixinLookupElement( config ) {
        OO.ui.mixin.RequestManager.call( this, config );
 
        // Properties
-       this.$overlay = config.$overlay || this.$element;
+       this.$overlay = ( config.$overlay === true ? OO.ui.getDefaultOverlay() : config.$overlay ) || this.$element;
        this.lookupMenu = new OO.ui.MenuSelectWidget( {
                widget: this,
                input: this,
@@ -2021,16 +2020,16 @@ OO.ui.BookletLayout.prototype.findClosestPage = function ( page ) {
                prev = pages[ index - 1 ];
                // Prefer adjacent pages at the same level
                if ( this.outlined ) {
-                       level = this.outlineSelectWidget.getItemFromData( page.getName() ).getLevel();
+                       level = this.outlineSelectWidget.findItemFromData( page.getName() ).getLevel();
                        if (
                                prev &&
-                               level === this.outlineSelectWidget.getItemFromData( prev.getName() ).getLevel()
+                               level === this.outlineSelectWidget.findItemFromData( prev.getName() ).getLevel()
                        ) {
                                return prev;
                        }
                        if (
                                next &&
-                               level === this.outlineSelectWidget.getItemFromData( next.getName() ).getLevel()
+                               level === this.outlineSelectWidget.findItemFromData( next.getName() ).getLevel()
                        ) {
                                return next;
                        }
@@ -2039,18 +2038,6 @@ OO.ui.BookletLayout.prototype.findClosestPage = function ( page ) {
        return prev || next || null;
 };
 
-/**
- * Get the page closest to the specified page.
- *
- * @deprecated 0.23.0 Use {@link OO.ui.BookletLayout#findClosestPage} instead.
- * @param {OO.ui.PageLayout} page Page to use as a reference point
- * @return {OO.ui.PageLayout|null} Page closest to the specified page
- */
-OO.ui.BookletLayout.prototype.getClosestPage = function ( page ) {
-       OO.ui.warnDeprecation( 'BookletLayout#getClosestPage: Deprecated function. Use findClosestPage instead. See T76630.' );
-       return this.findClosestPage( page );
-};
-
 /**
  * Get the outline widget.
  *
@@ -2177,7 +2164,7 @@ OO.ui.BookletLayout.prototype.removePages = function ( pages ) {
                name = page.getName();
                delete this.pages[ name ];
                if ( this.outlined ) {
-                       items.push( this.outlineSelectWidget.getItemFromData( name ) );
+                       items.push( this.outlineSelectWidget.findItemFromData( name ) );
                        page.setOutlineItem( null );
                }
        }
@@ -2500,16 +2487,16 @@ OO.ui.IndexLayout.prototype.getClosestTabPanel = function ( tabPanel ) {
                next = tabPanels[ index + 1 ];
                prev = tabPanels[ index - 1 ];
                // Prefer adjacent tab panels at the same level
-               level = this.tabSelectWidget.getItemFromData( tabPanel.getName() ).getLevel();
+               level = this.tabSelectWidget.findItemFromData( tabPanel.getName() ).getLevel();
                if (
                        prev &&
-                       level === this.tabSelectWidget.getItemFromData( prev.getName() ).getLevel()
+                       level === this.tabSelectWidget.findItemFromData( prev.getName() ).getLevel()
                ) {
                        return prev;
                }
                if (
                        next &&
-                       level === this.tabSelectWidget.getItemFromData( next.getName() ).getLevel()
+                       level === this.tabSelectWidget.findItemFromData( next.getName() ).getLevel()
                ) {
                        return next;
                }
@@ -2627,7 +2614,7 @@ OO.ui.IndexLayout.prototype.removeTabPanels = function ( tabPanels ) {
                tabPanel = tabPanels[ i ];
                name = tabPanel.getName();
                delete this.tabPanels[ name ];
-               items.push( this.tabSelectWidget.getItemFromData( name ) );
+               items.push( this.tabSelectWidget.findItemFromData( name ) );
                tabPanel.setTabItem( null );
        }
        if ( items.length ) {
@@ -3783,8 +3770,7 @@ OO.ui.CapsuleMultiselectWidget = function OoUiCapsuleMultiselectWidget( config )
        // Configuration initialization
        config = $.extend( {
                allowArbitrary: false,
-               allowDuplicates: false,
-               $overlay: this.$element
+               allowDuplicates: false
        }, config );
 
        // Properties (must be set before mixin constructor calls)
@@ -3816,7 +3802,7 @@ OO.ui.CapsuleMultiselectWidget = function OoUiCapsuleMultiselectWidget( config )
        this.$content = $( '<div>' );
        this.allowArbitrary = config.allowArbitrary;
        this.allowDuplicates = config.allowDuplicates;
-       this.$overlay = config.$overlay;
+       this.$overlay = ( config.$overlay === true ? OO.ui.getDefaultOverlay() : config.$overlay ) || this.$element;
        this.menu = new OO.ui.MenuSelectWidget( $.extend(
                {
                        widget: this,
@@ -3982,7 +3968,7 @@ OO.ui.CapsuleMultiselectWidget.prototype.setItemsFromData = function ( datas ) {
 
        $.each( datas, function ( i, data ) {
                var j, label,
-                       item = menu.getItemFromData( data );
+                       item = menu.findItemFromData( data );
 
                if ( item ) {
                        label = item.label;
@@ -4030,8 +4016,8 @@ OO.ui.CapsuleMultiselectWidget.prototype.addItemsFromData = function ( datas ) {
        $.each( datas, function ( i, data ) {
                var item;
 
-               if ( !widget.getItemFromData( data ) || widget.allowDuplicates ) {
-                       item = menu.getItemFromData( data );
+               if ( !widget.findItemFromData( data ) || widget.allowDuplicates ) {
+                       item = menu.findItemFromData( data );
                        if ( item ) {
                                item = widget.createItemWidget( data, item.label );
                        } else if ( widget.allowArbitrary ) {
@@ -4082,7 +4068,7 @@ OO.ui.CapsuleMultiselectWidget.prototype.removeItemsFromData = function ( datas
                items = [];
 
        $.each( datas, function ( i, data ) {
-               var item = widget.getItemFromData( data );
+               var item = widget.findItemFromData( data );
                if ( item ) {
                        items.push( item );
                }
@@ -4442,7 +4428,7 @@ OO.ui.CapsuleMultiselectWidget.prototype.onMenuChoose = function ( item ) {
  * Handle menu toggle events.
  *
  * @private
- * @param {boolean} isVisible Menu toggle event
+ * @param {boolean} isVisible Open state of the menu
  */
 OO.ui.CapsuleMultiselectWidget.prototype.onMenuToggle = function ( isVisible ) {
        this.$element.toggleClass( 'oo-ui-capsuleMultiselectWidget-open', isVisible );
@@ -4734,8 +4720,6 @@ OO.ui.TagItemWidget.prototype.isValid = function () {
  * A basic tag multiselect widget, similar in concept to {@link OO.ui.ComboBoxInputWidget combo box widget}
  * that allows the user to add multiple values that are displayed in a tag area.
  *
- * For more information about menus and options, please see the [OOjs UI documentation on MediaWiki][1].
- *
  * This widget is a base widget; see {@link OO.ui.MenuTagMultiselectWidget MenuTagMultiselectWidget} and
  * {@link OO.ui.PopupTagMultiselectWidget PopupTagMultiselectWidget} for the implementations that use
  * a menu and a popup respectively.
@@ -4749,8 +4733,6 @@ OO.ui.TagItemWidget.prototype.isValid = function () {
  *     } );
  *     $( 'body' ).append( widget.$element );
  *
- * [1]: https://www.mediawiki.org/wiki/OOjs_UI/Widgets/Selects_and_Options#Menu_selects_and_options
- *
  * @class
  * @extends OO.ui.Widget
  * @mixins OO.ui.mixin.GroupWidget
@@ -5218,7 +5200,7 @@ OO.ui.TagMultiselectWidget.prototype.clearInput = function () {
  * @return {boolean} Value is duplicate
  */
 OO.ui.TagMultiselectWidget.prototype.isDuplicateData = function ( data ) {
-       return !!this.getItemFromData( data );
+       return !!this.findItemFromData( data );
 };
 
 /**
@@ -5343,7 +5325,7 @@ OO.ui.TagMultiselectWidget.prototype.addTag = function ( data, label ) {
  * @param {string|Object} data Tag data
  */
 OO.ui.TagMultiselectWidget.prototype.removeTagByData = function ( data ) {
-       var item = this.getItemFromData( data );
+       var item = this.findItemFromData( data );
 
        this.removeItems( [ item ] );
 };
@@ -5548,8 +5530,6 @@ OO.ui.TagMultiselectWidget.prototype.isValid = function () {
  * PopupTagMultiselectWidget is a {@link OO.ui.TagMultiselectWidget OO.ui.TagMultiselectWidget} intended
  * to use a popup. The popup can be configured to have a default input to insert values into the widget.
  *
- * For more information about menus and options, please see the [OOjs UI documentation on MediaWiki][1].
- *
  *     @example
  *     // Example: A basic PopupTagMultiselectWidget.
  *     var widget = new OO.ui.PopupTagMultiselectWidget();
@@ -5565,8 +5545,6 @@ OO.ui.TagMultiselectWidget.prototype.isValid = function () {
  *         } );
  *     $( 'body' ).append( widget.$element );
  *
- * [1]: https://www.mediawiki.org/wiki/OOjs_UI/Widgets/Selects_and_Options#Menu_selects_and_options
- *
  * @class
  * @extends OO.ui.TagMultiselectWidget
  * @mixins OO.ui.mixin.PopupElement
@@ -5588,7 +5566,7 @@ OO.ui.PopupTagMultiselectWidget = function OoUiPopupTagMultiselectWidget( config
        // Parent constructor
        OO.ui.PopupTagMultiselectWidget.parent.call( this, $.extend( { inputPosition: 'none' }, config ) );
 
-       this.$overlay = config.$overlay || this.$element;
+       this.$overlay = ( config.$overlay === true ? OO.ui.getDefaultOverlay() : config.$overlay ) || this.$element;
 
        if ( !config.popup ) {
                // For the default base implementation, we give a popup
@@ -5708,8 +5686,6 @@ OO.ui.PopupTagMultiselectWidget.prototype.addTagByPopupValue = function ( data,
  * MenuTagMultiselectWidget is a {@link OO.ui.TagMultiselectWidget OO.ui.TagMultiselectWidget} intended
  * to use a menu of selectable options.
  *
- * For more information about menus and options, please see the [OOjs UI documentation on MediaWiki][1].
- *
  *     @example
  *     // Example: A basic MenuTagMultiselectWidget.
  *     var widget = new OO.ui.MenuTagMultiselectWidget( {
@@ -5723,8 +5699,6 @@ OO.ui.PopupTagMultiselectWidget.prototype.addTagByPopupValue = function ( data,
  *     } );
  *     $( 'body' ).append( widget.$element );
  *
- * [1]: https://www.mediawiki.org/wiki/OOjs_UI/Widgets/Selects_and_Options#Menu_selects_and_options
- *
  * @class
  * @extends OO.ui.TagMultiselectWidget
  *
@@ -5741,7 +5715,7 @@ OO.ui.MenuTagMultiselectWidget = function OoUiMenuTagMultiselectWidget( config )
        // Parent constructor
        OO.ui.MenuTagMultiselectWidget.parent.call( this, config );
 
-       this.$overlay = config.$overlay || this.$element;
+       this.$overlay = ( config.$overlay === true ? OO.ui.getDefaultOverlay() : config.$overlay ) || this.$element;
 
        this.menu = this.createMenuWidget( $.extend( {
                widget: this,
@@ -5749,7 +5723,7 @@ OO.ui.MenuTagMultiselectWidget = function OoUiMenuTagMultiselectWidget( config )
                $input: this.hasInput ? this.input.$input : null,
                filterFromInput: !!this.hasInput,
                $autoCloseIgnore: this.hasInput ?
-                       this.input.$element.add( this.$overlay ) : this.$overlay,
+                       this.input.$element : $( [] ),
                $floatableContainer: this.hasInput && this.inputPosition === 'outline' ?
                        this.input.$element : this.$element,
                $overlay: this.$overlay,
@@ -5836,12 +5810,17 @@ OO.ui.MenuTagMultiselectWidget.prototype.onMenuToggle = function ( isVisible ) {
  * @inheritdoc
  */
 OO.ui.MenuTagMultiselectWidget.prototype.onTagSelect = function ( tagItem ) {
-       var menuItem = this.menu.getItemFromData( tagItem.getData() );
+       var menuItem = this.menu.findItemFromData( tagItem.getData() );
        // Override the base behavior from TagMultiselectWidget; the base behavior
        // in TagMultiselectWidget is to remove the tag to edit it in the input,
        // but in our case, we want to utilize the menu selection behavior, and
        // definitely not remove the item.
 
+       // If there is an input that is used for filtering, erase the value so we don't filter
+       if ( this.hasInput && this.menu.filterFromInput ) {
+               this.input.setValue( '' );
+       }
+
        // Select the menu item
        this.menu.selectItem( menuItem );
 
@@ -5855,7 +5834,7 @@ OO.ui.MenuTagMultiselectWidget.prototype.addTagFromInput = function () {
        var inputValue = this.input.getValue(),
                validated = false,
                highlightedItem = this.menu.findHighlightedItem(),
-               item = this.menu.getItemFromData( inputValue );
+               item = this.menu.findItemFromData( inputValue );
 
        // Override the parent method so we add from the menu
        // rather than directly from the input