PageSourceSearch

https://starapraha.cz/script/slimbox1.js

js starapraha.cz collected 2026-10-02 13:46:59 UTC 7,457 bytes, 194 lines download raw bytes

1/*
2	Slimbox v1.41 - The ultimate lightweight Lightbox clone
3	by Christophe Beyls (http://www.digitalia.be) - MIT-style license.
4	Inspired by the original Lightbox v2 by Lokesh Dhakar.
5*/
6
7var Lightbox = {
8
9	init: function(options){
10		this.options = $extend({
11			resizeDuration: 360,
12			resizeTransition: Fx.Transitions.Sine.easeInOut,	// default transition, linear, Sine, Quad, Cubic, Quart, Quint, Expo, Circ, Back, Bounce, Elastic
13			initialWidth: 360,
14			initialHeight: 360,
15			animateCaption: false,
16			showCounter: false
17		}, options || {});
18
19		this.anchors = [];
20		$each(document.links, function(el){
21			if (el.rel && el.rel.test(/^lightbox/i)){
22				el.onclick = this.click.pass(el, this);
23				this.anchors.push(el);
24			}
25		}, this);
26		this.eventKeyDown = this.keyboardListener.bindAsEventListener(this);
27		this.eventPosition = this.position.bind(this);
28
29		this.overlay = new Element('div', {'id': 'lbOverlay'}).injectInside(document.body);
30
31		this.center = new Element('div', {'id': 'lbCenter', 'styles': {'width': this.options.initialWidth, 'height': this.options.initialHeight, 'marginLeft': -(this.options.initialWidth/2), 'display': 'none'}}).injectInside(document.body);
32		this.image = new Element('div', {'id': 'lbImage'}).injectInside(this.center);
33		this.prevLink = new Element('a', {'id': 'lbPrevLink', 'href': '#', 'styles': {'display': 'none'}}).injectInside(this.image);
34		this.nextLink = this.prevLink.clone().setProperty('id', 'lbNextLink').injectInside(this.image);
35		this.prevLink.onclick = this.previous.bind(this);
36		this.nextLink.onclick = this.next.bind(this);
37
38		this.bottomContainer = new Element('div', {'id': 'lbBottomContainer', 'styles': {'display': 'none'}}).injectInside(document.body);
39		this.bottom = new Element('div', {'id': 'lbBottom'}).injectInside(this.bottomContainer);
40		new Element('a', {'id': 'lbCloseLink', 'href': '#'}).injectInside(this.bottom).onclick = this.overlay.onclick = this.close.bind(this);
41		this.caption = new Element('div', {'id': 'lbCaption'}).injectInside(this.bottom);
42		this.copyright = new Element('div', {'id': 'lbCopyright'}).injectInside(this.bottom);
43		this.number = new Element('div', {'id': 'lbNumber'}).injectInside(this.bottom);
44		new Element('div', {'styles': {'clear': 'both'}}).injectInside(this.bottom);
45
46		var nextEffect = this.nextEffect.bind(this);
47		this.fx = {
48			overlay: this.overlay.effect('opacity', {duration: 480}).hide(),
49			resize: this.center.effects($extend({duration: this.options.resizeDuration, onComplete: nextEffect}, this.options.resizeTransition ? {transition: this.options.resizeTransition} : {})),
50			image: this.image.effect('opacity', {duration: 240, onComplete: nextEffect}),
51			bottom: this.bottom.effect('margin-top', {duration: 240, onComplete: nextEffect})
52		};
53
54		this.preloadPrev = new Image();
55		this.preloadNext = new Image();
56	},
57
58	click: function(link){
59		if (link.rel.length == 8) return this.show(link.href, link.title);
60
61		var j, imageNum, images = [];
62		this.anchors.each(function(el){
63			if (el.rel == link.rel){
64				for (j = 0; j < images.length; j++) if(images[j][0] == el.href) break;
65				if (j == images.length){
66					images.push([el.href, el.title]);
67					if (el.href == link.href) imageNum = j;
68				}
69			}
70		}, this);
71		return this.open(images, imageNum);
72	},
73
74	show: function(url, title){
75		return this.open([[url, title]], 0);
76	},
77
78	open: function(images, imageNum){
79		this.images = images;
80		this.position();
81		this.setup(true);
82		this.top = window.getScrollTop() + (window.getHeight() / 15);
83		this.center.setStyles({top: this.top, display: ''});
84		this.fx.overlay.start(0.8);
85		return this.changeImage(imageNum);
86	},
87
88	position: function(){
89		this.overlay.setStyles({'top': window.getScrollTop(), 'height': window.getHeight()});
90	},
91
92	setup: function(open){
93		var elements = $A(document.getElementsByTagName('object'));
94		elements.extend(document.getElementsByTagName(window.ie ? 'select' : 'embed'));
95		elements.each(function(el){
96			if (open) el.lbBackupStyle = el.style.visibility;
97			el.style.visibility = open ? 'hidden' : el.lbBackupStyle;
98		});
99		var fn = open ? 'addEvent' : 'removeEvent';
100		window[fn]('scroll', this.eventPosition)[fn]('resize', this.eventPosition);
101		document[fn]('keydown', this.eventKeyDown);
102		this.step = 0;
103	},
104
105	keyboardListener: function(event){
106		switch (event.keyCode){
107			case 27: case 88: case 67: this.close(); break;
108			case 37: case 90: this.previous(); break;	
109			case 39: case 68: this.next();
110		}
111	},
112
113	previous: function(){
114		return this.changeImage(this.activeImage-1);
115	},
116
117	next: function(){
118		return this.changeImage(this.activeImage+1);
119	},
120
121	changeImage: function(imageNum){
122		if (this.step || (imageNum < 0) || (imageNum >= this.images.length)) return false;
123		this.step = 1;
124		this.activeImage = imageNum;
125
126		this.bottomContainer.style.display = this.prevLink.style.display = this.nextLink.style.display = 'none';
127		this.fx.image.hide();
128		this.center.className = 'lbLoading';
129
130		this.preload = new Image();
131		this.preload.onload = this.nextEffect.bind(this);
132		this.preload.src = this.images[imageNum][0];
133		return false;
134	},
135
136	nextEffect: function(){
137		switch (this.step++){
138		case 1:
139			this.center.className = '';
140			this.image.style.backgroundImage = 'url('+this.images[this.activeImage][0]+')';
141			this.image.style.width = this.bottom.style.width = this.preload.width+'px';
142			this.image.style.height = this.prevLink.style.height = this.nextLink.style.height = this.preload.height+'px';
143
144			this.caption.setHTML(this.images[this.activeImage][1] || '');
145			this.copyright.setHTML('&copy; EPOQUE 1900, spol. s r.o. 2012, all rights reserved');
146			this.number.setHTML((!this.options.showCounter || (this.images.length == 1)) ? '' : 'Image '+(this.activeImage+1)+' of '+this.images.length);
147
148			if (this.activeImage) this.preloadPrev.src = this.images[this.activeImage-1][0];
149			if (this.activeImage != (this.images.length - 1)) this.preloadNext.src = this.images[this.activeImage+1][0];
150			if (this.center.clientHeight != this.image.offsetHeight){
151				this.fx.resize.start({height: this.image.offsetHeight, width: this.image.offsetWidth, marginLeft: -this.image.offsetWidth/2});
152				break;
153			}
154			this.step++;
155		case 2:
156			if (this.center.clientWidth != this.image.offsetWidth){
157				this.fx.resize.start({height: this.image.offsetHeight, width: this.image.offsetWidth, marginLeft: -this.image.offsetWidth/2});
158				break;
159			}
160			this.step++;
161		case 3:
162			this.bottomContainer.setStyles({top: this.top + this.center.clientHeight, height: 0, marginLeft: this.center.style.marginLeft, display: ''});
163			this.fx.image.start(1);
164			break;
165		case 4:
166			if (this.options.animateCaption){
167				this.fx.bottom.set(-this.bottom.offsetHeight);
168				this.bottomContainer.style.height = '';
169				this.fx.bottom.start(0);
170				break;
171			}
172			this.bottomContainer.style.height = '';
173		case 5:
174			if (this.activeImage) this.prevLink.style.display = '';
175			if (this.activeImage != (this.images.length - 1)) this.nextLink.style.display = '';
176			this.step = 0;
177		}
178	},
179
180	close: function(){
181		if (this.step < 0) return;
182		this.step = -1;
183		if (this.preload){
184			this.preload.onload = Class.empty;
185			this.preload = null;
186		}
187		for (var f in this.fx) this.fx[f].stop();
188		this.center.style.display = this.bottomContainer.style.display = 'none';
189		this.fx.overlay.chain(this.setup.pass(false, this)).start(0);
190		return false;
191	}
192};
193
194window.addEvent('domready', Lightbox.init.bind(Lightbox));

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.