diff --git a/lib/editor/tinymce/plugins/pdw/tinymce/editor_plugin.js b/lib/editor/tinymce/plugins/pdw/tinymce/editor_plugin.js index bd42cc0772555..90d5681e29243 100644 --- a/lib/editor/tinymce/plugins/pdw/tinymce/editor_plugin.js +++ b/lib/editor/tinymce/plugins/pdw/tinymce/editor_plugin.js @@ -156,31 +156,37 @@ _resizeIframe : function(ed, tb_id, dy) { var ifr = ed.getContentAreaContainer().firstChild; var ultcon = ed.getContainer().parentNode; //Ultimate parent container + var parcon = ed.getContainer(); //Parent container + var tablecon = ed.getContainer().childNodes[1]; // Table container var textarea = DOM.get(ed.id); var rows = textarea ? textarea.getAttribute('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'); + } // 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(textarea, 'width',DOM.getSize(ultcon).w); - DOM.setStyle(ifr, 'width',DOM.getSize(ultcon).w); // Resize iframe ed.theme.deltaHeight += dy; // For resize cookie + } - if (collapsedContainer) { - // We have a collapsedContainer, so collapse it again. - DOM.addClass(collapsedContainer, 'collapsed'); - } + // Set all the containers to the same width + DOM.setStyle(textarea, 'width',DOM.getSize(ultcon).w); + DOM.setStyle(parcon, 'width',DOM.getSize(ultcon).w); + DOM.setStyle(tablecon, 'width',DOM.getSize(ultcon).w); + DOM.setStyle(ifr, 'width',DOM.getSize(ultcon).w); + + + if (collapsedContainer) { + // We have a collapsedContainer, so collapse it again. + DOM.addClass(collapsedContainer, 'collapsed'); } }, @@ -205,3 +211,4 @@ // Register plugin tinymce.PluginManager.add('pdw', tinymce.plugins.pdw); })(); +