PageSourceSearch

https://bischwihr.fr/javascript/illicopage/thickbox.js

js bischwihr.fr collected 2026-10-02 21:28:25 UTC 16,321 bytes, 394 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 = "/javascript/illicopage/loadingAnimation.gif";
9var clickAjoute;
10var autorise = 1;
11jQuery.noConflict();
12/*!!!!!!!!!!!!!!!!! edit below this line at your own risk !!!!!!!!!!!!!!!!!!!!!!!*/
13
14		var CS = {};
15        CS.UploadAjax = function(){}
16
17        CS.UploadAjax.tb_remove = function(){
18			tb_remove();
19        }
20        CS.UploadAjax.tb_reload = function() {
21        	jQuery("#envoi_valeur_pour_recharger_quand_on_quitte_une_fenetre_popup").submit();
22        }
23        CS.UploadAjax.tb_reload_pour_validation = function() {
24        	jQuery("#valid").submit();
25        }
26
27//on page load call tb_init
28jQuery(document).ready(function(){
29	tb_init('a.thickbox, area.thickbox, input.thickbox');//pass where to apply thickbox
30	imgLoader = new Image();// preload image
31	imgLoader.src = tb_pathToImage;
32});
33
34//add thickbox to href & area elements that have a class of .thickbox
35function tb_init(domChunk){
36	
37	jQuery(domChunk).click(function(){
38	  
39	var t = this.title || this.name || null;
40	var a = this.href || this.alt;
41	var g = this.rel || false;
42	tb_show(t,a,g,0);
43	this.blur();
44	return false;
45	});
46	}
47
48function tb_show(caption, url, imageGroup,apercu) {//function called when the user clicks on a thickbox link
49	if(!autorise) {return false;}
50	try {
51		if (typeof document.body.style.maxHeight === "undefined") {//if IE 6
52			jQuery("body","html").css({height: "100%", width: "100%"});
53			jQuery("html").css("overflow","hidden");
54			if (document.getElementById("TB_HideSelect") === null) {//iframe to hide select elements in ie6
55				jQuery("body").append("<iframe id='TB_HideSelect'></iframe><div id='TB_overlay'></div><div id='TB_window'></div>");
56				jQuery("#TB_overlay").click(tb_remove);
57			}
58		}else{//all others
59			if(document.getElementById("TB_overlay") === null){
60				jQuery("body").append("<div id='TB_overlay'></div><div id='TB_window'></div>");
61				jQuery("#TB_overlay").click(tb_remove);
62			}
63		}
64
65		if(tb_detectMacXFF()){
66			jQuery("#TB_overlay").addClass("TB_overlayMacFFBGHack");//use png overlay so hide flash
67		}else{
68			jQuery("#TB_overlay").addClass("TB_overlayBG");//use background and opacity
69		}
70
71		if(caption===null){caption="";}
72		jQuery("body").append("<div id='TB_load'><img src='"+imgLoader.src+"' /></div>");//add loader to the page
73		jQuery('#TB_load').show();//show loader
74
75		var baseURL;
76	   if(url.indexOf("?")!==-1){ //ff there is a query string involved
77			baseURL = url.substr(0, url.indexOf("?"));
78	   }else{
79	   		baseURL = url;
80	   }
81
82	   var urlString = /\.jpg$|\.jpeg$|\.png$|\.gif$|\.bmp$|affiche_image/;
83	   var urlType = baseURL.toLowerCase().match(urlString);
84		if(urlType == '.jpg' || urlType == '.jpeg' || urlType == '.png' || urlType == '.gif' || urlType == '.bmp' || urlType == 'affiche_image'){//code to show images
85			TB_PrevCaption = "";
86			TB_PrevURL = "";
87			TB_PrevHTML = "";
88			TB_NextCaption = "";
89			TB_NextURL = "";
90			TB_NextHTML = "";
91			TB_imageCount = "";
92			TB_FoundURL = false;
93			if(imageGroup){
94				TB_TempArray = jQuery("a[rel="+imageGroup+"]").get();
95				for (TB_Counter = 0; ((TB_Counter < TB_TempArray.length) && (TB_NextHTML === "")); TB_Counter++) {
96					var urlTypeTemp = TB_TempArray[TB_Counter].href.toLowerCase().match(urlString);
97						if (!(TB_TempArray[TB_Counter].href == url)) {
98							if (TB_FoundURL) {
99								TB_NextCaption = TB_TempArray[TB_Counter].title;
100								TB_NextURL = TB_TempArray[TB_Counter].href;
101								TB_NextHTML = "<span id='TB_next'>&nbsp;&nbsp;<a href='#'>Suivant &gt;</a></span>";
102							} else {
103								TB_PrevCaption = TB_TempArray[TB_Counter].title;
104								TB_PrevURL = TB_TempArray[TB_Counter].href;
105								TB_PrevHTML = "<span id='TB_prev'>&nbsp;&nbsp;<a href='#'>&lt; Pr&eacute;c&eacute;dent</a></span>";
106							}
107						} else {
108							TB_FoundURL = true;
109							TB_imageCount = "Image " + (TB_Counter + 1) +" / "+ (TB_TempArray.length);
110						}
111				}
112			}
113
114			imgPreloader = new Image();
115			imgPreloader.onload = function(){
116			imgPreloader.onload = null;
117
118			// Resizing large images - orginal by Christian Montoya edited by me.
119			var pagesize = tb_getPageSize();
120			var x = pagesize[0] - 10;
121			var y = pagesize[1] - 80;
122			var imageWidth = imgPreloader.width;
123			var imageHeight = imgPreloader.height;
124			if (imageWidth > x) {
125				imageHeight = imageHeight * (x / imageWidth);
126				imageWidth = x;
127				if (imageHeight > y) {
128					imageWidth = imageWidth * (y / imageHeight);
129					imageHeight = y;
130				}
131			} else if (imageHeight > y) {
132				imageWidth = imageWidth * (y / imageHeight);
133				imageHeight = y;
134				if (imageWidth > x) {
135					imageHeight = imageHeight * (x / imageWidth);
136					imageWidth = x;
137				}
138			}
139			// End Resizing
140			/* MODIFICATION ED : ENLEVE MARGE*/
141			TB_WIDTH = imageWidth + 30;
142			TB_HEIGHT = imageHeight + 60;
143			//TB_WIDTH = imageWidth ;
144			//TB_HEIGHT = imageHeight ;
145                        jQuery("#TB_window").append("<a href='' id='TB_ImageOff' ><img id='TB_Image' src='"+url+"' width='"+imageWidth+"' height='"+imageHeight+"' alt=\""+caption+"\" title=\""+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='Fermer'>Fermer</a></div>");
146
147			jQuery("#TB_closeWindowButton").click(tb_remove);
148
149			if (!(TB_PrevHTML === "")) {
150				function goPrev(){
151					if(jQuery(document).unbind("click",goPrev)){jQuery(document).unbind("click",goPrev);}
152					jQuery("#TB_window").remove();
153					jQuery("body").append("<div id='TB_window'></div>");
154					tb_show(TB_PrevCaption, TB_PrevURL, imageGroup,0);
155					return false;
156				}
157				jQuery("#TB_prev").click(goPrev);
158			}
159
160			if (!(TB_NextHTML === "")) {
161				function goNext(){
162					jQuery("#TB_window").remove();
163					jQuery("body").append("<div id='TB_window'></div>");
164					tb_show(TB_NextCaption, TB_NextURL, imageGroup,0);
165					return false;
166				}
167				jQuery("#TB_next").click(goNext);
168
169			}
170
171			document.onkeydown = function(e){
172				if (e == null) { // ie
173					keycode = event.keyCode;
174				} else { // mozilla
175					keycode = e.which;
176				}
177				if(keycode == 27){ // close
178					tb_remove();
179				} else if(keycode == 190){ // display previous image
180					if(!(TB_NextHTML == "")){
181						document.onkeydown = "";
182						goNext();
183					}
184				} else if(keycode == 188){ // display next image
185					if(!(TB_PrevHTML == "")){
186						document.onkeydown = "";
187						goPrev();
188					}
189				}
190			};
191
192			tb_position();
193			jQuery("#TB_load").remove();
194			jQuery("#TB_ImageOff").click(tb_remove);
195			jQuery("#TB_window").css({display:"block"}); //for safari using css instead of show
196			};
197
198			imgPreloader.src = url;
199		}else{//code to show html
200
201			var queryString = url.replace(/^[^\?]+\??/,'');
202			var params = tb_parseQuery( queryString );
203			var largeur_ecran = jQuery(window).width(); //Recuperation de la largeur totale de l'ecran. Attention à ne pas utiliser cette variable telle qu'elle car le contour de l'iframe de ne serai pas correctement affiché
204			var hauteur_ecran = jQuery(window).height(); //Recuperation de la hauteur totale de l'ecran. Attention idem que la largeur
205
206			var hauteur_full = hauteur_ecran-30;
207
208			TB_WIDTH = (params['width']*1) + 30 || 630; //defaults to 630 if no paramaters were added to URL
209			TB_HEIGHT = (params['height']*1) + 40 || 440; //defaults to 440 if no paramaters were added to URL
210
211
212			if (TB_WIDTH >= largeur_ecran) { //Si la hauteur fourni en parametre à l'appel de la fonction est superieur à la largeur de l'ecran alors la largeur du thickbox prendra la valeure de la largeur de l'ecran
213				TB_WIDTH = largeur_ecran - 50;
214			}
215			if (TB_HEIGHT >= hauteur_ecran) { // idem pour la hauteur
216				TB_HEIGHT = hauteur_ecran - 50;
217			}
218			ajaxContentW = TB_WIDTH - 30;
219			ajaxContentH = TB_HEIGHT - 45;
220			if(url.indexOf('TB_iframe') != -1){// either iframe or ajax window
221
222					urlNoQuery = url.split('TB_');
223					jQuery("#TB_iframeContent").remove();
224					if(params['modal'] != "true"){//iframe no modal
225						if (clickAjoute == 1) {
226							if(confirm("Vous avez change(e) la position des blocs d'informations. Presser Ok si vous souhaitez enregistrer leur position. Sinon vous serez rediriges vers la page de modification afin de terminer le positionnement de vos blocs.")) {
227								jQuery("#envoi_valeur").submit();
228							}
229							else {
230								tb_remove();
231							}
232						}
233						if (apercu == 1) {
234							jQuery("#TB_window").append("<div id='TB_title'><div id='TB_ajaxWindowTitle'>"+caption+"</div><div id='TB_closeAjaxWindow'><a href='javascript:void(0)' id='TB_closeWindowButton' title='Close'>fermer</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>");
235						}
236						else {
237						    if(params['Fullscreen'] == 1)
238						      {// Si 100% demandé...
239// 							alert ('Fullscreen');
240							TB_WIDTH = largeur_ecran;
241							TB_HEIGHT = hauteur_ecran;
242							jQuery("#TB_window").append("<div id='TB_title'><div id='TB_closeAjaxWindow'><a href='javascript:void(0)' id='TB_closeWindowButton' title='Close'>fermer</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:"+largeur_ecran+"px;height:"+hauteur_full+"px;' >"+largeur_ecran+" "+hauteur_full+"</iframe>");
243						      }
244						    else
245						    {
246							jQuery("#TB_window").append("<div id='TB_title'><div id='TB_closeAjaxWindow'><a href='javascript:void(0)' id='TB_closeWindowButton' title='Close'>fermer</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>");
247						    }
248					//jQuery("#TB_window").append("<iframe frameborder='0' hspace='0' src='"+urlNoQuery[0]+"' id='TB_iframeContent' name='TB_iframeContent' onload='tb_showIframe()' style='width:"+(ajaxContentW + 29)+"px;height:"+(ajaxContentH + 17)+"px;' > </iframe><div id='TB_title'><div id='bt_continuer_achat'><span class='Bouton_retourner'><a href='javascript:void(0)' id='TB_closeWindowButton' title='Poursuivre mes achats' onClick='tb_remove(); redirect(\"reload\");'>Poursuivre mes achats</a></span></div><div id='bt_voir_panier'><span class='Bouton_continuer'><a href='javascript:void(0)' onClick='tb_remove(); redirect(\"paiement\");'>
248Voir mon panier</a></span></div></div>");
249						}
250					}else{//iframe modal
251					jQuery("#TB_overlay").unbind();
252					jQuery("#TB_window").append("<div id='TB_title'><div id='TB_closeAjaxWindow'><a href='javascript:void(0)' id='TB_closeWindowButton' title='Close'>fermer</a></div></div><iframe frameborder='0' hspace='0' src='"+urlNoQuery[0]+"' id='TB_iframeContent' name='TB_iframeContent' onload='tb_showIframe()' style='width:"+(ajaxContentW + 29)+"px;height:"+(ajaxContentH + 17)+"px;'> </iframe>");
253						//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;'> </iframe>");
254					}
255			}else{// not an iframe, ajax
256					if(jQuery("#TB_window").css("display") != "block"){
257						if(params['modal'] != "true"){//ajax no modal
258						jQuery("#TB_window").append("<div id='TB_title'><div id='TB_ajaxWindowTitle'>"+caption+"</div><div id='TB_closeAjaxWindow'><a href='#' id='TB_closeWindowButton'>fermer</a></div></div><div id='TB_ajaxContent' style='width:"+ajaxContentW+"px;height:"+ajaxContentH+"px'></div>");
259						}else{//ajax modal
260						jQuery("#TB_overlay").unbind();
261						jQuery("#TB_window").append("<div id='TB_ajaxContent' class='TB_modal' style='width:"+ajaxContentW+"px;height:"+ajaxContentH+"px;'></div>");
262						}
263					}else{//this means the window is already up, we are just loading new content via ajax
264						jQuery("#TB_ajaxContent")[0].style.width = ajaxContentW +"px";
265						jQuery("#TB_ajaxContent")[0].style.height = ajaxContentH +"px";
266						jQuery("#TB_ajaxContent")[0].scrollTop = 0;
267						jQuery("#TB_ajaxWindowTitle").html(caption);
268					}
269			}
270
271			jQuery("#TB_closeWindowButton").click(tb_remove);
272
273				if(url.indexOf('TB_inline') != -1){
274					jQuery("#TB_ajaxContent").append(jQuery('#' + params['inlineId']).children());
275					jQuery("#TB_window").unload(function () {
276						jQuery('#' + params['inlineId']).append( jQuery("#TB_ajaxContent").children() ); // move elements back when you're finished
277					});
278					tb_position();
279					jQuery("#TB_load").remove();
280					jQuery("#TB_window").css({display:"block"});
281				}else if(url.indexOf('TB_iframe') != -1){
282					tb_position();
283					if($.browser.safari){//safari needs help because it will not fire iframe onload
284						jQuery("#TB_load").remove();
285						jQuery("#TB_window").css({display:"block"});
286					}
287				}else{
288					jQuery("#TB_ajaxContent").load(url += "&random=" + (new Date().getTime()),function(){//to do a post change this load method
289						tb_position();
290						jQuery("#TB_load").remove();
291						tb_init("#TB_ajaxContent a.thickbox");
292						jQuery("#TB_window").css({display:"block"});
293					});
294				}
295
296		}
297
298		if(!params['modal']){
299			document.onkeyup = function(e){
300				if (e == null) { // ie
301					keycode = event.keyCode;
302				} else { // mozilla
303					keycode = e.which;
304				}
305				if(keycode == 27){ // close
306					tb_remove();
307				}
308			};
309		}
310
311	} catch(e) {
312		//nothing here
313	}
314}
315
316//helper functions below
317function tb_showIframe(){
318	jQuery("#TB_load").remove();
319	jQuery("#TB_window").css({display:"block"});
320}
321
322function tb_remove() {
323 	jQuery("#TB_imageOff").unbind("click");
324	jQuery("#TB_closeWindowButton").unbind("click");
325	jQuery("#TB_window").fadeOut("fast",function(){jQuery('#TB_window,#TB_overlay,#TB_HideSelect').trigger("unload").unbind().remove();});
326	jQuery("#TB_load").remove();
327	if (typeof document.body.style.maxHeight == "undefined") {//if IE 6
328		jQuery("body","html").css({height: "auto", width: "auto"});
329		jQuery("html").css("overflow","");
330	}
331	document.onkeydown = "";
332	document.onkeyup = "";
333	return false;
334}
335
336function tb_position() {
337jQuery("#TB_window").css({marginLeft: '-' + parseInt((TB_WIDTH / 2),10) + 'px', width: TB_WIDTH + 'px'});
338	if ( !(jQuery.browser.msie && jQuery.browser.version < 7)) { // take away IE6
339		jQuery("#TB_window").css({marginTop: '-' + parseInt((TB_HEIGHT / 2),10) + 'px'});
340	}
341}
342
343function tb_parseQuery ( query ) {
344   var Params = {};
345   if ( ! query ) {return Params;}// return empty object
346   var Pairs = query.split(/[;&]/);
347   for ( var i = 0; i < Pairs.length; i++ ) {
348      var KeyVal = Pairs[i].split('=');
349      if ( ! KeyVal || KeyVal.length != 2 ) {continue;}
350      var key = unescape( KeyVal[0] );
351      var val = unescape( KeyVal[1] );
352      val = val.replace(/\+/g, ' ');
353      Params[key] = val;
354   }
355   return Params;
356}
357
358function tb_getPageSize(){
359	var de = document.documentElement;
360	var w = window.innerWidth || self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth;
361	var h = window.innerHeight || self.innerHeight || (de&&de.clientHeight) || document.body.clientHeight;
362	arrayPageSize = [w,h];
363	return arrayPageSize;
364}
365
366function tb_detectMacXFF() {
367  var userAgent = navigator.userAgent.toLowerCase();
368  if (userAgent.indexOf('mac') != -1 && userAgent.indexOf('firefox')!=-1) {
369    return true;
370  }
371}
372
373function getCookieVal(offset)
374{
375var endstr=document.cookie.indexOf (";", offset);
376if (endstr==-1) endstr=document.cookie.length;
377return unescape(document.cookie.substring(offset, endstr));
378}
379
380function LireCookie(nom)
381{
382	var arg=nom+"=";
383	var alen=arg.length;
384	var clen=document.cookie.length;
385	var i=0;
386	while (i<clen)
387	{
388		var j=i+alen;
389		if (document.cookie.substring(i, j)==arg) return getCookieVal(j);
390		i=document.cookie.indexOf(" ",i)+1;
391		if (i==0) break;
392	}
393	return 0;
394}

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.