Esanders has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/247860

Change subject: TextInputWidget: Emit 'resize' events
......................................................................

TextInputWidget: Emit 'resize' events

Change-Id: Iaadaf1f9ffe9474d2e7bf2dedd1a0ac910dbaa55
---
M src/widgets/TextInputWidget.js
1 file changed, 15 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/oojs/ui refs/changes/60/247860/1

diff --git a/src/widgets/TextInputWidget.js b/src/widgets/TextInputWidget.js
index 9dddc9e..e09c78c 100644
--- a/src/widgets/TextInputWidget.js
+++ b/src/widgets/TextInputWidget.js
@@ -90,6 +90,7 @@
        this.minRows = config.rows !== undefined ? config.rows : '';
        this.maxRows = config.maxRows || Math.max( 2 * ( this.minRows || 0 ), 
10 );
        this.validate = null;
+       this.styleHeight = null;
 
        // Clone for resizing
        if ( this.autosize ) {
@@ -184,6 +185,12 @@
  * Not emitted if the input is multiline.
  *
  * @event enter
+ */
+
+/**
+ * A `resize` event is emitted when autosize is set and the widget resizes
+ *
+ * @event resize
  */
 
 /* Methods */
@@ -375,9 +382,10 @@
  * This only affects #multiline inputs that are {@link #autosize autosized}.
  *
  * @chainable
+ * @fires resize
  */
 OO.ui.TextInputWidget.prototype.adjustSize = function () {
-       var scrollHeight, innerHeight, outerHeight, maxInnerHeight, 
measurementError, idealHeight;
+       var scrollHeight, innerHeight, outerHeight, maxInnerHeight, 
measurementError, idealHeight, newHeight;
 
        if ( this.multiline && this.autosize && this.$input.val() !== 
this.valCache ) {
                this.$clone
@@ -412,11 +420,12 @@
                this.$clone.addClass( 'oo-ui-element-hidden' );
 
                // Only apply inline height when expansion beyond natural 
height is needed
-               if ( idealHeight > innerHeight ) {
-                       // Use the difference between the inner and outer 
height as a buffer
-                       this.$input.css( 'height', idealHeight + ( outerHeight 
- innerHeight ) );
-               } else {
-                       this.$input.css( 'height', '' );
+               // Use the difference between the inner and outer height as a 
buffer
+               newHeight = idealHeight > innerHeight ? idealHeight + ( 
outerHeight - innerHeight ) : '';
+               if ( newHeight !== this.styleHeight ) {
+                       this.$input.css( 'height', newHeight );
+                       this.styleHeight = newHeight;
+                       this.emit( 'resize' );
                }
        }
        return this;

-- 
To view, visit https://gerrit.wikimedia.org/r/247860
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iaadaf1f9ffe9474d2e7bf2dedd1a0ac910dbaa55
Gerrit-PatchSet: 1
Gerrit-Project: oojs/ui
Gerrit-Branch: master
Gerrit-Owner: Esanders <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to