PageSourceSearch

http://www.jizerskaliga.cz/file.php?f=plugins/thickbox/thickbox.js.php

js jizerskaliga.cz collected 2026-10-06 17:08:28 UTC 13,832 bytes, 388 lines download raw bytes

1/*
2 * Thickbox 3.1 - One Box To Rule Them All.
3 * By Cody Lindley (http://www.codylindley.com)
4 * Copyright (c) 2007 cody lindley
5 * Licensed under the MIT License: http://www.opensource.org/licenses/mit-license.php
6*/
7
8if (tb_pathToImage == null) {
9var tb_pathToImage = "plugins/thickbox/loadingAnimation.gif";
10var tb_pathToClose = "plugins/thickbox/close.gif";
11}
12
13/*!!!!!!!!!!!!!!!!! edit below this line at your own risk !!!!!!!!!!!!!!!!!!!!!!!*/
14
15//on page load call tb_init
16$(document).ready(function(){
17    $('a.thickbox, area.thickbox, input.thickbox').not('[rel]').attr('rel','tbauto');
18	tb_init('a.thickbox, area.thickbox, input.thickbox'); //pass where to apply thickbox
19	imgLoader = new Image();// preload image
20	imgLoader.src = tb_pathToImage;
21});
22
23//add thickbox to href & area elements that have a class of .thickbox
24function tb_init(domChunk){
25	$(domChunk).click(function(){
26	var t = this.title || this.name || null;
27	var a = this.href || this.alt;
28	var g = this.rel || false;
29	tb_show(t,a,g, true);
30	this.blur();
31	return false;
32	});
33}
34
35function tb_goFirst(){
36	if ( (window.TB_FirstURL == null) || ( (window.tb_slidestart != null) && (window.tb_slidestart == window.TB_FirstURL) ) )
37	    {return false;}
38	    
39	$("#TB_window").remove();
40	$("body").append("<div id='TB_window'></div>");
41	tb_show(window.TB_FirstCaption, window.TB_FirstURL, window.TB_imageGroup, false);
42	return false;
43	}
44
45function tb_goNext(){
46
47if ( (window.tb_slidestart != null) && (window.tb_slidestart == window.TB_NextURL) )
48    {return false;}
49
50	$("#TB_window").remove();
51	$("body").append("<div id='TB_window'></div>");
52	tb_show(window.TB_NextCaption, window.TB_NextURL, window.TB_imageGroup, false);
53	return false;
54}
55
56function tb_show(caption, url, imageGroup, firstimg) {//function called when the user clicks on a thickbox link
57
58	try {
59		if (typeof document.body.style.maxHeight === "undefined") {//if IE 6
60			$("body","html").css({height: "100%", width: "100%"});
61			$("html").css("overflow","hidden");
62			if (document.getElementById("TB_HideSelect") === null) {//iframe to hide select elements in ie6
63				$("body").append("<iframe id='TB_HideSelect'></iframe><div id='TB_overlay'></div><div id='TB_window'></div>");
64				$("#TB_overlay").click(tb_remove);
65			}
66		}else{//all others
67			if(document.getElementById("TB_overlay") === null){
68				$("body").append("<div id='TB_overlay'></div><div id='TB_window'></div>");
69				$("#TB_overlay").click(tb_remove);
70			}
71		}
72		
73		if(tb_detectMacXFF()){
74			$("#TB_overlay").addClass("TB_overlayMacFFBGHack");//use png overlay so hide flash
75		}else{
76			$("#TB_overlay").addClass("TB_overlayBG");//use background and opacity
77		}
78		
79		if(caption===null){caption="";}
80		$("body").append("<div id='TB_load'><img src='"+imgLoader.src+"' /></div>");//add loader to the page
81		$('#TB_load').show();//show loader
82		
83		var baseURL;
84	   if(url.indexOf("?")!==-1){ //ff there is a query string involved
85			baseURL = url.substr(0, url.indexOf("?"));
86	   }else{ 
87	   		baseURL = url;
88	   }
89	   
90	   var urlString = /\.jpg$|\.jpeg$|\.png$|\.gif$|\.bmp$|\.webp$/;
91	   var urlType = baseURL.toLowerCase().match(urlString);
92
93		if(urlType == '.jpg' || urlType == '.jpeg' || urlType == '.png' || urlType == '.gif' || urlType == '.bmp' || urlType == '.webp'){//code to show images
94				
95			TB_PrevCaption = "";
96			TB_PrevURL = "";
97			TB_PrevHTML = "";
98			TB_NextCaption = "";
99			TB_NextURL = "";
100			TB_NextHTML = "";
101			TB_imageCount = "";
102			TB_FoundURL = false;
103			if(imageGroup){
104				TB_TempArray = $("a[rel="+imageGroup+"]").get();
105				for (TB_Counter = 0; ((TB_Counter < TB_TempArray.length) && (TB_NextHTML === "")); TB_Counter++) {
106					var urlTypeTemp = TB_TempArray[TB_Counter].href.toLowerCase().match(urlString);
107						if (!(TB_TempArray[TB_Counter].href == url)) {
108							if (TB_FoundURL) {
109								TB_NextCaption = TB_TempArray[TB_Counter].title;
110								TB_NextURL = TB_TempArray[TB_Counter].href;
111								TB_NextHTML = "<span id='TB_next'>&nbsp;&nbsp;<a href='#'>Další &gt;</a></span>";
112								window.TB_NextCaption = TB_NextCaption;
113								window.TB_NextURL = TB_NextURL;
114								window.TB_imageGroup = imageGroup;
115							} else {
116								TB_PrevCaption = TB_TempArray[TB_Counter].title;
117								TB_PrevURL = TB_TempArray[TB_Counter].href;
118								TB_PrevHTML = "<span id='TB_prev'>&nbsp;&nbsp;<a href='#'>&lt; Předchozí</a></span>";
119							}
120						} else {
121							TB_FoundURL = true;
122							TB_imageCount = "Obrázek #1 z #2";
123							TB_imageCount = TB_imageCount.replace(/\#1/, (TB_Counter + 1).toString() ).replace(/\#2/, (TB_TempArray.length).toString() );
124						}
125				}
126			}
127
128
129			if ( (TB_FoundURL) && (TB_TempArray != null) && (TB_TempArray[0] != null) && (TB_TempArray[0].href != null) )
130			    {
131				window.TB_FirstCaption = TB_TempArray[0].title;
132				window.TB_FirstURL = TB_TempArray[0].href;
133				window.TB_imageGroup = imageGroup;
134				}
135
136			if (firstimg)
137			    {
138				window.tb_slidestart = url;
139				}
140
141			imgPreloader = new Image();
142			imgPreloader.onload = function(){		
143			imgPreloader.onload = null;
144				
145				
146			// Resizing large images - orginal by Christian Montoya edited by me.
147			var pagesize = tb_getPageSize();
148			var x = pagesize[0] - 100;
149			var y = pagesize[1] - 100;
150			var imageWidth = imgPreloader.width;
151			var imageHeight = imgPreloader.height;
152			if (imageWidth > x) {
153				imageHeight = imageHeight * (x / imageWidth); 
154				imageWidth = x; 
155				if (imageHeight > y) { 
156					imageWidth = imageWidth * (y / imageHeight); 
157					imageHeight = y; 
158				}
159			} else if (imageHeight > y) { 
160				imageWidth = imageWidth * (y / imageHeight); 
161				imageHeight = y; 
162				if (imageWidth > x) { 
163					imageHeight = imageHeight * (x / imageWidth); 
164					imageWidth = x;
165				}
166			}
167			// End Resizing
168			
169			TB_WIDTH = imageWidth + 30;
170			TB_HEIGHT = imageHeight + 60;
171			$("#TB_window").append("<a href='' id='TB_ImageOff' title='Zavřít'><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='Zavřít'><img src='"+tb_pathToClose+"' alt='Zavřít'></a></div>");
172			
173			$("#TB_closeWindowButton").click(tb_remove);
174			
175			if (!(TB_PrevHTML === "")) {
176				function goPrev(){
177					if($(document).unbind("click",goPrev)){$(document).unbind("click",goPrev);}
178					$("#TB_window").remove();
179					$("body").append("<div id='TB_window'></div>");
180					tb_show(TB_PrevCaption, TB_PrevURL, imageGroup, false);
181					return false;	
182				}
183				$("#TB_prev").click(goPrev);
184			}
185			
186			if (!(TB_NextHTML === "")) {		
187				function goNext(){
188					$("#TB_window").remove();
189					$("body").append("<div id='TB_window'></div>");
190					tb_show(TB_NextCaption, TB_NextURL, imageGroup);
191					return false;	
192				}
193				$("#TB_next").click(goNext);
194
195			}
196
197			document.onkeydown = function(e){
198				if (e == null) { // ie
199					keycode = event.keyCode;
200				} else { // mozilla
201					keycode = e.which;
202				}
203
204				switch (keycode)
205					{
206					case 27:         // close - esc
207					case 88:  //x
208                        tb_remove();
209                        document.onkeydown = "";
210						break;
211					case 188:        // display previous image
212					case 37:  //up+left
213					case 38:
214	                    if(!(TB_PrevHTML == "")){
215							document.onkeydown = "";
216							goPrev();
217							}
218						break;
219					case 190:        // display next image
220					case 39:  //dn+right
221					case 40:
222	                    if(!(TB_NextHTML == "")){
223							document.onkeydown = "";
224							goNext();
225							}
226						break;
227					}
228				};
229
230			tb_position();
231			$("#TB_load").remove();
232			$("#TB_ImageOff").click(tb_remove);
233			$("#TB_window").css({display:"block"}); //for safari using css instead of show
234			};
235			
236			imgPreloader.src = url;
237		}else{//code to show html
238			
239			var queryString = url.replace(/^[^\?]+\??/,'');
240			var params = tb_parseQuery( queryString );
241
242			TB_WIDTH = (params['width']*1) + 30 || 630; //defaults to 630 if no paramaters were added to URL
243			TB_HEIGHT = (params['height']*1) + 40 || 440; //defaults to 440 if no paramaters were added to URL
244			ajaxContentW = TB_WIDTH - 30;
245			ajaxContentH = TB_HEIGHT - 45;
246			
247			if(url.indexOf('TB_iframe') != -1){// either iframe or ajax window		
248					urlNoQuery = url.split('TB_');
249					$("#TB_iframeContent").remove();
250					if(params['modal'] != "true"){//iframe no modal
251						$("#TB_window").append("<div id='TB_title'><div id='TB_ajaxWindowTitle'>"+caption+"</div><div id='TB_closeAjaxWindow'><a href='#' id='TB_closeWindowButton' title='Zavřít'>Zavřít</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;' > </iframe>");
252					}else{//iframe modal
253					$("#TB_overlay").unbind();
254						$("#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;'> </iframe>");
255					}
256			}else{// not an iframe, ajax
257					if($("#TB_window").css("display") != "block"){
258						if(params['modal'] != "true"){//ajax no modal
259						$("#TB_window").append("<div id='TB_title'><div id='TB_ajaxWindowTitle'>"+caption+"</div><div id='TB_closeAjaxWindow'><a href='#' id='TB_closeWindowButton'>Zavřít</a></div></div><div id='TB_ajaxContent' style='width:"+ajaxContentW+"px;height:"+ajaxContentH+"px'></div>");
260						}else{//ajax modal
261						$("#TB_overlay").unbind();
262						$("#TB_window").append("<div id='TB_ajaxContent' class='TB_modal' style='width:"+ajaxContentW+"px;height:"+ajaxContentH+"px;'></div>");	
263						}
264					}else{//this means the window is already up, we are just loading new content via ajax
265						$("#TB_ajaxContent")[0].style.width = ajaxContentW +"px";
266						$("#TB_ajaxContent")[0].style.height = ajaxContentH +"px";
267						$("#TB_ajaxContent")[0].scrollTop = 0;
268						$("#TB_ajaxWindowTitle").html(caption);
269					}
270			}
271					
272			$("#TB_closeWindowButton").click(tb_remove);
273			
274				if(url.indexOf('TB_inline') != -1){	
275					$("#TB_ajaxContent").append($('#' + params['inlineId']).children());
276					$("#TB_window").unload(function () {
277						$('#' + params['inlineId']).append( $("#TB_ajaxContent").children() ); // move elements back when you're finished
278					});
279					tb_position();
280					$("#TB_load").remove();
281					$("#TB_window").css({display:"block"}); 
282				}else if(url.indexOf('TB_iframe') != -1){
283					tb_position();
284					if($.browser.safari){//safari needs help because it will not fire iframe onload
285						$("#TB_load").remove();
286						$("#TB_window").css({display:"block"});
287					}
288				}else{
289					$("#TB_ajaxContent").load(url += "&random=" + (new Date().getTime()),function(){//to do a post change this load method
290						tb_position();
291						$("#TB_load").remove();
292						tb_init("#TB_ajaxContent a.thickbox");
293						$("#TB_window").css({display:"block"});
294					});
295				}
296			
297		}
298
299		if(!params['modal']){
300			document.onkeyup = function(e){ 	
301				if (e == null) { // ie
302					keycode = event.keyCode;
303				} else { // mozilla
304					keycode = e.which;
305				}
306				if(keycode == 27){ // close
307					tb_remove();
308				}	
309			};
310		}
311		
312	} catch(e) {
313		//nothing here
314	}
315}
316
317//helper functions below
318function tb_showIframe(){
319	$("#TB_load").remove();
320	$("#TB_window").css({display:"block"});
321}
322
323function tb_remove() {
324 	$("#TB_imageOff").unbind("click");
325	$("#TB_closeWindowButton").unbind("click");
326	$("#TB_window").fadeOut("fast",function(){$('#TB_window,#TB_overlay,#TB_HideSelect').trigger("unload").unbind().remove();});
327	$("#TB_load").remove();
328	if (typeof document.body.style.maxHeight == "undefined") {//if IE 6
329		$("body","html").css({height: "auto", width: "auto"});
330		$("html").css("overflow","");
331	}
332	document.onkeydown = "";
333	document.onkeyup = "";
334	return false;
335}
336
337// function tb_position() {
338// $("#TB_window").css({marginLeft: '-' + parseInt((TB_WIDTH / 2),10) + 'px', width: TB_WIDTH + 'px'});
339// 	if ( !(jQuery.browser.msie && jQuery.browser.version < 7)) { // take away IE6
340// 		$("#TB_window").css({marginTop: '-' + parseInt((TB_HEIGHT / 2),10) + 'px'});
341// 	}
342// }
343// FIXED  http://www.multizone.cz/cs/thickbox/26.html
344
345function tb_position() {
346jQuery("#TB_window").css({marginLeft: '-' + parseInt((TB_WIDTH /2), 10) + 'px', width: TB_WIDTH + 'px'});
347var browser = navigator.userAgent.toLowerCase();
348var IEVersion;
349var brVerId = browser.indexOf('msie');
350if (brVerId > 0) {
351IEVersion = browser.substr( brVerId + 5 ,1);
352}
353if (! (IEVersion && IEVersion == '6')) {
354jQuery("#TB_window").css({marginTop: '-' + parseInt((TB_HEIGHT / 2),10) + 'px'});
355}
356}
357
358function tb_parseQuery ( query ) {
359   var Params = {};
360   if ( ! query ) {return Params;}// return empty object
361   var Pairs = query.split(/[;&]/);
362   for ( var i = 0; i < Pairs.length; i++ ) {
363      var KeyVal = Pairs[i].split('=');
364      if ( ! KeyVal || KeyVal.length != 2 ) {continue;}
365      var key = unescape( KeyVal[0] );
366      var val = unescape( KeyVal[1] );
367      val = val.replace(/\+/g, ' ');
368      Params[key] = val;
369   }
370   return Params;
371}
372
373function tb_getPageSize(){
374	var de = document.documentElement;
375	var w = window.innerWidth || self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth;
376	var h = window.innerHeight || self.innerHeight || (de&&de.clientHeight) || document.body.clientHeight;
377	arrayPageSize = [w,h];
378	return arrayPageSize;
379}
380
381function tb_detectMacXFF() {
382  var userAgent = navigator.userAgent.toLowerCase();
383  if (userAgent.indexOf('mac') != -1 && userAgent.indexOf('firefox')!=-1) {
384    return true;
385  }
386}
387
388

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.