Преглед изворни кода

Slimbox for view complete the image if its size is greater than 500px and some minor bug fixes

pecesama пре 18 година
родитељ
комит
bda5c184b8

BIN
admin/css/closelabel.gif Прегледај датотеку


BIN
admin/css/loading.gif Прегледај датотеку


BIN
admin/css/nextlabel.gif Прегледај датотеку


BIN
admin/css/prevlabel.gif Прегледај датотеку


+ 75 - 0
admin/css/slimbox.css Прегледај датотеку

@@ -0,0 +1,75 @@
1
+/* SLIMBOX */
2
+
3
+#lbOverlay {
4
+	position: absolute;
5
+	left: 0;
6
+	width: 100%;
7
+	background-color: #000;
8
+	cursor: pointer;
9
+}
10
+
11
+#lbCenter, #lbBottomContainer {
12
+	position: absolute;
13
+	left: 50%;
14
+	overflow: hidden;
15
+	background-color: #fff;
16
+}
17
+
18
+.lbLoading {
19
+	background: #fff url(loading.gif) no-repeat center;
20
+}
21
+
22
+#lbImage {
23
+	border: 10px solid #fff;
24
+}
25
+
26
+#lbPrevLink, #lbNextLink {
27
+	display: block;
28
+	position: absolute;
29
+	top: 0;
30
+	width: 50%;
31
+	outline: none;
32
+}
33
+
34
+#lbPrevLink {
35
+	left: 0;
36
+}
37
+
38
+#lbPrevLink:hover {
39
+	background: transparent url(prevlabel.gif) no-repeat 0% 15%;
40
+}
41
+
42
+#lbNextLink {
43
+	right: 0;
44
+}
45
+
46
+#lbNextLink:hover {
47
+	background: transparent url(nextlabel.gif) no-repeat 100% 15%;
48
+}
49
+
50
+#lbBottom {
51
+	font-family: Verdana, Helvetica, sans-serif;
52
+	font-size: 10px;
53
+	color: #666;
54
+	line-height: 1.4em;
55
+	text-align: left;
56
+	border: 10px solid #fff;
57
+	border-top-style: none;
58
+}
59
+
60
+#lbCloseLink {
61
+	display: block;
62
+	float: right;
63
+	width: 66px;
64
+	height: 22px;
65
+	background: transparent url(closelabel.gif) no-repeat center;
66
+	margin: 5px 0;
67
+}
68
+
69
+#lbCaption, #lbNumber {
70
+	margin-right: 71px;
71
+}
72
+
73
+#lbCaption {
74
+	font-weight: bold;
75
+}

+ 188 - 0
admin/scripts/slimbox.js Прегледај датотеку

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


BIN
images/favicon.ico Прегледај датотеку


+ 11 - 4
index.php Прегледај датотеку

@@ -44,8 +44,13 @@
44 44
 		}
45 45
 	}
46 46
 	
47
-	$input = array("{Title}", "{Description}", "{URL_Tumble}");
48
-	$output = array($conf->title, $conf->description, $conf->urlGelato);
47
+	$gelato_includes = "<script language=\"javascript\" type=\"text/javascript\" src=\"".$conf->urlGelato."/admin/scripts/mootools.js\"></script>\n";
48
+	$gelato_includes .= "\t<script language=\"javascript\" type=\"text/javascript\" src=\"".$conf->urlGelato."/admin/scripts/slimbox.js\"></script>\n";
49
+	$gelato_includes .= "\t<link rel=\"stylesheet\" type=\"text/css\" href=\"".$conf->urlGelato."/admin/css/slimbox.css\" />\n";
50
+	$gelato_includes .= "\t<link rel=\"shortcut icon\" href=\"".$conf->urlGelato."/images/favicon.ico\" />";
51
+	
52
+	$input = array("{Gelato_includes}","{Title}", "{Description}", "{URL_Tumble}");
53
+	$output = array($gelato_includes, $conf->title, $conf->description, $conf->urlGelato);
49 54
 	
50 55
 	$template->cargarPlantilla($input, $output, "template_header");
51 56
 	$template->mostrarPlantilla();
@@ -92,8 +97,10 @@
92 97
 							$photoPath = $register["url"];
93 98
 						}
94 99
 						
95
-						$input = array("{Date_Added}", "{Permalink}", "{PhotoURL}", "{PhotoAlt}", "{Caption}", "{URL_Tumble}");
96
-						$output = array($formatedDate, $permalink, $photoPath, "", $register["description"], $conf->urlGelato);
100
+						$effect = " onclick=\"Lightbox.show('".$register["url"]."', '".strip_tags(htmlentities($register["description"]))."');\" ";
101
+						
102
+						$input = array("{Date_Added}", "{Permalink}", "{PhotoURL}", "{PhotoAlt}", "{Caption}", "{Effect}", "{URL_Tumble}");
103
+						$output = array($formatedDate, $permalink, $photoPath, strip_tags($register["description"]), $register["description"], $effect, $conf->urlGelato);
97 104
 						
98 105
 						$template->cargarPlantilla($input, $output, "template_photo");
99 106
 						$template->mostrarPlantilla();							   

+ 1 - 0
themes/tumblr/template_header.htm Прегледај датотеку

@@ -3,6 +3,7 @@
3 3
 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4 4
 <head>    
5 5
 	<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
6
+	{Gelato_includes}
6 7
 	<link rel="stylesheet" type="text/css" href="{URL_Tumble}/themes/tumblr/style.css"/>
7 8
 	<link rel="alternate" type="application/rss+xml" title="RSS" href="{URL_Tumble}/rss.php"/>
8 9
     <title>{Title}</title>

+ 1 - 1
themes/tumblr/template_photo.htm Прегледај датотеку

@@ -10,7 +10,7 @@
10 10
                 
11 11
 			   
12 12
                     <div class="photo">
13
-                        <img src="{PhotoURL}" alt="{PhotoAlt}"/><br/>
13
+                        <img src="{PhotoURL}" alt="{PhotoAlt}" {Effect} /><br/>
14 14
                         
15 15
                             <div class="caption">{Caption}</div>
16 16