Item11541: Resizing EditBox broken: enlarges a lot, shrink doesn't work
Priority: Urgent
Current State: Closed
Released In: 1.1.5
Target Release: patch
Applies To: Engine
Component:
Branches: Release01x01 trunk
For some reason, the "Enlarge edit box" / "Shrink edit box" icons stopped working correctly. Enlarge would make the edit box
a lot bigger, while Shrink is unable to make it smaller again. This behaviour is consistent accross Firefox 10.0.2 and Opera 11.61, but unfortunately I'm unable to say since when.
Investigating the issue, it turns out that instead of (mathematically) adding or substracting 4 from the amount of rows, a "4" or "-1" is string-concatenated to the rows value. That is, after hitting Enlarge twice and then Shrink twice, the HTML says: rows="2244-4-4"
Looking at pub/System/JavascriptFiles/foswiki_edit_src.js, it seems that rowCount is a String now, and needs to be converted to an int in order to work properly again. The following patch has been tested, works, and shouldn't have any side-effects (yet I don't know how to properly generate the minified and gzipped versions, so would like to leave the checkin to somebody else).
--- a/pub/System/JavascriptFiles/foswiki_edit_src.js
+++ b/pub/System/JavascriptFiles/foswiki_edit_src.js
@@ -95,6 +95,7 @@ var EDITBOX_FONTSTYLE_PROPORTIONAL_STYLE = "foswikiEditboxStyleProportional";
*/
foswiki.Edit.changeEditBox = function(inDirection) {
var rowCount = $('#' + EDITBOX_ID).attr('rows');
+ rowCount = parseInt(rowCount);
rowCount += (inDirection * EDITBOX_CHANGE_STEP_SIZE);
rowCount = (rowCount < EDITBOX_MIN_ROWCOUNT)
? EDITBOX_MIN_ROWCOUNT : rowCount;
--
FlorianSchlichting - 20 Feb 2012
Fixed in Release01x01 and trunk. Thanks, Florian!
--
CrawfordCurrie - 20 Feb 2012