From 1607ead74d1094efe2279aa2ec31c2d226bb412e Mon Sep 17 00:00:00 2001 From: Andrew Nicols Date: Thu, 24 Oct 2013 11:11:11 +0800 Subject: [PATCH] MDL-42481 Editor: Temporarily unhide the editor to calculate its size --- .../tinymce/plugins/pdw/readme_moodle.txt | 1 + .../plugins/pdw/tinymce/editor_plugin.js | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/lib/editor/tinymce/plugins/pdw/readme_moodle.txt b/lib/editor/tinymce/plugins/pdw/readme_moodle.txt index cf2fcb0a783..17f75168cd9 100644 --- a/lib/editor/tinymce/plugins/pdw/readme_moodle.txt +++ b/lib/editor/tinymce/plugins/pdw/readme_moodle.txt @@ -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 diff --git a/lib/editor/tinymce/plugins/pdw/tinymce/editor_plugin.js b/lib/editor/tinymce/plugins/pdw/tinymce/editor_plugin.js index 869114775f5..22e42b796ba 100644 --- a/lib/editor/tinymce/plugins/pdw/tinymce/editor_plugin.js +++ b/lib/editor/tinymce/plugins/pdw/tinymce/editor_plugin.js @@ -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'); + } } + }, /**