wp/wp-includes/js/thickbox/thickbox.js
changeset 21 48c4eec2b7e6
parent 18 be944660c56a
equal deleted inserted replaced
20:7b1b88e27a20 21:48c4eec2b7e6
    74 			baseURL = url.substr(0, url.indexOf("?"));
    74 			baseURL = url.substr(0, url.indexOf("?"));
    75 	   }else{
    75 	   }else{
    76 	   		baseURL = url;
    76 	   		baseURL = url;
    77 	   }
    77 	   }
    78 
    78 
    79 	   var urlString = /\.jpg$|\.jpeg$|\.png$|\.gif$|\.bmp$/;
    79 	   var urlString = /\.jpg$|\.jpeg$|\.png$|\.gif$|\.bmp$|\.webp$|\.avif$/;
    80 	   var urlType = baseURL.toLowerCase().match(urlString);
    80 	   var urlType = baseURL.toLowerCase().match(urlString);
    81 
    81 
    82 		if(urlType == '.jpg' || urlType == '.jpeg' || urlType == '.png' || urlType == '.gif' || urlType == '.bmp'){//code to show images
    82 		if(urlType == '.jpg' ||
       
    83 			urlType == '.jpeg' ||
       
    84 			urlType == '.png' ||
       
    85 			urlType == '.gif' ||
       
    86 			urlType == '.bmp' ||
       
    87 			urlType == '.webp' ||
       
    88 			urlType == '.avif'
       
    89 		){//code to show images
    83 
    90 
    84 			TB_PrevCaption = "";
    91 			TB_PrevCaption = "";
    85 			TB_PrevURL = "";
    92 			TB_PrevURL = "";
    86 			TB_PrevHTML = "";
    93 			TB_PrevHTML = "";
    87 			TB_NextCaption = "";
    94 			TB_NextCaption = "";
   137 			}
   144 			}
   138 			// End Resizing
   145 			// End Resizing
   139 
   146 
   140 			TB_WIDTH = imageWidth + 30;
   147 			TB_WIDTH = imageWidth + 30;
   141 			TB_HEIGHT = imageHeight + 60;
   148 			TB_HEIGHT = imageHeight + 60;
   142 			jQuery("#TB_window").append("<a href='' id='TB_ImageOff'><span class='screen-reader-text'>"+thickboxL10n.close+"</span><img id='TB_Image' src='"+url+"' width='"+imageWidth+"' height='"+imageHeight+"' alt='"+caption+"'/></a>" + "<div id='TB_caption'>"+caption+"<div id='TB_secondLine'>" + TB_imageCount + TB_PrevHTML + TB_NextHTML + "</div></div><div id='TB_closeWindow'><button type='button' id='TB_closeWindowButton'><span class='screen-reader-text'>"+thickboxL10n.close+"</span><span class='tb-close-icon'></span></button></div>");
   149 			jQuery("#TB_window").append("<a href='' id='TB_ImageOff'><span class='screen-reader-text'>"+thickboxL10n.close+"</span><img id='TB_Image' src='"+url+"' width='"+imageWidth+"' height='"+imageHeight+"' alt='"+caption+"'/></a>" + "<div id='TB_caption'>"+caption+"<div id='TB_secondLine'>" + TB_imageCount + TB_PrevHTML + TB_NextHTML + "</div></div><div id='TB_closeWindow'><button type='button' id='TB_closeWindowButton'><span class='screen-reader-text'>"+thickboxL10n.close+"</span><span class='tb-close-icon' aria-hidden='true'></span></button></div>");
   143 
   150 
   144 			jQuery("#TB_closeWindowButton").on( 'click', tb_remove );
   151 			jQuery("#TB_closeWindowButton").on( 'click', tb_remove );
   145 
   152 
   146 			if (!(TB_PrevHTML === "")) {
   153 			if (!(TB_PrevHTML === "")) {
   147 				function goPrev(){
   154 				function goPrev(){
   202 
   209 
   203 			if(url.indexOf('TB_iframe') != -1){// either iframe or ajax window
   210 			if(url.indexOf('TB_iframe') != -1){// either iframe or ajax window
   204 					urlNoQuery = url.split('TB_');
   211 					urlNoQuery = url.split('TB_');
   205 					jQuery("#TB_iframeContent").remove();
   212 					jQuery("#TB_iframeContent").remove();
   206 					if(params['modal'] != "true"){//iframe no modal
   213 					if(params['modal'] != "true"){//iframe no modal
   207 						jQuery("#TB_window").append("<div id='TB_title'><div id='TB_ajaxWindowTitle'>"+caption+"</div><div id='TB_closeAjaxWindow'><button type='button' id='TB_closeWindowButton'><span class='screen-reader-text'>"+thickboxL10n.close+"</span><span class='tb-close-icon'></span></button></div></div><iframe frameborder='0' hspace='0' allowtransparency='true' src='"+urlNoQuery[0]+"' id='TB_iframeContent' name='TB_iframeContent"+Math.round(Math.random()*1000)+"' onload='tb_showIframe()' style='width:"+(ajaxContentW + 29)+"px;height:"+(ajaxContentH + 17)+"px;' >"+thickboxL10n.noiframes+"</iframe>");
   214 						jQuery("#TB_window").append("<div id='TB_title'><div id='TB_ajaxWindowTitle'>"+caption+"</div><div id='TB_closeAjaxWindow'><button type='button' id='TB_closeWindowButton'><span class='screen-reader-text'>"+thickboxL10n.close+"</span><span class='tb-close-icon' aria-hidden='true'></span></button></div></div><iframe frameborder='0' hspace='0' allowtransparency='true' src='"+urlNoQuery[0]+"' id='TB_iframeContent' name='TB_iframeContent"+Math.round(Math.random()*1000)+"' onload='tb_showIframe()' style='width:"+(ajaxContentW + 29)+"px;height:"+(ajaxContentH + 17)+"px;' >"+thickboxL10n.noiframes+"</iframe>");
   208 					}else{//iframe modal
   215 					}else{//iframe modal
   209 					jQuery("#TB_overlay").off();
   216 					jQuery("#TB_overlay").off();
   210 						jQuery("#TB_window").append("<iframe frameborder='0' hspace='0' allowtransparency='true' src='"+urlNoQuery[0]+"' id='TB_iframeContent' name='TB_iframeContent"+Math.round(Math.random()*1000)+"' onload='tb_showIframe()' style='width:"+(ajaxContentW + 29)+"px;height:"+(ajaxContentH + 17)+"px;'>"+thickboxL10n.noiframes+"</iframe>");
   217 						jQuery("#TB_window").append("<iframe frameborder='0' hspace='0' allowtransparency='true' src='"+urlNoQuery[0]+"' id='TB_iframeContent' name='TB_iframeContent"+Math.round(Math.random()*1000)+"' onload='tb_showIframe()' style='width:"+(ajaxContentW + 29)+"px;height:"+(ajaxContentH + 17)+"px;'>"+thickboxL10n.noiframes+"</iframe>");
   211 					}
   218 					}
   212 			}else{// not an iframe, ajax
   219 			}else{// not an iframe, ajax
   213 					if(jQuery("#TB_window").css("visibility") != "visible"){
   220 					if(jQuery("#TB_window").css("visibility") != "visible"){
   214 						if(params['modal'] != "true"){//ajax no modal
   221 						if(params['modal'] != "true"){//ajax no modal
   215 						jQuery("#TB_window").append("<div id='TB_title'><div id='TB_ajaxWindowTitle'>"+caption+"</div><div id='TB_closeAjaxWindow'><button type='button' id='TB_closeWindowButton'><span class='screen-reader-text'>"+thickboxL10n.close+"</span><span class='tb-close-icon'></span></button></div></div><div id='TB_ajaxContent' style='width:"+ajaxContentW+"px;height:"+ajaxContentH+"px'></div>");
   222 						jQuery("#TB_window").append("<div id='TB_title'><div id='TB_ajaxWindowTitle'>"+caption+"</div><div id='TB_closeAjaxWindow'><button type='button' id='TB_closeWindowButton'><span class='screen-reader-text'>"+thickboxL10n.close+"</span><span class='tb-close-icon' aria-hidden='true'></span></button></div></div><div id='TB_ajaxContent' style='width:"+ajaxContentW+"px;height:"+ajaxContentH+"px'></div>");
   216 						}else{//ajax modal
   223 						}else{//ajax modal
   217 						jQuery("#TB_overlay").off();
   224 						jQuery("#TB_overlay").off();
   218 						jQuery("#TB_window").append("<div id='TB_ajaxContent' class='TB_modal' style='width:"+ajaxContentW+"px;height:"+ajaxContentH+"px;'></div>");
   225 						jQuery("#TB_window").append("<div id='TB_ajaxContent' class='TB_modal' style='width:"+ajaxContentW+"px;height:"+ajaxContentH+"px;'></div>");
   219 						}
   226 						}
   220 					}else{//this means the window is already up, we are just loading new content via ajax
   227 					}else{//this means the window is already up, we are just loading new content via ajax