Change "Gallery - Caption" item to "Image - Caption" item in "Text - Caption" option

* Support also Caption of an image that is not in WordPress Gallery
 * Fix: Remove whitespace from both ends of Gallery Caption (regression by [545261] in v1.5)
This commit is contained in:
attosoft committed 2012-05-29 00:32:22 +00:00
1 parent b92e74b97c
commit 3f3d457f46
4 files changed
+15 -7

No files matched your search

+1 -1
View File
@@ -627,7 +627,7 @@ class auto_thickbox_options {
case "blank": echo "<li class='ui-state-default' id='blank'>" . __('Blank') . "</li>"; break;
case "img-title": echo "<li class='ui-state-default' id='img-title'>{$this->texts['image']} - " . __('Title') . " (<code>img@title</code>)</li>"; break;
case "img-alt": echo "<li class='ui-state-default' id='img-alt'>{$this->texts['image']} - " . __('Alternate Text') . " (<code>img@alt</code>)</li>"; break;
case "gallery-cap": echo "<li class='ui-state-default' id='gallery-cap'>" . __('Gallery') . " - " . __('Caption') . " (<code>dd.gallery-caption</code>)</li>"; break;
case "img-cap": echo "<li class='ui-state-default' id='img-cap'>{$this->texts['image']} - " . __('Caption') . " (<code>@class='wp-caption-text'</code>)</li>"; break;
case "img-desc": echo "<li class='ui-state-default' id='img-desc'>{$this->texts['image']} - " . __('Description') . " (<code>img@longdesc</code>)</li>"; break;
case "img-name": echo "<li class='ui-state-default' id='img-name'>{$this->texts['image']} - " . __('Name') . " (<code>img@name</code>)</li>"; break;
}
+7 -1
View File
@@ -564,7 +564,7 @@ SCRIPT;
'txt_shadow_title' => 'none',
'txt_shadow_cap' => 'none',
'ref_title' => "'link-title','link-name','blank','img-title','img-alt','img-desc','img-name'",
'ref_cap' => "'link-title','link-name','blank','img-title','img-alt','img-desc','img-name','gallery-cap'",
'ref_cap' => "'link-title','link-name','blank','img-title','img-alt','img-desc','img-name','img-cap'",
'post_id' => '0',
'img_prev' => $this->plugins_url('images/tb-prev.png', __FILE__),
'img_next' => $this->plugins_url('images/tb-next.png', __FILE__),
@@ -644,6 +644,12 @@ SCRIPT;
$updateOption = true;
}
// XXX: transition code for v1.6 or earlier
if (strpos($this->options['ref_cap'], 'gallery-cap') !== false) {
$this->options['ref_cap'] = str_replace('gallery-cap', 'img-cap', $this->options['ref_cap']);
$updateOption = true;
}
if ($this->is_default_options('post_id')) {
$args = array(
'post_status' => 'draft',
+3 -1
View File
@@ -84,7 +84,9 @@ function tb_caption(elem, refs) {
case "blank": return "";
case "img-title": caption = jQuery(elem).children("img").attr("title"); break;
case "img-alt": caption = jQuery(elem).children("img").attr("alt"); break;
case "gallery-cap": caption = jQuery(elem).parent().nextAll(".gallery-caption").text(); break;
case "img-cap": caption = jQuery(elem).parent().is('dt.gallery-icon') // for WordPress
? jQuery(elem).parent().nextAll(".wp-caption-text").text().replace(/^\s+|\s+$/g, '') // trim()
: jQuery(elem).nextAll(".wp-caption-text").text(); break;
case "img-desc": caption = jQuery(elem).children("img").attr("longdesc"); break;
case "img-name": caption = jQuery(elem).children("img").attr("name"); break;
}
+4 -4
View File
@@ -2,10 +2,10 @@ jQuery(document).ready(function(){"string"!=typeof tb_pathToImage&&(tb_pathToIma
var tb_options={auto_resize:!0,click_img:"close",click_end:"loop",click_bg:"close",wheel_img:"prev_next",keys_close:[27,13],keys_prev:[188,37],keys_next:[190,39],keys_first:[36],keys_last:[35],move_img:!1,move_content:!1,resize_img:!1,resize_content:!1,position_title:"top",position_cap:"bottom",ref_title:["link-title","link-name"],ref_cap:["link-title","link-name"],effect_open:"none",effect_close:"fade",effect_trans:"none",effect_title:"none",effect_cap:"none",effect_speed:"fast",debug:!1};
jQuery(document).ready(function(){tb_init("a.thickbox, area.thickbox, input.thickbox");imgLoader=new Image;imgLoader.src=tb_pathToImage});function tb_init(a){jQuery.isFunction(jQuery().live)?jQuery(a).live("click",tb_click):jQuery(a).bind("click",tb_click)}
function tb_click(){null!==document.getElementById("TB_window")&&(jQuery(document).unbind(".thickbox"),jQuery("#TB_window").trigger("tb_unload").remove(),jQuery("body").append("<div id='TB_window' class='TB_Transition'></div>"));tb_show(this,this.href||this.alt,this.rel||!1);this.blur();return!1}
function tb_caption(a,c){for(var c=c||tb_options.ref_cap,b,d=0;d<c.length&&!b;d++)switch(c[d]){case "link-title":b=a.title;break;case "link-name":b=a.name;break;case "blank":return"";case "img-title":b=jQuery(a).children("img").attr("title");break;case "img-alt":b=jQuery(a).children("img").attr("alt");break;case "gallery-cap":b=jQuery(a).parent().nextAll(".gallery-caption").text();break;case "img-desc":b=jQuery(a).children("img").attr("longdesc");break;case "img-name":b=jQuery(a).children("img").attr("name")}return b.replace(/(\r\n|[\n\r])/g,
"<br />")}
function tb_show(a,c,b){try{"undefined"===typeof document.body.style.maxHeight?(jQuery("body","html").css({height:"100%",width:"100%"}),jQuery("html").css("overflow","hidden"),null===document.getElementById("TB_HideSelect")&&(jQuery("body").append("<iframe id='TB_HideSelect'>"+thickboxL10n.noiframes+"</iframe><div id='TB_overlay'></div><div id='TB_window'></div>"),"close"==tb_options.click_bg&&jQuery("#TB_overlay").click(tb_remove))):null===document.getElementById("TB_overlay")&&(jQuery("body").append("<div id='TB_overlay'></div><div id='TB_window'></div>"),"close"==
tb_options.click_bg&&jQuery("#TB_overlay").click(tb_remove));tb_detectMacXFF()?jQuery("#TB_overlay").addClass("TB_overlayMacFFBGHack"):jQuery("#TB_overlay").addClass("TB_overlayBG");jQuery("body").append("<div id='TB_load'><img src='"+imgLoader.src+"' /></div>");0==parseInt(jQuery("#TB_load").css("marginLeft"))&&jQuery("#TB_load").css("marginLeft",-jQuery("#TB_load").outerWidth()/2);0==parseInt(jQuery("#TB_load").css("marginTop"))&&jQuery("#TB_load").css("marginTop",-jQuery("#TB_load").outerHeight()/
function tb_caption(a,c){for(var c=c||tb_options.ref_cap,b,d=0;d<c.length&&!b;d++)switch(c[d]){case "link-title":b=a.title;break;case "link-name":b=a.name;break;case "blank":return"";case "img-title":b=jQuery(a).children("img").attr("title");break;case "img-alt":b=jQuery(a).children("img").attr("alt");break;case "img-cap":b=jQuery(a).parent().is("dt.gallery-icon")?jQuery(a).parent().nextAll(".wp-caption-text").text().replace(/^\s+|\s+$/g,""):jQuery(a).nextAll(".wp-caption-text").text();break;case "img-desc":b=
jQuery(a).children("img").attr("longdesc");break;case "img-name":b=jQuery(a).children("img").attr("name")}return b.replace(/(\r\n|[\n\r])/g,"<br />")}
function tb_show(a,c,b){try{"undefined"===typeof document.body.style.maxHeight?(jQuery("body","html").css({height:"100%",width:"100%"}),jQuery("html").css("overflow","hidden"),null===document.getElementById("TB_HideSelect")&&(jQuery("body").append("<iframe id='TB_HideSelect'>"+thickboxL10n.noiframes+"</iframe><div id='TB_overlay'></div><div id='TB_window'></div>"),"close"==tb_options.click_bg&&jQuery("#TB_overlay").click(tb_remove))):null===document.getElementById("TB_overlay")&&(jQuery("body").append("<div id='TB_overlay'></div><div id='TB_window'></div>"),
"close"==tb_options.click_bg&&jQuery("#TB_overlay").click(tb_remove));tb_detectMacXFF()?jQuery("#TB_overlay").addClass("TB_overlayMacFFBGHack"):jQuery("#TB_overlay").addClass("TB_overlayBG");jQuery("body").append("<div id='TB_load'><img src='"+imgLoader.src+"' /></div>");0==parseInt(jQuery("#TB_load").css("marginLeft"))&&jQuery("#TB_load").css("marginLeft",-jQuery("#TB_load").outerWidth()/2);0==parseInt(jQuery("#TB_load").css("marginTop"))&&jQuery("#TB_load").css("marginTop",-jQuery("#TB_load").outerHeight()/
2);jQuery("#TB_load").show();var d=/\.jpg$|\.jpeg$|\.png$|\.gif$|\.bmp$|\.webp$/,e=(-1!==c.indexOf("?")?c.substr(0,c.indexOf("?")):c).toLowerCase().match(d);if(".jpg"==e||".jpeg"==e||".png"==e||".gif"==e||".bmp"==e||".webp"==e){TB_imageCount=TB_NextHTML=TB_NextURL=TB_NextCaption=TB_PrevHTML=TB_PrevURL=TB_PrevCaption="";TB_FoundURL=!1;TB_LastURL=TB_LastCaption=TB_FirstURL=TB_FirstCaption="";if(b){TB_TempArray=jQuery("a[rel="+b+"]").get();for(TB_Counter=0;TB_Counter<TB_TempArray.length&&""===TB_NextHTML;TB_Counter++)TB_TempArray[TB_Counter].href.toLowerCase().match(d),
("object"==typeof a?TB_TempArray[TB_Counter]!=a:TB_TempArray[TB_Counter].href!=c)?TB_FoundURL?(TB_NextCaption=TB_TempArray[TB_Counter],TB_NextURL=TB_TempArray[TB_Counter].href,TB_NextHTML="<span id='TB_next'>&nbsp;&nbsp;<a href='#'>"+thickboxL10n.next+"</a></span>"):(TB_PrevCaption=TB_TempArray[TB_Counter],TB_PrevURL=TB_TempArray[TB_Counter].href,TB_PrevHTML="<span id='TB_prev'>&nbsp;&nbsp;<a href='#'>"+thickboxL10n.prev+"</a></span>"):(TB_FoundURL=!0,TB_imageCount=thickboxL10n.image+" "+(TB_Counter+
1)+" "+thickboxL10n.of+" "+TB_TempArray.length);TB_FirstCaption=TB_TempArray[0];TB_FirstURL=TB_TempArray[0].href;TB_LastCaption=TB_TempArray[TB_TempArray.length-1];TB_LastURL=TB_TempArray[TB_TempArray.length-1].href}imgPreloader=new Image;imgPreloader.onload=function(){imgPreloader.onload=null;var d=c.replace(/^[^\?]+\??/,""),e=tb_parseQuery(d),j=tb_getPageSize(),d=j[0]-150,j=j[1]-150,m=e.width?Math.min(e.width*1,imgPreloader.width):imgPreloader.width,h=e.height?Math.min(e.height*1,imgPreloader.height):