Rillke has uploaded a new change for review.

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


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.

Bug: 48817
Change-Id: I9c4b2c928b181e4f3bac7a57109032c1d48b511f
---
M resources/js/ext.translate.editor.js
M resources/js/jquery.autosize.js
2 files changed, 10 insertions(+), 1 deletion(-)


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

diff --git a/resources/js/ext.translate.editor.js 
b/resources/js/ext.translate.editor.js
index bb42dee..88f135b 100644
--- a/resources/js/ext.translate.editor.js
+++ b/resources/js/ext.translate.editor.js
@@ -857,7 +857,10 @@
                        // layout of the text area after this function. Use 
very small
                        // delay to have it settle down and have correct 
results. Otherwise
                        // there will be a size change once the first letter is 
typed.
+                       // Calling resetAutosizeMirror makes sure that all 
style changes 
+                       // of the textarea are respected by the plugin
                        delay( function() {
+                               $.resetAutosizeMirror();
                                $textarea.trigger( 'autosize' );
                        }, 1 );
 
diff --git a/resources/js/jquery.autosize.js b/resources/js/jquery.autosize.js
index f90e81c..89734ec 100644
--- a/resources/js/jquery.autosize.js
+++ b/resources/js/jquery.autosize.js
@@ -189,4 +189,10 @@
                        adjust();
                });
        };
-}(window.jQuery || window.Zepto));
+       // Call this function if you made changes to the textareas
+       // or to the DOM-tree affection the textareas after calling
+       // .autosize() on them
+       $.resetAutosizeMirror = function(){
+               mirrored = null;
+       };
+}(window.jQuery));

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

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

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

Reply via email to