Edit File by line
/home/barbar84/public_h.../wp-inclu.../js/thickbox
File: thickbox.js
/*
[0] Fix | Delete
* Thickbox 3.1 - One Box To Rule Them All.
[1] Fix | Delete
* By Cody Lindley (http://www.codylindley.com)
[2] Fix | Delete
* Copyright (c) 2007 cody lindley
[3] Fix | Delete
* Licensed under the MIT License: http://www.opensource.org/licenses/mit-license.php
[4] Fix | Delete
*/
[5] Fix | Delete
[6] Fix | Delete
if ( typeof tb_pathToImage != 'string' ) {
[7] Fix | Delete
var tb_pathToImage = thickboxL10n.loadingAnimation;
[8] Fix | Delete
}
[9] Fix | Delete
[10] Fix | Delete
/*!!!!!!!!!!!!!!!!! edit below this line at your own risk !!!!!!!!!!!!!!!!!!!!!!!*/
[11] Fix | Delete
[12] Fix | Delete
//on page load call tb_init
[13] Fix | Delete
jQuery(document).ready(function(){
[14] Fix | Delete
tb_init('a.thickbox, area.thickbox, input.thickbox');//pass where to apply thickbox
[15] Fix | Delete
imgLoader = new Image();// preload image
[16] Fix | Delete
imgLoader.src = tb_pathToImage;
[17] Fix | Delete
});
[18] Fix | Delete
[19] Fix | Delete
/*
[20] Fix | Delete
* Add thickbox to href & area elements that have a class of .thickbox.
[21] Fix | Delete
* Remove the loading indicator when content in an iframe has loaded.
[22] Fix | Delete
*/
[23] Fix | Delete
function tb_init(domChunk){
[24] Fix | Delete
jQuery( 'body' )
[25] Fix | Delete
.on( 'click', domChunk, tb_click )
[26] Fix | Delete
.on( 'thickbox:iframe:loaded', function() {
[27] Fix | Delete
jQuery( '#TB_window' ).removeClass( 'thickbox-loading' );
[28] Fix | Delete
});
[29] Fix | Delete
}
[30] Fix | Delete
[31] Fix | Delete
function tb_click(){
[32] Fix | Delete
var t = this.title || this.name || null;
[33] Fix | Delete
var a = this.href || this.alt;
[34] Fix | Delete
var g = this.rel || false;
[35] Fix | Delete
tb_show(t,a,g);
[36] Fix | Delete
this.blur();
[37] Fix | Delete
return false;
[38] Fix | Delete
}
[39] Fix | Delete
[40] Fix | Delete
function tb_show(caption, url, imageGroup) {//function called when the user clicks on a thickbox link
[41] Fix | Delete
[42] Fix | Delete
var $closeBtn;
[43] Fix | Delete
[44] Fix | Delete
try {
[45] Fix | Delete
if (typeof document.body.style.maxHeight === "undefined") {//if IE 6
[46] Fix | Delete
jQuery("body","html").css({height: "100%", width: "100%"});
[47] Fix | Delete
jQuery("html").css("overflow","hidden");
[48] Fix | Delete
if (document.getElementById("TB_HideSelect") === null) {//iframe to hide select elements in ie6
[49] Fix | Delete
jQuery("body").append("<iframe id='TB_HideSelect'>"+thickboxL10n.noiframes+"</iframe><div id='TB_overlay'></div><div id='TB_window' class='thickbox-loading'></div>");
[50] Fix | Delete
jQuery("#TB_overlay").on( 'click', tb_remove );
[51] Fix | Delete
}
[52] Fix | Delete
}else{//all others
[53] Fix | Delete
if(document.getElementById("TB_overlay") === null){
[54] Fix | Delete
jQuery("body").append("<div id='TB_overlay'></div><div id='TB_window' class='thickbox-loading'></div>");
[55] Fix | Delete
jQuery("#TB_overlay").on( 'click', tb_remove );
[56] Fix | Delete
jQuery( 'body' ).addClass( 'modal-open' );
[57] Fix | Delete
}
[58] Fix | Delete
}
[59] Fix | Delete
[60] Fix | Delete
if(tb_detectMacXFF()){
[61] Fix | Delete
jQuery("#TB_overlay").addClass("TB_overlayMacFFBGHack");//use png overlay so hide flash
[62] Fix | Delete
}else{
[63] Fix | Delete
jQuery("#TB_overlay").addClass("TB_overlayBG");//use background and opacity
[64] Fix | Delete
}
[65] Fix | Delete
[66] Fix | Delete
if(caption===null){caption="";}
[67] Fix | Delete
jQuery("body").append("<div id='TB_load'><img src='"+imgLoader.src+"' width='208' /></div>");//add loader to the page
[68] Fix | Delete
jQuery('#TB_load').show();//show loader
[69] Fix | Delete
[70] Fix | Delete
var baseURL;
[71] Fix | Delete
if(url.indexOf("?")!==-1){ //ff there is a query string involved
[72] Fix | Delete
baseURL = url.substr(0, url.indexOf("?"));
[73] Fix | Delete
}else{
[74] Fix | Delete
baseURL = url;
[75] Fix | Delete
}
[76] Fix | Delete
[77] Fix | Delete
var urlString = /\.jpg$|\.jpeg$|\.png$|\.gif$|\.bmp$/;
[78] Fix | Delete
var urlType = baseURL.toLowerCase().match(urlString);
[79] Fix | Delete
[80] Fix | Delete
if(urlType == '.jpg' || urlType == '.jpeg' || urlType == '.png' || urlType == '.gif' || urlType == '.bmp'){//code to show images
[81] Fix | Delete
[82] Fix | Delete
TB_PrevCaption = "";
[83] Fix | Delete
TB_PrevURL = "";
[84] Fix | Delete
TB_PrevHTML = "";
[85] Fix | Delete
TB_NextCaption = "";
[86] Fix | Delete
TB_NextURL = "";
[87] Fix | Delete
TB_NextHTML = "";
[88] Fix | Delete
TB_imageCount = "";
[89] Fix | Delete
TB_FoundURL = false;
[90] Fix | Delete
if(imageGroup){
[91] Fix | Delete
TB_TempArray = jQuery("a[rel="+imageGroup+"]").get();
[92] Fix | Delete
for (TB_Counter = 0; ((TB_Counter < TB_TempArray.length) && (TB_NextHTML === "")); TB_Counter++) {
[93] Fix | Delete
var urlTypeTemp = TB_TempArray[TB_Counter].href.toLowerCase().match(urlString);
[94] Fix | Delete
if (!(TB_TempArray[TB_Counter].href == url)) {
[95] Fix | Delete
if (TB_FoundURL) {
[96] Fix | Delete
TB_NextCaption = TB_TempArray[TB_Counter].title;
[97] Fix | Delete
TB_NextURL = TB_TempArray[TB_Counter].href;
[98] Fix | Delete
TB_NextHTML = "<span id='TB_next'>&nbsp;&nbsp;<a href='#'>"+thickboxL10n.next+"</a></span>";
[99] Fix | Delete
} else {
[100] Fix | Delete
TB_PrevCaption = TB_TempArray[TB_Counter].title;
[101] Fix | Delete
TB_PrevURL = TB_TempArray[TB_Counter].href;
[102] Fix | Delete
TB_PrevHTML = "<span id='TB_prev'>&nbsp;&nbsp;<a href='#'>"+thickboxL10n.prev+"</a></span>";
[103] Fix | Delete
}
[104] Fix | Delete
} else {
[105] Fix | Delete
TB_FoundURL = true;
[106] Fix | Delete
TB_imageCount = thickboxL10n.image + ' ' + (TB_Counter + 1) + ' ' + thickboxL10n.of + ' ' + (TB_TempArray.length);
[107] Fix | Delete
}
[108] Fix | Delete
}
[109] Fix | Delete
}
[110] Fix | Delete
[111] Fix | Delete
imgPreloader = new Image();
[112] Fix | Delete
imgPreloader.onload = function(){
[113] Fix | Delete
imgPreloader.onload = null;
[114] Fix | Delete
[115] Fix | Delete
// Resizing large images - original by Christian Montoya edited by me.
[116] Fix | Delete
var pagesize = tb_getPageSize();
[117] Fix | Delete
var x = pagesize[0] - 150;
[118] Fix | Delete
var y = pagesize[1] - 150;
[119] Fix | Delete
var imageWidth = imgPreloader.width;
[120] Fix | Delete
var imageHeight = imgPreloader.height;
[121] Fix | Delete
if (imageWidth > x) {
[122] Fix | Delete
imageHeight = imageHeight * (x / imageWidth);
[123] Fix | Delete
imageWidth = x;
[124] Fix | Delete
if (imageHeight > y) {
[125] Fix | Delete
imageWidth = imageWidth * (y / imageHeight);
[126] Fix | Delete
imageHeight = y;
[127] Fix | Delete
}
[128] Fix | Delete
} else if (imageHeight > y) {
[129] Fix | Delete
imageWidth = imageWidth * (y / imageHeight);
[130] Fix | Delete
imageHeight = y;
[131] Fix | Delete
if (imageWidth > x) {
[132] Fix | Delete
imageHeight = imageHeight * (x / imageWidth);
[133] Fix | Delete
imageWidth = x;
[134] Fix | Delete
}
[135] Fix | Delete
}
[136] Fix | Delete
// End Resizing
[137] Fix | Delete
[138] Fix | Delete
TB_WIDTH = imageWidth + 30;
[139] Fix | Delete
TB_HEIGHT = imageHeight + 60;
[140] Fix | Delete
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>");
[141] Fix | Delete
[142] Fix | Delete
jQuery("#TB_closeWindowButton").on( 'click', tb_remove );
[143] Fix | Delete
[144] Fix | Delete
if (!(TB_PrevHTML === "")) {
[145] Fix | Delete
function goPrev(){
[146] Fix | Delete
if(jQuery(document).off("click",goPrev)){jQuery(document).off("click",goPrev);}
[147] Fix | Delete
jQuery("#TB_window").remove();
[148] Fix | Delete
jQuery("body").append("<div id='TB_window'></div>");
[149] Fix | Delete
tb_show(TB_PrevCaption, TB_PrevURL, imageGroup);
[150] Fix | Delete
return false;
[151] Fix | Delete
}
[152] Fix | Delete
jQuery("#TB_prev").on( 'click', goPrev );
[153] Fix | Delete
}
[154] Fix | Delete
[155] Fix | Delete
if (!(TB_NextHTML === "")) {
[156] Fix | Delete
function goNext(){
[157] Fix | Delete
jQuery("#TB_window").remove();
[158] Fix | Delete
jQuery("body").append("<div id='TB_window'></div>");
[159] Fix | Delete
tb_show(TB_NextCaption, TB_NextURL, imageGroup);
[160] Fix | Delete
return false;
[161] Fix | Delete
}
[162] Fix | Delete
jQuery("#TB_next").on( 'click', goNext );
[163] Fix | Delete
[164] Fix | Delete
}
[165] Fix | Delete
[166] Fix | Delete
jQuery(document).on('keydown.thickbox', function(e){
[167] Fix | Delete
if ( e.which == 27 ){ // close
[168] Fix | Delete
tb_remove();
[169] Fix | Delete
[170] Fix | Delete
} else if ( e.which == 190 ){ // display previous image
[171] Fix | Delete
if(!(TB_NextHTML == "")){
[172] Fix | Delete
jQuery(document).off('thickbox');
[173] Fix | Delete
goNext();
[174] Fix | Delete
}
[175] Fix | Delete
} else if ( e.which == 188 ){ // display next image
[176] Fix | Delete
if(!(TB_PrevHTML == "")){
[177] Fix | Delete
jQuery(document).off('thickbox');
[178] Fix | Delete
goPrev();
[179] Fix | Delete
}
[180] Fix | Delete
}
[181] Fix | Delete
return false;
[182] Fix | Delete
});
[183] Fix | Delete
[184] Fix | Delete
tb_position();
[185] Fix | Delete
jQuery("#TB_load").remove();
[186] Fix | Delete
jQuery("#TB_ImageOff").on( 'click', tb_remove );
[187] Fix | Delete
jQuery("#TB_window").css({'visibility':'visible'}); //for safari using css instead of show
[188] Fix | Delete
};
[189] Fix | Delete
[190] Fix | Delete
imgPreloader.src = url;
[191] Fix | Delete
}else{//code to show html
[192] Fix | Delete
[193] Fix | Delete
var queryString = url.replace(/^[^\?]+\??/,'');
[194] Fix | Delete
var params = tb_parseQuery( queryString );
[195] Fix | Delete
[196] Fix | Delete
TB_WIDTH = (params['width']*1) + 30 || 630; //defaults to 630 if no parameters were added to URL
[197] Fix | Delete
TB_HEIGHT = (params['height']*1) + 40 || 440; //defaults to 440 if no parameters were added to URL
[198] Fix | Delete
ajaxContentW = TB_WIDTH - 30;
[199] Fix | Delete
ajaxContentH = TB_HEIGHT - 45;
[200] Fix | Delete
[201] Fix | Delete
if(url.indexOf('TB_iframe') != -1){// either iframe or ajax window
[202] Fix | Delete
urlNoQuery = url.split('TB_');
[203] Fix | Delete
jQuery("#TB_iframeContent").remove();
[204] Fix | Delete
if(params['modal'] != "true"){//iframe no modal
[205] Fix | Delete
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>");
[206] Fix | Delete
}else{//iframe modal
[207] Fix | Delete
jQuery("#TB_overlay").off();
[208] Fix | Delete
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>");
[209] Fix | Delete
}
[210] Fix | Delete
}else{// not an iframe, ajax
[211] Fix | Delete
if(jQuery("#TB_window").css("visibility") != "visible"){
[212] Fix | Delete
if(params['modal'] != "true"){//ajax no modal
[213] Fix | Delete
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>");
[214] Fix | Delete
}else{//ajax modal
[215] Fix | Delete
jQuery("#TB_overlay").off();
[216] Fix | Delete
jQuery("#TB_window").append("<div id='TB_ajaxContent' class='TB_modal' style='width:"+ajaxContentW+"px;height:"+ajaxContentH+"px;'></div>");
[217] Fix | Delete
}
[218] Fix | Delete
}else{//this means the window is already up, we are just loading new content via ajax
[219] Fix | Delete
jQuery("#TB_ajaxContent")[0].style.width = ajaxContentW +"px";
[220] Fix | Delete
jQuery("#TB_ajaxContent")[0].style.height = ajaxContentH +"px";
[221] Fix | Delete
jQuery("#TB_ajaxContent")[0].scrollTop = 0;
[222] Fix | Delete
jQuery("#TB_ajaxWindowTitle").html(caption);
[223] Fix | Delete
}
[224] Fix | Delete
}
[225] Fix | Delete
[226] Fix | Delete
jQuery("#TB_closeWindowButton").on( 'click', tb_remove );
[227] Fix | Delete
[228] Fix | Delete
if(url.indexOf('TB_inline') != -1){
[229] Fix | Delete
jQuery("#TB_ajaxContent").append(jQuery('#' + params['inlineId']).children());
[230] Fix | Delete
jQuery("#TB_window").on('tb_unload', function () {
[231] Fix | Delete
jQuery('#' + params['inlineId']).append( jQuery("#TB_ajaxContent").children() ); // move elements back when you're finished
[232] Fix | Delete
});
[233] Fix | Delete
tb_position();
[234] Fix | Delete
jQuery("#TB_load").remove();
[235] Fix | Delete
jQuery("#TB_window").css({'visibility':'visible'});
[236] Fix | Delete
}else if(url.indexOf('TB_iframe') != -1){
[237] Fix | Delete
tb_position();
[238] Fix | Delete
jQuery("#TB_load").remove();
[239] Fix | Delete
jQuery("#TB_window").css({'visibility':'visible'});
[240] Fix | Delete
}else{
[241] Fix | Delete
var load_url = url;
[242] Fix | Delete
load_url += -1 === url.indexOf('?') ? '?' : '&';
[243] Fix | Delete
jQuery("#TB_ajaxContent").load(load_url += "random=" + (new Date().getTime()),function(){//to do a post change this load method
[244] Fix | Delete
tb_position();
[245] Fix | Delete
jQuery("#TB_load").remove();
[246] Fix | Delete
tb_init("#TB_ajaxContent a.thickbox");
[247] Fix | Delete
jQuery("#TB_window").css({'visibility':'visible'});
[248] Fix | Delete
});
[249] Fix | Delete
}
[250] Fix | Delete
[251] Fix | Delete
}
[252] Fix | Delete
[253] Fix | Delete
if(!params['modal']){
[254] Fix | Delete
jQuery(document).on('keydown.thickbox', function(e){
[255] Fix | Delete
if ( e.which == 27 ){ // close
[256] Fix | Delete
tb_remove();
[257] Fix | Delete
return false;
[258] Fix | Delete
}
[259] Fix | Delete
});
[260] Fix | Delete
}
[261] Fix | Delete
[262] Fix | Delete
$closeBtn = jQuery( '#TB_closeWindowButton' );
[263] Fix | Delete
/*
[264] Fix | Delete
* If the native Close button icon is visible, move focus on the button
[265] Fix | Delete
* (e.g. in the Network Admin Themes screen).
[266] Fix | Delete
* In other admin screens is hidden and replaced by a different icon.
[267] Fix | Delete
*/
[268] Fix | Delete
if ( $closeBtn.find( '.tb-close-icon' ).is( ':visible' ) ) {
[269] Fix | Delete
$closeBtn.trigger( 'focus' );
[270] Fix | Delete
}
[271] Fix | Delete
[272] Fix | Delete
} catch(e) {
[273] Fix | Delete
//nothing here
[274] Fix | Delete
}
[275] Fix | Delete
}
[276] Fix | Delete
[277] Fix | Delete
//helper functions below
[278] Fix | Delete
function tb_showIframe(){
[279] Fix | Delete
jQuery("#TB_load").remove();
[280] Fix | Delete
jQuery("#TB_window").css({'visibility':'visible'}).trigger( 'thickbox:iframe:loaded' );
[281] Fix | Delete
}
[282] Fix | Delete
[283] Fix | Delete
function tb_remove() {
[284] Fix | Delete
jQuery("#TB_imageOff").off("click");
[285] Fix | Delete
jQuery("#TB_closeWindowButton").off("click");
[286] Fix | Delete
jQuery( '#TB_window' ).fadeOut( 'fast', function() {
[287] Fix | Delete
jQuery( '#TB_window, #TB_overlay, #TB_HideSelect' ).trigger( 'tb_unload' ).off().remove();
[288] Fix | Delete
jQuery( 'body' ).trigger( 'thickbox:removed' );
[289] Fix | Delete
});
[290] Fix | Delete
jQuery( 'body' ).removeClass( 'modal-open' );
[291] Fix | Delete
jQuery("#TB_load").remove();
[292] Fix | Delete
if (typeof document.body.style.maxHeight == "undefined") {//if IE 6
[293] Fix | Delete
jQuery("body","html").css({height: "auto", width: "auto"});
[294] Fix | Delete
jQuery("html").css("overflow","");
[295] Fix | Delete
}
[296] Fix | Delete
jQuery(document).off('.thickbox');
[297] Fix | Delete
return false;
[298] Fix | Delete
}
[299] Fix | Delete
[300] Fix | Delete
function tb_position() {
[301] Fix | Delete
var isIE6 = typeof document.body.style.maxHeight === "undefined";
[302] Fix | Delete
jQuery("#TB_window").css({marginLeft: '-' + parseInt((TB_WIDTH / 2),10) + 'px', width: TB_WIDTH + 'px'});
[303] Fix | Delete
if ( ! isIE6 ) { // take away IE6
[304] Fix | Delete
jQuery("#TB_window").css({marginTop: '-' + parseInt((TB_HEIGHT / 2),10) + 'px'});
[305] Fix | Delete
}
[306] Fix | Delete
}
[307] Fix | Delete
[308] Fix | Delete
function tb_parseQuery ( query ) {
[309] Fix | Delete
var Params = {};
[310] Fix | Delete
if ( ! query ) {return Params;}// return empty object
[311] Fix | Delete
var Pairs = query.split(/[;&]/);
[312] Fix | Delete
for ( var i = 0; i < Pairs.length; i++ ) {
[313] Fix | Delete
var KeyVal = Pairs[i].split('=');
[314] Fix | Delete
if ( ! KeyVal || KeyVal.length != 2 ) {continue;}
[315] Fix | Delete
var key = unescape( KeyVal[0] );
[316] Fix | Delete
var val = unescape( KeyVal[1] );
[317] Fix | Delete
val = val.replace(/\+/g, ' ');
[318] Fix | Delete
Params[key] = val;
[319] Fix | Delete
}
[320] Fix | Delete
return Params;
[321] Fix | Delete
}
[322] Fix | Delete
[323] Fix | Delete
function tb_getPageSize(){
[324] Fix | Delete
var de = document.documentElement;
[325] Fix | Delete
var w = window.innerWidth || self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth;
[326] Fix | Delete
var h = window.innerHeight || self.innerHeight || (de&&de.clientHeight) || document.body.clientHeight;
[327] Fix | Delete
arrayPageSize = [w,h];
[328] Fix | Delete
return arrayPageSize;
[329] Fix | Delete
}
[330] Fix | Delete
[331] Fix | Delete
function tb_detectMacXFF() {
[332] Fix | Delete
var userAgent = navigator.userAgent.toLowerCase();
[333] Fix | Delete
if (userAgent.indexOf('mac') != -1 && userAgent.indexOf('firefox')!=-1) {
[334] Fix | Delete
return true;
[335] Fix | Delete
}
[336] Fix | Delete
}
[337] Fix | Delete
[338] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function