lightgallery-rails 1.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. checksums.yaml +7 -0
  2. data/Rakefile +1 -0
  3. data/lib/lightgallery/rails.rb +7 -0
  4. data/lib/lightgallery/rails/engine.rb +6 -0
  5. data/lib/lightgallery/rails/version.rb +5 -0
  6. data/vendor/assets/fonts/lightgallery/lg.eot +0 -0
  7. data/vendor/assets/fonts/lightgallery/lg.svg +47 -0
  8. data/vendor/assets/fonts/lightgallery/lg.ttf +0 -0
  9. data/vendor/assets/fonts/lightgallery/lg.woff +0 -0
  10. data/vendor/assets/images/lightgallery/loading.gif +0 -0
  11. data/vendor/assets/images/lightgallery/video-play.png +0 -0
  12. data/vendor/assets/images/lightgallery/vimeo-play.png +0 -0
  13. data/vendor/assets/images/lightgallery/youtube-play.png +0 -0
  14. data/vendor/assets/javascripts/lightgallery.autoplay.js +206 -0
  15. data/vendor/assets/javascripts/lightgallery.autoplay.min.js +4 -0
  16. data/vendor/assets/javascripts/lightgallery.fullscreen.js +116 -0
  17. data/vendor/assets/javascripts/lightgallery.fullscreen.min.js +4 -0
  18. data/vendor/assets/javascripts/lightgallery.hash.js +100 -0
  19. data/vendor/assets/javascripts/lightgallery.hash.min.js +4 -0
  20. data/vendor/assets/javascripts/lightgallery.js +1364 -0
  21. data/vendor/assets/javascripts/lightgallery.min.js +4 -0
  22. data/vendor/assets/javascripts/lightgallery.pager.js +105 -0
  23. data/vendor/assets/javascripts/lightgallery.pager.min.js +4 -0
  24. data/vendor/assets/javascripts/lightgallery.share.js +94 -0
  25. data/vendor/assets/javascripts/lightgallery.share.min.js +4 -0
  26. data/vendor/assets/javascripts/lightgallery.thumbnail.js +473 -0
  27. data/vendor/assets/javascripts/lightgallery.thumbnail.min.js +4 -0
  28. data/vendor/assets/javascripts/lightgallery.video.js +317 -0
  29. data/vendor/assets/javascripts/lightgallery.video.min.js +4 -0
  30. data/vendor/assets/javascripts/lightgallery.zoom.js +531 -0
  31. data/vendor/assets/javascripts/lightgallery.zoom.min.js +4 -0
  32. data/vendor/assets/stylesheets/lg-fb-comment-box.scss +57 -0
  33. data/vendor/assets/stylesheets/lg-transitions.css +779 -0
  34. data/vendor/assets/stylesheets/lightgallery.scss +978 -0
  35. metadata +104 -0
