PageSourceSearch

https://all-tours.com.ua/templates/templates/js/thickbox.js

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

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.