FIXED: Even unused key events are consumed (ThickBox bug). In addition, listens also orientationchange event for iOS that does not trigger resize event sometimes when the orientation is changed.
This commit is contained in:
1 parent
67683f311b
commit
c5633d0e14
3 files changed
+16
-14
No files matched your search
@@ -297,6 +297,7 @@ Modified ThickBox supports multiline (line breaks) in title/caption. The followi
|
||||
* FIXED: Invalid positioning on some mobile browsers such as older iOS (iPhone/iPad/iPod touch) and older Android, caused by not supporting `position:fixed` style.
|
||||
* FIXED: Title/caption bar misaligns by "Resize", "Expand/Shrink" and "Scale" when using "Effect - Title/Caption" option
|
||||
* FIXED: ThickBox window is not displayed in the center of browser due to hovering title when using "Effect - Title" option
|
||||
* FIXED: Even unused key events are consumed (ThickBox bug)
|
||||
* FIXED: Gallery images cannot be displayed in gallery style with [Cleaner Gallery](http://wordpress.org/extend/plugins/cleaner-gallery/)
|
||||
|
||||
= 1.8 =
|
||||
|
||||
+7
-6
@@ -384,8 +384,6 @@ function tb_show(caption, url, imageGroup) {//function called when the user clic
|
||||
}
|
||||
|
||||
jQuery(document).bind('keydown.thickbox', function(e){
|
||||
e.stopImmediatePropagation();
|
||||
|
||||
if ( params['modal'] != 'true' && jQuery.inArray(e.which, tb_options.keys_close) != -1 ){ // close
|
||||
if ( ! jQuery(document).triggerHandler( 'wp_CloseOnEscape', [{ event: e, what: 'thickbox', cb: tb_remove }] ) )
|
||||
tb_remove();
|
||||
@@ -406,7 +404,10 @@ function tb_show(caption, url, imageGroup) {//function called when the user clic
|
||||
if(!(TB_NextHTML == "")){
|
||||
goLast();
|
||||
}
|
||||
} else {
|
||||
return true; // unconsumed key events
|
||||
}
|
||||
e.stopImmediatePropagation();
|
||||
return false;
|
||||
});
|
||||
|
||||
@@ -488,7 +489,7 @@ function tb_show(caption, url, imageGroup) {//function called when the user clic
|
||||
}
|
||||
|
||||
tb_reposition(params);
|
||||
jQuery(window).bind('resize.thickbox', function() { tb_reposition(params); });
|
||||
jQuery(window).bind('resize.thickbox orientationchange.thickbox', function() { tb_reposition(params); });
|
||||
jQuery("#TB_load").remove();
|
||||
if (tb_options.click_img == "close" || (!imageGroup && tb_options.click_end == "close"))
|
||||
jQuery("#TB_ImageOff").click(tb_remove);
|
||||
@@ -551,13 +552,13 @@ function tb_show(caption, url, imageGroup) {//function called when the user clic
|
||||
jQuery('#' + params['inlineId']).append( jQuery("#TB_ajaxContent").children() ); // move elements back when you're finished
|
||||
});
|
||||
tb_reposition_html(url, params);
|
||||
jQuery(window).bind('resize.thickbox', function() { tb_reposition_html(url, params); });
|
||||
jQuery(window).bind('resize.thickbox orientationchange.thickbox', function() { tb_reposition_html(url, params); });
|
||||
jQuery("#TB_load").remove();
|
||||
tb_open();
|
||||
tb_roundCorner("iframe");
|
||||
}else if(url.indexOf('TB_iframe') != -1){
|
||||
tb_reposition_html(url, params);
|
||||
jQuery(window).bind('resize.thickbox', function() { tb_reposition_html(url, params); });
|
||||
jQuery(window).bind('resize.thickbox orientationchange.thickbox', function() { tb_reposition_html(url, params); });
|
||||
if ((!("onload" in jQuery("#TB_iframeContent")[0]) && (typeof jQuery("#TB_iframeContent")[0]["onload"] != "function")) // not support iframe onload - http://kangax.github.com/iseventsupported/
|
||||
|| urlType == '.pdf') { // XXX: Not wait for loading to complete because "onload" event won't triggered in IE and Firefox
|
||||
tb_showIframe();
|
||||
@@ -566,7 +567,7 @@ function tb_show(caption, url, imageGroup) {//function called when the user clic
|
||||
var sign = (url.indexOf('?') == -1) ? '?' : '&';
|
||||
jQuery("#TB_ajaxContent").load(url += sign + "random=" + (new Date().getTime()),function(){//to do a post change this load method
|
||||
tb_reposition_html(url, params);
|
||||
jQuery(window).bind('resize.thickbox', function() { tb_reposition_html(url, params); });
|
||||
jQuery(window).bind('resize.thickbox orientationchange.thickbox', function() { tb_reposition_html(url, params); });
|
||||
jQuery("#TB_load").remove();
|
||||
tb_open();
|
||||
tb_roundCorner("ajax")
|
||||
|
||||
Vendored
+8
-8
@@ -20,19 +20,19 @@ jQuery("#TB_window").remove();jQuery("body").append("<div id='TB_window' class='
|
||||
tb_show(TB_LastCaption,TB_LastURL,b);return!1}}if(b&&"next"==tb_options.click_img){var i,k,l;""!=TB_NextHTML?(i="TB_ImageNext",k=thickboxL10n.next,l=r):"close"==tb_options.click_end?(i="TB_ImageClose",k=thickboxL10n.close,l=tb_remove):"loop"==tb_options.click_end&&""!=TB_PrevHTML&&(i="TB_ImageFirst",k=thickboxL10n.first,l=h);i&&(k&&l)&&(jQuery("#TB_window").append("<div id='TB_ImageClick'><a href='' id='"+i+"' title='"+k+"'><span></span></a></div>"),jQuery("#"+i).click(l))}else if(b&&"prev_next"==
|
||||
tb_options.click_img){var m,p,s;""!=TB_PrevHTML&&(i="TB_ImagePrev",k=thickboxL10n.prev,l=g);""!=TB_NextHTML&&(m="TB_ImageNext",p=thickboxL10n.next,s=r);""==TB_PrevHTML&&("close"==tb_options.click_end?(i="TB_ImageClose",k=thickboxL10n.close,l=tb_remove):"loop"==tb_options.click_end&&""!=TB_NextHTML&&(i="TB_ImageLast",k=thickboxL10n.last,l=t));""==TB_NextHTML&&("close"==tb_options.click_end?(m="TB_ImageClose2",p=thickboxL10n.close,s=tb_remove):"loop"==tb_options.click_end&&""!=TB_PrevHTML&&(m="TB_ImageFirst",
|
||||
p=thickboxL10n.first,s=h));if(i&&k&&l||m&&p&&s)e=link2="",i&&(k&&l)&&(e="<a href='' id='"+i+"' class='TB_ImageLeft' title='"+k+"'></a>"),m&&(p&&s)&&(link2="<a href='' id='"+m+"' class='TB_ImageRight' title='"+p+"'></a>"),jQuery("#TB_window").append("<div id='TB_ImageClick'>"+e+link2+"</div>"),e&&jQuery("#"+i).click(l),link2&&jQuery("#"+m).click(s),jQuery.browser.msie&&7>=parseInt(jQuery.browser.version)&&jQuery("#TB_ImageClick > a").focus(function(){this.blur()})}"download"==tb_options.click_img?
|
||||
jQuery("#TB_window a.download").click(function(){window.location=thickboxL10n.forceDL+"?file="+this.href;return!1}):"expand_shrink"==tb_options.click_img&&jQuery("#TB_window a.scalable").click(function(){tb_fitToWindow?d(imgPreloader.width,imgPreloader.height,thickboxL10n.fit):d(tb_fitWidth,tb_fitHeight,thickboxL10n.actual);tb_fitToWindow=!tb_fitToWindow;return!1});jQuery(document).bind("keydown.thickbox",function(a){a.stopImmediatePropagation();"true"!=f.modal&&-1!=jQuery.inArray(a.which,tb_options.keys_close)?
|
||||
jQuery(document).triggerHandler("wp_CloseOnEscape",[{event:a,what:"thickbox",cb:tb_remove}])||tb_remove():-1!=jQuery.inArray(a.which,tb_options.keys_prev)||a.shiftKey&&-1!=jQuery.inArray(a.which,tb_options.keys_prev.shift)?""!=TB_PrevHTML&&g():-1!=jQuery.inArray(a.which,tb_options.keys_next)?""!=TB_NextHTML&&r():-1!=jQuery.inArray(a.which,tb_options.keys_first)?""!=TB_PrevHTML&&h():-1!=jQuery.inArray(a.which,tb_options.keys_last)&&""!=TB_NextHTML&&t();return!1});b&&"prev_next"==tb_options.wheel_img?
|
||||
jQuery("#TB_window").bind("mousewheel.thickbox DOMMouseScroll.thickbox",function(a){a.stopImmediatePropagation();var b=0,a=a.originalEvent;a.wheelDelta?b=a.wheelDelta:a.detail&&(b=-a.detail);jQuery(window).one("MozMousePixelScroll",function(){return!1});if(0<b){if(""!=TB_PrevHTML)return g(),!1}else if(0>b&&""!=TB_NextHTML)return r(),!1}):"scale"==tb_options.wheel_img?jQuery("#TB_window").bind("mousewheel.thickbox DOMMouseScroll.thickbox",function(a){if(a.ctrlKey)return!0;a.stopImmediatePropagation();
|
||||
jQuery("#TB_window a.download").click(function(){window.location=thickboxL10n.forceDL+"?file="+this.href;return!1}):"expand_shrink"==tb_options.click_img&&jQuery("#TB_window a.scalable").click(function(){tb_fitToWindow?d(imgPreloader.width,imgPreloader.height,thickboxL10n.fit):d(tb_fitWidth,tb_fitHeight,thickboxL10n.actual);tb_fitToWindow=!tb_fitToWindow;return!1});jQuery(document).bind("keydown.thickbox",function(a){if("true"!=f.modal&&-1!=jQuery.inArray(a.which,tb_options.keys_close))jQuery(document).triggerHandler("wp_CloseOnEscape",
|
||||
[{event:a,what:"thickbox",cb:tb_remove}])||tb_remove();else if(-1!=jQuery.inArray(a.which,tb_options.keys_prev)||a.shiftKey&&-1!=jQuery.inArray(a.which,tb_options.keys_prev.shift))""!=TB_PrevHTML&&g();else if(-1!=jQuery.inArray(a.which,tb_options.keys_next))""!=TB_NextHTML&&r();else if(-1!=jQuery.inArray(a.which,tb_options.keys_first))""!=TB_PrevHTML&&h();else if(-1!=jQuery.inArray(a.which,tb_options.keys_last))""!=TB_NextHTML&&t();else return!0;a.stopImmediatePropagation();return!1});b&&"prev_next"==
|
||||
tb_options.wheel_img?jQuery("#TB_window").bind("mousewheel.thickbox DOMMouseScroll.thickbox",function(a){a.stopImmediatePropagation();var b=0,a=a.originalEvent;a.wheelDelta?b=a.wheelDelta:a.detail&&(b=-a.detail);jQuery(window).one("MozMousePixelScroll",function(){return!1});if(0<b){if(""!=TB_PrevHTML)return g(),!1}else if(0>b&&""!=TB_NextHTML)return r(),!1}):"scale"==tb_options.wheel_img?jQuery("#TB_window").bind("mousewheel.thickbox DOMMouseScroll.thickbox",function(a){if(a.ctrlKey)return!0;a.stopImmediatePropagation();
|
||||
var b=0,a=a.originalEvent;a.wheelDelta?b=a.wheelDelta:a.detail&&(b=-a.detail);a=1+(0<b?0.1:-0.1);b=Math.round(jQuery("#TB_Image").width()*a);a=Math.round(jQuery("#TB_Image").height()*a);100<b&&100<a&&d(b,a);return!1}):"none"==tb_options.wheel_img&&jQuery("#TB_window").bind("mousewheel.thickbox DOMMouseScroll.thickbox",function(a){a.stopImmediatePropagation();return!1});"none"==tb_options.wheel_bg&&jQuery("#TB_overlay").bind("mousewheel.thickbox DOMMouseScroll.thickbox",function(a){a.stopImmediatePropagation();
|
||||
return!1});tb_options.move_img&&jQuery("#TB_window").bind("mousedown.thickbox",function(a){return tb_move(a,"image")});tb_options.resize_img&&(tb_resize_init(),jQuery("#TB_Resize").bind("mousedown.thickbox",function(a){return tb_resize(a,"image")}));"none"!=tb_options.effect_cap&&(jQuery("#TB_Image").css("margin",jQuery("#TB_Image").css("marginLeft")),jQuery("#TB_window").bind("mouseenter.thickbox",function(){tb_hover(jQuery("#TB_CaptionBar"),tb_options.effect_cap)}).bind("mouseleave.thickbox",function(){tb_hover(jQuery("#TB_CaptionBar"),
|
||||
tb_options.effect_cap,!0)}));tb_reposition(f);jQuery(window).bind("resize.thickbox",function(){tb_reposition(f)});jQuery("#TB_load").remove();("close"==tb_options.click_img||!b&&"close"==tb_options.click_end)&&jQuery("#TB_ImageOff").click(tb_remove);tb_open()};imgPreloader.src=c}else{var g=c.replace(/^[^\?]+\??/,""),h=tb_parseQuery(g);"object"==typeof a&&(a=tb_caption(a,tb_options.ref_title));TB_Title="<div id='TB_title'><div id='TB_ajaxWindowTitle'>"+a+"</div><div id='TB_closeAjaxWindow'><a href='#' id='TB_closeWindowButton' title='"+
|
||||
tb_options.effect_cap,!0)}));tb_reposition(f);jQuery(window).bind("resize.thickbox orientationchange.thickbox",function(){tb_reposition(f)});jQuery("#TB_load").remove();("close"==tb_options.click_img||!b&&"close"==tb_options.click_end)&&jQuery("#TB_ImageOff").click(tb_remove);tb_open()};imgPreloader.src=c}else{var g=c.replace(/^[^\?]+\??/,""),h=tb_parseQuery(g);"object"==typeof a&&(a=tb_caption(a,tb_options.ref_title));TB_Title="<div id='TB_title'><div id='TB_ajaxWindowTitle'>"+a+"</div><div id='TB_closeAjaxWindow'><a href='#' id='TB_closeWindowButton' title='"+
|
||||
thickboxL10n.close+"'><img src='"+tb_closeImage+"' /></a></div></div>";if(-1!=c.indexOf("TB_iframe"))if(urlNoQuery=c.split(/[?&]TB_/),jQuery("#TB_iframeContent").remove(),TB_Iframe="<iframe frameborder='0' hspace='0' src='"+urlNoQuery[0]+"' id='TB_iframeContent' name='TB_iframeContent"+Math.round(1E3*Math.random())+"' onload='tb_showIframe()'>"+thickboxL10n.noiframes+"</iframe>","true"!=h.modal)switch(tb_options.position_title){case "top":jQuery("#TB_window").append(TB_Title+TB_Iframe).addClass("TB_iframeContent TB_titleTop");
|
||||
break;case "bottom":jQuery("#TB_window").append(TB_Iframe+TB_Title).addClass("TB_iframeContent TB_titleBottom");break;case "none":jQuery("#TB_window").append(TB_Iframe).addClass("TB_iframeContent")}else jQuery("#TB_overlay").unbind(),jQuery("#TB_window").append(TB_Iframe).addClass("TB_iframeContent");else if("block"!=jQuery("#TB_window").css("display"))if(TB_Ajax="<div id='TB_ajaxContent'></div>","true"!=h.modal)switch(tb_options.position_title){case "top":jQuery("#TB_window").append(TB_Title+TB_Ajax).addClass("TB_ajaxContent TB_titleTop");
|
||||
break;case "bottom":jQuery("#TB_window").append(TB_Ajax+TB_Title).addClass("TB_ajaxContent TB_titleBottom");break;case "none":jQuery("#TB_window").append(TB_Ajax).addClass("TB_ajaxContent TB_titleNone")}else jQuery("#TB_overlay").unbind(),jQuery("#TB_window").append(TB_Ajax).addClass("TB_ajaxContent"),jQuery("#TB_ajaxContent").addClass("TB_modal");else jQuery("#TB_ajaxContent")[0].scrollTop=0,jQuery("#TB_ajaxWindowTitle").html(a);jQuery("#TB_closeWindowButton").click(tb_remove);if(-1!=c.indexOf("TB_inline"))jQuery("#TB_ajaxContent").append(jQuery("#"+
|
||||
h.inlineId).children()),jQuery("#TB_window").bind("tb_unload",function(){jQuery("#"+h.inlineId).append(jQuery("#TB_ajaxContent").children())}),tb_reposition_html(c,h),jQuery(window).bind("resize.thickbox",function(){tb_reposition_html(c,h)}),jQuery("#TB_load").remove(),tb_open(),tb_roundCorner("iframe");else if(-1!=c.indexOf("TB_iframe"))tb_reposition_html(c,h),jQuery(window).bind("resize.thickbox",function(){tb_reposition_html(c,h)}),(!("onload"in jQuery("#TB_iframeContent")[0])&&"function"!=typeof jQuery("#TB_iframeContent")[0].onload||
|
||||
".pdf"==f)&&tb_showIframe();else{var v=-1==c.indexOf("?")?"?":"&";jQuery("#TB_ajaxContent").load(c+=v+"random="+(new Date).getTime(),function(){tb_reposition_html(c,h);jQuery(window).bind("resize.thickbox",function(){tb_reposition_html(c,h)});jQuery("#TB_load").remove();tb_open();tb_roundCorner("ajax")})}tb_options.move_html&&jQuery("#TB_window").bind("mousedown.thickbox",function(a){return tb_move(a,-1!=c.indexOf("TB_iframe")?"iframe":"ajax")});tb_options.resize_html&&(tb_resize_init(),jQuery("#TB_Resize").bind("mousedown.thickbox",
|
||||
function(a){return tb_resize(a,-1!=c.indexOf("TB_iframe")?"iframe":"ajax")}));"none"!=tb_options.effect_title&&(jQuery("#TB_title").addClass("hover"),jQuery("#TB_window").bind("mouseenter.thickbox",function(){tb_hover(jQuery("#TB_title"),tb_options.effect_title)}).bind("mouseleave.thickbox",function(){tb_hover(jQuery("#TB_title"),tb_options.effect_title,!0)}));"true"!=h.modal&&jQuery(document).bind("keyup.thickbox",function(a){if(-1!=jQuery.inArray(a.which,tb_options.keys_close))return a.stopImmediatePropagation(),
|
||||
jQuery(document).triggerHandler("wp_CloseOnEscape",[{event:a,what:"thickbox",cb:tb_remove}])||tb_remove(),!1})}}catch(w){tb_options.debug&&alert(w)}}
|
||||
h.inlineId).children()),jQuery("#TB_window").bind("tb_unload",function(){jQuery("#"+h.inlineId).append(jQuery("#TB_ajaxContent").children())}),tb_reposition_html(c,h),jQuery(window).bind("resize.thickbox orientationchange.thickbox",function(){tb_reposition_html(c,h)}),jQuery("#TB_load").remove(),tb_open(),tb_roundCorner("iframe");else if(-1!=c.indexOf("TB_iframe"))tb_reposition_html(c,h),jQuery(window).bind("resize.thickbox orientationchange.thickbox",function(){tb_reposition_html(c,h)}),(!("onload"in
|
||||
jQuery("#TB_iframeContent")[0])&&"function"!=typeof jQuery("#TB_iframeContent")[0].onload||".pdf"==f)&&tb_showIframe();else{var v=-1==c.indexOf("?")?"?":"&";jQuery("#TB_ajaxContent").load(c+=v+"random="+(new Date).getTime(),function(){tb_reposition_html(c,h);jQuery(window).bind("resize.thickbox orientationchange.thickbox",function(){tb_reposition_html(c,h)});jQuery("#TB_load").remove();tb_open();tb_roundCorner("ajax")})}tb_options.move_html&&jQuery("#TB_window").bind("mousedown.thickbox",function(a){return tb_move(a,
|
||||
-1!=c.indexOf("TB_iframe")?"iframe":"ajax")});tb_options.resize_html&&(tb_resize_init(),jQuery("#TB_Resize").bind("mousedown.thickbox",function(a){return tb_resize(a,-1!=c.indexOf("TB_iframe")?"iframe":"ajax")}));"none"!=tb_options.effect_title&&(jQuery("#TB_title").addClass("hover"),jQuery("#TB_window").bind("mouseenter.thickbox",function(){tb_hover(jQuery("#TB_title"),tb_options.effect_title)}).bind("mouseleave.thickbox",function(){tb_hover(jQuery("#TB_title"),tb_options.effect_title,!0)}));"true"!=
|
||||
h.modal&&jQuery(document).bind("keyup.thickbox",function(a){if(-1!=jQuery.inArray(a.which,tb_options.keys_close))return a.stopImmediatePropagation(),jQuery(document).triggerHandler("wp_CloseOnEscape",[{event:a,what:"thickbox",cb:tb_remove}])||tb_remove(),!1})}}catch(w){tb_options.debug&&alert(w)}}
|
||||
function tb_open(){"hidden"==jQuery("#TB_window").css("visibility")&&jQuery("#TB_window").css("visibility","visible");var a=jQuery("#TB_window").is(".TB_Transition")?tb_options.effect_trans:tb_options.effect_open;tb_effectView(a,!1);var c=function(){tb_effectView(a)};switch(a){case "zoom":jQuery("#TB_window").height(jQuery("#TB_window").height());notSupportedPositionFixed&&"relative"!=jQuery("body").css("position")&&jQuery("#TB_window").css({marginTop:-jQuery("#TB_window").height()/2,top:jQuery(window).height()/
|
||||
2+jQuery(document).scrollTop()});jQuery("#TB_Image").hide().show(tb_options.effect_speed);jQuery("#TB_window").show(tb_options.effect_speed,c);break;case "slide":notSupportedPositionFixed&&"relative"!=jQuery("body").css("position")&&jQuery("#TB_window").css({marginTop:-jQuery("#TB_window").height()/2,top:jQuery(window).height()/2+jQuery(document).scrollTop()});jQuery("#TB_window").slideDown(tb_options.effect_speed,c);break;case "fade":jQuery("#TB_window").fadeIn(tb_options.effect_speed,c);break;default:jQuery("#TB_window").show()}"none"==
|
||||
jQuery("#TB_window").css("display")&&jQuery("#TB_window").css("display","block");jQuery("#TB_title").height(Math.max(jQuery("#TB_title").height(),jQuery("#TB_ajaxWindowTitle").height()+13));notSupportedPositionFixed&&jQuery("#TB_window").css({position:"absolute",marginTop:-parseInt(jQuery("#TB_window")[0].offsetHeight/2)+(TBWindowMargin=document.documentElement&&document.documentElement.scrollTop||document.body.scrollTop)+"px"})}
|
||||
|
||||
Reference in new issue
Block a user