wp/wp-includes/js/thickbox/thickbox.js
changeset 5 5e2f62d02dcd
parent 0 d970ebf37754
child 7 cf61fcea0001
equal deleted inserted replaced
4:346c88efed21 5:5e2f62d02dcd
    44 			}
    44 			}
    45 		}else{//all others
    45 		}else{//all others
    46 			if(document.getElementById("TB_overlay") === null){
    46 			if(document.getElementById("TB_overlay") === null){
    47 				jQuery("body").append("<div id='TB_overlay'></div><div id='TB_window'></div>");
    47 				jQuery("body").append("<div id='TB_overlay'></div><div id='TB_window'></div>");
    48 				jQuery("#TB_overlay").click(tb_remove);
    48 				jQuery("#TB_overlay").click(tb_remove);
       
    49 				jQuery( 'body' ).addClass( 'modal-open' );
    49 			}
    50 			}
    50 		}
    51 		}
    51 
    52 
    52 		if(tb_detectMacXFF()){
    53 		if(tb_detectMacXFF()){
    53 			jQuery("#TB_overlay").addClass("TB_overlayMacFFBGHack");//use png overlay so hide flash
    54 			jQuery("#TB_overlay").addClass("TB_overlayMacFFBGHack");//use png overlay so hide flash
   102 
   103 
   103 			imgPreloader = new Image();
   104 			imgPreloader = new Image();
   104 			imgPreloader.onload = function(){
   105 			imgPreloader.onload = function(){
   105 			imgPreloader.onload = null;
   106 			imgPreloader.onload = null;
   106 
   107 
   107 			// Resizing large images - orginal by Christian Montoya edited by me.
   108 			// Resizing large images - original by Christian Montoya edited by me.
   108 			var pagesize = tb_getPageSize();
   109 			var pagesize = tb_getPageSize();
   109 			var x = pagesize[0] - 150;
   110 			var x = pagesize[0] - 150;
   110 			var y = pagesize[1] - 150;
   111 			var y = pagesize[1] - 150;
   111 			var imageWidth = imgPreloader.width;
   112 			var imageWidth = imgPreloader.width;
   112 			var imageHeight = imgPreloader.height;
   113 			var imageHeight = imgPreloader.height;
   127 			}
   128 			}
   128 			// End Resizing
   129 			// End Resizing
   129 
   130 
   130 			TB_WIDTH = imageWidth + 30;
   131 			TB_WIDTH = imageWidth + 30;
   131 			TB_HEIGHT = imageHeight + 60;
   132 			TB_HEIGHT = imageHeight + 60;
   132 			jQuery("#TB_window").append("<a href='' id='TB_ImageOff' title='"+thickboxL10n.close+"'><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'><a href='#' id='TB_closeWindowButton' title='"+thickboxL10n.close+"'><div class='tb-close-icon'></div></a></div>");
   133 			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'><a href='#' id='TB_closeWindowButton'><span class='screen-reader-text'>"+thickboxL10n.close+"</span><div class='tb-close-icon'></div></a></div>");
   133 
   134 
   134 			jQuery("#TB_closeWindowButton").click(tb_remove);
   135 			jQuery("#TB_closeWindowButton").click(tb_remove);
   135 
   136 
   136 			if (!(TB_PrevHTML === "")) {
   137 			if (!(TB_PrevHTML === "")) {
   137 				function goPrev(){
   138 				function goPrev(){
   154 				jQuery("#TB_next").click(goNext);
   155 				jQuery("#TB_next").click(goNext);
   155 
   156 
   156 			}
   157 			}
   157 
   158 
   158 			jQuery(document).bind('keydown.thickbox', function(e){
   159 			jQuery(document).bind('keydown.thickbox', function(e){
   159 				e.stopImmediatePropagation();
       
   160 
       
   161 				if ( e.which == 27 ){ // close
   160 				if ( e.which == 27 ){ // close
   162 					if ( ! jQuery(document).triggerHandler( 'wp_CloseOnEscape', [{ event: e, what: 'thickbox', cb: tb_remove }] ) )
   161 					tb_remove();
   163 						tb_remove();
       
   164 
   162 
   165 				} else if ( e.which == 190 ){ // display previous image
   163 				} else if ( e.which == 190 ){ // display previous image
   166 					if(!(TB_NextHTML == "")){
   164 					if(!(TB_NextHTML == "")){
   167 						jQuery(document).unbind('thickbox');
   165 						jQuery(document).unbind('thickbox');
   168 						goNext();
   166 						goNext();
   186 		}else{//code to show html
   184 		}else{//code to show html
   187 
   185 
   188 			var queryString = url.replace(/^[^\?]+\??/,'');
   186 			var queryString = url.replace(/^[^\?]+\??/,'');
   189 			var params = tb_parseQuery( queryString );
   187 			var params = tb_parseQuery( queryString );
   190 
   188 
   191 			TB_WIDTH = (params['width']*1) + 30 || 630; //defaults to 630 if no paramaters were added to URL
   189 			TB_WIDTH = (params['width']*1) + 30 || 630; //defaults to 630 if no parameters were added to URL
   192 			TB_HEIGHT = (params['height']*1) + 40 || 440; //defaults to 440 if no paramaters were added to URL
   190 			TB_HEIGHT = (params['height']*1) + 40 || 440; //defaults to 440 if no parameters were added to URL
   193 			ajaxContentW = TB_WIDTH - 30;
   191 			ajaxContentW = TB_WIDTH - 30;
   194 			ajaxContentH = TB_HEIGHT - 45;
   192 			ajaxContentH = TB_HEIGHT - 45;
   195 
   193 
   196 			if(url.indexOf('TB_iframe') != -1){// either iframe or ajax window
   194 			if(url.indexOf('TB_iframe') != -1){// either iframe or ajax window
   197 					urlNoQuery = url.split('TB_');
   195 					urlNoQuery = url.split('TB_');
   198 					jQuery("#TB_iframeContent").remove();
   196 					jQuery("#TB_iframeContent").remove();
   199 					if(params['modal'] != "true"){//iframe no modal
   197 					if(params['modal'] != "true"){//iframe no modal
   200 						jQuery("#TB_window").append("<div id='TB_title'><div id='TB_ajaxWindowTitle'>"+caption+"</div><div id='TB_closeAjaxWindow'><a href='#' id='TB_closeWindowButton' title='"+thickboxL10n.close+"'><div class='tb-close-icon'></div></a></div></div><iframe frameborder='0' hspace='0' 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>");
   198 						jQuery("#TB_window").append("<div id='TB_title'><div id='TB_ajaxWindowTitle'>"+caption+"</div><div id='TB_closeAjaxWindow'><a href='#' id='TB_closeWindowButton'><span class='screen-reader-text'>"+thickboxL10n.close+"</span><div class='tb-close-icon'></div></a></div></div><iframe frameborder='0' hspace='0' 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>");
   201 					}else{//iframe modal
   199 					}else{//iframe modal
   202 					jQuery("#TB_overlay").unbind();
   200 					jQuery("#TB_overlay").unbind();
   203 						jQuery("#TB_window").append("<iframe frameborder='0' hspace='0' 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>");
   201 						jQuery("#TB_window").append("<iframe frameborder='0' hspace='0' 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>");
   204 					}
   202 					}
   205 			}else{// not an iframe, ajax
   203 			}else{// not an iframe, ajax
   242 				}
   240 				}
   243 
   241 
   244 		}
   242 		}
   245 
   243 
   246 		if(!params['modal']){
   244 		if(!params['modal']){
   247 			jQuery(document).bind('keyup.thickbox', function(e){
   245 			jQuery(document).bind('keydown.thickbox', function(e){
   248 
       
   249 				if ( e.which == 27 ){ // close
   246 				if ( e.which == 27 ){ // close
   250 					e.stopImmediatePropagation();
   247 					tb_remove();
   251 					if ( ! jQuery(document).triggerHandler( 'wp_CloseOnEscape', [{ event: e, what: 'thickbox', cb: tb_remove }] ) )
       
   252 						tb_remove();
       
   253 
       
   254 					return false;
   248 					return false;
   255 				}
   249 				}
   256 			});
   250 			});
   257 		}
   251 		}
   258 
   252 
   269 
   263 
   270 function tb_remove() {
   264 function tb_remove() {
   271  	jQuery("#TB_imageOff").unbind("click");
   265  	jQuery("#TB_imageOff").unbind("click");
   272 	jQuery("#TB_closeWindowButton").unbind("click");
   266 	jQuery("#TB_closeWindowButton").unbind("click");
   273 	jQuery("#TB_window").fadeOut("fast",function(){jQuery('#TB_window,#TB_overlay,#TB_HideSelect').trigger("tb_unload").unbind().remove();});
   267 	jQuery("#TB_window").fadeOut("fast",function(){jQuery('#TB_window,#TB_overlay,#TB_HideSelect').trigger("tb_unload").unbind().remove();});
       
   268 	jQuery( 'body' ).removeClass( 'modal-open' );
   274 	jQuery("#TB_load").remove();
   269 	jQuery("#TB_load").remove();
   275 	if (typeof document.body.style.maxHeight == "undefined") {//if IE 6
   270 	if (typeof document.body.style.maxHeight == "undefined") {//if IE 6
   276 		jQuery("body","html").css({height: "auto", width: "auto"});
   271 		jQuery("body","html").css({height: "auto", width: "auto"});
   277 		jQuery("html").css("overflow","");
   272 		jQuery("html").css("overflow","");
   278 	}
   273 	}