Merge "Group messages in WANObjectCache by key"
[lhc/web/wiklou.git] / resources / lib / oojs-ui / oojs-ui-core.js
index af099a9..20c58ff 100644 (file)
@@ -1,12 +1,12 @@
 /*!
- * OOjs UI v0.23.2
+ * OOjs UI v0.24.2
  * 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-09-26T20:18:42Z
+ * Date: 2017-11-07T22:52:40Z
  */
 ( function ( OO ) {
 
@@ -581,7 +581,9 @@ OO.ui.mixin = {};
  *  Data can also be specified with the #setData method.
  */
 OO.ui.Element = function OoUiElement( config ) {
-       this.initialConfig = config;
+       if ( OO.ui.isDemo ) {
+               this.initialConfig = config;
+       }
        // Configuration initialization
        config = config || {};
 
@@ -2958,13 +2960,14 @@ OO.ui.mixin.LabelElement.static.label = null;
  *  sub-string wrapped in highlighted span
  */
 OO.ui.mixin.LabelElement.static.highlightQuery = function ( text, query, compare ) {
-       var i, offset, tLen, qLen,
+       var i, tLen, qLen,
+               offset = -1,
                $result = $( '<span>' );
 
        if ( compare ) {
                tLen = text.length;
                qLen = query.length;
-               for ( i = 0; offset === undefined && i <= tLen - qLen; i++ ) {
+               for ( i = 0; offset === -1 && i <= tLen - qLen; i++ ) {
                        if ( compare( query, text.slice( i, i + qLen ) ) === 0 ) {
                                offset = i;
                        }
@@ -2974,15 +2977,16 @@ OO.ui.mixin.LabelElement.static.highlightQuery = function ( text, query, compare
        }
 
        if ( !query.length || offset === -1 ) {
-               return $result.text( text );
-       }
-       $result.append(
-               document.createTextNode( text.slice( 0, offset ) ),
-               $( '<span>' )
-                       .addClass( 'oo-ui-labelElement-label-highlight' )
-                       .text( text.slice( offset, offset + query.length ) ),
-               document.createTextNode( text.slice( offset + query.length ) )
-       );
+               $result.text( text );
+       } else {
+               $result.append(
+                       document.createTextNode( text.slice( 0, offset ) ),
+                       $( '<span>' )
+                               .addClass( 'oo-ui-labelElement-label-highlight' )
+                               .text( text.slice( offset, offset + query.length ) ),
+                       document.createTextNode( text.slice( offset + query.length ) )
+               );
+       }
        return $result.contents();
 };
 
@@ -5356,7 +5360,9 @@ OO.ui.PopupWidget.prototype.computePosition = function () {
        floatablePos = this.$floatableContainer.offset();
        floatablePos[ far ] = floatablePos[ near ] + this.$floatableContainer[ 'outer' + sizeProp ]();
        // Measure where the offsetParent is and compute our position based on that and parentPosition
-       offsetParentPos = this.$element.offsetParent().offset();
+       offsetParentPos = this.$element.offsetParent()[ 0 ] === document.documentElement ?
+               { top: 0, left: 0 } :
+               this.$element.offsetParent().offset();
 
        if ( positionProp === near ) {
                popupPos[ near ] = offsetParentPos[ near ] + parentPosition[ near ];
@@ -5392,7 +5398,9 @@ OO.ui.PopupWidget.prototype.computePosition = function () {
        }
 
        // Check if the popup will go beyond the edge of this.$container
-       containerPos = this.$container.offset();
+       containerPos = this.$container[ 0 ] === document.documentElement ?
+               { top: 0, left: 0 } :
+               this.$container.offset();
        containerPos[ far ] = containerPos[ near ] + this.$container[ 'inner' + sizeProp ]();
        // Take into account how much the popup will move because of the adjustments we're going to make
        popupPos[ near ] += ( positionProp === near ? 1 : -1 ) * positionAdjustment;
@@ -6081,9 +6089,16 @@ OO.ui.SelectWidget.prototype.onFocus = function ( event ) {
                        item = this.findFirstSelectableItem();
                }
        } else {
-               // One of the options got focussed (and the event bubbled up here).
-               // They can't be tabbed to, but they can be activated using accesskeys.
-               item = this.findTargetItem( event );
+               if ( event.target.tabIndex === -1 ) {
+                       // One of the options got focussed (and the event bubbled up here).
+                       // They can't be tabbed to, but they can be activated using accesskeys.
+                       // OptionWidgets and focusable UI elements inside them have tabindex="-1" set.
+                       item = this.findTargetItem( event );
+               } else {
+                       // There is something actually user-focusable in one of the labels of the options, and the
+                       // user focussed it (e.g. by tabbing to it). Do nothing (especially, don't change the focus).
+                       return;
+               }
        }
 
        if ( item ) {
@@ -7540,7 +7555,7 @@ OO.ui.DropdownWidget.prototype.onMenuSelect = function ( item ) {
  * Handle menu toggle events.
  *
  * @private
- * @param {boolean} isVisible Menu toggle event
+ * @param {boolean} isVisible Open state of the menu
  */
 OO.ui.DropdownWidget.prototype.onMenuToggle = function ( isVisible ) {
        this.$element.toggleClass( 'oo-ui-dropdownWidget-open', isVisible );
@@ -7574,10 +7589,15 @@ OO.ui.DropdownWidget.prototype.onKeyDown = function ( e ) {
                !this.isDisabled() &&
                (
                        e.which === OO.ui.Keys.ENTER ||
+                       (
+                               e.which === OO.ui.Keys.SPACE &&
+                               // Avoid conflicts with type-to-search, see SelectWidget#onKeyPress.
+                               // Space only closes the menu is the user is not typing to search.
+                               this.menu.keyPressBuffer === ''
+                       ) ||
                        (
                                !this.menu.isVisible() &&
                                (
-                                       e.which === OO.ui.Keys.SPACE ||
                                        e.which === OO.ui.Keys.UP ||
                                        e.which === OO.ui.Keys.DOWN
                                )
@@ -9939,7 +9959,7 @@ OO.ui.TextInputWidget.prototype.getInputElement = function ( config ) {
  *
  * @param {Object} config Configuration options
  * @return {string|null}
- * @private
+ * @protected
  */
 OO.ui.TextInputWidget.prototype.getSaneType = function ( config ) {
        var allowedTypes = [
@@ -10267,10 +10287,6 @@ OO.ui.SearchInputWidget = function OoUiSearchInputWidget( config ) {
                icon: 'search'
        }, config );
 
-       // Set type to text so that TextInputWidget doesn't
-       // get stuck in an infinite loop.
-       config.type = 'text';
-
        // Parent constructor
        OO.ui.SearchInputWidget.parent.call( this, config );
 
@@ -10280,7 +10296,6 @@ OO.ui.SearchInputWidget = function OoUiSearchInputWidget( config ) {
        } );
 
        // Initialization
-       this.$element.addClass( 'oo-ui-textInputWidget-type-search' );
        this.updateSearchIndicator();
        this.connect( this, {
                disable: 'onDisable'
@@ -10297,8 +10312,8 @@ OO.inheritClass( OO.ui.SearchInputWidget, OO.ui.TextInputWidget );
  * @inheritdoc
  * @protected
  */
-OO.ui.SearchInputWidget.prototype.getInputElement = function () {
-       return $( '<input>' ).attr( 'type', 'search' );
+OO.ui.SearchInputWidget.prototype.getSaneType = function () {
+       return 'search';
 };
 
 /**
@@ -10669,7 +10684,8 @@ OO.ui.ComboBoxInputWidget = function OoUiComboBoxInputWidget( config ) {
        this.menu.connect( this, {
                choose: 'onMenuChoose',
                add: 'onMenuItemsChange',
-               remove: 'onMenuItemsChange'
+               remove: 'onMenuItemsChange',
+               toggle: 'onMenuToggle'
        } );
 
        // Initialization
@@ -10780,6 +10796,16 @@ OO.ui.ComboBoxInputWidget.prototype.onMenuItemsChange = function () {
        this.$element.toggleClass( 'oo-ui-comboBoxInputWidget-empty', this.menu.isEmpty() );
 };
 
+/**
+ * Handle menu toggle events.
+ *
+ * @private
+ * @param {boolean} isVisible Open state of the menu
+ */
+OO.ui.ComboBoxInputWidget.prototype.onMenuToggle = function ( isVisible ) {
+       this.$element.toggleClass( 'oo-ui-comboBoxInputWidget-open', isVisible );
+};
+
 /**
  * @inheritdoc
  */