Skip to content

Instantly share code, notes, and snippets.

@jmav
Created December 10, 2011 11:24
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jmav/1454952 to your computer and use it in GitHub Desktop.
Save jmav/1454952 to your computer and use it in GitHub Desktop.
Resize jQuery UI dialog to window size if init dialog size is larger then window size.
(function ($) {
var _init = $.ui.dialog.prototype._init;
//Custom Dialog Init
$.ui.dialog.prototype._init = function () {
var self = this;
// set max size of dialog
var offSet = 20;
var wWidth = $(window).width() - offSet;
var wHeight = $(window).height() - offSet;
if(self.options.height > wHeight ){
self.options.height = wHeight ;
self.options.maxHeight = wHeight ;
};
if(self.options.width >= wWidth){
self.options.width = wWidth ;
self.options.maxWidth = wWidth ;
};
_init.apply(this, arguments);
};
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment