Skip to content

Commit

Permalink
1.4.2 updates
Browse files Browse the repository at this point in the history
  • Loading branch information
ericmmartin committed Oct 6, 2011
1 parent 4d0dce8 commit 26a811b
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 37 deletions.
7 changes: 7 additions & 0 deletions ChangeLog.txt
@@ -1,5 +1,12 @@
==== SimpleModal ChangeLog ====

== 1.4.2 ==
* Date: October 06, 2011
* Added a new 'fixed' option for fixed or absolute positioning
* Changed overlay to use the document dimensions instead of window
* Removed opera work-around for close() that was causing issues


== 1.4.1 ==
* Date: November 04, 2010
* Resolved the container height issue in IE6 & IE7 with jQuery 1.4.3
Expand Down
76 changes: 40 additions & 36 deletions src/jquery.simplemodal.js
@@ -1,7 +1,7 @@
/*
* SimpleModal @VERSION - jQuery Plugin
* http://www.ericmmartin.com/projects/simplemodal/
* Copyright (c) 2010 Eric Martin (http://twitter.com/ericmmartin)
* Copyright (c) 2011 Eric Martin (http://twitter.com/ericmmartin)
* Dual licensed under the MIT and GPL licenses
* Date:
*/
Expand Down Expand Up @@ -47,11 +47,11 @@
* overlayCss, containerCss, and dataCss options.
*
* SimpleModal has been tested in the following browsers:
* - IE 6-9
* - Firefox 2-4
* - Opera 9, 10
* - Safari 3-5
* - Chrome 1-6
* - IE 6+
* - Firefox 2+
* - Opera 9+
* - Safari 3+
* - Chrome 1+
*
* @name SimpleModal
* @type jQuery
Expand All @@ -61,9 +61,12 @@
* @version @VERSION
*/
;(function ($) {
var ie6 = $.browser.msie && parseInt($.browser.version) === 6 && typeof window['XMLHttpRequest'] !== 'object',
var d = [],
doc = $(document),
ie6 = $.browser.msie && parseInt($.browser.version) === 6 && typeof window['XMLHttpRequest'] !== 'object',
ie7 = $.browser.msie && parseInt($.browser.version) === 7,
ieQuirks = null,
wndw = $(window),
w = [];

/*
Expand Down Expand Up @@ -153,6 +156,8 @@
* closeClass: (String:'simplemodal-close') The CSS class used to bind to the close event
* escClose: (Boolean:true) Allow Esc keypress to close the dialog?
* overlayClose: (Boolean:false) Allow click on overlay to close the dialog?
* fixed: (Boolean:true) If true, the container will use a fixed position. If false, it will use a
absolute position (the dialog will scroll with the page)
* position: (Array:null) Position of container [top, left]. Can be number of pixels or percentage
* persist: (Boolean:false) Persist the data across modal calls? Only used for existing
DOM elements. If true, the data will be maintained across modal calls, if false,
Expand Down Expand Up @@ -186,6 +191,7 @@
closeClass: 'simplemodal-close',
escClose: true,
overlayClose: false,
fixed: true,
position: null,
persist: false,
modal: true,
Expand Down Expand Up @@ -280,7 +286,7 @@
var s = this;

// get the window properties
w = s.getDimensions();
s.getDimensions();

// add an iframe to prevent select options from bleeding through
if (s.o.modal && ie6) {
Expand All @@ -305,8 +311,8 @@
.css($.extend(s.o.overlayCss, {
display: 'none',
opacity: s.o.opacity / 100,
height: s.o.modal ? w[0] : 0,
width: s.o.modal ? w[1] : 0,
height: s.o.modal ? d[0] : 0,
width: s.o.modal ? d[1] : 0,
position: 'fixed',
left: 0,
top: 0,
Expand All @@ -318,11 +324,11 @@
s.d.container = $('<div></div>')
.attr('id', s.o.containerId)
.addClass('simplemodal-container')
.css($.extend(s.o.containerCss, {
display: 'none',
position: 'fixed',
zIndex: s.o.zIndex + 2
}))
.css($.extend(
{position: s.o.fixed ? 'fixed' : 'absolute'},
s.o.containerCss,
{display: 'none', zIndex: s.o.zIndex + 2}
))
.append(s.o.close && s.o.closeHTML
? $(s.o.closeHTML).addClass(s.o.closeClass)
: '')
Expand Down Expand Up @@ -374,7 +380,7 @@
}

// bind keydown events
$(document).bind('keydown.simplemodal', function (e) {
doc.bind('keydown.simplemodal', function (e) {
if (s.o.modal && e.keyCode === 9) { // TAB
s.watchTab(e);
}
Expand All @@ -385,9 +391,9 @@
});

// update window size
$(window).bind('resize.simplemodal', function () {
wndw.bind('resize.simplemodal orientationchange.simplemodal', function () {
// redetermine the window width/height
w = s.getDimensions();
s.getDimensions();

// reposition the dialog
s.o.autoResize ? s.setContainerDimensions() : s.o.autoPosition && s.setPosition();
Expand All @@ -398,7 +404,7 @@
else if (s.o.modal) {
// update the iframe & overlay
s.d.iframe && s.d.iframe.css({height: w[0], width: w[1]});
s.d.overlay.css({height: w[0], width: w[1]});
s.d.overlay.css({height: d[0], width: d[1]});
}
});
},
Expand All @@ -407,8 +413,8 @@
*/
unbindEvents: function () {
$('.' + this.o.closeClass).unbind('click.simplemodal');
$(document).unbind('keydown.simplemodal');
$(window).unbind('resize.simplemodal');
doc.unbind('keydown.simplemodal');
wndw.unbind('.simplemodal');
this.d.overlay.unbind('click.simplemodal');
},
/*
Expand All @@ -418,7 +424,7 @@
var s = this, p = s.o.position;

// simulate fixed position - adapted from BlockUI
$.each([s.d.iframe || null, !s.o.modal ? null : s.d.overlay, s.d.container], function (i, el) {
$.each([s.d.iframe || null, !s.o.modal ? null : s.d.overlay, s.d.container.css('position') === 'fixed' ? s.d.container : null], function (i, el) {
if (el) {
var bch = 'document.body.clientHeight', bcw = 'document.body.clientWidth',
bsh = 'document.body.scrollHeight', bsl = 'document.body.scrollLeft',
Expand Down Expand Up @@ -476,14 +482,14 @@
}, 10);
},
getDimensions: function () {
var el = $(window);

// fix a jQuery/Opera bug with determining the window height
var h = $.browser.opera && $.browser.version > '9.5' && $.fn.jquery < '1.3'
var s = this,
h = $.browser.opera && $.browser.version > '9.5' && $.fn.jquery < '1.3'
|| $.browser.opera && $.browser.version < '9.5' && $.fn.jquery > '1.2.6'
? el[0].innerHeight : el.height();
? wndw[0].innerHeight : wndw.height();

return [h, el.width()];
d = [doc.height(), doc.width()];
w = [h, wndw.width()];
},
getVal: function (v, d) {
return v ? (typeof v === 'number' ? v
Expand Down Expand Up @@ -573,13 +579,14 @@
setPosition: function () {
var s = this, top, left,
hc = (w[0]/2) - (s.d.container.outerHeight(true)/2),
vc = (w[1]/2) - (s.d.container.outerWidth(true)/2);
vc = (w[1]/2) - (s.d.container.outerWidth(true)/2),
st = s.d.container.css('position') !== 'fixed' ? wndw.scrollTop() : 0;

if (s.o.position && Object.prototype.toString.call(s.o.position) === '[object Array]') {
top = s.o.position[0] || hc;
top = st + (s.o.position[0] || hc);
left = s.o.position[1] || vc;
} else {
top = hc;
top = st + hc;
left = vc;
}
s.d.container.css({left: left, top: top});
Expand Down Expand Up @@ -685,13 +692,10 @@
s.d.container.hide().remove();
s.d.overlay.hide();
s.d.iframe && s.d.iframe.hide().remove();
setTimeout(function(){
// opera work-around
s.d.overlay.remove();
s.d.overlay.remove();

// reset the dialog object
s.d = {};
}, 10);
// reset the dialog object
s.d = {};
}
}
};
Expand Down
2 changes: 1 addition & 1 deletion version.txt
@@ -1 +1 @@
1.4.1
1.4.2

0 comments on commit 26a811b

Please sign in to comment.