wp/wp-includes/js/thickbox/thickbox.js
changeset 18 be944660c56a
parent 7 cf61fcea0001
child 21 48c4eec2b7e6
--- a/wp/wp-includes/js/thickbox/thickbox.js	Tue Dec 15 15:52:01 2020 +0100
+++ b/wp/wp-includes/js/thickbox/thickbox.js	Wed Sep 21 18:19:35 2022 +0200
@@ -49,12 +49,12 @@
 			jQuery("html").css("overflow","hidden");
 			if (document.getElementById("TB_HideSelect") === null) {//iframe to hide select elements in ie6
 				jQuery("body").append("<iframe id='TB_HideSelect'>"+thickboxL10n.noiframes+"</iframe><div id='TB_overlay'></div><div id='TB_window' class='thickbox-loading'></div>");
-				jQuery("#TB_overlay").click(tb_remove);
+				jQuery("#TB_overlay").on( 'click', tb_remove );
 			}
 		}else{//all others
 			if(document.getElementById("TB_overlay") === null){
 				jQuery("body").append("<div id='TB_overlay'></div><div id='TB_window' class='thickbox-loading'></div>");
-				jQuery("#TB_overlay").click(tb_remove);
+				jQuery("#TB_overlay").on( 'click', tb_remove );
 				jQuery( 'body' ).addClass( 'modal-open' );
 			}
 		}
@@ -141,17 +141,17 @@
 			TB_HEIGHT = imageHeight + 60;
 			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>");
 
-			jQuery("#TB_closeWindowButton").click(tb_remove);
+			jQuery("#TB_closeWindowButton").on( 'click', tb_remove );
 
 			if (!(TB_PrevHTML === "")) {
 				function goPrev(){
-					if(jQuery(document).unbind("click",goPrev)){jQuery(document).unbind("click",goPrev);}
+					if(jQuery(document).off("click",goPrev)){jQuery(document).off("click",goPrev);}
 					jQuery("#TB_window").remove();
 					jQuery("body").append("<div id='TB_window'></div>");
 					tb_show(TB_PrevCaption, TB_PrevURL, imageGroup);
 					return false;
 				}
-				jQuery("#TB_prev").click(goPrev);
+				jQuery("#TB_prev").on( 'click', goPrev );
 			}
 
 			if (!(TB_NextHTML === "")) {
@@ -161,22 +161,22 @@
 					tb_show(TB_NextCaption, TB_NextURL, imageGroup);
 					return false;
 				}
-				jQuery("#TB_next").click(goNext);
+				jQuery("#TB_next").on( 'click', goNext );
 
 			}
 
-			jQuery(document).bind('keydown.thickbox', function(e){
+			jQuery(document).on('keydown.thickbox', function(e){
 				if ( e.which == 27 ){ // close
 					tb_remove();
 
 				} else if ( e.which == 190 ){ // display previous image
 					if(!(TB_NextHTML == "")){
-						jQuery(document).unbind('thickbox');
+						jQuery(document).off('thickbox');
 						goNext();
 					}
 				} else if ( e.which == 188 ){ // display next image
 					if(!(TB_PrevHTML == "")){
-						jQuery(document).unbind('thickbox');
+						jQuery(document).off('thickbox');
 						goPrev();
 					}
 				}
@@ -185,7 +185,7 @@
 
 			tb_position();
 			jQuery("#TB_load").remove();
-			jQuery("#TB_ImageOff").click(tb_remove);
+			jQuery("#TB_ImageOff").on( 'click', tb_remove );
 			jQuery("#TB_window").css({'visibility':'visible'}); //for safari using css instead of show
 			};
 
@@ -206,7 +206,7 @@
 					if(params['modal'] != "true"){//iframe no modal
 						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>");
 					}else{//iframe modal
-					jQuery("#TB_overlay").unbind();
+					jQuery("#TB_overlay").off();
 						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>");
 					}
 			}else{// not an iframe, ajax
@@ -214,7 +214,7 @@
 						if(params['modal'] != "true"){//ajax no modal
 						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>");
 						}else{//ajax modal
-						jQuery("#TB_overlay").unbind();
+						jQuery("#TB_overlay").off();
 						jQuery("#TB_window").append("<div id='TB_ajaxContent' class='TB_modal' style='width:"+ajaxContentW+"px;height:"+ajaxContentH+"px;'></div>");
 						}
 					}else{//this means the window is already up, we are just loading new content via ajax
@@ -225,11 +225,11 @@
 					}
 			}
 
-			jQuery("#TB_closeWindowButton").click(tb_remove);
+			jQuery("#TB_closeWindowButton").on( 'click', tb_remove );
 
 				if(url.indexOf('TB_inline') != -1){
 					jQuery("#TB_ajaxContent").append(jQuery('#' + params['inlineId']).children());
-					jQuery("#TB_window").bind('tb_unload', function () {
+					jQuery("#TB_window").on('tb_unload', function () {
 						jQuery('#' + params['inlineId']).append( jQuery("#TB_ajaxContent").children() ); // move elements back when you're finished
 					});
 					tb_position();
@@ -253,7 +253,7 @@
 		}
 
 		if(!params['modal']){
-			jQuery(document).bind('keydown.thickbox', function(e){
+			jQuery(document).on('keydown.thickbox', function(e){
 				if ( e.which == 27 ){ // close
 					tb_remove();
 					return false;
@@ -268,7 +268,7 @@
 		 * In other admin screens is hidden and replaced by a different icon.
 		 */
 		if ( $closeBtn.find( '.tb-close-icon' ).is( ':visible' ) ) {
-			$closeBtn.focus();
+			$closeBtn.trigger( 'focus' );
 		}
 
 	} catch(e) {
@@ -283,10 +283,10 @@
 }
 
 function tb_remove() {
- 	jQuery("#TB_imageOff").unbind("click");
-	jQuery("#TB_closeWindowButton").unbind("click");
+ 	jQuery("#TB_imageOff").off("click");
+	jQuery("#TB_closeWindowButton").off("click");
 	jQuery( '#TB_window' ).fadeOut( 'fast', function() {
-		jQuery( '#TB_window, #TB_overlay, #TB_HideSelect' ).trigger( 'tb_unload' ).unbind().remove();
+		jQuery( '#TB_window, #TB_overlay, #TB_HideSelect' ).trigger( 'tb_unload' ).off().remove();
 		jQuery( 'body' ).trigger( 'thickbox:removed' );
 	});
 	jQuery( 'body' ).removeClass( 'modal-open' );
@@ -295,7 +295,7 @@
 		jQuery("body","html").css({height: "auto", width: "auto"});
 		jQuery("html").css("overflow","");
 	}
-	jQuery(document).unbind('.thickbox');
+	jQuery(document).off('.thickbox');
 	return false;
 }