Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Scale WYMeditor when the window size changes
function scaleEditor(wym) {
var min_width = 675;
var max_width = 850;
var min_height = 300;
var max_height = 600;
var width = $(window).width() - 50;
width = Math.max(width, min_width);
width = Math.min(width, max_width);
var height = $(window).height() - 200;
height = Math.max(height, min_height);
height = Math.min(height, max_height);
$(wym._box).css('width', width);
$(wym._iframe).css('height', height);
}
// Initialize the editor
$('#wymeditor').wymeditor(
postInit: function(wym) {
scaleEditor(wym);
$(window).resize(function() { scaleEditor(wym) });
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment