Skip to content

Instantly share code, notes, and snippets.

@winhamwr
Created January 18, 2013 21:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save winhamwr/4568858 to your computer and use it in GitHub Desktop.
Save winhamwr/4568858 to your computer and use it in GitHub Desktop.
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