FIXED: [http://api.jquery.com/innerWidth/ innerWidth()] and [http://api.jquery.com/innerHeight/ innerHeight()] are not applicable to window and document objects.

In a theme with `body { position:relative; }`, the following JS error has occurred in jQuery 1.6.2 or earlier.

{{{
Uncaught TypeError: Cannot read property 'defaultView' of undefined (jquery.js)
}}}
This commit is contained in:
attosoft committed 2012-07-17 03:48:36 +00:00
1 parent c6b04e20f3
commit ba540c1390
2 files changed
+4 -4

No files matched your search

+3 -3
View File
@@ -688,13 +688,13 @@ function tb_position() {
// workaround for "body { position: relative; }" style
if (jQuery("body").css("position") == "relative") {
if (!isIE6) {
var top = parseInt((jQuery(window).innerHeight() - height) / 2, 10);
var top = parseInt((window.innerHeight - height) / 2, 10);
if (jQuery("#TB_window").css("position") == "absolute")
top += jQuery(document).scrollTop();
jQuery("#TB_window").css({marginTop: '', top: top + 'px'});
} else {
marginLeft = parseInt((jQuery(window).innerWidth() - width) / 2, 10) + jQuery(document).scrollLeft();
marginTop = parseInt((jQuery(window).innerHeight() - height) / 2, 10) + jQuery(document).scrollTop();
marginLeft = parseInt((window.innerWidth - width) / 2, 10) + jQuery(document).scrollLeft();
marginTop = parseInt((window.innerHeight - height) / 2, 10) + jQuery(document).scrollTop();
jQuery("#TB_window").css({marginLeft: marginLeft + 'px', marginTop: marginTop + 'px', top: '0', left: '0'});
}
}
+1 -1
View File
@@ -39,7 +39,7 @@ borderRadius:0}).after("<div id='TB_ajaxContentMarginTop'></div>"),jQuery("#TB_a
function tb_remove(){tb_effectView(tb_options.effect_close,!1);var a=function(){jQuery("#TB_window,#TB_overlay,#TB_HideSelect").trigger("tb_unload").unbind().remove();"undefined"==typeof document.body.style.maxHeight&&(jQuery("body","html").css({height:"auto",width:"auto"}),jQuery("html").css("overflow",""))};switch(tb_options.effect_close){case "zoom":jQuery("#TB_Image").hide(tb_options.effect_speed);jQuery("#TB_window").hide(tb_options.effect_speed,a);break;case "slide":jQuery("#TB_window").slideUp(tb_options.effect_speed,
a);break;case "fade":jQuery("#TB_window").fadeOut(tb_options.effect_speed,a);break;default:a()}jQuery("#TB_load").remove();jQuery(document).unbind(".thickbox");return!1}
function tb_position(){var a=TB_WIDTH+jQuery("#TB_window").outerWidth()-jQuery("#TB_window").width(),c=TB_HEIGHT+jQuery("#TB_window").outerHeight()-jQuery("#TB_window").height(),b=-parseInt(a/2,10),d=-parseInt(c/2,10),e="undefined"===typeof document.body.style.maxHeight;!e&&"absolute"==jQuery("#TB_window").css("position")&&(b+=jQuery(document).scrollLeft(),d+=jQuery(document).scrollTop());jQuery("#TB_window").css({marginLeft:b+"px",width:TB_WIDTH+"px"});e||jQuery("#TB_window").css({marginTop:d+"px"});
"relative"==jQuery("body").css("position")&&(e?(b=parseInt((jQuery(window).innerWidth()-a)/2,10)+jQuery(document).scrollLeft(),d=parseInt((jQuery(window).innerHeight()-c)/2,10)+jQuery(document).scrollTop(),jQuery("#TB_window").css({marginLeft:b+"px",marginTop:d+"px",top:"0",left:"0"})):(a=parseInt((jQuery(window).innerHeight()-c)/2,10),"absolute"==jQuery("#TB_window").css("position")&&(a+=jQuery(document).scrollTop()),jQuery("#TB_window").css({marginTop:"",top:a+"px"})))}
"relative"==jQuery("body").css("position")&&(e?(b=parseInt((window.innerWidth-a)/2,10)+jQuery(document).scrollLeft(),d=parseInt((window.innerHeight-c)/2,10)+jQuery(document).scrollTop(),jQuery("#TB_window").css({marginLeft:b+"px",marginTop:d+"px",top:"0",left:"0"})):(a=parseInt((window.innerHeight-c)/2,10),"absolute"==jQuery("#TB_window").css("position")&&(a+=jQuery(document).scrollTop()),jQuery("#TB_window").css({marginTop:"",top:a+"px"})))}
function tb_parseQuery(a){var c={};if(!a)return c;for(var a=a.substring(a.indexOf("?")+1),a=a.split(/[;&]/),b=0;b<a.length;b++){var d=a[b].split("=");if(d&&2==d.length){var e=unescape(d[0]),d=unescape(d[1]),d=d.replace(/\+/g," ");c[e]=d}}return c}function tb_getPageSize(){var a=document.documentElement;return arrayPageSize=[window.innerWidth||self.innerWidth||a&&a.clientWidth||document.body.clientWidth,window.innerHeight||self.innerHeight||a&&a.clientHeight||document.body.clientHeight]}
function tb_detectMacXFF(){var a=navigator.userAgent.toLowerCase();if(-1!=a.indexOf("mac")&&-1!=a.indexOf("firefox"))return!0}function tb_move(a,c){if("image"==c){if(jQuery(a.target).parent().is("#TB_prev, #TB_next, #TB_closeWindowButton"))return!0}else if(!jQuery(a.target).closest("#TB_title").length||jQuery(a.target).parent().is("#TB_closeWindowButton"))return!0;return tb_drag(a,c,"move")}
function tb_resize(a,c){var b;switch(a.target.id){case "TB_ResizeN":b="n-resize";break;case "TB_ResizeE":b="e-resize";break;case "TB_ResizeW":b="w-resize";break;case "TB_ResizeS":b="s-resize";break;case "TB_ResizeNE":b="ne-resize";break;case "TB_ResizeNW":b="nw-resize";break;case "TB_ResizeSE":b="se-resize";break;case "TB_ResizeSW":b="sw-resize";break;default:return!0}return tb_drag(a,c,b)}