@@ -0,0 +1,4 @@
1
+ /*! lg-hash - v1.0.2 - 2017-06-03
2
+ * http://sachinchoolur.github.io/lightGallery
3
+ * Copyright (c) 2017 Sachin N; Licensed GPLv3 */
4
+ !function(a,b){"function"==typeof define&&define.amd?define(["jquery"],function(a){return b(a)}):"object"==typeof exports?module.exports=b(require("jquery")):b(jQuery)}(this,function(a){!function(){"use strict";var b={hash:!0},c=function(c){return this.core=a(c).data("lightGallery"),this.core.s=a.extend({},b,this.core.s),this.core.s.hash&&(this.oldHash=window.location.hash,this.init()),this};c.prototype.init=function(){var b,c=this;c.core.$el.on("onAfterSlide.lg.tm",function(a,b,d){history.replaceState?history.replaceState(null,null,"#lg="+c.core.s.galleryId+"&slide="+d):window.location.hash="lg="+c.core.s.galleryId+"&slide="+d}),a(window).on("hashchange.lg.hash",function(){b=window.location.hash;var a=parseInt(b.split("&slide=")[1],10);b.indexOf("lg="+c.core.s.galleryId)>-1?c.core.slide(a,!1,!1):c.core.lGalleryOn&&c.core.destroy()})},c.prototype.destroy=function(){this.core.s.hash&&(this.oldHash&&this.oldHash.indexOf("lg="+this.core.s.galleryId)<0?history.replaceState?history.replaceState(null,null,this.oldHash):window.location.hash=this.oldHash:history.replaceState?history.replaceState(null,document.title,window.location.pathname+window.location.search):window.location.hash="",this.core.$el.off(".lg.hash"))},a.fn.lightGallery.modules.hash=c}()});
@@ -0,0 +1,1364 @@
1
+ /*! lightgallery - v1.4.0 - 2017-06-04
2
+ * http://sachinchoolur.github.io/lightGallery/
3
+ * Copyright (c) 2017 Sachin N; Licensed GPLv3 */
4
+
5
+ (function (root, factory) {
6
+ if (typeof define === 'function' && define.amd) {
7
+ // AMD. Register as an anonymous module unless amdModuleId is set
8
+ define(['jquery'], function (a0) {
9
+ return (factory(a0));
10
+ });
11
+ } else if (typeof exports === 'object') {
12
+ // Node. Does not work with strict CommonJS, but
13
+ // only CommonJS-like environments that support module.exports,
14
+ // like Node.
15
+ module.exports = factory(require('jquery'));
16
+ } else {
17
+ factory(root["jQuery"]);
18
+ }
19
+ }(this, function ($) {
20
+
21
+ (function() {
22
+ 'use strict';
23
+
24
+ var defaults = {
25
+
26
+ mode: 'lg-slide',
27
+
28
+ // Ex : 'ease'
29
+ cssEasing: 'ease',
30
+
31
+ //'for jquery animation'
32
+ easing: 'linear',
33
+ speed: 600,
34
+ height: '100%',
35
+ width: '100%',
36
+ addClass: '',
37
+ startClass: 'lg-start-zoom',
38
+ backdropDuration: 150,
39
+ hideBarsDelay: 6000,
40
+
41
+ useLeft: false,
42
+
43
+ closable: true,
44
+ loop: true,
45
+ escKey: true,
46
+ keyPress: true,
47
+ controls: true,
48
+ slideEndAnimatoin: true,
49
+ hideControlOnEnd: false,
50
+ mousewheel: true,
51
+
52
+ getCaptionFromTitleOrAlt: true,
53
+
54
+ // .lg-item || '.lg-sub-html'
55
+ appendSubHtmlTo: '.lg-sub-html',
56
+
57
+ subHtmlSelectorRelative: false,
58
+
59
+ /**
60
+ * @desc number of preload slides
61
+ * will exicute only after the current slide is fully loaded.
62
+ *
63
+ * @ex you clicked on 4th image and if preload = 1 then 3rd slide and 5th
64
+ * slide will be loaded in the background after the 4th slide is fully loaded..
65
+ * if preload is 2 then 2nd 3rd 5th 6th slides will be preloaded.. ... ...
66
+ *
67
+ */
68
+ preload: 1,
69
+ showAfterLoad: true,
70
+ selector: '',
71
+ selectWithin: '',
72
+ nextHtml: '',
73
+ prevHtml: '',
74
+
75
+ // 0, 1
76
+ index: false,
77
+
78
+ iframeMaxWidth: '100%',
79
+
80
+ download: true,
81
+ counter: true,
82
+ appendCounterTo: '.lg-toolbar',
83
+
84
+ swipeThreshold: 50,
85
+ enableSwipe: true,
86
+ enableDrag: true,
87
+
88
+ dynamic: false,
89
+ dynamicEl: [],
90
+ galleryId: 1
91
+ };
92
+
93
+ function Plugin(element, options) {
94
+
95
+ // Current lightGallery element
96
+ this.el = element;
97
+
98
+ // Current jquery element
99
+ this.$el = $(element);
100
+
101
+ // lightGallery settings
102
+ this.s = $.extend({}, defaults, options);
103
+
104
+ // When using dynamic mode, ensure dynamicEl is an array
105
+ if (this.s.dynamic && this.s.dynamicEl !== 'undefined' && this.s.dynamicEl.constructor === Array && !this.s.dynamicEl.length) {
106
+ throw ('When using dynamic mode, you must also define dynamicEl as an Array.');
107
+ }
108
+
109
+ // lightGallery modules
110
+ this.modules = {};
111
+
112
+ // false when lightgallery complete first slide;
113
+ this.lGalleryOn = false;
114
+
115
+ this.lgBusy = false;
116
+
117
+ // Timeout function for hiding controls;
118
+ this.hideBartimeout = false;
119
+
120
+ // To determine browser supports for touch events;
121
+ this.isTouch = ('ontouchstart' in document.documentElement);
122
+
123
+ // Disable hideControlOnEnd if sildeEndAnimation is true
124
+ if (this.s.slideEndAnimatoin) {
125
+ this.s.hideControlOnEnd = false;
126
+ }
127
+
128
+ // Gallery items
129
+ if (this.s.dynamic) {
130
+ this.$items = this.s.dynamicEl;
131
+ } else {
132
+ if (this.s.selector === 'this') {
133
+ this.$items = this.$el;
134
+ } else if (this.s.selector !== '') {
135
+ if (this.s.selectWithin) {
136
+ this.$items = $(this.s.selectWithin).find(this.s.selector);
137
+ } else {
138
+ this.$items = this.$el.find($(this.s.selector));
139
+ }
140
+ } else {
141
+ this.$items = this.$el.children();
142
+ }
143
+ }
144
+
145
+ // .lg-item
146
+ this.$slide = '';
147
+
148
+ // .lg-outer
149
+ this.$outer = '';
150
+
151
+ this.init();
152
+
153
+ return this;
154
+ }
155
+
156
+ Plugin.prototype.init = function() {
157
+
158
+ var _this = this;
159
+
160
+ // s.preload should not be more than $item.length
161
+ if (_this.s.preload > _this.$items.length) {
162
+ _this.s.preload = _this.$items.length;
163
+ }
164
+
165
+ // if dynamic option is enabled execute immediately
166
+ var _hash = window.location.hash;
167
+ if (_hash.indexOf('lg=' + this.s.galleryId) > 0) {
168
+
169
+ _this.index = parseInt(_hash.split('&slide=')[1], 10);
170
+
171
+ $('body').addClass('lg-from-hash');
172
+ if (!$('body').hasClass('lg-on')) {
173
+ setTimeout(function() {
174
+ _this.build(_this.index);
175
+ });
176
+
177
+ $('body').addClass('lg-on');
178
+ }
179
+ }
180
+
181
+ if (_this.s.dynamic) {
182
+
183
+ _this.$el.trigger('onBeforeOpen.lg');
184
+
185
+ _this.index = _this.s.index || 0;
186
+
187
+ // prevent accidental double execution
188
+ if (!$('body').hasClass('lg-on')) {
189
+ setTimeout(function() {
190
+ _this.build(_this.index);
191
+ $('body').addClass('lg-on');
192
+ });
193
+ }
194
+ } else {
195
+
196
+ // Using different namespace for click because click event should not unbind if selector is same object('this')
197
+ _this.$items.on('click.lgcustom', function(event) {
198
+
199
+ // For IE8
200
+ try {
201
+ event.preventDefault();
202
+ event.preventDefault();
203
+ } catch (er) {
204
+ event.returnValue = false;
205
+ }
206
+
207
+ _this.$el.trigger('onBeforeOpen.lg');
208
+
209
+ _this.index = _this.s.index || _this.$items.index(this);
210
+
211
+ // prevent accidental double execution
212
+ if (!$('body').hasClass('lg-on')) {
213
+ _this.build(_this.index);
214
+ $('body').addClass('lg-on');
215
+ }
216
+ });
217
+ }
218
+
219
+ };
220
+
221
+ Plugin.prototype.build = function(index) {
222
+
223
+ var _this = this;
224
+
225
+ _this.structure();
226
+
227
+ // module constructor
228
+ $.each($.fn.lightGallery.modules, function(key) {
229
+ _this.modules[key] = new $.fn.lightGallery.modules[key](_this.el);
230
+ });
231
+
232
+ // initiate slide function
233
+ _this.slide(index, false, false, false);
234
+
235
+ if (_this.s.keyPress) {
236
+ _this.keyPress();
237
+ }
238
+
239
+ if (_this.$items.length > 1) {
240
+
241
+ _this.arrow();
242
+
243
+ setTimeout(function() {
244
+ _this.enableDrag();
245
+ _this.enableSwipe();
246
+ }, 50);
247
+
248
+ if (_this.s.mousewheel) {
249
+ _this.mousewheel();
250
+ }
251
+ } else {
252
+ _this.$slide.on('click.lg', function() {
253
+ _this.$el.trigger('onSlideClick.lg');
254
+ });
255
+ }
256
+
257
+ _this.counter();
258
+
259
+ _this.closeGallery();
260
+
261
+ _this.$el.trigger('onAfterOpen.lg');
262
+
263
+ // Hide controllers if mouse doesn't move for some period
264
+ _this.$outer.on('mousemove.lg click.lg touchstart.lg', function() {
265
+
266
+ _this.$outer.removeClass('lg-hide-items');
267
+
268
+ clearTimeout(_this.hideBartimeout);
269
+
270
+ // Timeout will be cleared on each slide movement also
271
+ _this.hideBartimeout = setTimeout(function() {
272
+ _this.$outer.addClass('lg-hide-items');
273
+ }, _this.s.hideBarsDelay);
274
+
275
+ });
276
+
277
+ _this.$outer.trigger('mousemove.lg');
278
+
279
+ };
280
+
281
+ Plugin.prototype.structure = function() {
282
+ var list = '';
283
+ var controls = '';
284
+ var i = 0;
285
+ var subHtmlCont = '';
286
+ var template;
287
+ var _this = this;
288
+
289
+ $('body').append('<div class="lg-backdrop"></div>');
290
+ $('.lg-backdrop').css('transition-duration', this.s.backdropDuration + 'ms');
291
+
292
+ // Create gallery items
293
+ for (i = 0; i < this.$items.length; i++) {
294
+ list += '<div class="lg-item"></div>';
295
+ }
296
+
297
+ // Create controlls
298
+ if (this.s.controls && this.$items.length > 1) {
299
+ controls = '<div class="lg-actions">' +
300
+ '<button class="lg-prev lg-icon">' + this.s.prevHtml + '</button>' +
301
+ '<button class="lg-next lg-icon">' + this.s.nextHtml + '</button>' +
302
+ '</div>';
303
+ }
304
+
305
+ if (this.s.appendSubHtmlTo === '.lg-sub-html') {
306
+ subHtmlCont = '<div class="lg-sub-html"></div>';
307
+ }
308
+
309
+ template = '<div class="lg-outer ' + this.s.addClass + ' ' + this.s.startClass + '">' +
310
+ '<div class="lg" style="width:' + this.s.width + '; height:' + this.s.height + '">' +
311
+ '<div class="lg-inner">' + list + '</div>' +
312
+ '<div class="lg-toolbar lg-group">' +
313
+ '<span class="lg-close lg-icon"></span>' +
314
+ '</div>' +
315
+ controls +
316
+ subHtmlCont +
317
+ '</div>' +
318
+ '</div>';
319
+
320
+ $('body').append(template);
321
+ this.$outer = $('.lg-outer');
322
+ this.$slide = this.$outer.find('.lg-item');
323
+
324
+ if (this.s.useLeft) {
325
+ this.$outer.addClass('lg-use-left');
326
+
327
+ // Set mode lg-slide if use left is true;
328
+ this.s.mode = 'lg-slide';
329
+ } else {
330
+ this.$outer.addClass('lg-use-css3');
331
+ }
332
+
333
+ // For fixed height gallery
334
+ _this.setTop();
335
+ $(window).on('resize.lg orientationchange.lg', function() {
336
+ setTimeout(function() {
337
+ _this.setTop();
338
+ }, 100);
339
+ });
340
+
341
+ // add class lg-current to remove initial transition
342
+ this.$slide.eq(this.index).addClass('lg-current');
343
+
344
+ // add Class for css support and transition mode
345
+ if (this.doCss()) {
346
+ this.$outer.addClass('lg-css3');
347
+ } else {
348
+ this.$outer.addClass('lg-css');
349
+
350
+ // Set speed 0 because no animation will happen if browser doesn't support css3
351
+ this.s.speed = 0;
352
+ }
353
+
354
+ this.$outer.addClass(this.s.mode);
355
+
356
+ if (this.s.enableDrag && this.$items.length > 1) {
357
+ this.$outer.addClass('lg-grab');
358
+ }
359
+
360
+ if (this.s.showAfterLoad) {
361
+ this.$outer.addClass('lg-show-after-load');
362
+ }
363
+
364
+ if (this.doCss()) {
365
+ var $inner = this.$outer.find('.lg-inner');
366
+ $inner.css('transition-timing-function', this.s.cssEasing);
367
+ $inner.css('transition-duration', this.s.speed + 'ms');
368
+ }
369
+
370
+ setTimeout(function() {
371
+ $('.lg-backdrop').addClass('in');
372
+ });
373
+
374
+ setTimeout(function() {
375
+ _this.$outer.addClass('lg-visible');
376
+ }, this.s.backdropDuration);
377
+
378
+ if (this.s.download) {
379
+ this.$outer.find('.lg-toolbar').append('<a id="lg-download" target="_blank" download class="lg-download lg-icon"></a>');
380
+ }
381
+
382
+ // Store the current scroll top value to scroll back after closing the gallery..
383
+ this.prevScrollTop = $(window).scrollTop();
384
+
385
+ };
386
+
387
+ // For fixed height gallery
388
+ Plugin.prototype.setTop = function() {
389
+ if (this.s.height !== '100%') {
390
+ var wH = $(window).height();
391
+ var top = (wH - parseInt(this.s.height, 10)) / 2;
392
+ var $lGallery = this.$outer.find('.lg');
393
+ if (wH >= parseInt(this.s.height, 10)) {
394
+ $lGallery.css('top', top + 'px');
395
+ } else {
396
+ $lGallery.css('top', '0px');
397
+ }
398
+ }
399
+ };
400
+
401
+ // Find css3 support
402
+ Plugin.prototype.doCss = function() {
403
+ // check for css animation support
404
+ var support = function() {
405
+ var transition = ['transition', 'MozTransition', 'WebkitTransition', 'OTransition', 'msTransition', 'KhtmlTransition'];
406
+ var root = document.documentElement;
407
+ var i = 0;
408
+ for (i = 0; i < transition.length; i++) {
409
+ if (transition[i] in root.style) {
410
+ return true;
411
+ }
412
+ }
413
+ };
414
+
415
+ if (support()) {
416
+ return true;
417
+ }
418
+
419
+ return false;
420
+ };
421
+
422
+ /**
423
+ * @desc Check the given src is video
424
+ * @param {String} src
425
+ * @return {Object} video type
426
+ * Ex:{ youtube : ["//www.youtube.com/watch?v=c0asJgSyxcY", "c0asJgSyxcY"] }
427
+ */
428
+ Plugin.prototype.isVideo = function(src, index) {
429
+
430
+ var html;
431
+ if (this.s.dynamic) {
432
+ html = this.s.dynamicEl[index].html;
433
+ } else {
434
+ html = this.$items.eq(index).attr('data-html');
435
+ }
436
+
437
+ if (!src) {
438
+ if(html) {
439
+ return {
440
+ html5: true
441
+ };
442
+ } else {
443
+ console.error('lightGallery :- data-src is not pvovided on slide item ' + (index + 1) + '. Please make sure the selector property is properly configured. More info - http://sachinchoolur.github.io/lightGallery/demos/html-markup.html');
444
+ return false;
445
+ }
446
+ }
447
+
448
+ var youtube = src.match(/\/\/(?:www\.)?youtu(?:\.be|be\.com)\/(?:watch\?v=|embed\/)?([a-z0-9\-\_\%]+)/i);
449
+ var vimeo = src.match(/\/\/(?:www\.)?vimeo.com\/([0-9a-z\-_]+)/i);
450
+ var dailymotion = src.match(/\/\/(?:www\.)?dai.ly\/([0-9a-z\-_]+)/i);
451
+ var vk = src.match(/\/\/(?:www\.)?(?:vk\.com|vkontakte\.ru)\/(?:video_ext\.php\?)(.*)/i);
452
+
453
+ if (youtube) {
454
+ return {
455
+ youtube: youtube
456
+ };
457
+ } else if (vimeo) {
458
+ return {
459
+ vimeo: vimeo
460
+ };
461
+ } else if (dailymotion) {
462
+ return {
463
+ dailymotion: dailymotion
464
+ };
465
+ } else if (vk) {
466
+ return {
467
+ vk: vk
468
+ };
469
+ }
470
+ };
471
+
472
+ /**
473
+ * @desc Create image counter
474
+ * Ex: 1/10
475
+ */
476
+ Plugin.prototype.counter = function() {
477
+ if (this.s.counter) {
478
+ $(this.s.appendCounterTo).append('<div id="lg-counter"><span id="lg-counter-current">' + (parseInt(this.index, 10) + 1) + '</span> / <span id="lg-counter-all">' + this.$items.length + '</span></div>');
479
+ }
480
+ };
481
+
482
+ /**
483
+ * @desc add sub-html into the slide
484
+ * @param {Number} index - index of the slide
485
+ */
486
+ Plugin.prototype.addHtml = function(index) {
487
+ var subHtml = null;
488
+ var subHtmlUrl;
489
+ var $currentEle;
490
+ if (this.s.dynamic) {
491
+ if (this.s.dynamicEl[index].subHtmlUrl) {
492
+ subHtmlUrl = this.s.dynamicEl[index].subHtmlUrl;
493
+ } else {
494
+ subHtml = this.s.dynamicEl[index].subHtml;
495
+ }
496
+ } else {
497
+ $currentEle = this.$items.eq(index);
498
+ if ($currentEle.attr('data-sub-html-url')) {
499
+ subHtmlUrl = $currentEle.attr('data-sub-html-url');
500
+ } else {
501
+ subHtml = $currentEle.attr('data-sub-html');
502
+ if (this.s.getCaptionFromTitleOrAlt && !subHtml) {
503
+ subHtml = $currentEle.attr('title') || $currentEle.find('img').first().attr('alt');
504
+ }
505
+ }
506
+ }
507
+
508
+ if (!subHtmlUrl) {
509
+ if (typeof subHtml !== 'undefined' && subHtml !== null) {
510
+
511
+ // get first letter of subhtml
512
+ // if first letter starts with . or # get the html form the jQuery object
513
+ var fL = subHtml.substring(0, 1);
514
+ if (fL === '.' || fL === '#') {
515
+ if (this.s.subHtmlSelectorRelative && !this.s.dynamic) {
516
+ subHtml = $currentEle.find(subHtml).html();
517
+ } else {
518
+ subHtml = $(subHtml).html();
519
+ }
520
+ }
521
+ } else {
522
+ subHtml = '';
523
+ }
524
+ }
525
+
526
+ if (this.s.appendSubHtmlTo === '.lg-sub-html') {
527
+
528
+ if (subHtmlUrl) {
529
+ this.$outer.find(this.s.appendSubHtmlTo).load(subHtmlUrl);
530
+ } else {
531
+ this.$outer.find(this.s.appendSubHtmlTo).html(subHtml);
532
+ }
533
+
534
+ } else {
535
+
536
+ if (subHtmlUrl) {
537
+ this.$slide.eq(index).load(subHtmlUrl);
538
+ } else {
539
+ this.$slide.eq(index).append(subHtml);
540
+ }
541
+ }
542
+
543
+ // Add lg-empty-html class if title doesn't exist
544
+ if (typeof subHtml !== 'undefined' && subHtml !== null) {
545
+ if (subHtml === '') {
546
+ this.$outer.find(this.s.appendSubHtmlTo).addClass('lg-empty-html');
547
+ } else {
548
+ this.$outer.find(this.s.appendSubHtmlTo).removeClass('lg-empty-html');
549
+ }
550
+ }
551
+
552
+ this.$el.trigger('onAfterAppendSubHtml.lg', [index]);
553
+ };
554
+
555
+ /**
556
+ * @desc Preload slides
557
+ * @param {Number} index - index of the slide
558
+ */
559
+ Plugin.prototype.preload = function(index) {
560
+ var i = 1;
561
+ var j = 1;
562
+ for (i = 1; i <= this.s.preload; i++) {
563
+ if (i >= this.$items.length - index) {
564
+ break;
565
+ }
566
+
567
+ this.loadContent(index + i, false, 0);
568
+ }
569
+
570
+ for (j = 1; j <= this.s.preload; j++) {
571
+ if (index - j < 0) {
572
+ break;
573
+ }
574
+
575
+ this.loadContent(index - j, false, 0);
576
+ }
577
+ };
578
+
579
+ /**
580
+ * @desc Load slide content into slide.
581
+ * @param {Number} index - index of the slide.
582
+ * @param {Boolean} rec - if true call loadcontent() function again.
583
+ * @param {Boolean} delay - delay for adding complete class. it is 0 except first time.
584
+ */
585
+ Plugin.prototype.loadContent = function(index, rec, delay) {
586
+
587
+ var _this = this;
588
+ var _hasPoster = false;
589
+ var _$img;
590
+ var _src;
591
+ var _poster;
592
+ var _srcset;
593
+ var _sizes;
594
+ var _html;
595
+ var getResponsiveSrc = function(srcItms) {
596
+ var rsWidth = [];
597
+ var rsSrc = [];
598
+ for (var i = 0; i < srcItms.length; i++) {
599
+ var __src = srcItms[i].split(' ');
600
+
601
+ // Manage empty space
602
+ if (__src[0] === '') {
603
+ __src.splice(0, 1);
604
+ }
605
+
606
+ rsSrc.push(__src[0]);
607
+ rsWidth.push(__src[1]);
608
+ }
609
+
610
+ var wWidth = $(window).width();
611
+ for (var j = 0; j < rsWidth.length; j++) {
612
+ if (parseInt(rsWidth[j], 10) > wWidth) {
613
+ _src = rsSrc[j];
614
+ break;
615
+ }
616
+ }
617
+ };
618
+
619
+ if (_this.s.dynamic) {
620
+
621
+ if (_this.s.dynamicEl[index].poster) {
622
+ _hasPoster = true;
623
+ _poster = _this.s.dynamicEl[index].poster;
624
+ }
625
+
626
+ _html = _this.s.dynamicEl[index].html;
627
+ _src = _this.s.dynamicEl[index].src;
628
+
629
+ if (_this.s.dynamicEl[index].responsive) {
630
+ var srcDyItms = _this.s.dynamicEl[index].responsive.split(',');
631
+ getResponsiveSrc(srcDyItms);
632
+ }
633
+
634
+ _srcset = _this.s.dynamicEl[index].srcset;
635
+ _sizes = _this.s.dynamicEl[index].sizes;
636
+
637
+ } else {
638
+
639
+ if (_this.$items.eq(index).attr('data-poster')) {
640
+ _hasPoster = true;
641
+ _poster = _this.$items.eq(index).attr('data-poster');
642
+ }
643
+
644
+ _html = _this.$items.eq(index).attr('data-html');
645
+ _src = _this.$items.eq(index).attr('href') || _this.$items.eq(index).attr('data-src');
646
+
647
+ if (_this.$items.eq(index).attr('data-responsive')) {
648
+ var srcItms = _this.$items.eq(index).attr('data-responsive').split(',');
649
+ getResponsiveSrc(srcItms);
650
+ }
651
+
652
+ _srcset = _this.$items.eq(index).attr('data-srcset');
653
+ _sizes = _this.$items.eq(index).attr('data-sizes');
654
+
655
+ }
656
+
657
+ //if (_src || _srcset || _sizes || _poster) {
658
+
659
+ var iframe = false;
660
+ if (_this.s.dynamic) {
661
+ if (_this.s.dynamicEl[index].iframe) {
662
+ iframe = true;
663
+ }
664
+ } else {
665
+ if (_this.$items.eq(index).attr('data-iframe') === 'true') {
666
+ iframe = true;
667
+ }
668
+ }
669
+
670
+ var _isVideo = _this.isVideo(_src, index);
671
+ if (!_this.$slide.eq(index).hasClass('lg-loaded')) {
672
+ if (iframe) {
673
+ _this.$slide.eq(index).prepend('<div class="lg-video-cont lg-has-iframe" style="max-width:' + _this.s.iframeMaxWidth + '"><div class="lg-video"><iframe class="lg-object" frameborder="0" src="' + _src + '" allowfullscreen="true"></iframe></div></div>');
674
+ } else if (_hasPoster) {
675
+ var videoClass = '';
676
+ if (_isVideo && _isVideo.youtube) {
677
+ videoClass = 'lg-has-youtube';
678
+ } else if (_isVideo && _isVideo.vimeo) {
679
+ videoClass = 'lg-has-vimeo';
680
+ } else {
681
+ videoClass = 'lg-has-html5';
682
+ }
683
+
684
+ _this.$slide.eq(index).prepend('<div class="lg-video-cont ' + videoClass + ' "><div class="lg-video"><span class="lg-video-play"></span><img class="lg-object lg-has-poster" src="' + _poster + '" /></div></div>');
685
+
686
+ } else if (_isVideo) {
687
+ _this.$slide.eq(index).prepend('<div class="lg-video-cont "><div class="lg-video"></div></div>');
688
+ _this.$el.trigger('hasVideo.lg', [index, _src, _html]);
689
+ } else {
690
+ _this.$slide.eq(index).prepend('<div class="lg-img-wrap"><img class="lg-object lg-image" src="' + _src + '" /></div>');
691
+ }
692
+
693
+ _this.$el.trigger('onAferAppendSlide.lg', [index]);
694
+
695
+ _$img = _this.$slide.eq(index).find('.lg-object');
696
+ if (_sizes) {
697
+ _$img.attr('sizes', _sizes);
698
+ }
699
+
700
+ if (_srcset) {
701
+ _$img.attr('srcset', _srcset);
702
+ try {
703
+ picturefill({
704
+ elements: [_$img[0]]
705
+ });
706
+ } catch (e) {
707
+ console.warn('lightGallery :- If you want srcset to be supported for older browser please include picturefil version 2 javascript library in your document.');
708
+ }
709
+ }
710
+
711
+ if (this.s.appendSubHtmlTo !== '.lg-sub-html') {
712
+ _this.addHtml(index);
713
+ }
714
+
715
+ _this.$slide.eq(index).addClass('lg-loaded');
716
+ }
717
+
718
+ _this.$slide.eq(index).find('.lg-object').on('load.lg error.lg', function() {
719
+
720
+ // For first time add some delay for displaying the start animation.
721
+ var _speed = 0;
722
+
723
+ // Do not change the delay value because it is required for zoom plugin.
724
+ // If gallery opened from direct url (hash) speed value should be 0
725
+ if (delay && !$('body').hasClass('lg-from-hash')) {
726
+ _speed = delay;
727
+ }
728
+
729
+ setTimeout(function() {
730
+ _this.$slide.eq(index).addClass('lg-complete');
731
+ _this.$el.trigger('onSlideItemLoad.lg', [index, delay || 0]);
732
+ }, _speed);
733
+
734
+ });
735
+
736
+ // @todo check load state for html5 videos
737
+ if (_isVideo && _isVideo.html5 && !_hasPoster) {
738
+ _this.$slide.eq(index).addClass('lg-complete');
739
+ }
740
+
741
+ if (rec === true) {
742
+ if (!_this.$slide.eq(index).hasClass('lg-complete')) {
743
+ _this.$slide.eq(index).find('.lg-object').on('load.lg error.lg', function() {
744
+ _this.preload(index);
745
+ });
746
+ } else {
747
+ _this.preload(index);
748
+ }
749
+ }
750
+
751
+ //}
752
+ };
753
+
754
+ /**
755
+ * @desc slide function for lightgallery
756
+ ** Slide() gets call on start
757
+ ** ** Set lg.on true once slide() function gets called.
758
+ ** Call loadContent() on slide() function inside setTimeout
759
+ ** ** On first slide we do not want any animation like slide of fade
760
+ ** ** So on first slide( if lg.on if false that is first slide) loadContent() should start loading immediately
761
+ ** ** Else loadContent() should wait for the transition to complete.
762
+ ** ** So set timeout s.speed + 50
763
+ <=> ** loadContent() will load slide content in to the particular slide
764
+ ** ** It has recursion (rec) parameter. if rec === true loadContent() will call preload() function.
765
+ ** ** preload will execute only when the previous slide is fully loaded (images iframe)
766
+ ** ** avoid simultaneous image load
767
+ <=> ** Preload() will check for s.preload value and call loadContent() again accoring to preload value
768
+ ** loadContent() <====> Preload();
769
+
770
+ * @param {Number} index - index of the slide
771
+ * @param {Boolean} fromTouch - true if slide function called via touch event or mouse drag
772
+ * @param {Boolean} fromThumb - true if slide function called via thumbnail click
773
+ * @param {String} direction - Direction of the slide(next/prev)
774
+ */
775
+ Plugin.prototype.slide = function(index, fromTouch, fromThumb, direction) {
776
+
777
+ var _prevIndex = this.$outer.find('.lg-current').index();
778
+ var _this = this;
779
+
780
+ // Prevent if multiple call
781
+ // Required for hsh plugin
782
+ if (_this.lGalleryOn && (_prevIndex === index)) {
783
+ return;
784
+ }
785
+
786
+ var _length = this.$slide.length;
787
+ var _time = _this.lGalleryOn ? this.s.speed : 0;
788
+
789
+ if (!_this.lgBusy) {
790
+
791
+ if (this.s.download) {
792
+ var _src;
793
+ if (_this.s.dynamic) {
794
+ _src = _this.s.dynamicEl[index].downloadUrl !== false && (_this.s.dynamicEl[index].downloadUrl || _this.s.dynamicEl[index].src);
795
+ } else {
796
+ _src = _this.$items.eq(index).attr('data-download-url') !== 'false' && (_this.$items.eq(index).attr('data-download-url') || _this.$items.eq(index).attr('href') || _this.$items.eq(index).attr('data-src'));
797
+
798
+ }
799
+
800
+ if (_src) {
801
+ $('#lg-download').attr('href', _src);
802
+ _this.$outer.removeClass('lg-hide-download');
803
+ } else {
804
+ _this.$outer.addClass('lg-hide-download');
805
+ }
806
+ }
807
+
808
+ this.$el.trigger('onBeforeSlide.lg', [_prevIndex, index, fromTouch, fromThumb]);
809
+
810
+ _this.lgBusy = true;
811
+
812
+ clearTimeout(_this.hideBartimeout);
813
+
814
+ // Add title if this.s.appendSubHtmlTo === lg-sub-html
815
+ if (this.s.appendSubHtmlTo === '.lg-sub-html') {
816
+
817
+ // wait for slide animation to complete
818
+ setTimeout(function() {
819
+ _this.addHtml(index);
820
+ }, _time);
821
+ }
822
+
823
+ this.arrowDisable(index);
824
+
825
+ if (!direction) {
826
+ if (index < _prevIndex) {
827
+ direction = 'prev';
828
+ } else if (index > _prevIndex) {
829
+ direction = 'next';
830
+ }
831
+ }
832
+
833
+ if (!fromTouch) {
834
+
835
+ // remove all transitions
836
+ _this.$outer.addClass('lg-no-trans');
837
+
838
+ this.$slide.removeClass('lg-prev-slide lg-next-slide');
839
+
840
+ if (direction === 'prev') {
841
+
842
+ //prevslide
843
+ this.$slide.eq(index).addClass('lg-prev-slide');
844
+ this.$slide.eq(_prevIndex).addClass('lg-next-slide');
845
+ } else {
846
+
847
+ // next slide
848
+ this.$slide.eq(index).addClass('lg-next-slide');
849
+ this.$slide.eq(_prevIndex).addClass('lg-prev-slide');
850
+ }
851
+
852
+ // give 50 ms for browser to add/remove class
853
+ setTimeout(function() {
854
+ _this.$slide.removeClass('lg-current');
855
+
856
+ //_this.$slide.eq(_prevIndex).removeClass('lg-current');
857
+ _this.$slide.eq(index).addClass('lg-current');
858
+
859
+ // reset all transitions
860
+ _this.$outer.removeClass('lg-no-trans');
861
+ }, 50);
862
+ } else {
863
+
864
+ this.$slide.removeClass('lg-prev-slide lg-current lg-next-slide');
865
+ var touchPrev;
866
+ var touchNext;
867
+ if (_length > 2) {
868
+ touchPrev = index - 1;
869
+ touchNext = index + 1;
870
+
871
+ if ((index === 0) && (_prevIndex === _length - 1)) {
872
+
873
+ // next slide
874
+ touchNext = 0;
875
+ touchPrev = _length - 1;
876
+ } else if ((index === _length - 1) && (_prevIndex === 0)) {
877
+
878
+ // prev slide
879
+ touchNext = 0;
880
+ touchPrev = _length - 1;
881
+ }
882
+
883
+ } else {
884
+ touchPrev = 0;
885
+ touchNext = 1;
886
+ }
887
+
888
+ if (direction === 'prev') {
889
+ _this.$slide.eq(touchNext).addClass('lg-next-slide');
890
+ } else {
891
+ _this.$slide.eq(touchPrev).addClass('lg-prev-slide');
892
+ }
893
+
894
+ _this.$slide.eq(index).addClass('lg-current');
895
+ }
896
+
897
+ if (_this.lGalleryOn) {
898
+ setTimeout(function() {
899
+ _this.loadContent(index, true, 0);
900
+ }, this.s.speed + 50);
901
+
902
+ setTimeout(function() {
903
+ _this.lgBusy = false;
904
+ _this.$el.trigger('onAfterSlide.lg', [_prevIndex, index, fromTouch, fromThumb]);
905
+ }, this.s.speed);
906
+
907
+ } else {
908
+ _this.loadContent(index, true, _this.s.backdropDuration);
909
+
910
+ _this.lgBusy = false;
911
+ _this.$el.trigger('onAfterSlide.lg', [_prevIndex, index, fromTouch, fromThumb]);
912
+ }
913
+
914
+ _this.lGalleryOn = true;
915
+
916
+ if (this.s.counter) {
917
+ $('#lg-counter-current').text(index + 1);
918
+ }
919
+
920
+ }
921
+
922
+ };
923
+
924
+ /**
925
+ * @desc Go to next slide
926
+ * @param {Boolean} fromTouch - true if slide function called via touch event
927
+ */
928
+ Plugin.prototype.goToNextSlide = function(fromTouch) {
929
+ var _this = this;
930
+ var _loop = _this.s.loop;
931
+ if (fromTouch && _this.$slide.length < 3) {
932
+ _loop = false;
933
+ }
934
+
935
+ if (!_this.lgBusy) {
936
+ if ((_this.index + 1) < _this.$slide.length) {
937
+ _this.index++;
938
+ _this.$el.trigger('onBeforeNextSlide.lg', [_this.index]);
939
+ _this.slide(_this.index, fromTouch, false, 'next');
940
+ } else {
941
+ if (_loop) {
942
+ _this.index = 0;
943
+ _this.$el.trigger('onBeforeNextSlide.lg', [_this.index]);
944
+ _this.slide(_this.index, fromTouch, false, 'next');
945
+ } else if (_this.s.slideEndAnimatoin && !fromTouch) {
946
+ _this.$outer.addClass('lg-right-end');
947
+ setTimeout(function() {
948
+ _this.$outer.removeClass('lg-right-end');
949
+ }, 400);
950
+ }
951
+ }
952
+ }
953
+ };
954
+
955
+ /**
956
+ * @desc Go to previous slide
957
+ * @param {Boolean} fromTouch - true if slide function called via touch event
958
+ */
959
+ Plugin.prototype.goToPrevSlide = function(fromTouch) {
960
+ var _this = this;
961
+ var _loop = _this.s.loop;
962
+ if (fromTouch && _this.$slide.length < 3) {
963
+ _loop = false;
964
+ }
965
+
966
+ if (!_this.lgBusy) {
967
+ if (_this.index > 0) {
968
+ _this.index--;
969
+ _this.$el.trigger('onBeforePrevSlide.lg', [_this.index, fromTouch]);
970
+ _this.slide(_this.index, fromTouch, false, 'prev');
971
+ } else {
972
+ if (_loop) {
973
+ _this.index = _this.$items.length - 1;
974
+ _this.$el.trigger('onBeforePrevSlide.lg', [_this.index, fromTouch]);
975
+ _this.slide(_this.index, fromTouch, false, 'prev');
976
+ } else if (_this.s.slideEndAnimatoin && !fromTouch) {
977
+ _this.$outer.addClass('lg-left-end');
978
+ setTimeout(function() {
979
+ _this.$outer.removeClass('lg-left-end');
980
+ }, 400);
981
+ }
982
+ }
983
+ }
984
+ };
985
+
986
+ Plugin.prototype.keyPress = function() {
987
+ var _this = this;
988
+ if (this.$items.length > 1) {
989
+ $(window).on('keyup.lg', function(e) {
990
+ if (_this.$items.length > 1) {
991
+ if (e.keyCode === 37) {
992
+ e.preventDefault();
993
+ _this.goToPrevSlide();
994
+ }
995
+
996
+ if (e.keyCode === 39) {
997
+ e.preventDefault();
998
+ _this.goToNextSlide();
999
+ }
1000
+ }
1001
+ });
1002
+ }
1003
+
1004
+ $(window).on('keydown.lg', function(e) {
1005
+ if (_this.s.escKey === true && e.keyCode === 27) {
1006
+ e.preventDefault();
1007
+ if (!_this.$outer.hasClass('lg-thumb-open')) {
1008
+ _this.destroy();
1009
+ } else {
1010
+ _this.$outer.removeClass('lg-thumb-open');
1011
+ }
1012
+ }
1013
+ });
1014
+ };
1015
+
1016
+ Plugin.prototype.arrow = function() {
1017
+ var _this = this;
1018
+ this.$outer.find('.lg-prev').on('click.lg', function() {
1019
+ _this.goToPrevSlide();
1020
+ });
1021
+
1022
+ this.$outer.find('.lg-next').on('click.lg', function() {
1023
+ _this.goToNextSlide();
1024
+ });
1025
+ };
1026
+
1027
+ Plugin.prototype.arrowDisable = function(index) {
1028
+
1029
+ // Disable arrows if s.hideControlOnEnd is true
1030
+ if (!this.s.loop && this.s.hideControlOnEnd) {
1031
+ if ((index + 1) < this.$slide.length) {
1032
+ this.$outer.find('.lg-next').removeAttr('disabled').removeClass('disabled');
1033
+ } else {
1034
+ this.$outer.find('.lg-next').attr('disabled', 'disabled').addClass('disabled');
1035
+ }
1036
+
1037
+ if (index > 0) {
1038
+ this.$outer.find('.lg-prev').removeAttr('disabled').removeClass('disabled');
1039
+ } else {
1040
+ this.$outer.find('.lg-prev').attr('disabled', 'disabled').addClass('disabled');
1041
+ }
1042
+ }
1043
+ };
1044
+
1045
+ Plugin.prototype.setTranslate = function($el, xValue, yValue) {
1046
+ // jQuery supports Automatic CSS prefixing since jQuery 1.8.0
1047
+ if (this.s.useLeft) {
1048
+ $el.css('left', xValue);
1049
+ } else {
1050
+ $el.css({
1051
+ transform: 'translate3d(' + (xValue) + 'px, ' + yValue + 'px, 0px)'
1052
+ });
1053
+ }
1054
+ };
1055
+
1056
+ Plugin.prototype.touchMove = function(startCoords, endCoords) {
1057
+
1058
+ var distance = endCoords - startCoords;
1059
+
1060
+ if (Math.abs(distance) > 15) {
1061
+ // reset opacity and transition duration
1062
+ this.$outer.addClass('lg-dragging');
1063
+
1064
+ // move current slide
1065
+ this.setTranslate(this.$slide.eq(this.index), distance, 0);
1066
+
1067
+ // move next and prev slide with current slide
1068
+ this.setTranslate($('.lg-prev-slide'), -this.$slide.eq(this.index).width() + distance, 0);
1069
+ this.setTranslate($('.lg-next-slide'), this.$slide.eq(this.index).width() + distance, 0);
1070
+ }
1071
+ };
1072
+
1073
+ Plugin.prototype.touchEnd = function(distance) {
1074
+ var _this = this;
1075
+
1076
+ // keep slide animation for any mode while dragg/swipe
1077
+ if (_this.s.mode !== 'lg-slide') {
1078
+ _this.$outer.addClass('lg-slide');
1079
+ }
1080
+
1081
+ this.$slide.not('.lg-current, .lg-prev-slide, .lg-next-slide').css('opacity', '0');
1082
+
1083
+ // set transition duration
1084
+ setTimeout(function() {
1085
+ _this.$outer.removeClass('lg-dragging');
1086
+ if ((distance < 0) && (Math.abs(distance) > _this.s.swipeThreshold)) {
1087
+ _this.goToNextSlide(true);
1088
+ } else if ((distance > 0) && (Math.abs(distance) > _this.s.swipeThreshold)) {
1089
+ _this.goToPrevSlide(true);
1090
+ } else if (Math.abs(distance) < 5) {
1091
+
1092
+ // Trigger click if distance is less than 5 pix
1093
+ _this.$el.trigger('onSlideClick.lg');
1094
+ }
1095
+
1096
+ _this.$slide.removeAttr('style');
1097
+ });
1098
+
1099
+ // remove slide class once drag/swipe is completed if mode is not slide
1100
+ setTimeout(function() {
1101
+ if (!_this.$outer.hasClass('lg-dragging') && _this.s.mode !== 'lg-slide') {
1102
+ _this.$outer.removeClass('lg-slide');
1103
+ }
1104
+ }, _this.s.speed + 100);
1105
+
1106
+ };
1107
+
1108
+ Plugin.prototype.enableSwipe = function() {
1109
+ var _this = this;
1110
+ var startCoords = 0;
1111
+ var endCoords = 0;
1112
+ var isMoved = false;
1113
+
1114
+ if (_this.s.enableSwipe && _this.isTouch && _this.doCss()) {
1115
+
1116
+ _this.$slide.on('touchstart.lg', function(e) {
1117
+ if (!_this.$outer.hasClass('lg-zoomed') && !_this.lgBusy) {
1118
+ e.preventDefault();
1119
+ _this.manageSwipeClass();
1120
+ startCoords = e.originalEvent.targetTouches[0].pageX;
1121
+ }
1122
+ });
1123
+
1124
+ _this.$slide.on('touchmove.lg', function(e) {
1125
+ if (!_this.$outer.hasClass('lg-zoomed')) {
1126
+ e.preventDefault();
1127
+ endCoords = e.originalEvent.targetTouches[0].pageX;
1128
+ _this.touchMove(startCoords, endCoords);
1129
+ isMoved = true;
1130
+ }
1131
+ });
1132
+
1133
+ _this.$slide.on('touchend.lg', function() {
1134
+ if (!_this.$outer.hasClass('lg-zoomed')) {
1135
+ if (isMoved) {
1136
+ isMoved = false;
1137
+ _this.touchEnd(endCoords - startCoords);
1138
+ } else {
1139
+ _this.$el.trigger('onSlideClick.lg');
1140
+ }
1141
+ }
1142
+ });
1143
+ }
1144
+
1145
+ };
1146
+
1147
+ Plugin.prototype.enableDrag = function() {
1148
+ var _this = this;
1149
+ var startCoords = 0;
1150
+ var endCoords = 0;
1151
+ var isDraging = false;
1152
+ var isMoved = false;
1153
+ if (_this.s.enableDrag && !_this.isTouch && _this.doCss()) {
1154
+ _this.$slide.on('mousedown.lg', function(e) {
1155
+ // execute only on .lg-object
1156
+ if (!_this.$outer.hasClass('lg-zoomed')) {
1157
+ if ($(e.target).hasClass('lg-object') || $(e.target).hasClass('lg-video-play')) {
1158
+ e.preventDefault();
1159
+
1160
+ if (!_this.lgBusy) {
1161
+ _this.manageSwipeClass();
1162
+ startCoords = e.pageX;
1163
+ isDraging = true;
1164
+
1165
+ // ** Fix for webkit cursor issue https://code.google.com/p/chromium/issues/detail?id=26723
1166
+ _this.$outer.scrollLeft += 1;
1167
+ _this.$outer.scrollLeft -= 1;
1168
+
1169
+ // *
1170
+
1171
+ _this.$outer.removeClass('lg-grab').addClass('lg-grabbing');
1172
+
1173
+ _this.$el.trigger('onDragstart.lg');
1174
+ }
1175
+
1176
+ }
1177
+ }
1178
+ });
1179
+
1180
+ $(window).on('mousemove.lg', function(e) {
1181
+ if (isDraging) {
1182
+ isMoved = true;
1183
+ endCoords = e.pageX;
1184
+ _this.touchMove(startCoords, endCoords);
1185
+ _this.$el.trigger('onDragmove.lg');
1186
+ }
1187
+ });
1188
+
1189
+ $(window).on('mouseup.lg', function(e) {
1190
+ if (isMoved) {
1191
+ isMoved = false;
1192
+ _this.touchEnd(endCoords - startCoords);
1193
+ _this.$el.trigger('onDragend.lg');
1194
+ } else if ($(e.target).hasClass('lg-object') || $(e.target).hasClass('lg-video-play')) {
1195
+ _this.$el.trigger('onSlideClick.lg');
1196
+ }
1197
+
1198
+ // Prevent execution on click
1199
+ if (isDraging) {
1200
+ isDraging = false;
1201
+ _this.$outer.removeClass('lg-grabbing').addClass('lg-grab');
1202
+ }
1203
+ });
1204
+
1205
+ }
1206
+ };
1207
+
1208
+ Plugin.prototype.manageSwipeClass = function() {
1209
+ var _touchNext = this.index + 1;
1210
+ var _touchPrev = this.index - 1;
1211
+ if (this.s.loop && this.$slide.length > 2) {
1212
+ if (this.index === 0) {
1213
+ _touchPrev = this.$slide.length - 1;
1214
+ } else if (this.index === this.$slide.length - 1) {
1215
+ _touchNext = 0;
1216
+ }
1217
+ }
1218
+
1219
+ this.$slide.removeClass('lg-next-slide lg-prev-slide');
1220
+ if (_touchPrev > -1) {
1221
+ this.$slide.eq(_touchPrev).addClass('lg-prev-slide');
1222
+ }
1223
+
1224
+ this.$slide.eq(_touchNext).addClass('lg-next-slide');
1225
+ };
1226
+
1227
+ Plugin.prototype.mousewheel = function() {
1228
+ var _this = this;
1229
+ _this.$outer.on('mousewheel.lg', function(e) {
1230
+
1231
+ if (!e.deltaY) {
1232
+ return;
1233
+ }
1234
+
1235
+ if (e.deltaY > 0) {
1236
+ _this.goToPrevSlide();
1237
+ } else {
1238
+ _this.goToNextSlide();
1239
+ }
1240
+
1241
+ e.preventDefault();
1242
+ });
1243
+
1244
+ };
1245
+
1246
+ Plugin.prototype.closeGallery = function() {
1247
+
1248
+ var _this = this;
1249
+ var mousedown = false;
1250
+ this.$outer.find('.lg-close').on('click.lg', function() {
1251
+ _this.destroy();
1252
+ });
1253
+
1254
+ if (_this.s.closable) {
1255
+
1256
+ // If you drag the slide and release outside gallery gets close on chrome
1257
+ // for preventing this check mousedown and mouseup happened on .lg-item or lg-outer
1258
+ _this.$outer.on('mousedown.lg', function(e) {
1259
+
1260
+ if ($(e.target).is('.lg-outer') || $(e.target).is('.lg-item ') || $(e.target).is('.lg-img-wrap')) {
1261
+ mousedown = true;
1262
+ } else {
1263
+ mousedown = false;
1264
+ }
1265
+
1266
+ });
1267
+
1268
+ _this.$outer.on('mouseup.lg', function(e) {
1269
+
1270
+ if ($(e.target).is('.lg-outer') || $(e.target).is('.lg-item ') || $(e.target).is('.lg-img-wrap') && mousedown) {
1271
+ if (!_this.$outer.hasClass('lg-dragging')) {
1272
+ _this.destroy();
1273
+ }
1274
+ }
1275
+
1276
+ });
1277
+
1278
+ }
1279
+
1280
+ };
1281
+
1282
+ Plugin.prototype.destroy = function(d) {
1283
+
1284
+ var _this = this;
1285
+
1286
+ if (!d) {
1287
+ _this.$el.trigger('onBeforeClose.lg');
1288
+ $(window).scrollTop(_this.prevScrollTop);
1289
+ }
1290
+
1291
+
1292
+ /**
1293
+ * if d is false or undefined destroy will only close the gallery
1294
+ * plugins instance remains with the element
1295
+ *
1296
+ * if d is true destroy will completely remove the plugin
1297
+ */
1298
+
1299
+ if (d) {
1300
+ if (!_this.s.dynamic) {
1301
+ // only when not using dynamic mode is $items a jquery collection
1302
+ this.$items.off('click.lg click.lgcustom');
1303
+ }
1304
+
1305
+ $.removeData(_this.el, 'lightGallery');
1306
+ }
1307
+
1308
+ // Unbind all events added by lightGallery
1309
+ this.$el.off('.lg.tm');
1310
+
1311
+ // Distroy all lightGallery modules
1312
+ $.each($.fn.lightGallery.modules, function(key) {
1313
+ if (_this.modules[key]) {
1314
+ _this.modules[key].destroy();
1315
+ }
1316
+ });
1317
+
1318
+ this.lGalleryOn = false;
1319
+
1320
+ clearTimeout(_this.hideBartimeout);
1321
+ this.hideBartimeout = false;
1322
+ $(window).off('.lg');
1323
+ $('body').removeClass('lg-on lg-from-hash');
1324
+
1325
+ if (_this.$outer) {
1326
+ _this.$outer.removeClass('lg-visible');
1327
+ }
1328
+
1329
+ $('.lg-backdrop').removeClass('in');
1330
+
1331
+ setTimeout(function() {
1332
+ if (_this.$outer) {
1333
+ _this.$outer.remove();
1334
+ }
1335
+
1336
+ $('.lg-backdrop').remove();
1337
+
1338
+ if (!d) {
1339
+ _this.$el.trigger('onCloseAfter.lg');
1340
+ }
1341
+
1342
+ }, _this.s.backdropDuration + 50);
1343
+ };
1344
+
1345
+ $.fn.lightGallery = function(options) {
1346
+ return this.each(function() {
1347
+ if (!$.data(this, 'lightGallery')) {
1348
+ $.data(this, 'lightGallery', new Plugin(this, options));
1349
+ } else {
1350
+ try {
1351
+ $(this).data('lightGallery').init();
1352
+ } catch (err) {
1353
+ console.error('lightGallery has not initiated properly');
1354
+ }
1355
+ }
1356
+ });
1357
+ };
1358
+
1359
+ $.fn.lightGallery.modules = {};
1360
+
1361
+ })();
1362
+
1363
+
1364
+ }));