forked from Pixabay/jQuery-flexImages
-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo.html
340 lines (310 loc) · 22.1 KB
/
demo.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
<!DOCTYPE html><html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery flexImages Plugin</title>
<meta name="description" content="A lightweight jQuery plugin for creating fluid galleries as seen on Flickr and Google Images.">
<link rel="shortcut icon" href="https://pixabay.com/favicon.ico">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300">
<link rel="stylesheet" href="https://cdn.rawgit.com/yahoo/pure-release/v0.6.0/pure-min.css">
<style>
body { margin: 0; padding: 0; border: 0; min-width: 320px; color: #777; }
html, button, input, select, textarea, .pure-g [class *= "pure-u"] { font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 1.02em; }
p, td { line-height: 1.5; }
ul { padding: 0 0 0 20px; }
th { background: #eee; white-space: nowrap; }
th, td { padding: 10px; text-align: left; vertical-align: top; font-size: .9em; font-weight: normal; border-right: 1px solid #fff; }
td:first-child { white-space: nowrap; color: #008000; width: 1%; font-style: italic; }
h1, h2, h3 { color: #4b4b4b; font-family: "Source Sans Pro", sans-serif; font-weight: 300; margin: 0 0 1.2em; }
h1 { font-size: 4.5em; color: #1f8dd6; margin: 0 0 .4em; }
h2 { font-size: 2em; color: #636363; }
h3 { font-size: 1.8em; color: #4b4b4b; margin: 1.8em 0 .8em }
h4 { font: bold 1em sans-serif; color: #636363; margin: 4em 0 1em; }
a { color: #4e99c7; text-decoration: none; }
a:hover { text-decoration: underline; }
p, pre { margin: 0 0 1.2em; }
::selection { color: #fff; background: #328efd; }
::-moz-selection { color: #fff; background: #328efd; }
@media (max-width:480px) {
h1 { font-size: 3em; }
h2 { font-size: 1.8em; }
h3 { font-size: 1.5em; }
td:first-child { white-space: normal; }
}
.inline-code { padding: 1px 5px; background: #eee; border-radius: 2px; }
pre { padding: 15px 10px; font-size: .9em; color: #555; background: #edf3f8; }
pre i { color: #aaa; } /* comments */
pre b { font-weight: normal; color: #cf4b25; } /* strings */
pre em { color: #0c59e9; } /* numeric */
/* Pure CSS */
.pure-button { margin: 5px 0; text-decoration: none !important; }
.button-lg { margin: 5px 0; padding: .65em 1.6em; font-size: 105%; }
/* demo4 */
#demo4 .item { margin: 0 1px 10px 1px; border: 0; }
#demo4 .item .img { position: absolute; left: 0; top: 0; right: 2px; bottom: 20px; }
#demo4 .bottom { position: absolute; left: 2px; bottom: 0; right: 2px; font-size: 13px; height: 18px; }
/* demo5 */
#demo5 .over { position: absolute; bottom: 0; left: 0; right: 0; padding: 4px 6px; font-size: 13px; color: #fff; background: #222; background: rgba(0,0,0,.7); }
/* demo6 */
#demo6 a { display: block; position: absolute; top: 0; right: 0; bottom: -12px; left: 0; }
</style>
<link rel="stylesheet" href="jquery.flex-images.css">
</head>
<body>
<div style="max-width:900px;padding:0 10px;margin:40px auto;text-align:center">
<h1>flexImages</h1>
<h2>A lightweight jQuery plugin for creating fluid galleries as seen on Flickr and Google Images.</h2>
<a href="https://github.com/Pixabay/jQuery-flexImages/archive/master.zip" class="pure-button pure-button-primary button-lg">Download</a>
<a href="https://github.com/Pixabay/jQuery-flexImages" class="pure-button button-lg">View on GitHub</a>
</div>
<div style="max-width:900px;margin:auto;padding:0 10px">
<h3>Overview and Features</h3>
<p>
Released under the <a href="http://www.opensource.org/licenses/mit-license.php">MIT License</a>.
Source on <a href="https://github.com/Pixabay/jQuery-flexImages">Github</a> (<a href="https://github.com/Pixabay/jQuery-flexImages#changelog">changelog</a>).
Compatible with jQuery 1.7.0+ in Firefox, Safari, Chrome, Opera, Internet Explorer 7+. No dependencies except the jQuery library.
A <a href="https://goodies.pixabay.com/javascript/flex-images/demo.html">vanilla JavaScript version</a> is available, which works down to IE8.
</p>
<ul>
<li>Ridiculously tiny: 1.4 kB of JavaScript - less than 0.7 kB gzipped</li>
<li>Source images/objects can have any size</li>
<li>Works with more than just images, e.g. videos, iframes and plain text</li>
<li>Responsive</li>
<li>Equal margins between images controlled via CSS</li>
<li>No cropping or reordering</li>
<li>AJAX ready, e.g. for infinite scrolling</li>
<li>Support for lazy loading of images and iframe contents</li>
<li>Layout options to control e.g. the maximum number of rows - or whether or not to display an incomplete (last) row.</li>
</ul>
<p>
This plugin was developed by and for <a href="https://pixabay.com/">Pixabay.com</a> - an international repository for free Public Domain images.
We have <a href="https://pixabay.com/en/photos/?order=best">implemented this plugin in production</a> and we share this piece of software - in the spirit of Pixabay - freely with others.
</p>
<h3>Live Demo</h3>
</div>
<div style="max-width:908px;margin:auto;padding:0 10px 10px">
<div id="demo1" class="flex-images">
<div class="item" data-w="219" data-h="180"><img src="images/1.jpg"></div>
<div class="item" data-w="279" data-h="180"><img src="images/2.jpg"></div>
<div class="item" data-w="270" data-h="180"><img src="images/3.jpg"></div>
<div class="item" data-w="270" data-h="180"><img src="images/4.jpg"></div>
<div class="item" data-w="147" data-h="180"><img src="images/5.jpg"></div>
<div class="item" data-w="276" data-h="180"><img src="images/6.jpg"></div>
<div class="item" data-w="319" data-h="180"><img src="images/7.jpg"></div>
<div class="item" data-w="270" data-h="180"><img src="images/8.jpg"></div>
<div class="item" data-w="240" data-h="180"><img src="images/9.jpg"></div>
<div class="item" data-w="270" data-h="180"><img src="images/10.jpg"></div>
<div class="item" data-w="240" data-h="180"><img src="images/11.jpg"></div>
<div class="item" data-w="270" data-h="180"><img src="images/12.jpg"></div>
<div class="item" data-w="283" data-h="180"><img src="images/13.jpg"></div>
<div class="item" data-w="271" data-h="180"><img src="images/14.jpg"></div>
<div class="item" data-w="258" data-h="180"><img src="images/15.jpg"></div>
</div>
</div>
<div style="max-width:900px;margin:auto;padding:0 10px 50px">
<h3>Usage</h3>
<p>
Include the stylesheet <span class="inline-code">jquery.flex-images.css</span> in the <span class="inline-code"><head></span> section of your HTML document - and the JavaScript file <span class="inline-code">jquery.flex-images.min.js</span> after loading jQuery.
flexImages accepts settings from an object of key/value pairs.
</p>
<pre>$(selector).flexImages({key1: value1, key2: value2});</pre>
<p>
To <b>update</b> any settings or to <b>reload</b> modified content, simply re-initialize flexImages again on the appropriate container.
The plugin automatically prevents multiple bindings to one and the same element.
This may be used for content that gets modified later on via AJAX.
</p>
<h3>Settings</h3>
<table>
<tr><th>Property</th><th>Default</th><th>Description</th></tr>
<tr><td>container</td><td>'.item'</td><td>Selector of the individual image/object containers.</td></tr>
<tr><td>object</td><td>'img'</td><td>Selector of the image/object inside a container.</td></tr>
<tr><td>rowHeight</td><td>180</td><td>Maximum height of a row.</td></tr>
<tr><td>maxRows</td><td><i>null</i></td><td>Maximum number of rows to display. Images/Objects exceeding this row are hidden.</td></tr>
<tr><td>truncate</td><td><i>false</i></td><td>Hide <i>incomplete</i> last row of images/objects.</td></tr>
</table>
<h3 style="margin-top:.8em;border-top:1px solid #eee;padding-top:1.8em">Example Code</h3>
<p><b>HTML Markup</b></p>
<pre>
<div class=<b>"flex-images"</b>>
<div class=<b>"item"</b> data-w=<b>"200"</b> data-h=<b>"150"</b>><img src=<b>"image1.jpg"</b>></div>
<div class=<b>"item"</b> data-w=<b>"250"</b> data-h=<b>"150"</b>><img src=<b>"image2.jpg"</b>></div>
<div class=<b>"item"</b> data-w=<b>"150"</b> data-h=<b>"150"</b>><img src=<b>"image3.jpg"</b>></div>
<div class=<b>"item"</b> data-w=<b>"150"</b> data-h=<b>"150"</b>><img src=<b>"image4.jpg"</b>></div>
<div class=<b>"item"</b> data-w=<b>"200"</b> data-h=<b>"150"</b>><img src=<b>"image5.jpg"</b>></div>
<div class=<b>"item"</b> data-w=<b>"100"</b> data-h=<b>"150"</b>><img src=<b>"image6.jpg"</b>></div>
<div class=<b>"item"</b> data-w=<b>"180"</b> data-h=<b>"150"</b>><img src=<b>"image7.jpg"</b>></div>
<div class=<b>"item"</b> data-w=<b>"185"</b> data-h=<b>"150"</b>><img src=<b>"image8.jpg"</b>></div>
<div class=<b>"item"</b> data-w=<b>"350"</b> data-h=<b>"150"</b>><img src=<b>"image9.jpg"</b>></div>
<div class=<b>"item"</b> data-w=<b>"200"</b> data-h=<b>"150"</b>><img src=<b>"image10.jpg"</b>></div>
<div class=<b>"item"</b> data-w=<b>"165"</b> data-h=<b>"150"</b>><img src=<b>"image11.jpg"</b>></div>
<div class=<b>"item"</b> data-w=<b>"150"</b> data-h=<b>"150"</b>><img src=<b>"image12.jpg"</b>></div>
<div class=<b>"item"</b> data-w=<b>"120"</b> data-h=<b>"150"</b>><img src=<b>"image13.jpg"</b>></div>
<div class=<b>"item"</b> data-w=<b>"120"</b> data-h=<b>"150"</b>><img src=<b>"image14.jpg"</b>></div>
</div></pre>
<p>
Each image must be wrapped inside a container element. The container must have a width (data-w) and height (data-h) attribute set that corresponds to the image's/object's original dimension.
</p>
<p><b>JavaScript code</b></p>
<pre>$(<b>'.flex-images'</b>).flexImages({rowHeight: <em>140</em>});</pre>
<p>
How it works: The plugin dynamically changes the width and height of all containers.
The images themselves have their height and width set to 100%.
Thus, each image takes up the full space inside its container.
</p>
<p>
This architecture enables a very flexible grid layout that works with more than just images.
E.g. objects may be placed on top of the images via absolute positioning. Or instead of images, the containers may be filled with videos or even plain text.
</p>
<h3>More Examples</h3>
<p>Please take a look at the source code of this page to see how these demos work.</p>
<p style="margin:0 0 8px">1. Fixed number of two complete rows with lazy loading of images; only images that are actually visible are retrieved from the server:</p>
<div id="demo2" class="flex-images">
<div class="item" data-w="219" data-h="180"><img src="blank.gif" data-src="images/1.jpg"></div>
<div class="item" data-w="279" data-h="180"><img src="blank.gif" data-src="images/2.jpg"></div>
<div class="item" data-w="270" data-h="180"><img src="blank.gif" data-src="images/3.jpg"></div>
<div class="item" data-w="270" data-h="180"><img src="blank.gif" data-src="images/4.jpg"></div>
<div class="item" data-w="147" data-h="180"><img src="blank.gif" data-src="images/5.jpg"></div>
<div class="item" data-w="276" data-h="180"><img src="blank.gif" data-src="images/6.jpg"></div>
<div class="item" data-w="319" data-h="180"><img src="blank.gif" data-src="images/7.jpg"></div>
<div class="item" data-w="270" data-h="180"><img src="blank.gif" data-src="images/8.jpg"></div>
<div class="item" data-w="240" data-h="180"><img src="blank.gif" data-src="images/9.jpg"></div>
<div class="item" data-w="270" data-h="180"><img src="blank.gif" data-src="images/10.jpg"></div>
<div class="item" data-w="240" data-h="180"><img src="blank.gif" data-src="images/11.jpg"></div>
</div>
<p style="margin:10px 0">
For lazy loading of images or iframes, it's required to use a "blank.gif" pixel as the source of all images. The actual source URL must be given in a data-src attribute of the image.
On init, the plugin will replace the dummy src attribute (blank.gif) with the actual source URL for all visible images.
</p>
<p style="margin:60px 0 8px">2. A fluid grid with video content and only full rows:</p>
<div id="demo3" class="flex-images">
<div class="item" data-w="280" data-h="157">
<iframe style="width:100%;height:100%;border:0" src="https://www.youtube.com/embed/JGCsyshUU-A?showinfo=0" allowfullscreen></iframe>
</div>
<div class="item" data-w="280" data-h="157">
<iframe style="width:100%;height:100%;border:0" src="https://www.youtube.com/embed/QeR47AQ05Jo?showinfo=0" allowfullscreen></iframe>
</div>
<div class="item" data-w="280" data-h="157">
<iframe style="width:100%;height:100%;border:0" src="https://www.youtube.com/embed/DlM2CWNTQ84?showinfo=0" allowfullscreen></iframe>
</div>
</div>
<p style="margin:60px 0 8px">3. Showing a title underneath + less margin between images:</p>
<div id="demo4" class="flex-images">
<div class="item" data-w="219" data-h="197">
<div class="img"><img src="blank.gif" data-src="images/1.jpg"></div>
<div class="bottom">Caption 1</div>
</div>
<div class="item" data-w="279" data-h="197">
<div class="img"><img src="blank.gif" data-src="images/2.jpg"></div>
<div class="bottom">Caption 2</div>
</div>
<div class="item" data-w="270" data-h="197">
<div class="img"><img src="blank.gif" data-src="images/3.jpg"></div>
<div class="bottom">Caption 3</div>
</div>
<div class="item" data-w="270" data-h="197">
<div class="img"><img src="blank.gif" data-src="images/4.jpg"></div>
<div class="bottom">Caption 4</div>
</div>
<div class="item" data-w="147" data-h="197">
<div class="img"><img src="blank.gif" data-src="images/5.jpg"></div>
<div class="bottom">Caption 5</div>
</div>
</div>
<p style="margin:60px 0 8px">4. Overlaying caption - could be a link or a button, as well:</p>
<div id="demo5" class="flex-images">
<div class="item" data-w="219" data-h="180">
<img src="blank.gif" data-src="images/1.jpg">
<div class="over">Caption 1</div>
</div>
<div class="item" data-w="279" data-h="180">
<img src="blank.gif" data-src="images/2.jpg">
<div class="over">Caption 2</div>
</div>
<div class="item" data-w="270" data-h="180">
<img src="blank.gif" data-src="images/3.jpg">
<div class="over">Caption 3</div>
</div>
<div class="item" data-w="270" data-h="180">
<img src="blank.gif" data-src="images/4.jpg">
<div class="over">Caption 4</div>
</div>
<div class="item" data-w="147" data-h="180">
<img src="blank.gif" data-src="images/5.jpg">
<div class="over">Caption 5</div>
</div>
</div>
<p style="margin:60px 0 8px">5. Cut off parts of the images, e.g. a Shutterstock ID:</p>
<div id="demo6" class="flex-images">
<div class="item" data-w="450" data-h="300">
<a target="_blank" href="https://pixabay.com/go/?t=shutterstock&id=115679980">
<img src="https://thumb1.shutterstock.com/photos/display_pic_with_logo/619663/115679980.jpg">
</a>
</div>
<div class="item" data-w="450" data-h="437">
<a target="_blank" href="https://pixabay.com/go/?t=shutterstock&id=128624426">
<img src="https://thumb9.shutterstock.com/photos/display_pic_with_logo/588718/128624426.jpg">
</a>
</div>
<div class="item" data-w="450" data-h="300">
<a target="_blank" href="https://pixabay.com/go/?t=shutterstock&id=140507401">
<img src="https://thumb7.shutterstock.com/photos/display_pic_with_logo/1312372/140507401.jpg">
</a>
</div>
<div class="item" data-w="450" data-h="298">
<a target="_blank" href="https://pixabay.com/go/?t=shutterstock&id=167693018">
<img src="https://thumb1.shutterstock.com/photos/display_pic_with_logo/1014806/167693018.jpg">
</a>
</div>
</div>
<p style="margin:15px 0 5px">Original (uncut) first image with Shutterstock ID at the bottom:</p>
<div>
<img style="max-width:100%" src="https://thumb1.shutterstock.com/photos/display_pic_with_logo/619663/115679980.jpg">
</div>
<p style="margin-top:60px;border-top:1px solid #eee;padding-top:30px">
This plugin is used in production on <a href="https://pixabay.com/">Pixabay.com</a>,
where you can see flexImages at work in various locations and with all available options.
Please report any bugs and issues at the <a href="https://github.com/Pixabay/jQuery-flexImages">GitHub repositiory</a>.
</p>
<div style="margin:40px 0;overflow:hidden">
<span id="github_social"></span>
<div style="float:left;margin-right:35px">
<a href="#" data-width="70" class="twitter-share-button" data-text="jQuery flexImages Plugin"></a>
</div>
<div style="float:left">
<div class="g-plusone" data-size="medium"></div>
</div>
<div style="float:left;width:140px" class="fb-like" data-send="false" data-layout="button_count" data-width="140" data-show-faces="false"></div>
</div>
<p>This software is released as Open Source under the <a href="http://www.opensource.org/licenses/mit-license.php">MIT License</a> by <a href="https://pixabay.com/users/Simon/">Simon Steinberger / Pixabay.com</a>.</p>
</div>
<div style="background:#fafafa;border-top:1px solid #eee;padding:15px;font-size:.9em">
<div style="max-width:900px;margin:auto;padding:0 10px">
<a style="float:right;margin-left:20px" href="https://pixabay.com/en/service/about/">About Us</a>
<a style="float:right;margin-left:20px" href="https://pixabay.com/en/blog/">Blog</a>
<a style="float:right;margin-left:20px" href="https://goodies.pixabay.com/">More Goodies</a>
© <a href="https://pixabay.com/">Pixabay.com</a> / Simon Steinberger / Hans Braxmeier
</div>
</div>
<div id="fb-root"></div>
<script src="https://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="jquery.flex-images.js"></script>
<script>
$('#demo1').flexImages({rowHeight: 140});
$('#demo2').flexImages({rowHeight: 120, truncate: 1, maxRows: 2});
$('#demo3').flexImages({object: 'iframe', rowHeight: 200, truncate: 1});
$('#demo4').flexImages({ truncate: 1 });
$('#demo5').flexImages({ truncate: 1 });
$('#demo6').flexImages({ truncate: 1 });
if (~window.location.href.indexOf('http')) {
(function() {var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;po.src = 'https://apis.google.com/js/plusone.js';var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);})();
(function(d, s, id) {var js, fjs = d.getElementsByTagName(s)[0];if (d.getElementById(id)) return;js = d.createElement(s); js.id = id;js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.4&appId=114593902037957";fjs.parentNode.insertBefore(js, fjs);}(document, 'script', 'facebook-jssdk'));
!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');
$('#github_social').html('\
<iframe style="float:left;margin-right:15px" src="//ghbtns.com/github-btn.html?user=Pixabay&repo=jQuery-flexImages&type=watch&count=true" allowtransparency="true" frameborder="0" scrolling="0" width="110" height="20"></iframe>\
<iframe style="float:left;margin-right:15px" src="//ghbtns.com/github-btn.html?user=Pixabay&repo=jQuery-flexImages&type=fork&count=true" allowtransparency="true" frameborder="0" scrolling="0" width="110" height="20"></iframe>\
');
}
</script>
</body>
</html>