PageSourceSearch

http://www.pilotenbilder.de/blog/wp-content/plugins/lightbox/js/lightbox.js

js pilotenbilder.de collected 2026-10-08 02:30:39 UTC 16,369 bytes, 487 lines download raw bytes

1// -----------------------------------------------------------------------------------
2//	Lightbox v2.03.3
3//	by Lokesh Dhakar - http://www.huddletogether.com
4//	5/21/06
5//
6//	For more information on this script, visit:
7//	http://huddletogether.com/projects/lightbox2/
8//
9//	Licensed under the Creative Commons Attribution 2.5 License - http://creativecommons.org/licenses/by/2.5/
10//	
11//	Credit also due to those who have helped, inspired, and made their code available to the public.
12//	Including: Scott Upton(uptonic.com), Peter-Paul Koch(quirksmode.com), Thomas Fuchs(mir.aculo.us), and others.
13// -----------------------------------------------------------------------------------
14var imageArray = new Array;
15var activeImage;
16
17if(animate == true){
18	overlayDuration = 0.2;	// shadow fade in/out duration
19	if(resizeSpeed > 10){ resizeSpeed = 10;}
20	if(resizeSpeed < 1){ resizeSpeed = 1;}
21	resizeDuration = (11 - resizeSpeed) * 0.15;
22} else { 
23	overlayDuration = 0;
24	resizeDuration = 0;
25}
26Object.extend(Element, {
27	getWidth: function(element) {
28	   	element = $(element);
29	   	return element.offsetWidth; 
30	},
31	setWidth: function(element,w) {
32	   	element = $(element);
33    	element.style.width = w +"px";
34	},
35	setHeight: function(element,h) {
36   		element = $(element);
37    	element.style.height = h +"px";
38	},
39	setTop: function(element,t) {
40	   	element = $(element);
41    	element.style.top = t +"px";
42	},
43	setLeft: function(element,l) {
44	   	element = $(element);
45    	element.style.left = l +"px";
46	},
47	setSrc: function(element,src) {
48    	element = $(element);
49    	element.src = src; 
50	},
51	setHref: function(element,href) {
52    	element = $(element);
53    	element.href = href; 
54	},
55	setInnerHTML: function(element,content) {
56		element = $(element);
57		element.innerHTML = content;
58	}
59});
60Array.prototype.removeDuplicates = function () {
61    for(i = 0; i < this.length; i++){
62        for(j = this.length-1; j>i; j--){        
63            if(this[i][0] == this[j][0]){
64                this.splice(j,1);
65            }
66        }
67    }
68}
69Array.prototype.empty = function () {
70	for(i = 0; i <= this.length; i++){
71		this.shift();
72	}
73}
74var Lightbox = Class.create();
75
76Lightbox.prototype = {
77	initialize: function() {
78		this.updateImageList();
79		var objBody = document.getElementsByTagName("body").item(0);
80		
81		var objOverlay = document.createElement("div");
82		objOverlay.setAttribute('id','overlay');
83		objOverlay.style.display = 'none';
84		objOverlay.onclick = function() { myLightbox.end(); }
85		objBody.appendChild(objOverlay);
86		
87		var objLightbox = document.createElement("div");
88		objLightbox.setAttribute('id','lightbox');
89		objLightbox.style.display = 'none';
90		objLightbox.onclick = function(e) {	// close Lightbox is user clicks shadow overlay
91			if (!e) var e = window.event;
92			var clickObj = Event.element(e).id;
93			if ( clickObj == 'lightbox') {
94				myLightbox.end();
95			}
96		};
97		objBody.appendChild(objLightbox);
98			
99		var objOuterImageContainer = document.createElement("div");
100		objOuterImageContainer.setAttribute('id','outerImageContainer');
101		objLightbox.appendChild(objOuterImageContainer);
102
103		if(animate){
104			Element.setWidth('outerImageContainer', 250);
105			Element.setHeight('outerImageContainer', 250);			
106		} else {
107			Element.setWidth('outerImageContainer', 1);
108			Element.setHeight('outerImageContainer', 1);			
109		}
110
111		var objImageContainer = document.createElement("div");
112		objImageContainer.setAttribute('id','imageContainer');
113		objOuterImageContainer.appendChild(objImageContainer);
114	
115		var objLightboxImage = document.createElement("img");
116		objLightboxImage.setAttribute('id','lightboxImage');
117		objImageContainer.appendChild(objLightboxImage);
118	
119		var objHoverNav = document.createElement("div");
120		objHoverNav.setAttribute('id','hoverNav');
121		objImageContainer.appendChild(objHoverNav);
122	
123		var objPrevLink = document.createElement("a");
124		objPrevLink.setAttribute('id','prevLink');
125		objPrevLink.setAttribute('href','#');
126		objHoverNav.appendChild(objPrevLink);
127		
128		var objNextLink = document.createElement("a");
129		objNextLink.setAttribute('id','nextLink');
130		objNextLink.setAttribute('href','#');
131		objHoverNav.appendChild(objNextLink);
132	
133		var objLoading = document.createElement("div");
134		objLoading.setAttribute('id','loading');
135		objImageContainer.appendChild(objLoading);
136	
137		var objLoadingLink = document.createElement("a");
138		objLoadingLink.setAttribute('id','loadingLink');
139		objLoadingLink.setAttribute('href','#');
140		objLoadingLink.onclick = function() { myLightbox.end(); return false; }
141		objLoading.appendChild(objLoadingLink);
142	
143		var objLoadingImage = document.createElement("img");
144		objLoadingImage.setAttribute('src', fileLoadingImage);
145		objLoadingLink.appendChild(objLoadingImage);
146
147		var objImageDataContainer = document.createElement("div");
148		objImageDataContainer.setAttribute('id','imageDataContainer');
149		objLightbox.appendChild(objImageDataContainer);
150
151		var objImageData = document.createElement("div");
152		objImageData.setAttribute('id','imageData');
153		objImageDataContainer.appendChild(objImageData);
154	
155		var objImageDetails = document.createElement("div");
156		objImageDetails.setAttribute('id','imageDetails');
157		objImageData.appendChild(objImageDetails);
158	
159		var objCaption = document.createElement("span");
160		objCaption.setAttribute('id','caption');
161		objImageDetails.appendChild(objCaption);
162	
163		var objNumberDisplay = document.createElement("span");
164		objNumberDisplay.setAttribute('id','numberDisplay');
165		objImageDetails.appendChild(objNumberDisplay);
166		
167		var objBottomNav = document.createElement("div");
168		objBottomNav.setAttribute('id','bottomNav');
169		objImageData.appendChild(objBottomNav);
170	
171		var objBottomNavCloseLink = document.createElement("a");
172		objBottomNavCloseLink.setAttribute('id','bottomNavClose');
173		objBottomNavCloseLink.setAttribute('href','#');
174		objBottomNavCloseLink.onclick = function() { myLightbox.end(); return false; }
175		objBottomNav.appendChild(objBottomNavCloseLink);
176	
177		var objBottomNavCloseImage = document.createElement("img");
178		objBottomNavCloseImage.setAttribute('src', fileBottomNavCloseImage);
179		objBottomNavCloseLink.appendChild(objBottomNavCloseImage);
180	},
181	updateImageList: function() {	
182		if (!document.getElementsByTagName){ return; }
183		var anchors = document.getElementsByTagName('a');
184		var areas = document.getElementsByTagName('area');
185		for (var i=0; i<anchors.length; i++){
186			var anchor = anchors[i];
187			var relAttribute = String(anchor.getAttribute('rel'));
188			if (anchor.getAttribute('href') && (relAttribute.toLowerCase().match('lightbox'))){
189				anchor.onclick = function () {myLightbox.start(this); return false;}
190			}
191		}
192		for (var i=0; i< areas.length; i++){
193			var area = areas[i];
194			
195			var relAttribute = String(area.getAttribute('rel'));
196			if (area.getAttribute('href') && (relAttribute.toLowerCase().match('lightbox'))){
197				area.onclick = function () {myLightbox.start(this); return false;}
198			}
199		}
200	},
201	start: function(imageLink) {
202		hideSelectBoxes();
203		hideFlash();
204		var arrayPageSize = getPageSize();
205		Element.setWidth('overlay', arrayPageSize[0]);
206		Element.setHeight('overlay', arrayPageSize[1]);
207		new Effect.Appear('overlay', { duration: overlayDuration, from: 0.0, to: overlayOpacity });
208
209		imageArray = [];
210		imageNum = 0;		
211		
212		if (!document.getElementsByTagName){ return; }
213		var anchors = document.getElementsByTagName( imageLink.tagName);
214		if((imageLink.getAttribute('rel') == 'lightbox')){
215			imageArray.push(new Array(imageLink.getAttribute('href'), imageLink.getAttribute('title')));			
216		} else {
217			for (var i=0; i<anchors.length; i++){
218				var anchor = anchors[i];
219				if (anchor.getAttribute('href') && (anchor.getAttribute('rel') == imageLink.getAttribute('rel'))){
220					imageArray.push(new Array(anchor.getAttribute('href'), anchor.getAttribute('title')));
221				}
222			}
223			imageArray.removeDuplicates();
224			while(imageArray[imageNum][0] != imageLink.getAttribute('href')) { imageNum++;}
225		}
226		var arrayPageScroll = getPageScroll();
227		var lightboxTop = arrayPageScroll[1] + (arrayPageSize[3] / 10);
228		var lightboxLeft = arrayPageScroll[0];
229		Element.setTop('lightbox', lightboxTop);
230		Element.setLeft('lightbox', lightboxLeft);
231		
232		Element.show('lightbox');
233		
234		this.changeImage(imageNum);
235	},
236	changeImage: function(imageNum) {	
237		activeImage = imageNum;	// update global va
238		if(animate){ Element.show('loading');}
239		Element.hide('lightboxImage');
240		Element.hide('hoverNav');
241		Element.hide('prevLink');
242		Element.hide('nextLink');
243		Element.hide('imageDataContainer');
244		Element.hide('numberDisplay');		
245		imgPreloader = new Image();
246		imgPreloader.onload=function(){
247			Element.setSrc('lightboxImage', imageArray[activeImage][0]);
248			myLightbox.resizeImageContainer(imgPreloader.width, imgPreloader.height);
249			
250			imgPreloader.onload=function(){};	//	clear onLoad, IE behaves irratically with animated gifs otherwise 
251		}
252		imgPreloader.src = imageArray[activeImage][0];
253	},
254	resizeImageContainer: function( imgWidth, imgHeight) {
255		this.widthCurrent = Element.getWidth('outerImageContainer');
256		this.heightCurrent = Element.getHeight('outerImageContainer');
257		var widthNew = (imgWidth  + (borderSize * 2));
258		var heightNew = (imgHeight  + (borderSize * 2));
259		this.xScale = ( widthNew / this.widthCurrent) * 100;
260		this.yScale = ( heightNew / this.heightCurrent) * 100;
261		wDiff = this.widthCurrent - widthNew;
262		hDiff = this.heightCurrent - heightNew;
263
264		if(!( hDiff == 0)){ new Effect.Scale('outerImageContainer', this.yScale, {scaleX: false, duration: resizeDuration, queue: 'front'}); }
265		if(!( wDiff == 0)){ new Effect.Scale('outerImageContainer', this.xScale, {scaleY: false, delay: resizeDuration, duration: resizeDuration}); }
266		if((hDiff == 0) && (wDiff == 0)){
267			if (navigator.appVersion.indexOf("MSIE")!=-1){ pause(250); } else { pause(100);} 
268		}
269		Element.setHeight('prevLink', imgHeight);
270		Element.setHeight('nextLink', imgHeight);
271		Element.setWidth( 'imageDataContainer', widthNew);
272
273		this.showImage();
274	},
275	showImage: function(){
276		Element.hide('loading');
277		new Effect.Appear('lightboxImage', { duration: resizeDuration, queue: 'end', afterFinish: function(){	myLightbox.updateDetails(); } });
278		this.preloadNeighborImages();
279	},
280	updateDetails: function() {
281		if(imageArray[activeImage][1]){
282			Element.show('caption');
283			Element.setInnerHTML( 'caption', imageArray[activeImage][1]);
284		}
285		if(imageArray.length > 1){
286			Element.show('numberDisplay');
287			Element.setInnerHTML( 'numberDisplay', "Image " + eval(activeImage + 1) + " of " + imageArray.length);
288		}
289		new Effect.Parallel(
290			[ new Effect.SlideDown( 'imageDataContainer', { sync: true, duration: resizeDuration, from: 0.0, to: 1.0 }), 
291			  new Effect.Appear('imageDataContainer', { sync: true, duration: resizeDuration }) ], 
292			{ duration: resizeDuration, afterFinish: function() {
293				// update overlay size and update nav
294				var arrayPageSize = getPageSize();
295				Element.setHeight('overlay', arrayPageSize[1]);
296				myLightbox.updateNav();
297				}
298			} 
299		);
300	},
301	updateNav: function() {
302		Element.show('hoverNav');				
303
304		if(activeImage != 0){
305			Element.show('prevLink');
306			document.getElementById('prevLink').onclick = function() {
307				myLightbox.changeImage(activeImage - 1); return false;
308			}
309		}
310		if(activeImage != (imageArray.length - 1)){
311			Element.show('nextLink');
312			document.getElementById('nextLink').onclick = function() {
313				myLightbox.changeImage(activeImage + 1); return false;
314			}
315		}
316		this.enableKeyboardNav();
317	},
318	enableKeyboardNav: function() {
319		document.onkeydown = this.keyboardAction; 
320	},
321	disableKeyboardNav: function() {
322		document.onkeydown = '';
323	},
324	keyboardAction: function(e) {
325		if (e == null) { // ie
326			keycode = event.keyCode;
327			escapeKey = 27;
328		} else { // mozilla
329			keycode = e.keyCode;
330			escapeKey = e.DOM_VK_ESCAPE;
331		}
332
333		key = String.fromCharCode(keycode).toLowerCase();
334		
335		if((key == 'x') || (key == 'o') || (key == 'c') || (keycode == escapeKey)){	// close lightbox
336			myLightbox.end();
337		} else if((key == 'p') || (keycode == 37)){	// display previous image
338			if(activeImage != 0){
339				myLightbox.disableKeyboardNav();
340				myLightbox.changeImage(activeImage - 1);
341			}
342		} else if((key == 'n') || (keycode == 39)){	// display next image
343			if(activeImage != (imageArray.length - 1)){
344				myLightbox.disableKeyboardNav();
345				myLightbox.changeImage(activeImage + 1);
346			}
347		}
348
349	},
350	preloadNeighborImages: function(){
351
352		if((imageArray.length - 1) > activeImage){
353			preloadNextImage = new Image();
354			preloadNextImage.src = imageArray[activeImage + 1][0];
355		}
356		if(activeImage > 0){
357			preloadPrevImage = new Image();
358			preloadPrevImage.src = imageArray[activeImage - 1][0];
359		}
360	
361	},
362
363	end: function() {
364		this.disableKeyboardNav();
365		Element.hide('lightbox');
366		new Effect.Fade('overlay', { duration: overlayDuration});
367		showSelectBoxes();
368		showFlash();
369	}
370}
371function getPageScroll(){
372
373	var xScroll, yScroll;
374
375	if (self.pageYOffset) {
376		yScroll = self.pageYOffset;
377		xScroll = self.pageXOffset;
378	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
379		yScroll = document.documentElement.scrollTop;
380		xScroll = document.documentElement.scrollLeft;
381	} else if (document.body) {// all other Explorers
382		yScroll = document.body.scrollTop;
383		xScroll = document.body.scrollLeft;	
384	}
385
386	arrayPageScroll = new Array(xScroll,yScroll) 
387	return arrayPageScroll;
388}
389function getPageSize(){
390	
391	var xScroll, yScroll;
392	
393	if (window.innerHeight && window.scrollMaxY) {	
394		xScroll = window.innerWidth + window.scrollMaxX;
395		yScroll = window.innerHeight + window.scrollMaxY;
396	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
397		xScroll = document.body.scrollWidth;
398		yScroll = document.body.scrollHeight;
399	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
400		xScroll = document.body.offsetWidth;
401		yScroll = document.body.offsetHeight;
402	}
403	
404	var windowWidth, windowHeight;
405	if (self.innerHeight) {	// all except Explorer
406		if(document.documentElement.clientWidth){
407			windowWidth = document.documentElement.clientWidth; 
408		} else {
409			windowWidth = self.innerWidth;
410		}
411		windowHeight = self.innerHeight;
412	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
413		windowWidth = document.documentElement.clientWidth;
414		windowHeight = document.documentElement.clientHeight;
415	} else if (document.body) { // other Explorers
416		windowWidth = document.body.clientWidth;
417		windowHeight = document.body.clientHeight;
418	}	
419	if(yScroll < windowHeight){
420		pageHeight = windowHeight;
421	} else { 
422		pageHeight = yScroll;
423	}
424	if(xScroll < windowWidth){	
425		pageWidth = xScroll;		
426	} else {
427		pageWidth = windowWidth;
428	}
429	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
430	return arrayPageSize;
431}
432function getKey(e){
433	if (e == null) { // ie
434		keycode = event.keyCode;
435	} else { // mozilla
436		keycode = e.which;
437	}
438	key = String.fromCharCode(keycode).toLowerCase();
439	
440	if(key == 'x'){
441	}
442}
443function listenKey () {	document.onkeypress = getKey; }
444function showSelectBoxes(){
445	var selects = document.getElementsByTagName("select");
446	for (i = 0; i != selects.length; i++) {
447		selects[i].style.visibility = "visible";
448	}
449}
450function hideSelectBoxes(){
451	var selects = document.getElementsByTagName("select");
452	for (i = 0; i != selects.length; i++) {
453		selects[i].style.visibility = "hidden";
454	}
455}
456function showFlash(){
457	var flashObjects = document.getElementsByTagName("object");
458	for (i = 0; i < flashObjects.length; i++) {
459		flashObjects[i].style.visibility = "visible";
460	}
461
462	var flashEmbeds = document.getElementsByTagName("embed");
463	for (i = 0; i < flashEmbeds.length; i++) {
464		flashEmbeds[i].style.visibility = "visible";
465	}
466}
467function hideFlash(){
468	var flashObjects = document.getElementsByTagName("object");
469	for (i = 0; i < flashObjects.length; i++) {
470		flashObjects[i].style.visibility = "hidden";
471	}
472
473	var flashEmbeds = document.getElementsByTagName("embed");
474	for (i = 0; i < flashEmbeds.length; i++) {
475		flashEmbeds[i].style.visibility = "hidden";
476	}
477
478}
479function pause(ms){
480	var date = new Date();
481	curDate = null;
482	do{var curDate = new Date();}
483	while( curDate - date < ms);
484}
485
486function initLightbox() { myLightbox = new Lightbox(); }
487Event.observe(window, 'load', initLightbox, false);

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.