Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
MDL-42684 TinyMCE: Correct widths on screens with narrow fieldsets
  • Loading branch information
jsnfwlr authored and Damyon Wiese committed Nov 12, 2013
1 parent b8a598a commit 0b11609
Showing 1 changed file with 24 additions and 17 deletions.
41 changes: 24 additions & 17 deletions lib/editor/tinymce/plugins/pdw/tinymce/editor_plugin.js
Expand Up @@ -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');
}

},
Expand All @@ -205,3 +211,4 @@
// Register plugin
tinymce.PluginManager.add('pdw', tinymce.plugins.pdw);
})();

0 comments on commit 0b11609

Please sign in to comment.