Rillke has uploaded a new change for review.

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


Change subject: Make jquery.autosize aware of style changes
......................................................................

Make jquery.autosize aware of style changes

The jquery.autosize plug-in is used to dynamically expand or shrink the
textarea while translating. Once it is initialized for a textarea, and
if no other textarea is edited in-between, it will not copy all styles
again to its hidden mirror-textarea that is used to compute the required
size of the textarea for performance reasons.

This works fine as long as the explicit and inherited styles of a
textarea do not change. But if they do, the plug-in gets it wrong and
consequently applies a wrong size. This is a serious issue if the
textarea is smaller than its content because the plug-in also sets
overflow to hidden.

In the screenshot provided as attachment #3 in bug 48817, the font size
is 16px in the visible textarea and 13px in the mirror due to this
issue.

This is a slightly modified approach of
29880d5b55c3f6b0c4cc564b7b92bc131a568481

Doing
 $( 'textarea' ).trigger( 'autosize' );
is now sufficient and does both: Resetting the mirror-textarea and
resizing the set of textareas it was called on.

Bug: 48817
Change-Id: I9049e8479c8a77d42cdd6d8c6909a30da8005f3c
---
M resources/js/jquery.autosize.js
1 file changed, 8 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Translate 
refs/changes/82/76482/1

diff --git a/resources/js/jquery.autosize.js b/resources/js/jquery.autosize.js
index f90e81c..c5a313e 100644
--- a/resources/js/jquery.autosize.js
+++ b/resources/js/jquery.autosize.js
@@ -48,6 +48,13 @@
        }
        mirror.style.lineHeight = '';
 
+       // Call this function if you made changes to the textareas
+       // or to the DOM-tree affecting the textareas after calling
+       // .autosize() on them
+       $.autosizeResetMirror = function() {
+               mirrored = null;
+       };
+
        $.fn.autosize = function (options) {
                options = $.extend({}, defaults, options || {});
 
@@ -181,6 +188,7 @@
 
                        // Allow for manual triggering if needed.
                        $ta.on('autosize', function(){
+                               $.autosizeResetMirror();
                                active = false;
                                adjust();
                        });

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I9049e8479c8a77d42cdd6d8c6909a30da8005f3c
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Translate
Gerrit-Branch: master
Gerrit-Owner: Rillke <[email protected]>

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

Reply via email to