Merge "Remove .mw-help-field-hint and -data CSS classes from mw.legacy/shared"
[lhc/web/wiklou.git] / resources / lib / oojs-ui / oojs-ui-widgets.js
index 8d93b80..62195df 100644 (file)
@@ -1,12 +1,12 @@
 /*!
- * OOjs UI v0.17.6
+ * OOjs UI v0.17.9
  * https://www.mediawiki.org/wiki/OOjs_UI
  *
  * Copyright 2011–2016 OOjs UI Team and other contributors.
  * Released under the MIT license
  * http://oojs.mit-license.org
  *
- * Date: 2016-07-12T20:26:03Z
+ * Date: 2016-09-13T18:30:02Z
  */
 ( function ( OO ) {
 
@@ -2170,7 +2170,7 @@ OO.ui.BookletLayout.prototype.selectFirstSelectablePage = function () {
  *     };
  *
  *     var card1 = new CardOneLayout( 'one' ),
- *         card2 = new CardLayout( 'two', { label: 'Card two' } );
+ *         card2 = new OO.ui.CardLayout( 'two', { label: 'Card two' } );
  *
  *     card2.$element.append( '<p>Second card</p>' );
  *
@@ -2709,7 +2709,7 @@ OO.ui.ToggleButtonWidget = function OoUiToggleButtonWidget( config ) {
        OO.ui.ToggleButtonWidget.parent.call( this, config );
 
        // Mixin constructors
-       OO.ui.mixin.ButtonElement.call( this, config );
+       OO.ui.mixin.ButtonElement.call( this, $.extend( {}, config, { active: this.active } ) );
        OO.ui.mixin.IconElement.call( this, config );
        OO.ui.mixin.IndicatorElement.call( this, config );
        OO.ui.mixin.LabelElement.call( this, config );
@@ -3057,7 +3057,7 @@ OO.inheritClass( OO.ui.OutlineOptionWidget, OO.ui.DecoratedOptionWidget );
 
 /* Static Properties */
 
-OO.ui.OutlineOptionWidget.static.highlightable = false;
+OO.ui.OutlineOptionWidget.static.highlightable = true;
 
 OO.ui.OutlineOptionWidget.static.scrollIntoViewOnSelect = true;
 
@@ -3098,6 +3098,22 @@ OO.ui.OutlineOptionWidget.prototype.getLevel = function () {
        return this.level;
 };
 
+/**
+ * @inheritdoc
+ */
+OO.ui.OutlineOptionWidget.prototype.setPressed = function ( state ) {
+       OO.ui.OutlineOptionWidget.parent.prototype.setPressed.call( this, state );
+       if ( this.constructor.static.pressable ) {
+               this.pressed = !!state;
+               if ( this.pressed ) {
+                       this.setFlags( 'progressive' );
+               } else if ( !this.selected ) {
+                       this.clearFlags();
+               }
+       }
+       return this;
+};
+
 /**
  * Set movability.
  *
@@ -3126,6 +3142,22 @@ OO.ui.OutlineOptionWidget.prototype.setRemovable = function ( removable ) {
        return this;
 };
 
+/**
+ * @inheritdoc
+ */
+OO.ui.OutlineOptionWidget.prototype.setSelected = function ( state ) {
+       OO.ui.OutlineOptionWidget.parent.prototype.setSelected.call( this, state );
+       if ( this.constructor.static.selectable ) {
+               this.selected = !!state;
+               if ( this.selected ) {
+                       this.setFlags( 'progressive' );
+               } else {
+                       this.clearFlags();
+               }
+       }
+       return this;
+};
+
 /**
  * Set indentation level.
  *
@@ -3629,6 +3661,7 @@ OO.ui.CapsuleMultiselectWidget = function OoUiCapsuleMultiselectWidget( config )
        }
        this.menu.connect( this, {
                choose: 'onMenuChoose',
+               toggle: 'onMenuToggle',
                add: 'onMenuItemsChange',
                remove: 'onMenuItemsChange'
        } );
@@ -4174,6 +4207,16 @@ OO.ui.CapsuleMultiselectWidget.prototype.onMenuChoose = function ( item ) {
        }
 };
 
+/**
+ * Handle menu toggle events.
+ *
+ * @private
+ * @param {boolean} isVisible Menu toggle event
+ */
+OO.ui.CapsuleMultiselectWidget.prototype.onMenuToggle = function ( isVisible ) {
+       this.$element.toggleClass( 'oo-ui-capsuleMultiselectWidget-open', isVisible );
+};
+
 /**
  * Handle menu item change events.
  *
@@ -4365,8 +4408,8 @@ OO.ui.SelectFileWidget = function OoUiSelectFileWidget( config ) {
                this.selectButton.setIcon( 'upload' );
                this.$thumbnail = $( '<div>' ).addClass( 'oo-ui-selectFileWidget-thumbnail' );
                this.setPendingElement( this.$thumbnail );
-               this.$dropTarget = $( '<div>' )
-                       .addClass( 'oo-ui-selectFileWidget-dropTarget' )
+               this.$element
+                       .addClass( 'oo-ui-selectFileWidget-dropTarget oo-ui-selectFileWidget' )
                        .on( {
                                click: this.onDropTargetClick.bind( this )
                        } )
@@ -4378,7 +4421,6 @@ OO.ui.SelectFileWidget = function OoUiSelectFileWidget( config ) {
                                        .addClass( 'oo-ui-selectFileWidget-dropLabel' )
                                        .text( OO.ui.msg( 'ooui-selectfile-dragdrop-placeholder' ) )
                        );
-               this.$element.append( this.$dropTarget );
        } else {
                this.$element
                        .addClass( 'oo-ui-selectFileWidget' )
@@ -4481,13 +4523,6 @@ OO.ui.SelectFileWidget.prototype.updateUI = function () {
                                        .addClass( 'oo-ui-selectFileWidget-fileName' )
                                        .text( this.currentFile.name )
                        );
-                       if ( this.currentFile.type !== '' ) {
-                               $label = $label.add(
-                                       $( '<span>' )
-                                               .addClass( 'oo-ui-selectFileWidget-fileType' )
-                                               .text( this.currentFile.type )
-                               );
-                       }
                        this.setLabel( $label );
 
                        if ( this.showDropTarget ) {
@@ -4504,12 +4539,12 @@ OO.ui.SelectFileWidget.prototype.updateUI = function () {
                                }.bind( this ) ).always( function () {
                                        this.popPending();
                                }.bind( this ) );
-                               this.$dropTarget.off( 'click' );
+                               this.$element.off( 'click' );
                        }
                } else {
                        if ( this.showDropTarget ) {
-                               this.$dropTarget.off( 'click' );
-                               this.$dropTarget.on( {
+                               this.$element.off( 'click' );
+                               this.$element.on( {
                                        click: this.onDropTargetClick.bind( this )
                                } );
                                this.$thumbnail
@@ -4771,103 +4806,6 @@ OO.ui.SelectFileWidget.prototype.setDisabled = function ( disabled ) {
        return this;
 };
 
-/**
- * Progress bars visually display the status of an operation, such as a download,
- * and can be either determinate or indeterminate:
- *
- * - **determinate** process bars show the percent of an operation that is complete.
- *
- * - **indeterminate** process bars use a visual display of motion to indicate that an operation
- *   is taking place. Because the extent of an indeterminate operation is unknown, the bar does
- *   not use percentages.
- *
- * The value of the `progress` configuration determines whether the bar is determinate or indeterminate.
- *
- *     @example
- *     // Examples of determinate and indeterminate progress bars.
- *     var progressBar1 = new OO.ui.ProgressBarWidget( {
- *         progress: 33
- *     } );
- *     var progressBar2 = new OO.ui.ProgressBarWidget();
- *
- *     // Create a FieldsetLayout to layout progress bars
- *     var fieldset = new OO.ui.FieldsetLayout;
- *     fieldset.addItems( [
- *        new OO.ui.FieldLayout( progressBar1, {label: 'Determinate', align: 'top'}),
- *        new OO.ui.FieldLayout( progressBar2, {label: 'Indeterminate', align: 'top'})
- *     ] );
- *     $( 'body' ).append( fieldset.$element );
- *
- * @class
- * @extends OO.ui.Widget
- *
- * @constructor
- * @param {Object} [config] Configuration options
- * @cfg {number|boolean} [progress=false] The type of progress bar (determinate or indeterminate).
- *  To create a determinate progress bar, specify a number that reflects the initial percent complete.
- *  By default, the progress bar is indeterminate.
- */
-OO.ui.ProgressBarWidget = function OoUiProgressBarWidget( config ) {
-       // Configuration initialization
-       config = config || {};
-
-       // Parent constructor
-       OO.ui.ProgressBarWidget.parent.call( this, config );
-
-       // Properties
-       this.$bar = $( '<div>' );
-       this.progress = null;
-
-       // Initialization
-       this.setProgress( config.progress !== undefined ? config.progress : false );
-       this.$bar.addClass( 'oo-ui-progressBarWidget-bar' );
-       this.$element
-               .attr( {
-                       role: 'progressbar',
-                       'aria-valuemin': 0,
-                       'aria-valuemax': 100
-               } )
-               .addClass( 'oo-ui-progressBarWidget' )
-               .append( this.$bar );
-};
-
-/* Setup */
-
-OO.inheritClass( OO.ui.ProgressBarWidget, OO.ui.Widget );
-
-/* Static Properties */
-
-OO.ui.ProgressBarWidget.static.tagName = 'div';
-
-/* Methods */
-
-/**
- * Get the percent of the progress that has been completed. Indeterminate progresses will return `false`.
- *
- * @return {number|boolean} Progress percent
- */
-OO.ui.ProgressBarWidget.prototype.getProgress = function () {
-       return this.progress;
-};
-
-/**
- * Set the percent of the process completed or `false` for an indeterminate process.
- *
- * @param {number|boolean} progress Progress percent or `false` for indeterminate
- */
-OO.ui.ProgressBarWidget.prototype.setProgress = function ( progress ) {
-       this.progress = progress;
-
-       if ( progress !== false ) {
-               this.$bar.css( 'width', this.progress + '%' );
-               this.$element.attr( 'aria-valuenow', this.progress );
-       } else {
-               this.$bar.css( 'width', '' );
-               this.$element.removeAttr( 'aria-valuenow' );
-       }
-       this.$element.toggleClass( 'oo-ui-progressBarWidget-indeterminate', !progress );
-};
-
 /**
  * SearchWidgets combine a {@link OO.ui.TextInputWidget text input field}, where users can type a search query,
  * and a menu of search results, which is displayed beneath the query
@@ -5053,24 +4991,20 @@ OO.ui.NumberInputWidget = function OoUiNumberInputWidget( config ) {
                this.minusButton = new OO.ui.ButtonWidget( $.extend(
                        {
                                disabled: this.isDisabled(),
-                               tabIndex: -1
-                       },
-                       config.minusButton,
-                       {
+                               tabIndex: -1,
                                classes: [ 'oo-ui-numberInputWidget-minusButton' ],
                                label: '−'
-                       }
+                       },
+                       config.minusButton
                ) );
                this.plusButton = new OO.ui.ButtonWidget( $.extend(
                        {
                                disabled: this.isDisabled(),
-                               tabIndex: -1
-                       },
-                       config.plusButton,
-                       {
+                               tabIndex: -1,
                                classes: [ 'oo-ui-numberInputWidget-plusButton' ],
                                label: '+'
-                       }
+                       },
+                       config.plusButton
                ) );
        }
 
@@ -5268,11 +5202,11 @@ OO.ui.NumberInputWidget.prototype.validateNumber = function ( value ) {
                return false;
        }
 
-       /*jshint bitwise: false */
+       /* eslint-disable no-bitwise */
        if ( this.isInteger && ( n | 0 ) !== n ) {
                return false;
        }
-       /*jshint bitwise: true */
+       /* eslint-enable no-bitwise */
 
        if ( n < this.min || n > this.max ) {
                return false;