Lightgallery All
Lightgallery All
0 - 2020-05-03
* http://sachinchoolur.github.io/lightGallery/
* Copyright (c) 2020 Sachin N; Licensed GPLv3 */
/*! lightgallery - v1.7.0 - 2020-05-03
* http://sachinchoolur.github.io/lightGallery/
* Copyright (c) 2020 Sachin N; Licensed GPLv3 */
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module unless amdModuleId is set
define(['jquery'], function (a0) {
return (factory(a0));
});
} else if (typeof module === 'object' && module.exports) {
// Node. Does not work with strict CommonJS, but
// only CommonJS-like environments that support module.exports,
// like Node.
module.exports = factory(require('jquery'));
} else {
factory(root["jQuery"]);
}
}(this, function ($) {
(function() {
'use strict';
var defaults = {
mode: 'lg-slide',
// Ex : 'ease'
cssEasing: 'ease',
useLeft: false,
closable: true,
loop: true,
escKey: true,
keyPress: true,
controls: true,
slideEndAnimatoin: true,
hideControlOnEnd: false,
mousewheel: true,
getCaptionFromTitleOrAlt: true,
// .lg-item || '.lg-sub-html'
appendSubHtmlTo: '.lg-sub-html',
subHtmlSelectorRelative: false,
/**
* @desc number of preload slides
* will exicute only after the current slide is fully loaded.
*
* @ex you clicked on 4th image and if preload = 1 then 3rd slide and 5th
* slide will be loaded in the background after the 4th slide is fully
loaded..
* if preload is 2 then 2nd 3rd 5th 6th slides will be preloaded.. ... ...
*
*/
preload: 1,
showAfterLoad: true,
selector: '',
selectWithin: '',
nextHtml: '',
prevHtml: '',
// 0, 1
index: false,
iframeMaxWidth: '100%',
download: true,
counter: true,
appendCounterTo: '.lg-toolbar',
swipeThreshold: 50,
enableSwipe: true,
enableDrag: true,
dynamic: false,
dynamicEl: [],
galleryId: 1
};
// lightGallery settings
this.s = $.extend({}, defaults, options);
this.lgBusy = false;
// Gallery items
if (this.s.dynamic) {
this.$items = this.s.dynamicEl;
} else {
if (this.s.selector === 'this') {
this.$items = this.$el;
} else if (this.s.selector !== '') {
if (this.s.selectWithin) {
this.$items = $(this.s.selectWithin).find(this.s.selector);
} else {
this.$items = this.$el.find($(this.s.selector));
}
} else {
this.$items = this.$el.children();
}
}
// .lg-item
this.$slide = '';
// .lg-outer
this.$outer = '';
this.init();
return this;
}
Plugin.prototype.init = function() {
$('body').addClass('lg-from-hash');
if (!$('body').hasClass('lg-on')) {
setTimeout(function() {
_this.build(_this.index);
});
$('body').addClass('lg-on');
}
}
if (_this.s.dynamic) {
_this.$el.trigger('onBeforeOpen.lg');
_this.index = _this.s.index || 0;
// Using different namespace for click because click event should not
unbind if selector is same object('this')
_this.$items.on('click.lgcustom', function(event) {
// For IE8
try {
event.preventDefault();
event.preventDefault();
} catch (er) {
event.returnValue = false;
}
_this.$el.trigger('onBeforeOpen.lg');
};
Plugin.prototype.build = function(index) {
// module constructor
$.each($.fn.lightGallery.modules, function(key) {
_this.modules[key] = new $.fn.lightGallery.modules[key](_this.el);
});
if (_this.s.keyPress) {
_this.keyPress();
}
if (_this.$items.length > 1) {
_this.arrow();
setTimeout(function() {
_this.enableDrag();
_this.enableSwipe();
}, 50);
if (_this.s.mousewheel) {
_this.mousewheel();
}
} else {
_this.$slide.on('click.lg', function() {
_this.$el.trigger('onSlideClick.lg');
});
}
_this.counter();
_this.closeGallery();
_this.$el.trigger('onAfterOpen.lg');
_this.$outer.removeClass('lg-hide-items');
clearTimeout(_this.hideBartimeout);
});
_this.$outer.trigger('mousemove.lg');
};
Plugin.prototype.structure = function() {
var list = '';
var controls = '';
var i = 0;
var subHtmlCont = '';
var template;
var _this = this;
$('body').append('<div class="lg-backdrop"></div>');
$('.lg-backdrop').css('transition-duration', this.s.backdropDuration +
'ms');
// Create controlls
if (this.s.controls && this.$items.length > 1) {
controls = '<div class="lg-actions">' +
'<button aria-label="Previous slide" class="lg-prev lg-icon">' +
this.s.prevHtml + '</button>' +
'<button aria-label="Next slide" class="lg-next lg-icon">' +
this.s.nextHtml + '</button>' +
'</div>';
}
$('body').append(template);
this.$outer = $('.lg-outer');
this.$outer.focus();
this.$slide = this.$outer.find('.lg-item');
if (this.s.useLeft) {
this.$outer.addClass('lg-use-left');
this.$outer.addClass(this.s.mode);
if (this.s.showAfterLoad) {
this.$outer.addClass('lg-show-after-load');
}
if (this.doCss()) {
var $inner = this.$outer.find('.lg-inner');
$inner.css('transition-timing-function', this.s.cssEasing);
$inner.css('transition-duration', this.s.speed + 'ms');
}
setTimeout(function() {
$('.lg-backdrop').addClass('in');
});
setTimeout(function() {
_this.$outer.addClass('lg-visible');
}, this.s.backdropDuration);
if (this.s.download) {
this.$outer.find('.lg-toolbar').append('<a id="lg-download" aria-
label="Download" target="_blank" download class="lg-download lg-icon"></a>');
}
// Store the current scroll top value to scroll back after closing the
gallery..
this.prevScrollTop = $(window).scrollTop();
};
if (support()) {
return true;
}
return false;
};
/**
* @desc Check the given src is video
* @param {String} src
* @return {Object} video type
* Ex:{ youtube : ["//www.youtube.com/watch?v=c0asJgSyxcY", "c0asJgSyxcY"] }
*/
Plugin.prototype.isVideo = function(src, index) {
var html;
if (this.s.dynamic) {
html = this.s.dynamicEl[index].html;
} else {
html = this.$items.eq(index).attr('data-html');
}
if (!src) {
if (html) {
return {
html5: true
};
} else {
console.error('lightGallery :- data-src is not provided 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');
return false;
}
}
if (youtube) {
return {
youtube: youtube
};
} else if (vimeo) {
return {
vimeo: vimeo
};
} else if (dailymotion) {
return {
dailymotion: dailymotion
};
} else if (vk) {
return {
vk: vk
};
}
};
/**
* @desc Create image counter
* Ex: 1/10
*/
Plugin.prototype.counter = function() {
if (this.s.counter) {
$(this.s.appendCounterTo).append('<div id="lg-counter" role="status"
aria-live="polite"><span id="lg-counter-current">' + (parseInt(this.index, 10) + 1)
+ '</span> / <span id="lg-counter-all">' + this.$items.length + '</span></div>');
}
};
/**
* @desc add sub-html into the slide
* @param {Number} index - index of the slide
*/
Plugin.prototype.addHtml = function(index) {
var subHtml = null;
var subHtmlUrl;
var $currentEle;
if (this.s.dynamic) {
if (this.s.dynamicEl[index].subHtmlUrl) {
subHtmlUrl = this.s.dynamicEl[index].subHtmlUrl;
} else {
subHtml = this.s.dynamicEl[index].subHtml;
}
} else {
$currentEle = this.$items.eq(index);
if ($currentEle.attr('data-sub-html-url')) {
subHtmlUrl = $currentEle.attr('data-sub-html-url');
} else {
subHtml = $currentEle.attr('data-sub-html');
if (this.s.getCaptionFromTitleOrAlt && !subHtml) {
subHtml = $currentEle.attr('title') ||
$currentEle.find('img').first().attr('alt');
}
}
}
if (!subHtmlUrl) {
if (typeof subHtml !== 'undefined' && subHtml !== null) {
if (subHtmlUrl) {
this.$outer.find(this.s.appendSubHtmlTo).load(subHtmlUrl);
} else {
this.$outer.find(this.s.appendSubHtmlTo).html(subHtml);
}
} else {
if (subHtmlUrl) {
this.$slide.eq(index).load(subHtmlUrl);
} else {
this.$slide.eq(index).append(subHtml);
}
}
/**
* @desc Preload slides
* @param {Number} index - index of the slide
*/
Plugin.prototype.preload = function(index) {
var i = 1;
var j = 1;
for (i = 1; i <= this.s.preload; i++) {
if (i >= this.$items.length - index) {
break;
}
/**
* @desc Load slide content into slide.
* @param {Number} index - index of the slide.
* @param {Boolean} rec - if true call loadcontent() function again.
* @param {Boolean} delay - delay for adding complete class. it is 0 except
first time.
*/
Plugin.prototype.loadContent = function(index, rec, delay) {
rsSrc.push(__src[0]);
rsWidth.push(__src[1]);
}
if (_this.s.dynamic) {
if (_this.s.dynamicEl[index].poster) {
_hasPoster = true;
_poster = _this.s.dynamicEl[index].poster;
}
_html = _this.s.dynamicEl[index].html;
_src = _this.s.dynamicEl[index].src;
_alt = _this.s.dynamicEl[index].alt;
if (_this.s.dynamicEl[index].responsive) {
var srcDyItms = _this.s.dynamicEl[index].responsive.split(',');
getResponsiveSrc(srcDyItms);
}
_srcset = _this.s.dynamicEl[index].srcset;
_sizes = _this.s.dynamicEl[index].sizes;
} else {
var $currentEle = _this.$items.eq(index);
if ($currentEle.attr('data-poster')) {
_hasPoster = true;
_poster = $currentEle.attr('data-poster');
}
_html = $currentEle.attr('data-html');
_src = $currentEle.attr('href') || $currentEle.attr('data-src');
_alt = $currentEle.attr('title') ||
$currentEle.find('img').first().attr('alt');
if ($currentEle.attr('data-responsive')) {
var srcItms = $currentEle.attr('data-responsive').split(',');
getResponsiveSrc(srcItms);
}
_srcset = $currentEle.attr('data-srcset');
_sizes = $currentEle.attr('data-sizes');
} else if (_isVideo) {
_this.$slide.eq(index).prepend('<div class="lg-video-cont "><div
class="lg-video"></div></div>');
_this.$el.trigger('hasVideo.lg', [index, _src, _html]);
} else {
_alt = _alt ? 'alt="' + _alt + '"' : '';
_this.$slide.eq(index).prepend('<div class="lg-img-wrap"><img
class="lg-object lg-image" ' + _alt + ' src="' + _src + '" /></div>');
}
_this.$el.trigger('onAferAppendSlide.lg', [index]);
_$img = _this.$slide.eq(index).find('.lg-object');
if (_sizes) {
_$img.attr('sizes', _sizes);
}
if (_srcset) {
_$img.attr('srcset', _srcset);
try {
picturefill({
elements: [_$img[0]]
});
} catch (e) {
console.warn('lightGallery :- If you want srcset to be
supported for older browser please include picturefil version 2 javascript library
in your document.');
}
}
_this.$slide.eq(index).addClass('lg-loaded');
}
// For first time add some delay for displaying the start animation.
var _speed = 0;
setTimeout(function() {
_this.$slide.eq(index).addClass('lg-complete');
_this.$el.trigger('onSlideItemLoad.lg', [index, delay || 0]);
}, _speed);
});
//}
};
/**
* @desc slide function for lightgallery
** Slide() gets call on start
** ** Set lg.on true once slide() function gets called.
** Call loadContent() on slide() function inside setTimeout
** ** On first slide we do not want any animation like slide of fade
** ** So on first slide( if lg.on if false that is first slide)
loadContent() should start loading immediately
** ** Else loadContent() should wait for the transition to complete.
** ** So set timeout s.speed + 50
<=> ** loadContent() will load slide content in to the particular slide
** ** It has recursion (rec) parameter. if rec === true loadContent() will
call preload() function.
** ** preload will execute only when the previous slide is fully loaded
(images iframe)
** ** avoid simultaneous image load
<=> ** Preload() will check for s.preload value and call loadContent() again
accoring to preload value
** loadContent() <====> Preload();
if (!_this.lgBusy) {
if (this.s.download) {
var _src;
if (_this.s.dynamic) {
_src = _this.s.dynamicEl[index].downloadUrl !== false &&
(_this.s.dynamicEl[index].downloadUrl || _this.s.dynamicEl[index].src);
} else {
_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'));
if (_src) {
$('#lg-download').attr('href', _src);
_this.$outer.removeClass('lg-hide-download');
} else {
_this.$outer.addClass('lg-hide-download');
}
}
_this.lgBusy = true;
clearTimeout(_this.hideBartimeout);
this.arrowDisable(index);
if (!direction) {
if (index < _prevIndex) {
direction = 'prev';
} else if (index > _prevIndex) {
direction = 'next';
}
}
if (!fromTouch) {
this.$slide.removeClass('lg-prev-slide lg-next-slide');
//prevslide
this.$slide.eq(index).addClass('lg-prev-slide');
this.$slide.eq(_prevIndex).addClass('lg-next-slide');
} else {
// next slide
this.$slide.eq(index).addClass('lg-next-slide');
this.$slide.eq(_prevIndex).addClass('lg-prev-slide');
}
//_this.$slide.eq(_prevIndex).removeClass('lg-current');
_this.$slide.eq(index).addClass('lg-current');
// next slide
touchNext = 0;
touchPrev = _length - 1;
} else if ((index === _length - 1) && (_prevIndex === 0)) {
// prev slide
touchNext = 0;
touchPrev = _length - 1;
}
} else {
touchPrev = 0;
touchNext = 1;
}
_this.$slide.eq(index).addClass('lg-current');
}
if (_this.lGalleryOn) {
setTimeout(function() {
_this.loadContent(index, true, 0);
}, this.s.speed + 50);
setTimeout(function() {
_this.lgBusy = false;
_this.$el.trigger('onAfterSlide.lg', [_prevIndex, index,
fromTouch, fromThumb]);
}, this.s.speed);
} else {
_this.loadContent(index, true, _this.s.backdropDuration);
_this.lgBusy = false;
_this.$el.trigger('onAfterSlide.lg', [_prevIndex, index, fromTouch,
fromThumb]);
}
_this.lGalleryOn = true;
if (this.s.counter) {
$('#lg-counter-current').text(index + 1);
}
}
_this.index = index;
};
/**
* @desc Go to next slide
* @param {Boolean} fromTouch - true if slide function called via touch event
*/
Plugin.prototype.goToNextSlide = function(fromTouch) {
var _this = this;
var _loop = _this.s.loop;
if (fromTouch && _this.$slide.length < 3) {
_loop = false;
}
if (!_this.lgBusy) {
if ((_this.index + 1) < _this.$slide.length) {
_this.index++;
_this.$el.trigger('onBeforeNextSlide.lg', [_this.index]);
_this.slide(_this.index, fromTouch, false, 'next');
} else {
if (_loop) {
_this.index = 0;
_this.$el.trigger('onBeforeNextSlide.lg', [_this.index]);
_this.slide(_this.index, fromTouch, false, 'next');
} else if (_this.s.slideEndAnimatoin && !fromTouch) {
_this.$outer.addClass('lg-right-end');
setTimeout(function() {
_this.$outer.removeClass('lg-right-end');
}, 400);
}
}
}
};
/**
* @desc Go to previous slide
* @param {Boolean} fromTouch - true if slide function called via touch event
*/
Plugin.prototype.goToPrevSlide = function(fromTouch) {
var _this = this;
var _loop = _this.s.loop;
if (fromTouch && _this.$slide.length < 3) {
_loop = false;
}
if (!_this.lgBusy) {
if (_this.index > 0) {
_this.index--;
_this.$el.trigger('onBeforePrevSlide.lg', [_this.index,
fromTouch]);
_this.slide(_this.index, fromTouch, false, 'prev');
} else {
if (_loop) {
_this.index = _this.$items.length - 1;
_this.$el.trigger('onBeforePrevSlide.lg', [_this.index,
fromTouch]);
_this.slide(_this.index, fromTouch, false, 'prev');
} else if (_this.s.slideEndAnimatoin && !fromTouch) {
_this.$outer.addClass('lg-left-end');
setTimeout(function() {
_this.$outer.removeClass('lg-left-end');
}, 400);
}
}
}
};
Plugin.prototype.keyPress = function() {
var _this = this;
if (this.$items.length > 1) {
$(window).on('keyup.lg', function(e) {
if (_this.$items.length > 1) {
if (e.keyCode === 37) {
e.preventDefault();
_this.goToPrevSlide();
}
$(window).on('keydown.lg', function(e) {
if (_this.s.escKey === true && e.keyCode === 27) {
e.preventDefault();
if (!_this.$outer.hasClass('lg-thumb-open')) {
_this.destroy();
} else {
_this.$outer.removeClass('lg-thumb-open');
}
}
});
};
Plugin.prototype.arrow = function() {
var _this = this;
this.$outer.find('.lg-prev').on('click.lg', function() {
_this.goToPrevSlide();
});
this.$outer.find('.lg-next').on('click.lg', function() {
_this.goToNextSlide();
});
};
Plugin.prototype.arrowDisable = function(index) {
if (index > 0) {
this.$outer.find('.lg-
prev').removeAttr('disabled').removeClass('disabled');
} else {
this.$outer.find('.lg-prev').attr('disabled',
'disabled').addClass('disabled');
}
}
};
Plugin.prototype.setTranslate = function($el, xValue, yValue) {
// jQuery supports Automatic CSS prefixing since jQuery 1.8.0
if (this.s.useLeft) {
$el.css('left', xValue);
} else {
$el.css({
transform: 'translate3d(' + (xValue) + 'px, ' + yValue + 'px, 0px)'
});
}
};
Plugin.prototype.touchEnd = function(distance) {
var _this = this;
_this.$slide.removeAttr('style');
});
};
Plugin.prototype.enableSwipe = function() {
var _this = this;
var startCoords = 0;
var endCoords = 0;
var isMoved = false;
_this.$slide.on('touchstart.lg', function(e) {
if (!_this.$outer.hasClass('lg-zoomed') && !_this.lgBusy) {
e.preventDefault();
_this.manageSwipeClass();
startCoords = e.originalEvent.targetTouches[0].pageX;
}
});
_this.$slide.on('touchmove.lg', function(e) {
if (!_this.$outer.hasClass('lg-zoomed')) {
e.preventDefault();
endCoords = e.originalEvent.targetTouches[0].pageX;
_this.touchMove(startCoords, endCoords);
isMoved = true;
}
});
_this.$slide.on('touchend.lg', function() {
if (!_this.$outer.hasClass('lg-zoomed')) {
if (isMoved) {
isMoved = false;
_this.touchEnd(endCoords - startCoords);
} else {
_this.$el.trigger('onSlideClick.lg');
}
}
});
}
};
Plugin.prototype.enableDrag = function() {
var _this = this;
var startCoords = 0;
var endCoords = 0;
var isDraging = false;
var isMoved = false;
if (_this.s.enableDrag && _this.doCss()) {
_this.$slide.on('mousedown.lg', function(e) {
if (!_this.$outer.hasClass('lg-zoomed') && !_this.lgBusy && !$
(e.target).text().trim()) {
e.preventDefault();
_this.manageSwipeClass();
startCoords = e.pageX;
isDraging = true;
// *
_this.$outer.removeClass('lg-grab').addClass('lg-grabbing');
_this.$el.trigger('onDragstart.lg');
}
});
$(window).on('mousemove.lg', function(e) {
if (isDraging) {
isMoved = true;
endCoords = e.pageX;
_this.touchMove(startCoords, endCoords);
_this.$el.trigger('onDragmove.lg');
}
});
$(window).on('mouseup.lg', function(e) {
if (isMoved) {
isMoved = false;
_this.touchEnd(endCoords - startCoords);
_this.$el.trigger('onDragend.lg');
} else if ($(e.target).hasClass('lg-object') || $
(e.target).hasClass('lg-video-play')) {
_this.$el.trigger('onSlideClick.lg');
}
}
};
Plugin.prototype.manageSwipeClass = function() {
var _touchNext = this.index + 1;
var _touchPrev = this.index - 1;
if (this.s.loop && this.$slide.length > 2) {
if (this.index === 0) {
_touchPrev = this.$slide.length - 1;
} else if (this.index === this.$slide.length - 1) {
_touchNext = 0;
}
}
this.$slide.removeClass('lg-next-slide lg-prev-slide');
if (_touchPrev > -1) {
this.$slide.eq(_touchPrev).addClass('lg-prev-slide');
}
this.$slide.eq(_touchNext).addClass('lg-next-slide');
};
Plugin.prototype.mousewheel = function() {
var _this = this;
_this.$outer.on('mousewheel.lg', function(e) {
if (!e.deltaY) {
return;
}
if (e.deltaY > 0) {
_this.goToPrevSlide();
} else {
_this.goToNextSlide();
}
e.preventDefault();
});
};
Plugin.prototype.closeGallery = function() {
if (_this.s.closable) {
// If you drag the slide and release outside gallery gets close on
chrome
// for preventing this check mousedown and mouseup happened on .lg-item
or lg-outer
_this.$outer.on('mousedown.lg', function(e) {
});
_this.$outer.on('mousemove.lg', function() {
mousedown = false;
});
_this.$outer.on('mouseup.lg', function(e) {
});
};
Plugin.prototype.destroy = function(d) {
if (!d) {
_this.$el.trigger('onBeforeClose.lg');
$(window).scrollTop(_this.prevScrollTop);
}
/**
* if d is false or undefined destroy will only close the gallery
* plugins instance remains with the element
*
* if d is true destroy will completely remove the plugin
*/
if (d) {
if (!_this.s.dynamic) {
// only when not using dynamic mode is $items a jquery collection
this.$items.off('click.lg click.lgcustom');
}
$.removeData(_this.el, 'lightGallery');
}
this.lGalleryOn = false;
clearTimeout(_this.hideBartimeout);
this.hideBartimeout = false;
$(window).off('.lg');
$('body').removeClass('lg-on lg-from-hash');
if (_this.$outer) {
_this.$outer.removeClass('lg-visible');
}
$('.lg-backdrop').removeClass('in');
setTimeout(function() {
if (_this.$outer) {
_this.$outer.remove();
}
$('.lg-backdrop').remove();
if (!d) {
_this.$el.trigger('onCloseAfter.lg');
}
_this.$el.focus();
}, _this.s.backdropDuration + 50);
};
$.fn.lightGallery = function(options) {
return this.each(function() {
if (!$.data(this, 'lightGallery')) {
$.data(this, 'lightGallery', new Plugin(this, options));
} else {
try {
$(this).data('lightGallery').init();
} catch (err) {
console.error('lightGallery has not initiated properly');
}
}
});
};
$.fn.lightGallery.modules = {};
})();
}));
(function() {
'use strict';
var defaults = {
autoplay: false,
pause: 5000,
progressBar: true,
fourceAutoplay: false,
autoplayControls: true,
appendAutoplayControlsTo: '.lg-toolbar'
};
/**
* Creates the autoplay plugin.
* @param {object} element - lightGallery element
*/
var Autoplay = function(element) {
this.core = $(element).data('lightGallery');
this.$el = $(element);
// do not allow progress bar if browser does not support css3 transitions
if (!this.core.doCss()) {
this.core.s.progressBar = false;
}
this.init();
return this;
};
Autoplay.prototype.init = function() {
var _this = this;
// set progress
_this.progress();
// Start autoplay
if (_this.core.s.autoplay) {
_this.$el.one('onSlideItemLoad.lg.tm', function() {
_this.startlAuto();
});
}
};
Autoplay.prototype.progress = function() {
_this.$el.on('onBeforeSlide.lg.tm', function() {
_this.fromAuto = false;
});
};
_this.core.$outer.find('.lg-autoplay-button').on('click.lg', function() {
if ($(_this.core.$outer).hasClass('lg-show-autoplay')) {
_this.cancelAuto();
_this.core.s.fourceAutoplay = false;
} else {
if (!_this.interval) {
_this.startlAuto();
_this.core.s.fourceAutoplay = _this.fourceAutoplayTemp;
}
}
});
};
// Autostart gallery
Autoplay.prototype.startlAuto = function() {
var _this = this;
_this.interval = setInterval(function() {
if (_this.core.index + 1 < _this.core.$items.length) {
_this.core.index++;
} else {
_this.core.index = 0;
}
_this.fromAuto = true;
_this.core.slide(_this.core.index, false, false, 'next');
}, _this.core.s.speed + _this.core.s.pause);
};
// cancel Autostart
Autoplay.prototype.cancelAuto = function() {
clearInterval(this.interval);
this.interval = false;
this.core.$outer.find('.lg-progress').removeAttr('style');
this.core.$outer.removeClass('lg-show-autoplay');
this.core.$outer.find('.lg-progress-bar').removeClass('lg-start');
};
Autoplay.prototype.destroy = function() {
this.cancelAuto();
this.core.$outer.find('.lg-progress-bar').remove();
};
$.fn.lightGallery.modules.autoplay = Autoplay;
})();
}));
(function() {
'use strict';
var defaults = {
fullScreen: true
};
function isFullScreen() {
return (
document.fullscreenElement ||
document.mozFullScreenElement ||
document.webkitFullscreenElement ||
document.msFullscreenElement
);
}
this.$el = $(element);
return this;
};
Fullscreen.prototype.init = function() {
var fullScreen = '';
if (this.core.s.fullScreen) {
Fullscreen.prototype.requestFullscreen = function() {
var el = document.documentElement;
if (el.requestFullscreen) {
el.requestFullscreen();
} else if (el.msRequestFullscreen) {
el.msRequestFullscreen();
} else if (el.mozRequestFullScreen) {
el.mozRequestFullScreen();
} else if (el.webkitRequestFullscreen) {
el.webkitRequestFullscreen();
}
};
Fullscreen.prototype.exitFullscreen = function() {
if (document.exitFullscreen) {
document.exitFullscreen();
} else if (document.msExitFullscreen) {
document.msExitFullscreen();
} else if (document.mozCancelFullScreen) {
document.mozCancelFullScreen();
} else if (document.webkitExitFullscreen) {
document.webkitExitFullscreen();
}
};
// https://developer.mozilla.org/en-
US/docs/Web/Guide/API/DOM/Using_full_screen_mode
Fullscreen.prototype.fullScreen = function() {
var _this = this;
$(document).on('fullscreenchange.lg webkitfullscreenchange.lg
mozfullscreenchange.lg MSFullscreenChange.lg', function() {
_this.core.$outer.toggleClass('lg-fullscreen-on');
});
this.core.$outer.find('.lg-fullscreen').on('click.lg', function() {
if (isFullScreen()) {
_this.exitFullscreen();
} else {
_this.requestFullscreen();
}
});
};
Fullscreen.prototype.destroy = function() {
$(document).off('fullscreenchange.lg webkitfullscreenchange.lg
mozfullscreenchange.lg MSFullscreenChange.lg');
};
$.fn.lightGallery.modules.fullscreen = Fullscreen;
})();
}));
(function() {
'use strict';
var defaults = {
pager: false
};
this.core = $(element).data('lightGallery');
this.$el = $(element);
this.core.s = $.extend({}, defaults, this.core.s);
if (this.core.s.pager && this.core.$items.length > 1) {
this.init();
}
return this;
};
Pager.prototype.init = function() {
var _this = this;
var pagerList = '';
var $pagerCont;
var $pagerOuter;
var timeout;
_this.core.$outer.find('.lg').append('<div class="lg-pager-outer"></div>');
if (_this.core.s.dynamic) {
for (var i = 0; i < _this.core.s.dynamicEl.length; i++) {
pagerList += '<span class="lg-pager-cont"> <span class="lg-
pager"></span><div class="lg-pager-thumb-cont"><span class="lg-caret"></span> <img
src="' + _this.core.s.dynamicEl[i].thumb + '" /></div></span>';
}
} else {
_this.core.$items.each(function() {
if (!_this.core.s.exThumbImage) {
pagerList += '<span class="lg-pager-cont"> <span class="lg-
pager"></span><div class="lg-pager-thumb-cont"><span class="lg-caret"></span> <img
src="' + $(this).find('img').attr('src') + '" /></div></span>';
} else {
pagerList += '<span class="lg-pager-cont"> <span class="lg-
pager"></span><div class="lg-pager-thumb-cont"><span class="lg-caret"></span> <img
src="' + $(this).attr(_this.core.s.exThumbImage) + '" /></div></span>';
}
});
}
$pagerOuter = _this.core.$outer.find('.lg-pager-outer');
$pagerOuter.html(pagerList);
$pagerCont = _this.core.$outer.find('.lg-pager-cont');
$pagerCont.on('click.lg touchend.lg', function() {
var _$this = $(this);
_this.core.index = _$this.index();
_this.core.slide(_this.core.index, false, true, false);
});
$pagerOuter.on('mouseover.lg', function() {
clearTimeout(timeout);
$pagerOuter.addClass('lg-pager-hover');
});
$pagerOuter.on('mouseout.lg', function() {
timeout = setTimeout(function() {
$pagerOuter.removeClass('lg-pager-hover');
});
});
};
Pager.prototype.destroy = function() {
};
$.fn.lightGallery.modules.pager = Pager;
})();
}));
(function() {
'use strict';
var defaults = {
thumbnail: true,
animateThumb: true,
currentPagerPosition: 'middle',
thumbWidth: 100,
thumbHeight: '80px',
thumbContHeight: 100,
thumbMargin: 5,
exThumbImage: false,
showThumbByDefault: true,
toogleThumb: true,
pullCaptionUp: true,
enableThumbDrag: true,
enableThumbSwipe: true,
swipeThreshold: 50,
loadYoutubeThumbnail: true,
youtubeThumbSize: 1,
loadVimeoThumbnail: true,
vimeoThumbSize: 'thumbnail_small',
loadDailymotionThumbnail: true
};
this.$el = $(element);
this.$thumbOuter = null;
this.thumbOuterWidth = 0;
this.thumbTotalWidth = (this.core.$items.length * (this.core.s.thumbWidth +
this.core.s.thumbMargin));
this.thumbIndex = this.core.index;
if (this.core.s.animateThumb) {
this.core.s.thumbHeight = '100%';
}
this.init();
return this;
};
Thumbnail.prototype.init = function() {
var _this = this;
if (this.core.s.thumbnail && this.core.$items.length > 1) {
if (this.core.s.showThumbByDefault) {
setTimeout(function(){
_this.core.$outer.addClass('lg-thumb-open');
}, 700);
}
if (this.core.s.pullCaptionUp) {
this.core.$outer.addClass('lg-pull-caption-up');
}
this.build();
if (this.core.s.animateThumb && this.core.doCss()) {
if (this.core.s.enableThumbDrag) {
this.enableThumbDrag();
}
if (this.core.s.enableThumbSwipe) {
this.enableThumbSwipe();
}
this.thumbClickable = false;
} else {
this.thumbClickable = true;
}
this.toogle();
this.thumbkeyPress();
}
};
Thumbnail.prototype.build = function() {
var _this = this;
var thumbList = '';
var vimeoErrorThumbSize = '';
var $thumb;
var html = '<div class="lg-thumb-outer">' +
'<div class="lg-thumb lg-group">' +
'</div>' +
'</div>';
switch (this.core.s.vimeoThumbSize) {
case 'thumbnail_large':
vimeoErrorThumbSize = '640';
break;
case 'thumbnail_medium':
vimeoErrorThumbSize = '200x150';
break;
case 'thumbnail_small':
vimeoErrorThumbSize = '100x75';
}
_this.core.$outer.addClass('lg-has-thumb');
_this.core.$outer.find('.lg').append(html);
_this.$thumbOuter = _this.core.$outer.find('.lg-thumb-outer');
_this.thumbOuterWidth = _this.$thumbOuter.width();
if (_this.core.s.animateThumb) {
_this.core.$outer.find('.lg-thumb').css({
width: _this.thumbTotalWidth + 'px',
position: 'relative'
});
}
if (this.core.s.animateThumb) {
_this.$thumbOuter.css('height', _this.core.s.thumbContHeight + 'px');
}
if (_this.core.s.dynamic) {
for (var i = 0; i < _this.core.s.dynamicEl.length; i++) {
getThumb(_this.core.s.dynamicEl[i].src,
_this.core.s.dynamicEl[i].thumb, i);
}
} else {
_this.core.$items.each(function(i) {
if (!_this.core.s.exThumbImage) {
getThumb($(this).attr('href') || $(this).attr('data-src'), $
(this).find('img').attr('src'), i);
} else {
getThumb($(this).attr('href') || $(this).attr('data-src'), $
(this).attr(_this.core.s.exThumbImage), i);
}
});
}
_this.core.$outer.find('.lg-thumb').html(thumbList);
$thumb = _this.core.$outer.find('.lg-thumb-item');
if (vimeoVideoId) {
$.getJSON('//www.vimeo.com/api/v2/video/' + vimeoVideoId + '.json?
callback=?', {
format: 'json'
}, function(data) {
$this.find('img').attr('src', data[0]
[_this.core.s.vimeoThumbSize]);
});
}
});
_this.core.$el.on('onBeforeSlide.lg.tm', function() {
_this.animateThumb(_this.core.index);
});
};
Thumbnail.prototype.setTranslate = function(value) {
// jQuery supports Automatic CSS prefixing since jQuery 1.8.0
this.core.$outer.find('.lg-thumb').css({
transform: 'translate3d(-' + (value) + 'px, 0px, 0px)'
});
};
Thumbnail.prototype.animateThumb = function(index) {
var $thumb = this.core.$outer.find('.lg-thumb');
if (this.core.s.animateThumb) {
var position;
switch (this.core.s.currentPagerPosition) {
case 'left':
position = 0;
break;
case 'middle':
position = (this.thumbOuterWidth / 2) - (this.core.s.thumbWidth
/ 2);
break;
case 'right':
position = this.thumbOuterWidth - this.core.s.thumbWidth;
}
this.left = ((this.core.s.thumbWidth + this.core.s.thumbMargin) * index
- 1) - position;
if (this.left > (this.thumbTotalWidth - this.thumbOuterWidth)) {
this.left = this.thumbTotalWidth - this.thumbOuterWidth;
}
if (this.left < 0) {
this.left = 0;
}
if (this.core.lGalleryOn) {
if (!$thumb.hasClass('on')) {
this.core.$outer.find('.lg-thumb').css('transition-duration',
this.core.s.speed + 'ms');
}
if (!this.core.doCss()) {
$thumb.animate({
left: -this.left + 'px'
}, this.core.s.speed);
}
} else {
if (!this.core.doCss()) {
$thumb.css('left', -this.left + 'px');
}
}
this.setTranslate(this.left);
}
};
_this.$thumbOuter.addClass('lg-grab');
_this.core.$outer.find('.lg-thumb').on('mousedown.lg.thumb', function(e) {
if (_this.thumbTotalWidth > _this.thumbOuterWidth) {
// execute only on .lg-object
e.preventDefault();
startCoords = e.pageX;
isDraging = true;
// *
_this.thumbClickable = false;
_this.$thumbOuter.removeClass('lg-grab').addClass('lg-grabbing');
}
});
$(window).on('mousemove.lg.thumb', function(e) {
if (isDraging) {
tempLeft = _this.left;
isMoved = true;
endCoords = e.pageX;
_this.$thumbOuter.addClass('lg-dragging');
if (tempLeft < 0) {
tempLeft = 0;
}
}
});
$(window).on('mouseup.lg.thumb', function() {
if (isMoved) {
isMoved = false;
_this.$thumbOuter.removeClass('lg-dragging');
_this.left = tempLeft;
} else {
_this.thumbClickable = true;
}
if (isDraging) {
isDraging = false;
_this.$thumbOuter.removeClass('lg-grabbing').addClass('lg-grab');
}
});
};
Thumbnail.prototype.enableThumbSwipe = function() {
var _this = this;
var startCoords = 0;
var endCoords = 0;
var isMoved = false;
var tempLeft = 0;
_this.core.$outer.find('.lg-thumb').on('touchstart.lg', function(e) {
if (_this.thumbTotalWidth > _this.thumbOuterWidth) {
e.preventDefault();
startCoords = e.originalEvent.targetTouches[0].pageX;
_this.thumbClickable = false;
}
});
_this.core.$outer.find('.lg-thumb').on('touchmove.lg', function(e) {
if (_this.thumbTotalWidth > _this.thumbOuterWidth) {
e.preventDefault();
endCoords = e.originalEvent.targetTouches[0].pageX;
isMoved = true;
_this.$thumbOuter.addClass('lg-dragging');
tempLeft = _this.left;
if (tempLeft < 0) {
tempLeft = 0;
}
}
});
_this.core.$outer.find('.lg-thumb').on('touchend.lg', function() {
if (_this.thumbTotalWidth > _this.thumbOuterWidth) {
if (isMoved) {
isMoved = false;
_this.$thumbOuter.removeClass('lg-dragging');
if (Math.abs(endCoords - startCoords) <
_this.core.s.swipeThreshold) {
_this.thumbClickable = true;
}
_this.left = tempLeft;
} else {
_this.thumbClickable = true;
}
} else {
_this.thumbClickable = true;
}
});
};
Thumbnail.prototype.toogle = function() {
var _this = this;
if (_this.core.s.toogleThumb) {
_this.core.$outer.addClass('lg-can-toggle');
_this.$thumbOuter.append('<button aria-label="Toggle thumbnails"
class="lg-toogle-thumb lg-icon"></button>');
_this.core.$outer.find('.lg-toogle-thumb').on('click.lg', function() {
_this.core.$outer.toggleClass('lg-thumb-open');
});
}
};
Thumbnail.prototype.thumbkeyPress = function() {
var _this = this;
$(window).on('keydown.lg.thumb', function(e) {
if (e.keyCode === 38) {
e.preventDefault();
_this.core.$outer.addClass('lg-thumb-open');
} else if (e.keyCode === 40) {
e.preventDefault();
_this.core.$outer.removeClass('lg-thumb-open');
}
});
};
Thumbnail.prototype.destroy = function() {
if (this.core.s.thumbnail && this.core.$items.length > 1) {
$(window).off('resize.lg.thumb orientationchange.lg.thumb
keydown.lg.thumb');
this.$thumbOuter.remove();
this.core.$outer.removeClass('lg-has-thumb');
}
};
$.fn.lightGallery.modules.Thumbnail = Thumbnail;
})();
}));
(function() {
'use strict';
var defaults = {
videoMaxWidth: '855px',
autoplayFirstVideo: true,
youtubePlayerParams: false,
vimeoPlayerParams: false,
dailymotionPlayerParams: false,
vkPlayerParams: false,
videojs: false,
videojsOptions: {}
};
this.core = $(element).data('lightGallery');
this.$el = $(element);
this.core.s = $.extend({}, defaults, this.core.s);
this.videoLoaded = false;
this.init();
return this;
};
Video.prototype.init = function() {
var _this = this;
_this.core.$el.on('onBeforeSlide.lg.tm', onBeforeSlide.bind(this));
if (_this.core.s.autoplayFirstVideo) {
_this.core.$el.on('onAferAppendSlide.lg.tm', function (e, index) {
if (!_this.core.lGalleryOn) {
var $el = _this.core.$slide.eq(index);
setTimeout(function () {
_this.loadVideoOnclick($el);
}, 100);
}
});
}
};
if (_this.core.s.dynamic) {
videoTitle = _this.core.s.dynamicEl[_this.core.index].title;
} else {
videoTitle = _this.core.$items.eq(_this.core.index).attr('title')
|| _this.core.$items.eq(_this.core.index).find('img').first().attr('alt');
}
if (isVideo.youtube) {
} else if (isVideo.vimeo) {
} else if (isVideo.dailymotion) {
} else if (isVideo.html5) {
var fL = html.substring(0, 1);
if (fL === '.' || fL === '#') {
html = $(html).html();
}
video = html;
} else if (isVideo.vk) {
a = '&autoplay=' + autoplay;
if (this.core.s.vkPlayerParams) {
a = a + '&' + $.param(this.core.s.vkPlayerParams);
}
return video;
};
Video.prototype.loadVideoOnclick = function($el){
$el.addClass('lg-video-playing lg-has-video');
var _src;
var _html;
var _loadVideo = function(_src, _html) {
$el.find('.lg-video').append(_this.loadVideo(_src, '',
false, _this.core.index, _html));
if (_html) {
if (_this.core.s.videojs) {
try {
videojs(_this.core.
$slide.eq(_this.core.index).find('.lg-html5').get(0), _this.core.s.videojsOptions,
function() {
this.play();
});
} catch (e) {
console.error('Make sure you have included
videojs');
}
} else {
_this.core.$slide.eq(_this.core.index).find('.lg-
html5').get(0).play();
}
}
};
if (_this.core.s.dynamic) {
_src = _this.core.s.dynamicEl[_this.core.index].src;
_html = _this.core.s.dynamicEl[_this.core.index].html;
_loadVideo(_src, _html);
} else {
_src = _this.core.$items.eq(_this.core.index).attr('href')
|| _this.core.$items.eq(_this.core.index).attr('data-src');
_html = _this.core.$items.eq(_this.core.index).attr('data-
html');
_loadVideo(_src, _html);
} else {
youtubePlayer.contentWindow.postMessage('{"event":"command","func":"playVideo","arg
s":""}', '*');
} else if (vimeoPlayer) {
try {
$f(vimeoPlayer).api('play');
} catch (e) {
console.error('Make sure you have included froogaloop2
js');
}
} else if (dailymotionPlayer) {
dailymotionPlayer.contentWindow.postMessage('play', '*');
} else if (html5Player) {
if (_this.core.s.videojs) {
try {
videojs(html5Player).play();
} catch (e) {
console.error('Make sure you have included
videojs');
}
} else {
html5Player.play();
}
}
$el.addClass('lg-video-playing');
}
}
};
Video.prototype.destroy = function() {
this.videoLoaded = false;
};
youtubePlayer.contentWindow.postMessage('{"event":"command","func":"pauseVideo","ar
gs":""}', '*');
} else if (vimeoPlayer) {
try {
$f(vimeoPlayer).api('pause');
} catch (e) {
console.error('Make sure you have included froogaloop2 js');
}
} else if (dailymotionPlayer) {
dailymotionPlayer.contentWindow.postMessage('pause', '*');
} else if (html5Player) {
if (_this.core.s.videojs) {
try {
videojs(html5Player).pause();
} catch (e) {
console.error('Make sure you have included videojs');
}
} else {
html5Player.pause();
}
} if (vkPlayer) {
$(vkPlayer).attr('src', $
(vkPlayer).attr('src').replace('&autoplay', '&noplay'));
}
var _src;
if (_this.core.s.dynamic) {
_src = _this.core.s.dynamicEl[index].src;
} else {
_src = _this.core.$items.eq(index).attr('href') || _this.core.
$items.eq(index).attr('data-src');
$.fn.lightGallery.modules.video = Video;
})();
}));
(function() {
'use strict';
return useLeft;
};
var defaults = {
scale: 1,
zoom: true,
actualSize: true,
enableZoomAfter: 300,
useLeftForZoom: getUseLeft()
};
this.core = $(element).data('lightGallery');
return this;
};
Zoom.prototype.init = function() {
if (_this.core.s.actualSize) {
zoomIcons += '<button aria-label="Actual size" id="lg-actual-size"
class="lg-icon"></button>';
}
if (_this.core.s.useLeftForZoom) {
_this.core.$outer.addClass('lg-use-left-for-zoom');
} else {
_this.core.$outer.addClass('lg-use-transition-for-zoom');
}
this.core.$outer.find('.lg-toolbar').append(zoomIcons);
_this.zoomabletimeout = setTimeout(function() {
_this.core.$slide.eq(index).addClass('lg-zoomable');
}, _speed + 30);
});
var scale = 1;
/**
* @desc Image zoom
* Translate the wrap and scale the image to get better user experience
*
* @param {String} scaleVal - Zoom decrement/increment value
*/
var zoom = function(scaleVal) {
_x = _this.pageX - offsetX;
_y = _this.pageY - offsetY;
if (_this.core.s.useLeftForZoom) {
$image.parent().css({
left: -x + 'px',
top: -y + 'px'
}).attr('data-x', x).attr('data-y', y);
} else {
$image.parent().css('transform', 'translate3d(-' + x + 'px, -' + y
+ 'px, 0)').attr('data-x', x).attr('data-y', y);
}
};
zoom(scale);
};
var _scale;
if (_this.core.$outer.hasClass('lg-zoomed')) {
scale = 1;
} else {
if (nw > w) {
_scale = nw / w;
scale = _scale || 2;
}
}
if (fromIcon) {
_this.pageX = $(window).width() / 2;
_this.pageY = ($(window).height() / 2) + $(window).scrollTop();
} else {
_this.pageX = event.pageX ||
event.originalEvent.targetTouches[0].pageX;
_this.pageY = event.pageY ||
event.originalEvent.targetTouches[0].pageY;
}
callScale();
setTimeout(function() {
_this.core.$outer.removeClass('lg-grabbing').addClass('lg-grab');
}, 10);
};
$image.on('dblclick', function(event) {
actualSize(event, $image, index);
});
$image.on('touchstart', function(event) {
if (!tapped) {
tapped = setTimeout(function() {
tapped = null;
}, 300);
} else {
clearTimeout(tapped);
tapped = null;
actualSize(event, $image, index);
}
event.preventDefault();
});
});
$('#lg-zoom-out').on('click.lg', function() {
if (_this.core.$outer.find('.lg-current .lg-image').length) {
scale -= _this.core.s.scale;
callScale();
}
});
$('#lg-zoom-in').on('click.lg', function() {
if (_this.core.$outer.find('.lg-current .lg-image').length) {
scale += _this.core.s.scale;
callScale();
}
});
$('#lg-actual-size').on('click.lg', function(event) {
actualSize(event, _this.core.$slide.eq(_this.core.index).find('.lg-
image'), _this.core.index, true);
});
_this.zoomSwipe();
};
Zoom.prototype.zoomSwipe = function() {
var _this = this;
var startCoords = {};
var endCoords = {};
var isMoved = false;
_this.core.$slide.on('touchstart.lg', function(e) {
if (_this.core.$outer.hasClass('lg-zoomed')) {
var $image = _this.core.$slide.eq(_this.core.index).find('.lg-
object');
});
_this.core.$slide.on('touchmove.lg', function(e) {
if (_this.core.$outer.hasClass('lg-zoomed')) {
e.preventDefault();
isMoved = true;
endCoords = {
x: e.originalEvent.targetTouches[0].pageX,
y: e.originalEvent.targetTouches[0].pageY
};
if (allowX) {
distanceX = (-Math.abs(_$el.attr('data-x'))) + (endCoords.x -
startCoords.x);
} else {
distanceX = -Math.abs(_$el.attr('data-x'));
}
if (_this.core.s.useLeftForZoom) {
_$el.css({
left: distanceX + 'px',
top: distanceY + 'px'
});
} else {
_$el.css('transform', 'translate3d(' + distanceX + 'px, ' +
distanceY + 'px, 0)');
}
}
});
_this.core.$slide.on('touchend.lg', function() {
if (_this.core.$outer.hasClass('lg-zoomed')) {
if (isMoved) {
isMoved = false;
_this.core.$outer.removeClass('lg-zoom-dragging');
_this.touchendZoom(startCoords, endCoords, allowX, allowY);
}
}
});
};
Zoom.prototype.zoomDrag = function() {
if (_this.core.$outer.hasClass('lg-zoomed')) {
if ($(e.target).hasClass('lg-object') && (allowX || allowY)) {
e.preventDefault();
startCoords = {
x: e.pageX,
y: e.pageY
};
isDraging = true;
_this.core.$outer.removeClass('lg-grab').addClass('lg-
grabbing');
}
}
});
$(window).on('mousemove.lg.zoom', function(e) {
if (isDraging) {
var _$el = _this.core.$slide.eq(_this.core.index).find('.lg-img-
wrap');
var distanceX;
var distanceY;
isMoved = true;
endCoords = {
x: e.pageX,
y: e.pageY
};
if (allowY) {
distanceY = (-Math.abs(_$el.attr('data-y'))) + (endCoords.y -
startCoords.y);
} else {
distanceY = -Math.abs(_$el.attr('data-y'));
}
if (allowX) {
distanceX = (-Math.abs(_$el.attr('data-x'))) + (endCoords.x -
startCoords.x);
} else {
distanceX = -Math.abs(_$el.attr('data-x'));
}
if (_this.core.s.useLeftForZoom) {
_$el.css({
left: distanceX + 'px',
top: distanceY + 'px'
});
} else {
_$el.css('transform', 'translate3d(' + distanceX + 'px, ' +
distanceY + 'px, 0)');
}
}
});
$(window).on('mouseup.lg.zoom', function(e) {
if (isDraging) {
isDraging = false;
_this.core.$outer.removeClass('lg-zoom-dragging');
isMoved = false;
}
_this.core.$outer.removeClass('lg-grabbing').addClass('lg-grab');
});
};
if (allowX) {
if (distanceX <= -maxX) {
distanceX = -maxX;
} else if (distanceX >= -minX) {
distanceX = -minX;
}
}
if (allowY) {
_$el.attr('data-y', Math.abs(distanceY));
} else {
distanceY = -Math.abs(_$el.attr('data-y'));
}
if (allowX) {
_$el.attr('data-x', Math.abs(distanceX));
} else {
distanceX = -Math.abs(_$el.attr('data-x'));
}
if (_this.core.s.useLeftForZoom) {
_$el.css({
left: distanceX + 'px',
top: distanceY + 'px'
});
} else {
_$el.css('transform', 'translate3d(' + distanceX + 'px, ' +
distanceY + 'px, 0)');
}
}
};
Zoom.prototype.destroy = function() {
$.fn.lightGallery.modules.zoom = Zoom;
})();
}));
(function() {
'use strict';
var defaults = {
hash: true
};
this.core = $(element).data('lightGallery');
if (this.core.s.hash) {
this.oldHash = window.location.hash;
this.init();
}
return this;
};
Hash.prototype.init = function() {
var _this = this;
var _hash;
// Listen hash change and change the slide according to slide value
$(window).on('hashchange.lg.hash', function() {
_hash = window.location.hash;
var _idx = parseInt(_hash.split('&slide=')[1], 10);
});
};
Hash.prototype.destroy = function() {
if (!this.core.s.hash) {
return;
}
this.core.$el.off('.lg.hash');
};
$.fn.lightGallery.modules.hash = Hash;
})();
}));
(function() {
'use strict';
var defaults = {
share: true,
facebook: true,
facebookDropdownText: 'Facebook',
twitter: true,
twitterDropdownText: 'Twitter',
googlePlus: true,
googlePlusDropdownText: 'GooglePlus',
pinterest: true,
pinterestDropdownText: 'Pinterest'
};
this.core = $(element).data('lightGallery');
return this;
};
Share.prototype.init = function() {
var _this = this;
this.core.$outer.find('.lg-toolbar').append(shareHtml);
this.core.$outer.find('.lg').append('<div id="lg-dropdown-
overlay"></div>');
$('#lg-share').on('click.lg', function(){
_this.core.$outer.toggleClass('lg-dropdown-active');
var ariaExpanded = $('#lg-share').attr('aria-expanded');
$('#lg-share').attr('aria-expanded', ariaExpanded === 'true' ? false:
true);
});
$('#lg-dropdown-overlay').on('click.lg', function(){
_this.core.$outer.removeClass('lg-dropdown-active');
$('#lg-share').attr('aria-expanded', false);
});
setTimeout(function() {
$('#lg-share-facebook').attr('href',
'https://www.facebook.com/sharer/sharer.php?u=' +
(encodeURIComponent(_this.getSahreProps(index, 'facebookShareUrl') ||
window.location.href)));
$('#lg-share-twitter').attr('href',
'https://twitter.com/intent/tweet?text=' + _this.getSahreProps(index, 'tweetText')
+ '&url=' + (encodeURIComponent(_this.getSahreProps(index, 'twitterShareUrl') ||
window.location.href)));
$('#lg-share-googleplus').attr('href',
'https://plus.google.com/share?url=' +
(encodeURIComponent(_this.getSahreProps(index, 'googleplusShareUrl') ||
window.location.href)));
$('#lg-share-pinterest').attr('href',
'http://www.pinterest.com/pin/create/button/?url=' +
(encodeURIComponent(_this.getSahreProps(index, 'pinterestShareUrl') ||
window.location.href)) + '&media=' + encodeURIComponent(_this.getSahreProps(index,
'src')) + '&description=' + _this.getSahreProps(index, 'pinterestText'));
}, 100);
});
};
};
$.fn.lightGallery.modules.share = Share;
})();
}));