Merge "Set migration stage for change tag to read new"
[lhc/web/wiklou.git] / resources / lib / ooui / oojs-ui-toolbars.js
index a83965e..e0d9b3c 100644 (file)
@@ -1,12 +1,12 @@
 /*!
- * OOUI v0.28.2
+ * OOUI v0.29.5
  * 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-09-11T23:05:15Z
+ * Date: 2018-11-08T22:38:07Z
  */
 ( function ( OO ) {
 
@@ -400,6 +400,7 @@ OO.ui.Toolbar.prototype.getToolGroupFactory = function () {
  *
  * @private
  * @param {jQuery.Event} e Mouse down event
+ * @return {undefined/boolean} False to prevent default if event is handled
  */
 OO.ui.Toolbar.prototype.onPointerDown = function ( e ) {
        var $closestWidgetToEvent = $( e.target ).closest( '.oo-ui-widget' ),
@@ -857,6 +858,7 @@ OO.ui.Tool.prototype.setActive = function ( state ) {
  *
  * @param {string|Function} title Title text or a function that returns text
  * @chainable
+ * @return {OO.ui.Tool} The tool, for chaining
  */
 OO.ui.Tool.prototype.setTitle = function ( title ) {
        this.title = OO.ui.resolveMsg( title );
@@ -973,7 +975,7 @@ OO.ui.ToolGroup = function OoUiToolGroup( toolbar, config ) {
        this.exclude = config.exclude || [];
        this.promote = config.promote || [];
        this.demote = config.demote || [];
-       this.onCapturedMouseKeyUpHandler = this.onCapturedMouseKeyUp.bind( this );
+       this.onDocumentMouseKeyUpHandler = this.onDocumentMouseKeyUp.bind( this );
 
        // Events
        this.$group.on( {
@@ -1107,6 +1109,7 @@ OO.ui.ToolGroup.prototype.onDisable = function ( isDisabled ) {
  *
  * @protected
  * @param {jQuery.Event} e Mouse down or key down event
+ * @return {undefined/boolean} False to prevent default if event is handled
  */
 OO.ui.ToolGroup.prototype.onMouseKeyDown = function ( e ) {
        if (
@@ -1116,27 +1119,33 @@ OO.ui.ToolGroup.prototype.onMouseKeyDown = function ( e ) {
                this.pressed = this.findTargetTool( e );
                if ( this.pressed ) {
                        this.pressed.setActive( true );
-                       this.getElementDocument().addEventListener( 'mouseup', this.onCapturedMouseKeyUpHandler, true );
-                       this.getElementDocument().addEventListener( 'keyup', this.onCapturedMouseKeyUpHandler, true );
+                       this.getElementDocument().addEventListener( 'mouseup', this.onDocumentMouseKeyUpHandler, true );
+                       this.getElementDocument().addEventListener( 'keyup', this.onDocumentMouseKeyUpHandler, true );
                        return false;
                }
        }
 };
 
 /**
- * Handle captured mouse up and key up events.
+ * Handle document mouse up and key up events.
  *
  * @protected
  * @param {MouseEvent|KeyboardEvent} e Mouse up or key up event
  */
-OO.ui.ToolGroup.prototype.onCapturedMouseKeyUp = function ( e ) {
-       this.getElementDocument().removeEventListener( 'mouseup', this.onCapturedMouseKeyUpHandler, true );
-       this.getElementDocument().removeEventListener( 'keyup', this.onCapturedMouseKeyUpHandler, true );
+OO.ui.ToolGroup.prototype.onDocumentMouseKeyUp = function ( e ) {
+       this.getElementDocument().removeEventListener( 'mouseup', this.onDocumentMouseKeyUpHandler, true );
+       this.getElementDocument().removeEventListener( 'keyup', this.onDocumentMouseKeyUpHandler, true );
        // onMouseKeyUp may be called a second time, depending on where the mouse is when the button is
        // released, but since `this.pressed` will no longer be true, the second call will be ignored.
        this.onMouseKeyUp( e );
 };
 
+// Deprecated alias since 0.28.3
+OO.ui.ToolGroup.prototype.onCapturedMouseKeyUp = function () {
+       OO.ui.warnDeprecation( 'onCapturedMouseKeyUp is deprecated, use onDocumentMouseKeyUp instead' );
+       this.onDocumentMouseKeyUp.apply( this, arguments );
+};
+
 /**
  * Handle mouse up and key up events.
  *
@@ -1547,6 +1556,7 @@ OO.ui.PopupTool = function OoUiPopupTool( toolGroup, config ) {
        this.popup.connect( this, { toggle: 'onPopupToggle' } );
 
        // Initialization
+       this.popup.setAutoFlip( false );
        this.popup.setPosition( toolGroup.getToolbar().position === 'bottom' ? 'above' : 'below' );
        this.$element.addClass( 'oo-ui-popupTool' );
        this.popup.$element.addClass( 'oo-ui-popupTool-popup' );
@@ -1859,8 +1869,8 @@ OO.ui.BarToolGroup.static.name = 'bar';
 
 /**
  * PopupToolGroup is an abstract base class used by both {@link OO.ui.MenuToolGroup MenuToolGroup}
- * and {@link OO.ui.ListToolGroup ListToolGroup} to provide a popup--an overlaid menu or list of tools with an
- * optional icon and label. This class can be used for other base classes that also use this functionality.
+ * and {@link OO.ui.ListToolGroup ListToolGroup} to provide a popup (an overlaid menu or list of tools with an
+ * optional icon and label). This class can be used for other base classes that also use this functionality.
  *
  * @abstract
  * @class
@@ -1897,7 +1907,8 @@ OO.ui.PopupToolGroup = function OoUiPopupToolGroup( toolbar, config ) {
        // Properties
        this.active = false;
        this.dragging = false;
-       this.onBlurHandler = this.onBlur.bind( this );
+       // Don't conflict with parent method of the same name
+       this.onPopupDocumentMouseKeyUpHandler = this.onPopupDocumentMouseKeyUp.bind( this );
        this.$handle = $( '<span>' );
 
        // Mixin constructors
@@ -1972,14 +1983,12 @@ OO.ui.PopupToolGroup.prototype.setDisabled = function () {
 };
 
 /**
- * Handle focus being lost.
- *
- * The event is actually generated from a mouseup/keyup, so it is not a normal blur event object.
+ * Handle document mouse up and key up events.
  *
  * @protected
  * @param {MouseEvent|KeyboardEvent} e Mouse up or key up event
  */
-OO.ui.PopupToolGroup.prototype.onBlur = function ( e ) {
+OO.ui.PopupToolGroup.prototype.onPopupDocumentMouseKeyUp = function ( e ) {
        var $target = $( e.target );
        // Only deactivate when clicking outside the dropdown element
        if ( $target.closest( '.oo-ui-popupToolGroup' )[ 0 ] === this.$element[ 0 ] ) {
@@ -1991,6 +2000,12 @@ OO.ui.PopupToolGroup.prototype.onBlur = function ( e ) {
        this.setActive( false );
 };
 
+// Deprecated alias since 0.28.3
+OO.ui.PopupToolGroup.prototype.onBlur = function () {
+       OO.ui.warnDeprecation( 'onBlur is deprecated, use onPopupDocumentMouseKeyUp instead' );
+       this.onPopupDocumentMouseKeyUp.apply( this, arguments );
+};
+
 /**
  * @inheritdoc
  */
@@ -2038,6 +2053,7 @@ OO.ui.PopupToolGroup.prototype.onMouseKeyDown = function ( e ) {
  *
  * @protected
  * @param {jQuery.Event} e Mouse up or key up event
+ * @return {undefined/boolean} False to prevent default if event is handled
  */
 OO.ui.PopupToolGroup.prototype.onHandleMouseKeyUp = function ( e ) {
        if (
@@ -2053,6 +2069,7 @@ OO.ui.PopupToolGroup.prototype.onHandleMouseKeyUp = function ( e ) {
  *
  * @protected
  * @param {jQuery.Event} e Mouse down or key down event
+ * @return {undefined/boolean} False to prevent default if event is handled
  */
 OO.ui.PopupToolGroup.prototype.onHandleMouseKeyDown = function ( e ) {
        var $focusable;
@@ -2096,8 +2113,8 @@ OO.ui.PopupToolGroup.prototype.setActive = function ( value ) {
        if ( this.active !== value ) {
                this.active = value;
                if ( value ) {
-                       this.getElementDocument().addEventListener( 'mouseup', this.onBlurHandler, true );
-                       this.getElementDocument().addEventListener( 'keyup', this.onBlurHandler, true );
+                       this.getElementDocument().addEventListener( 'mouseup', this.onPopupDocumentMouseKeyUpHandler, true );
+                       this.getElementDocument().addEventListener( 'keyup', this.onPopupDocumentMouseKeyUpHandler, true );
 
                        this.$clippable.css( 'left', '' );
                        this.$element.addClass( 'oo-ui-popupToolGroup-active' );
@@ -2128,8 +2145,8 @@ OO.ui.PopupToolGroup.prototype.setActive = function ( value ) {
                                } );
                        }
                } else {
-                       this.getElementDocument().removeEventListener( 'mouseup', this.onBlurHandler, true );
-                       this.getElementDocument().removeEventListener( 'keyup', this.onBlurHandler, true );
+                       this.getElementDocument().removeEventListener( 'mouseup', this.onPopupDocumentMouseKeyUpHandler, true );
+                       this.getElementDocument().removeEventListener( 'keyup', this.onPopupDocumentMouseKeyUpHandler, true );
                        this.$element.removeClass( 'oo-ui-popupToolGroup-active' );
                        this.$group.removeClass( 'oo-ui-popupToolGroup-active-tools' );
                        this.togglePositioning( false );