Browse Source

Fixes #528 Fixes modal to resize page if not enough room to fit modal

pull/656/head
jlukic 10 years ago
parent
commit
39b04e696c
1 changed files with 23 additions and 0 deletions
  1. 23
      src/modules/modal.js

23
src/modules/modal.js

@ -16,6 +16,7 @@ $.fn.modal = function(parameters) {
$allModules = $(this),
$window = $(window),
$document = $(document),
$body = $('body'),
time = new Date().getTime(),
performance = [],
@ -127,6 +128,7 @@ $.fn.modal = function(parameters) {
refresh: function() {
module.remove.scrolling();
module.cacheSizes();
module.set.screenHeight();
module.set.type();
module.set.position();
},
@ -239,6 +241,7 @@ $.fn.modal = function(parameters) {
if( !module.is.active() ) {
module.cacheSizes();
module.set.position();
module.set.screenHeight();
module.set.type();
if( $otherModals.filter(':visible').size() > 0 && !settings.allowMultiple) {
@ -309,6 +312,7 @@ $.fn.modal = function(parameters) {
$module
.transition('reset')
;
module.remove.screenHeight();
}
module.remove.active();
});
@ -402,6 +406,14 @@ $.fn.modal = function(parameters) {
active: function() {
$module.removeClass(className.active);
},
screenHeight: function() {
if(module.cache.height > module.cache.pageHeight) {
module.debug('Removing page height');
$body
.css('height', '')
;
}
},
keyboardShortcuts: function() {
module.verbose('Removing keyboard shortcuts');
$document
@ -416,6 +428,7 @@ $.fn.modal = function(parameters) {
cacheSizes: function() {
module.cache = {
pageHeight : $body.outerHeight(),
height : $module.outerHeight() + settings.offset + parseInt($module.css('marginTop'), 10),
contextHeight : (settings.context == 'body')
? $(window).height()
@ -441,6 +454,14 @@ $.fn.modal = function(parameters) {
},
set: {
screenHeight: function() {
if(module.cache.height > module.cache.pageHeight) {
module.debug('Modal is taller than page content, resizing page height');
$body
.css('height', module.cache.height + settings.padding)
;
}
},
active: function() {
module.add.keyboardShortcuts();
module.save.focus();
@ -683,6 +704,8 @@ $.fn.modal.settings = {
offset : 0,
transition : 'scale',
padding : 30,
onShow : function(){},
onHide : function(){},
onApprove : function(){ return true; },

Loading…
Cancel
Save