Created
January 18, 2013 21:39
-
-
Save winhamwr/4568858 to your computer and use it in GitHub Desktop.
Scale WYMeditor when the window size changes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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