Update OOjs UI to v0.16.2
[lhc/web/wiklou.git] / resources / lib / oojs-ui / oojs-ui-widgets.js
index ac4b5b4..04137da 100644 (file)
@@ -1,12 +1,12 @@
 /*!
- * OOjs UI v0.16.1
+ * OOjs UI v0.16.2
  * 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-03-01T21:50:12Z
+ * Date: 2016-03-08T21:46:49Z
  */
 ( function ( OO ) {
 
@@ -3720,6 +3720,13 @@ OO.mixinClass( OO.ui.CapsuleMultiSelectWidget, OO.ui.mixin.IconElement );
  * @param {Mixed[]} datas Data of the now-selected items
  */
 
+/**
+ * @event resize
+ *
+ * A resize event is emitted when the widget's dimensions change to accomodate newly added items or
+ * current user input.
+ */
+
 /* Methods */
 
 /**
@@ -3882,7 +3889,7 @@ OO.ui.CapsuleMultiSelectWidget.prototype.addItems = function ( items ) {
        }
        if ( !same ) {
                this.emit( 'change', this.getItemsData() );
-               this.menu.position();
+               this.updateIfHeightChanged();
        }
 
        return this;
@@ -3919,7 +3926,7 @@ OO.ui.CapsuleMultiSelectWidget.prototype.removeItems = function ( items ) {
        }
        if ( !same ) {
                this.emit( 'change', this.getItemsData() );
-               this.menu.position();
+               this.updateIfHeightChanged();
        }
 
        return this;
@@ -3932,7 +3939,7 @@ OO.ui.CapsuleMultiSelectWidget.prototype.clearItems = function () {
        if ( this.items.length ) {
                OO.ui.mixin.GroupElement.prototype.clearItems.call( this );
                this.emit( 'change', this.getItemsData() );
-               this.menu.position();
+               this.updateIfHeightChanged();
        }
        return this;
 };
@@ -4162,8 +4169,21 @@ OO.ui.CapsuleMultiSelectWidget.prototype.updateInputSize = function () {
                        bestWidth = this.$content.innerWidth() - 10;
                }
                this.$input.width( Math.floor( bestWidth ) );
+               this.updateIfHeightChanged();
+       }
+};
 
+/**
+ * Determine if widget height changed, and if so, update menu position and emit 'resize' event.
+ *
+ * @private
+ */
+OO.ui.CapsuleMultiSelectWidget.prototype.updateIfHeightChanged = function () {
+       var height = this.$element.height();
+       if ( height !== this.height ) {
+               this.height = height;
                this.menu.position();
+               this.emit( 'resize' );
        }
 };