Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Bug fix. Parent window scroll bar problem when more than one Modal wa…

…s open.
  • Loading branch information...
commit 0e3da039b40a45e6c4d1a4439bff9c8560fe950d 1 parent 2cd49f6
@cootetom authored
Showing with 9 additions and 11 deletions.
  1. +6 −4 SimpleModal.js
  2. +3 −7 SimpleModal.min.js
View
10 SimpleModal.js
@@ -56,10 +56,12 @@ var SimpleModal = function() {
}
// prevent parent from scrolling whilst pop up is overlayed on top
- var overflow = $(document.body).css('overflow').toLowerCase() || 'visible';
- $(document.body).data('simpleModalOverflow', overflow);
- $(document.body).css('overflow', 'hidden');
-
+ if ($('._simpleModalMask').length < 1) {
+ var overflow = $(document.body).css('overflow').toLowerCase() || 'visible';
+ $(document.body).data('simpleModalOverflow', overflow);
+ $(document.body).css('overflow', 'hidden');
+ }
+
var mask = document.createElement('div'),
eDiv = document.createElement('div');
View
10 SimpleModal.min.js
@@ -1,12 +1,8 @@
-/**
- * @name SimpleModal
- * @author Tom Coote (tomcoote.co.uk)
- * @version 2.0
- * @license released under the BSD (3-clause) licences
- */
+
var topWin=window;var SimpleModal=function(){var that={};that.open=function(url,height,width,callback){if(!window.SimpleModal.isController){if(typeof topWin.SimpleModal!=='object'){alert('Simple modals need the JavaScript available in the modal window itself.');}else{return topWin.SimpleModal.open(url,height,width,callback);}}
if(jQuery.browser.msie){$('select').css('visibility','hidden');}
-var overflow=$(document.body).css('overflow').toLowerCase()||'visible';$(document.body).data('simpleModalOverflow',overflow);$(document.body).css('overflow','hidden');var mask=document.createElement('div'),eDiv=document.createElement('div');$(document.body).append(mask).append(eDiv);$(mask).addClass('_simpleModalMask').css({'position':'absolute','top':'0px','left':'0px','width':$(document).width()+'px','height':$(document).height()+'px','margin':'0px','padding':'0px','background-color':'#FFFFFF','opacity':0.8,'overflow':'hidden'});$(eDiv).addClass('_simpleModal').css({'height':height+'px','width':width+'px','padding':'0px','margin':'0px','border':'1px solid #ccc','position':'absolute','background-color':'#FFF','left':(($(window).width()/2)-(width/2))+$(document).scrollLeft()+'px','top':(($(window).height()/2)-(height/2))+$(document).scrollTop()+'px'}).append("<iframe frameborder='0' scrolling='no'></iframe>");$('iframe:first',eDiv).attr('src',url).css({'height':'100%','width':'100%','background-color':'#FFF','border':'none','overflow':'hidden'});that.callbacks.push(callback);return false;};that.close=function(data){if(!window.SimpleModal.isController){if(typeof topWin.SimpleModal!=='object'){alert('Simple modals need the JavaScript available in the top window.');}else{return topWin.SimpleModal.close(data);}}
+if($('._simpleModalMask').length<1){var overflow=$(document.body).css('overflow').toLowerCase()||'visible';$(document.body).data('simpleModalOverflow',overflow);$(document.body).css('overflow','hidden');}
+var mask=document.createElement('div'),eDiv=document.createElement('div');$(document.body).append(mask).append(eDiv);$(mask).addClass('_simpleModalMask').css({'position':'absolute','top':'0px','left':'0px','width':$(document).width()+'px','height':$(document).height()+'px','margin':'0px','padding':'0px','background-color':'#FFFFFF','opacity':0.8,'overflow':'hidden'});$(eDiv).addClass('_simpleModal').css({'height':height+'px','width':width+'px','padding':'0px','margin':'0px','border':'1px solid #ccc','position':'absolute','background-color':'#FFF','left':(($(window).width()/2)-(width/2))+$(document).scrollLeft()+'px','top':(($(window).height()/2)-(height/2))+$(document).scrollTop()+'px'}).append("<iframe frameborder='0' scrolling='no'></iframe>");$('iframe:first',eDiv).attr('src',url).css({'height':'100%','width':'100%','background-color':'#FFF','border':'none','overflow':'hidden'});that.callbacks.push(callback);return false;};that.close=function(data){if(!window.SimpleModal.isController){if(typeof topWin.SimpleModal!=='object'){alert('Simple modals need the JavaScript available in the top window.');}else{return topWin.SimpleModal.close(data);}}
$('div._simpleModal:last').remove();$('div._simpleModalMask:last').remove();if($('div._simpleModal').length<1){if(jQuery.browser.msie){$('select').css('visibility','visible');}
var overflow=$(document.body).data('simpleModalOverflow');if(overflow){$(document.body).css('overflow',overflow);}}
if(that.callbacks.length>0){var fn=that.callbacks.pop();if(typeof fn==='function'){fn(data);}}
Please sign in to comment.
Something went wrong with that request. Please try again.