MDL-42481 Editor: Temporarily unhide the editor to calculate its size

This commit is contained in:
Andrew Nicols
2013-10-24 11:11:11 +08:00
parent 34fb3545ea
commit 1607ead74d
2 changed files with 18 additions and 0 deletions
@@ -15,3 +15,4 @@ Upgrade procedure:
5/ reimplement patch in MDL-40668
6/ add in "DOM.setStyle(ifr, 'width',DOM.getSize(ifrcon).w); // Resize iframe" (without quotes)
after "DOM.setStyle(ifr, 'height',DOM.getSize(ifr).h + dy); // Resize iframe"
7/ reimplement patch in MDL-42481
@@ -161,10 +161,27 @@
// For very small text areas - allow the editable region to be smaller than the size of the toolbars.
if (rows >= 3) {
// This set of changes addresses MDL-42481.
// Moodle collapses form sections by setting display to none on the fcontainer element.
// In order to calculate the offsetWidth, the iframe must be visible within the DOM, otherwise it's offsetWidth is
// calculate as 0px.
// We attempt to find any collapsed element, uncollapse them, then calculate the width and height, and finally
// collapse them again.
var collapsedContainer = DOM.getParent(ifr, 'fieldset.collapsed');
if (collapsedContainer) {
DOM.removeClass(collapsedContainer, 'collapsed');
}
DOM.setStyle(ifr, 'height',DOM.getSize(ifr).h + dy); // Resize iframe
DOM.setStyle(ifr, 'width',DOM.getSize(ifrcon).w); // Resize iframe
ed.theme.deltaHeight += dy; // For resize cookie
if (collapsedContainer) {
// We have a collapsedContainer, so collapse it again.
DOM.addClass(collapsedContainer, 'collapsed');
}
}
},
/**