Responsive Lightbox & Gallery - Version 1.4.0.1

Version Description

  • New: Added Image Lightbox script
  • New: Option to load scripts in header or footer
Download this release

Release Info

Developer dfactory
Plugin Icon 128x128 Responsive Lightbox & Gallery
Version 1.4.0.1
Comparing to
See all releases

Code changes from version 1.4.0 to 1.4.0.1

assets/swipebox/source/jquery.swipebox.js ADDED
@@ -0,0 +1,472 @@
1
+ /**
2
+ * Swipebox - A touchable jQuery lightbox
3
+ *
4
+ * @author Constantin Saguin - @brutaldesign
5
+ * @author Arno Welzel
6
+ * @link http://csag.co
7
+ * @github http://github.com/brutaldesign/swipebox
8
+ * @github https://github.com/arnowelzel/swipebox
9
+ * @version 1.2.1
10
+ * @license MIT License
11
+ */
12
+ ;
13
+ (function (e, t, n, r) {
14
+ n.swipebox = function (i, s) {
15
+ var o = {
16
+ useCSS: true,
17
+ initialIndexOnArray: 0,
18
+ hideBarsDelay: 3e3,
19
+ videoMaxWidth: 1140,
20
+ vimeoColor: "CCCCCC",
21
+ beforeOpen: null,
22
+ afterClose: null
23
+ }, u = this,
24
+ a = [],
25
+ i = i,
26
+ f = i.selector,
27
+ l = n(f),
28
+ c = t.createTouch !== r || "ontouchstart" in e || "onmsgesturechange" in e || navigator.msMaxTouchPoints,
29
+ h = !! e.SVGSVGElement,
30
+ p = e.innerWidth ? e.innerWidth : n(e).width(),
31
+ d = e.innerHeight ? e.innerHeight : n(e).height(),
32
+ v = '<div id="swipebox-overlay"> <div id="swipebox-slider"></div> <div id="swipebox-caption"></div> <div id="swipebox-action"> <a id="swipebox-close"></a> <a id="swipebox-prev"></a> <a id="swipebox-next"></a> </div> </div>';
33
+ u.settings = {};
34
+ u.init = function () {
35
+ u.settings = n.extend({}, o, s);
36
+ if (n.isArray(i)) {
37
+ a = i;
38
+ m.target = n(e);
39
+ m.init(u.settings.initialIndexOnArray)
40
+ } else {
41
+ l.click(function (e) {
42
+ u.refresh();
43
+ a = [];
44
+ var t, r, i;
45
+ if (!i) {
46
+ r = "rel";
47
+ i = n(this).attr(r)
48
+ }
49
+ if (i && i !== "" && i !== "nofollow") {
50
+ $elem = l.filter("[" + r + '="' + i + '"]')
51
+ } else {
52
+ $elem = n(f)
53
+ }
54
+ $elem.each(function () {
55
+ var e = null,
56
+ t = null;
57
+ if (n(this).attr("title")) e = n(this).attr("title");
58
+ else if (n(this).children("img").attr("alt")) e = n(this).children("img").attr("alt");
59
+ if (n(this).attr("href")) t = n(this).attr("href");
60
+ a.push({
61
+ href: t,
62
+ title: e
63
+ })
64
+ });
65
+ t = $elem.index(n(this));
66
+ e.preventDefault();
67
+ e.stopPropagation();
68
+ m.target = n(e.target);
69
+ m.init(t)
70
+ })
71
+ }
72
+ };
73
+ u.refresh = function () {
74
+ if (!n.isArray(i)) {
75
+ m.destroy();
76
+ $elem = n(f);
77
+ m.actions()
78
+ }
79
+ };
80
+ var m = {
81
+ init: function (e) {
82
+ if (u.settings.beforeOpen) u.settings.beforeOpen();
83
+ this.target.trigger("swipebox-start");
84
+ n.swipebox.isOpen = true;
85
+ this.build();
86
+ this.openSlide(e);
87
+ this.openMedia(e);
88
+ this.preloadMedia(e + 1);
89
+ this.preloadMedia(e - 1)
90
+ },
91
+ build: function () {
92
+ var e = this;
93
+ n("body").append(v);
94
+ if (e.doCssTrans()) {
95
+ n("#swipebox-slider").css({
96
+ "-webkit-transition": "left 0.4s ease",
97
+ "-moz-transition": "left 0.4s ease",
98
+ "-o-transition": "left 0.4s ease",
99
+ "-khtml-transition": "left 0.4s ease",
100
+ transition: "left 0.4s ease"
101
+ });
102
+ n("#swipebox-overlay").css({
103
+ "-webkit-transition": "opacity 1s ease",
104
+ "-moz-transition": "opacity 1s ease",
105
+ "-o-transition": "opacity 1s ease",
106
+ "-khtml-transition": "opacity 1s ease",
107
+ transition: "opacity 1s ease"
108
+ });
109
+ n("#swipebox-action, #swipebox-caption").css({
110
+ "-webkit-transition": "0.5s",
111
+ "-moz-transition": "0.5s",
112
+ "-o-transition": "0.5s",
113
+ "-khtml-transition": "0.5s",
114
+ transition: "0.5s"
115
+ })
116
+ }
117
+ if (h) {
118
+ var t = n("#swipebox-action #swipebox-close").css("background-image");
119
+ t = t.replace("png", "svg");
120
+ n("#swipebox-action #swipebox-prev,#swipebox-action #swipebox-next,#swipebox-action #swipebox-close").css({
121
+ "background-image": t
122
+ })
123
+ }
124
+ n.each(a, function () {
125
+ n("#swipebox-slider").append('<div class="slide"></div>')
126
+ });
127
+ e.setDim();
128
+ e.actions();
129
+ e.keyboard();
130
+ e.gesture();
131
+ e.animBars();
132
+ e.resize();
133
+
134
+ scrollTimer = setInterval(function () {
135
+ window.scrollTo(window.scrollX, window.scrollY);
136
+ }, 1000);
137
+ },
138
+ setDim: function () {
139
+ var t, r, i = {};
140
+ if ("onorientationchange" in e) {
141
+ e.addEventListener("orientationchange", function () {
142
+ if (e.orientation == 0) {
143
+ t = p;
144
+ r = d
145
+ } else if (e.orientation == 90 || e.orientation == -90) {
146
+ t = d;
147
+ r = p
148
+ }
149
+ }, false)
150
+ } else {
151
+ t = e.innerWidth ? e.innerWidth : n(e).width();
152
+ r = e.innerHeight ? e.innerHeight : n(e).height()
153
+ }
154
+ i = {
155
+ width: t,
156
+ height: r
157
+ };
158
+ n("#swipebox-overlay").css(i)
159
+ },
160
+ resize: function () {
161
+ var t = this;
162
+ n(e).resize(function () {
163
+ t.setDim()
164
+ }).resize()
165
+ },
166
+ supportTransition: function () {
167
+ var e = "transition WebkitTransition MozTransition OTransition msTransition KhtmlTransition".split(" ");
168
+ for (var n = 0; n < e.length; n++) {
169
+ if (t.createElement("div").style[e[n]] !== r) {
170
+ return e[n]
171
+ }
172
+ }
173
+ return false
174
+ },
175
+ doCssTrans: function () {
176
+ if (u.settings.useCSS && this.supportTransition()) {
177
+ return true
178
+ }
179
+ },
180
+ gesture: function () {
181
+ if (c) {
182
+ var e = this,
183
+ t = null,
184
+ r = 10,
185
+ i = {}, s = {};
186
+ var o = n("#swipebox-caption, #swipebox-action");
187
+ o.addClass("visible-bars");
188
+ e.setTimeout();
189
+ n("#swipebox-slider").bind("touchstart", function (e) {
190
+ n(this).addClass("touching");
191
+ s = e.originalEvent.targetTouches[0];
192
+ i.pageX = e.originalEvent.targetTouches[0].pageX;
193
+ n(".touching").bind("touchmove", function (e) {
194
+ e.preventDefault();
195
+ e.stopPropagation();
196
+ s = e.originalEvent.targetTouches[0]
197
+ });
198
+ return false
199
+ }).bind("touchend", function (u) {
200
+ u.preventDefault();
201
+ u.stopPropagation();
202
+ t = s.pageX - i.pageX;
203
+ if (t >= r) {
204
+ e.getPrev()
205
+ } else if (t <= -r) {
206
+ e.getNext()
207
+ } else {
208
+ if (!o.hasClass("visible-bars")) {
209
+ e.showBars();
210
+ e.setTimeout()
211
+ } else {
212
+ e.clearTimeout();
213
+ e.hideBars()
214
+ }
215
+ }
216
+ n(".touching").off("touchmove").removeClass("touching")
217
+ })
218
+ }
219
+ },
220
+ setTimeout: function () {
221
+ if (u.settings.hideBarsDelay > 0) {
222
+ var t = this;
223
+ t.clearTimeout();
224
+ t.timeout = e.setTimeout(function () {
225
+ t.hideBars()
226
+ }, u.settings.hideBarsDelay)
227
+ }
228
+ },
229
+ clearTimeout: function () {
230
+ e.clearTimeout(this.timeout);
231
+ this.timeout = null
232
+ },
233
+ showBars: function () {
234
+ var e = n("#swipebox-caption, #swipebox-action");
235
+ if (this.doCssTrans()) {
236
+ e.addClass("visible-bars")
237
+ } else {
238
+ n("#swipebox-caption").animate({
239
+ top: 0
240
+ }, 500);
241
+ n("#swipebox-action").animate({
242
+ bottom: 0
243
+ }, 500);
244
+ setTimeout(function () {
245
+ e.addClass("visible-bars")
246
+ }, 1e3)
247
+ }
248
+ },
249
+ hideBars: function () {
250
+ var e = n("#swipebox-caption, #swipebox-action");
251
+ if (this.doCssTrans()) {
252
+ e.removeClass("visible-bars")
253
+ } else {
254
+ n("#swipebox-caption").animate({
255
+ top: "-50px"
256
+ }, 500);
257
+ n("#swipebox-action").animate({
258
+ bottom: "-50px"
259
+ }, 500);
260
+ setTimeout(function () {
261
+ e.removeClass("visible-bars")
262
+ }, 1e3)
263
+ }
264
+ },
265
+ animBars: function () {
266
+ var e = this;
267
+ var t = n("#swipebox-caption, #swipebox-action");
268
+ t.addClass("visible-bars");
269
+ e.setTimeout();
270
+ n("#swipebox-slider").click(function (n) {
271
+ if (!t.hasClass("visible-bars")) {
272
+ e.showBars();
273
+ e.setTimeout()
274
+ } else {
275
+ e.clearTimeout();
276
+ e.hideBars()
277
+ }
278
+ });
279
+ n("#swipebox-action").hover(function () {
280
+ e.showBars();
281
+ t.addClass("force-visible-bars");
282
+ e.clearTimeout()
283
+ }, function () {
284
+ t.removeClass("force-visible-bars");
285
+ e.setTimeout()
286
+ })
287
+ },
288
+ keyboard: function () {
289
+ var t = this;
290
+ n(e).bind("keyup", function (e) {
291
+ e.preventDefault();
292
+ e.stopPropagation();
293
+ if (e.keyCode == 37) {
294
+ t.getPrev()
295
+ } else if (e.keyCode == 39) {
296
+ t.getNext()
297
+ } else if (e.keyCode == 27) {
298
+ t.closeSlide()
299
+ }
300
+ })
301
+ },
302
+ actions: function () {
303
+ var e = this;
304
+ if (a.length < 2) {
305
+ n("#swipebox-prev, #swipebox-next").hide()
306
+ } else {
307
+ n("#swipebox-prev").bind("click", function (t) {
308
+ t.preventDefault();
309
+ t.stopPropagation();
310
+ e.getPrev();
311
+ e.setTimeout()
312
+ });
313
+ n("#swipebox-next").bind("click", function (t) {
314
+ t.preventDefault();
315
+ t.stopPropagation();
316
+ e.getNext();
317
+ e.setTimeout()
318
+ })
319
+ }
320
+ n("#swipebox-close").bind("click", function (t) {
321
+ e.closeSlide()
322
+ })
323
+ },
324
+ setSlide: function (e, t) {
325
+ t = t || false;
326
+ var r = n("#swipebox-slider");
327
+ if (this.doCssTrans()) {
328
+ r.css({
329
+ left: -e * 100 + "%"
330
+ })
331
+ } else {
332
+ r.animate({
333
+ left: -e * 100 + "%"
334
+ })
335
+ }
336
+ n("#swipebox-slider .slide").removeClass("current");
337
+ n("#swipebox-slider .slide").eq(e).addClass("current");
338
+ this.setTitle(e);
339
+ if (t) {
340
+ r.fadeIn()
341
+ }
342
+ n("#swipebox-prev, #swipebox-next").removeClass("disabled");
343
+ if (e == 0) {
344
+ n("#swipebox-prev").addClass("disabled")
345
+ } else if (e == a.length - 1) {
346
+ n("#swipebox-next").addClass("disabled")
347
+ }
348
+ },
349
+ openSlide: function (t) {
350
+ n("html").addClass("swipebox");
351
+ n(e).trigger("resize");
352
+ this.setSlide(t, true)
353
+ },
354
+ preloadMedia: function (e) {
355
+ var t = this,
356
+ n = null;
357
+ if (a[e] !== r) n = a[e].href;
358
+ if (!t.isVideo(n)) {
359
+ setTimeout(function () {
360
+ t.openMedia(e)
361
+ }, 1e3)
362
+ } else {
363
+ t.openMedia(e)
364
+ }
365
+ },
366
+ openMedia: function (e) {
367
+ var t = this,
368
+ i = null;
369
+ if (a[e] !== r) i = a[e].href;
370
+ if (e < 0 || e >= a.length) {
371
+ return false
372
+ }
373
+ if (!t.isVideo(i)) {
374
+ t.loadMedia(i, function () {
375
+ n("#swipebox-slider .slide").eq(e).html(this)
376
+ })
377
+ } else {
378
+ n("#swipebox-slider .slide").eq(e).html(t.getVideo(i))
379
+ }
380
+ },
381
+ setTitle: function (e, t) {
382
+ var i = null;
383
+ n("#swipebox-caption").empty();
384
+ if (a[e] !== r) i = a[e].title;
385
+ if (i) {
386
+ n("#swipebox-caption").append(i)
387
+ }
388
+ },
389
+ isVideo: function (e) {
390
+ if (e) {
391
+ if (e.match(/youtube\.com\/watch\?v=([a-zA-Z0-9\-_]+)/) || e.match(/vimeo\.com\/([0-9]*)/)) {
392
+ return true
393
+ }
394
+ }
395
+ },
396
+ getVideo: function (e) {
397
+ var t = "";
398
+ var n = "";
399
+ var r = e.match(/watch\?v=([a-zA-Z0-9\-_]+)/);
400
+ var i = e.match(/vimeo\.com\/([0-9]*)/);
401
+ if (r) {
402
+ t = '<iframe width="560" height="315" src="//www.youtube.com/embed/' + r[1] + '" frameborder="0" allowfullscreen></iframe>'
403
+ } else if (i) {
404
+ t = '<iframe width="560" height="315" src="http://player.vimeo.com/video/' + i[1] + "?byline=0&portrait=0&color=" + u.settings.vimeoColor + '" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>'
405
+ }
406
+ return '<div class="swipebox-video-container" style="max-width:' + u.settings.videoMaxWidth + 'px"><div class="swipebox-video">' + t + "</div></div>"
407
+ },
408
+ loadMedia: function (e, t) {
409
+ if (!this.isVideo(e)) {
410
+ var r = n("<img>").on("load", function () {
411
+ t.call(r)
412
+ });
413
+ r.attr("src", e)
414
+ }
415
+ },
416
+ getNext: function () {
417
+ var e = this;
418
+ index = n("#swipebox-slider .slide").index(n("#swipebox-slider .slide.current"));
419
+ if (index + 1 < a.length) {
420
+ index++;
421
+ e.setSlide(index);
422
+ e.preloadMedia(index + 1)
423
+ } else {
424
+ n("#swipebox-slider").addClass("rightSpring");
425
+ setTimeout(function () {
426
+ n("#swipebox-slider").removeClass("rightSpring")
427
+ }, 500)
428
+ }
429
+ },
430
+ getPrev: function () {
431
+ index = n("#swipebox-slider .slide").index(n("#swipebox-slider .slide.current"));
432
+ if (index > 0) {
433
+ index--;
434
+ this.setSlide(index);
435
+ this.preloadMedia(index - 1)
436
+ } else {
437
+ n("#swipebox-slider").addClass("leftSpring");
438
+ setTimeout(function () {
439
+ n("#swipebox-slider").removeClass("leftSpring")
440
+ }, 500)
441
+ }
442
+ },
443
+ closeSlide: function () {
444
+ n("html").removeClass("swipebox");
445
+ n(e).trigger("resize");
446
+ this.destroy()
447
+ },
448
+ destroy: function () {
449
+ n(e).unbind("keyup");
450
+ n("#swipebox-slider").unbind("touchstart");
451
+ n("#swipebox-slider").unbind("touchmove");
452
+ n("#swipebox-slider").unbind("touchend");
453
+ n("#swipebox-slider").unbind();
454
+ n("#swipebox-overlay").remove();
455
+ if (!n.isArray(i)) i.removeData("_swipebox");
456
+ if (this.target) this.target.trigger("swipebox-destroy");
457
+ n.swipebox.isOpen = false;
458
+ if (u.settings.afterClose) u.settings.afterClose();
459
+
460
+ scrollTimer = null;
461
+ }
462
+ };
463
+ u.init()
464
+ };
465
+ n.fn.swipebox = function (e) {
466
+ if (!n.data(this, "_swipebox")) {
467
+ var t = new n.swipebox(this, e);
468
+ this.data("_swipebox", t)
469
+ }
470
+ return this.data("_swipebox")
471
+ }
472
+ })(window, document, jQuery)
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://www.dfactory.eu/
4
Tags: gallery, images, lightbox, links, photos, template, theme, photo, image, picture, slideshow, modal, overlay, YouTube, Vimeo, video, videos
5
Requires at least: 3.3
6
Tested up to: 3.8.1
7
- Stable tag: 1.4.0
8
License: MIT License
9
License URI: http://opensource.org/licenses/MIT
10
@@ -141,7 +141,7 @@ Initial release
141
142
== Upgrade Notice ==
143
144
- = 1.4.0 =
145
146
* New: Added Image Lightbox script
147
* New: Option to load scripts in header or footer
4
Tags: gallery, images, lightbox, links, photos, template, theme, photo, image, picture, slideshow, modal, overlay, YouTube, Vimeo, video, videos
5
Requires at least: 3.3
6
Tested up to: 3.8.1
7
+ Stable tag: 1.4.0.1
8
License: MIT License
9
License URI: http://opensource.org/licenses/MIT
10
141
142
== Upgrade Notice ==
143
144
+ = 1.4.0.1 =
145
146
* New: Added Image Lightbox script
147
* New: Option to load scripts in header or footer
responsive-lightbox.php CHANGED
@@ -2,7 +2,7 @@
2
/*
3
Plugin Name: Responsive Lightbox
4
Description: Responsive Lightbox allows users to view larger versions of images and galleries in a lightbox (overlay) effect optimized for mobile devices.
5
- Version: 1.4.0
6
Author: dFactory
7
Author URI: http://www.dfactory.eu/
8
Plugin URI: http://www.dfactory.eu/plugins/responsive-lightbox/
@@ -109,7 +109,7 @@ class Responsive_Lightbox
109
'quit_on_document_click' => true
110
)
111
),
112
- 'version' => '1.4.0'
113
);
114
private $scripts = array();
115
private $options = array();
2
/*
3
Plugin Name: Responsive Lightbox
4
Description: Responsive Lightbox allows users to view larger versions of images and galleries in a lightbox (overlay) effect optimized for mobile devices.
5
+ Version: 1.4.0.1
6
Author: dFactory
7
Author URI: http://www.dfactory.eu/
8
Plugin URI: http://www.dfactory.eu/plugins/responsive-lightbox/
109
'quit_on_document_click' => true
110
)
111
),
112
+ 'version' => '1.4.0.1'
113
);
114
private $scripts = array();
115
private $options = array();