Santhosh has uploaded a new change for review. https://gerrit.wikimedia.org/r/57712
Change subject: Better adapt textarea to content ...................................................................... Better adapt textarea to content grow when the user opens an existing translation that is larger than the textarea. Bug: 45430 Change-Id: I0eaa1b7f63dfdda9c7f061468a41f690012e1369 --- M resources/js/ext.translate.editor.js 1 file changed, 19 insertions(+), 14 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Translate refs/changes/12/57712/1 diff --git a/resources/js/ext.translate.editor.js b/resources/js/ext.translate.editor.js index 972c715..0912aeb 100644 --- a/resources/js/ext.translate.editor.js +++ b/resources/js/ext.translate.editor.js @@ -365,14 +365,7 @@ translateEditor.dirty = true; mw.translate.dirty = true; - // Expand the text area height as content grows - while ( $this.outerHeight() < - this.scrollHeight + - parseFloat( $this.css( 'borderTopWidth' ) ) + - parseFloat( $this.css( 'borderBottomWidth' ) ) - ) { - $this.height( $this.height() + parseFloat( $this.css( 'fontSize' ) ) ); - } + adjustSize( $this ); } ); $textArea.on( 'input propertychange', function () { @@ -727,12 +720,13 @@ }, show: function () { - var $next; + var $next, $textarea; if ( !this.$editor ) { this.init(); } + $textarea = this.$editor.find( 'textarea' ); // Hide all other open editors in the page $( '.tux-message.open' ).each( function () { $( this ).data( 'translateeditor' ).hide(); @@ -744,11 +738,9 @@ this.$editor.find( '.tux-editor-skip-button' ).attr( 'accesskey', 'd' ); this.$messageItem.addClass( 'hide' ); - this.$editor - .removeClass( 'hide' ) - .find( 'textarea' ) - .focus(); - + this.$editor.removeClass( 'hide' ); + $textarea.focus(); + adjustSize( $textarea ); this.shown = true; this.$editTrigger.addClass( 'open' ); @@ -882,6 +874,19 @@ $.fn.translateeditor.Constructor = TranslateEditor; + /* + * Expand the text area height as content grows + */ + function adjustSize( $textarea ) { + while ( $textarea.outerHeight() < + ( $textarea.prop( 'scrollHeight' ) + + parseFloat( $textarea.css( 'borderTopWidth' ) ) + + parseFloat( $textarea.css( 'borderBottomWidth' ) ) ) + ) { + $textarea.height( $textarea.height() + parseFloat( $textarea.css( 'fontSize' ) ) ); + } + } + var delay = ( function () { var timer = 0; -- To view, visit https://gerrit.wikimedia.org/r/57712 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I0eaa1b7f63dfdda9c7f061468a41f690012e1369 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Translate Gerrit-Branch: master Gerrit-Owner: Santhosh <santhosh.thottin...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits