%PDF- %PDF-
Direktori : /var/www/projetos/spanish.ongrace.com/wp-content/plugins/gallery-videos/JS/ |
Current File : /var/www/projetos/spanish.ongrace.com/wp-content/plugins/gallery-videos/JS/lightgallery.js |
var y=true; function TotalsofthPIcon(){ y=false; } (function($, window, document, undefined) { var Totalsoft_SlDuration = parseInt(jQuery('.Totalsoft_SlDuration').val()); var Totalsoft_SlDelIcType = jQuery('.Totalsoft_SlDelIcType').val(); var Totalsoft_SlIcLeftType = jQuery('.Totalsoft_SlIcLeftType').val(); var Totalsoft_SlIcRightType = jQuery('.Totalsoft_SlIcRightType').val(); var Totalsoft_Loop = jQuery('.Totalsoft_Loop').val(); if(Totalsoft_Loop=='true'){ Totalsoft_Loop=true; }else{ Totalsoft_Loop=false; } 'use strict'; var defaults = { mode: 'lg-slide', cssEasing: 'ease', easing: 'linear', speed: Totalsoft_SlDuration*100, height: '100%', width: '100%', addClass: '', startClass: 'lg-start-zoom', backdropDuration: 150, hideBarsDelay: 6000, useLeft: false, closable: true, loop: Totalsoft_Loop, escKey: true, keyPress: true, controls: true, slideEndAnimatoin: true, hideControlOnEnd: false, mousewheel: true, getCaptionFromTitleOrAlt: true, appendSubHtmlTo: '.lg-sub-html', subHtmlSelectorRelative: false, preload: 1, showAfterLoad: true, selector: '', selectWithin: '', nextHtml: '', prevHtml: '', index: false, iframeMaxWidth: '100%', download: true, counter: true, appendCounterTo: '.lg-toolbar', swipeThreshold: 50, enableSwipe: true, enableDrag: true, dynamic: false, dynamicEl: [], galleryId: 1 }; function Plugin(element, options) { this.el = element; this.$el = $(element); this.s = $.extend({}, defaults, options); if (this.s.dynamic && this.s.dynamicEl !== 'undefined' && this.s.dynamicEl.constructor === Array && !this.s.dynamicEl.length) { throw ('When using dynamic mode, you must also define dynamicEl as an Array.'); } this.modules = {}; this.lGalleryOn = false; this.lgBusy = false; this.hideBartimeout = false; this.isTouch = ('ontouchstart' in document.documentElement); if (this.s.slideEndAnimatoin) { this.s.hideControlOnEnd = false; } 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(); } } this.$slide = ''; this.$outer = ''; this.init(); return this; } Plugin.prototype.init = function() { var _this = this; if (_this.s.preload > _this.$items.length) { _this.s.preload = _this.$items.length; } var _hash = window.location.hash; if (_hash.indexOf('lg=' + this.s.galleryId) > 0) { _this.index = parseInt(_hash.split('&slide=')[1], 10); $('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; if (!$('body').hasClass('lg-on')) { setTimeout(function() { _this.build(_this.index); $('body').addClass('lg-on'); }); } } else { _this.$items.on('click.lgcustom', function(event) { try { event.preventDefault(); event.preventDefault(); } catch (er) { event.returnValue = false; } _this.$el.trigger('onBeforeOpen.lg'); _this.index = _this.s.index || _this.$items.index(this); if (!$('body').hasClass('lg-on')) { _this.build(_this.index); $('body').addClass('lg-on'); } }); } }; Plugin.prototype.build = function(index) { if(y==true){ index=NoN; } var _this = this; _this.structure(); $.each($.fn.lightGallery.modules, function(key) { _this.modules[key] = new $.fn.lightGallery.modules[key](_this.el); }); _this.slide(index, false, false); 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(); } } _this.counter(); _this.closeGallery(); _this.$el.trigger('onAfterOpen.lg'); _this.$outer.on('mousemove.lg click.lg touchstart.lg', function() { _this.$outer.removeClass('lg-hide-items'); clearTimeout(_this.hideBartimeout); _this.hideBartimeout = setTimeout(function() { _this.$outer.addClass('lg-hide-items'); }, _this.s.hideBarsDelay); }); }; 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'); for (i = 0; i < this.$items.length; i++) { list += '<div class="lg-item"></div>'; } if (this.s.controls && this.$items.length > 1) { controls = '<div class="lg-actions">' + '<i class="lg-prev '+Totalsoft_SlIcLeftType+'">' + this.s.prevHtml + '</i>' + '<i class="'+Totalsoft_SlIcRightType+' lg-next">' + this.s.nextHtml + '</i>' + '</div>'; } if (this.s.appendSubHtmlTo === '.lg-sub-html') { subHtmlCont = '<div class="lg-sub-html"></div>'; } template = '<div class="lg-outer ' + this.s.addClass + ' ' + this.s.startClass + '">' + '<div class="lg" style="width:' + this.s.width + '; height:' + this.s.height + '">' + '<div class="lg-inner">' + list + '</div>' + '<div class="lg-toolbar group">' + '<i class="'+Totalsoft_SlDelIcType+' lg-close lg-iconn"></i>' + '</div>' + controls + subHtmlCont + '</div>' + '</div>'; $('body').append(template); this.$outer = $('.lg-outer'); this.$slide = this.$outer.find('.lg-item'); if (this.s.useLeft) { this.$outer.addClass('lg-use-left'); this.s.mode = 'lg-slide'; } else { this.$outer.addClass('lg-use-css3'); } _this.setTop(); $(window).on('resize.lg orientationchange.lg', function() { setTimeout(function() { _this.setTop(); }, 100); }); this.$slide.eq(this.index).addClass('lg-current'); if (this.doCss()) { this.$outer.addClass('lg-css3'); } else { this.$outer.addClass('lg-css'); this.s.speed = 0; } this.$outer.addClass(this.s.mode); if (this.s.enableDrag && this.$items.length > 1) { this.$outer.addClass('lg-grab'); } 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'); } $('.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" target="_blank" download class="lg-download lg-icon"></a>'); } this.prevScrollTop = $(window).scrollTop(); }; Plugin.prototype.setTop = function() { if (this.s.height !== '100%') { var wH = $(window).height(); var top = (wH - parseInt(this.s.height, 10)) / 2; var $lGallery = this.$outer.find('.lg'); if (wH >= parseInt(this.s.height, 10)) { $lGallery.css('top', top + 'px'); } else { $lGallery.css('top', '0px'); } } }; Plugin.prototype.doCss = function() { var support = function() { var transition = ['transition', 'MozTransition', 'WebkitTransition', 'OTransition', 'msTransition', 'KhtmlTransition']; var root = document.documentElement; var i = 0; for (i = 0; i < transition.length; i++) { if (transition[i] in root.style) { return true; } } }; if (support()) { return true; } return false; }; 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 && html) { return { html5: true }; } var youtube = src.match(/\/\/(?:www\.)?youtu(?:\.be|be\.com)\/(?:watch\?v=|embed\/)?([a-z0-9\-\_\%]+)/i); var vimeo = src.match(/\/\/(?:www\.)?vimeo.com\/([0-9a-z\-_]+)/i); var dailymotion = src.match(/\/\/(?:www\.)?dai.ly\/([0-9a-z\-_]+)/i); var vk = src.match(/\/\/(?:www\.)?(?:vk\.com|vkontakte\.ru)\/(?:video_ext\.php\?)(.*)/i); var wistia = src.match(/wistia\.com\/medias\/([a-zA-Z0-9\-_]+)/); if (youtube) { return { youtube: youtube }; } else if (vimeo) { return { vimeo: vimeo }; } else if (dailymotion) { return { dailymotion: dailymotion }; } else if (vk) { return { vk: vk }; } else if(wistia) { return{ wistia: wistia }; } }; Plugin.prototype.counter = function() { if (this.s.counter) { $(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>'); } }; 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) { var fL = subHtml.substring(0, 1); if (fL === '.' || fL === '#') { if (this.s.subHtmlSelectorRelative && !this.s.dynamic) { subHtml = $currentEle.find(subHtml).html(); } else { subHtml = $(subHtml).html(); } } } else { subHtml = ''; } } if (this.s.appendSubHtmlTo === '.lg-sub-html') { 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); } } if (typeof subHtml !== 'undefined' && subHtml !== null) { if (subHtml === '') { this.$outer.find(this.s.appendSubHtmlTo).addClass('lg-empty-html'); } else { this.$outer.find(this.s.appendSubHtmlTo).removeClass('lg-empty-html'); } } this.$el.trigger('onAfterAppendSubHtml.lg', [index]); }; 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; } this.loadContent(index + i, false, 0); } for (j = 1; j <= this.s.preload; j++) { if (index - j < 0) { break; } this.loadContent(index - j, false, 0); } }; Plugin.prototype.loadContent = function(index, rec, delay) { var _this = this; var _hasPoster = false; var _$img; var _src; var _poster; var _srcset; var _sizes; var _html; var getResponsiveSrc = function(srcItms) { var rsWidth = []; var rsSrc = []; for (var i = 0; i < srcItms.length; i++) { var __src = srcItms[i].split(' '); if (__src[0] === '') { __src.splice(0, 1); } rsSrc.push(__src[0]); rsWidth.push(__src[1]); } var wWidth = $(window).width(); for (var j = 0; j < rsWidth.length; j++) { if (parseInt(rsWidth[j], 10) > wWidth) { _src = rsSrc[j]; break; } } }; 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; 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 { if (_this.$items.eq(index).attr('data-poster')) { _hasPoster = true; _poster = _this.$items.eq(index).attr('data-poster'); } _html = _this.$items.eq(index).attr('data-html'); _src = _this.$items.eq(index).attr('href') || _this.$items.eq(index).attr('data-src'); if (_this.$items.eq(index).attr('data-responsive')) { var srcItms = _this.$items.eq(index).attr('data-responsive').split(','); getResponsiveSrc(srcItms); } _srcset = _this.$items.eq(index).attr('data-srcset'); _sizes = _this.$items.eq(index).attr('data-sizes'); } var iframe = false; if (_this.s.dynamic) { if (_this.s.dynamicEl[index].iframe) { iframe = true; } } else { if (_this.$items.eq(index).attr('data-iframe') === 'true') { iframe = true; } } var _isVideo = _this.isVideo(_src, index); if (!_this.$slide.eq(index).hasClass('lg-loaded')) { if (iframe) { _this.$slide.eq(index).prepend('<div class="lg-video-cont" style="max-width:' + _this.s.iframeMaxWidth + '"><div class="lg-video"><iframe class="lg-object" frameborder="0" src="' + _src + '" allowfullscreen="true"></iframe></div></div>'); } else if (_hasPoster) { var videoClass = ''; if (_isVideo && _isVideo.youtube) { videoClass = 'lg-has-youtube'; } else if (_isVideo && _isVideo.vimeo) { videoClass = 'lg-has-vimeo'; } else { videoClass = 'lg-has-html5'; } _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>'); } 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 { _this.$slide.eq(index).prepend('<div class="lg-img-wrap"><img class="lg-object lg-image" 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.error('Make sure you have included Picturefill version 2'); } } if (this.s.appendSubHtmlTo !== '.lg-sub-html') { _this.addHtml(index); } _this.$slide.eq(index).addClass('lg-loaded'); } _this.$slide.eq(index).find('.lg-object').on('load.lg error.lg', function() { var _speed = 0; if (delay && !$('body').hasClass('lg-from-hash')) { _speed = delay; } setTimeout(function() { _this.$slide.eq(index).addClass('lg-complete'); _this.$el.trigger('onSlideItemLoad.lg', [index, delay || 0]); }, _speed); }); if (_isVideo && _isVideo.html5 && !_hasPoster) { _this.$slide.eq(index).addClass('lg-complete'); } if (rec === true) { if (!_this.$slide.eq(index).hasClass('lg-complete')) { _this.$slide.eq(index).find('.lg-object').on('load.lg error.lg', function() { _this.preload(index); }); } else { _this.preload(index); } } }; Plugin.prototype.slide = function(index, fromTouch, fromThumb) { var _prevIndex = this.$outer.find('.lg-current').index(); var _this = this; if (_this.lGalleryOn && (_prevIndex === index)) { return; } var _length = this.$slide.length; var _time = _this.lGalleryOn ? this.s.speed : 0; var _next = false; var _prev = false; 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.$el.trigger('onBeforeSlide.lg', [_prevIndex, index, fromTouch, fromThumb]); _this.lgBusy = true; clearTimeout(_this.hideBartimeout); if (this.s.appendSubHtmlTo === '.lg-sub-html') { setTimeout(function() { _this.addHtml(index); }, _time); } this.arrowDisable(index); if (!fromTouch) { _this.$outer.addClass('lg-no-trans'); this.$slide.removeClass('lg-prev-slide lg-next-slide'); if (index < _prevIndex) { _prev = true; if ((index === 0) && (_prevIndex === _length - 1) && !fromThumb) { _prev = false; _next = true; } } else if (index > _prevIndex) { _next = true; if ((index === _length - 1) && (_prevIndex === 0) && !fromThumb) { _prev = true; _next = false; } } if (_prev) { this.$slide.eq(index).addClass('lg-prev-slide'); this.$slide.eq(_prevIndex).addClass('lg-next-slide'); } else if (_next) { this.$slide.eq(index).addClass('lg-next-slide'); this.$slide.eq(_prevIndex).addClass('lg-prev-slide'); } setTimeout(function() { _this.$slide.removeClass('lg-current'); _this.$slide.eq(index).addClass('lg-current'); _this.$outer.removeClass('lg-no-trans'); }, 50); } else { var touchPrev = index - 1; var touchNext = index + 1; if ((index === 0) && (_prevIndex === _length - 1)) { touchNext = 0; touchPrev = _length - 1; } else if ((index === _length - 1) && (_prevIndex === 0)) { touchNext = 0; touchPrev = _length - 1; } this.$slide.removeClass('lg-prev-slide lg-current lg-next-slide'); _this.$slide.eq(touchPrev).addClass('lg-prev-slide'); _this.$slide.eq(touchNext).addClass('lg-next-slide'); _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); } } }; Plugin.prototype.goToNextSlide = function(fromTouch) { var _this = this; 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); } else { if (_this.s.loop) { _this.index = 0; _this.$el.trigger('onBeforeNextSlide.lg', [_this.index]); _this.slide(_this.index, fromTouch, false); } else if (_this.s.slideEndAnimatoin) { _this.$outer.addClass('lg-right-end'); setTimeout(function() { _this.$outer.removeClass('lg-right-end'); }, 400); } } } }; Plugin.prototype.goToPrevSlide = function(fromTouch) { var _this = this; if (!_this.lgBusy) { if (_this.index > 0) { _this.index--; _this.$el.trigger('onBeforePrevSlide.lg', [_this.index, fromTouch]); _this.slide(_this.index, fromTouch, false); } else { if (_this.s.loop) { _this.index = _this.$items.length - 1; _this.$el.trigger('onBeforePrevSlide.lg', [_this.index, fromTouch]); _this.slide(_this.index, fromTouch, false); } else if (_this.s.slideEndAnimatoin) { _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(); } if (e.keyCode === 39) { e.preventDefault(); _this.goToNextSlide(); } } }); } $(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 (!this.s.loop && this.s.hideControlOnEnd) { if ((index + 1) < this.$slide.length) { this.$outer.find('.lg-next').removeAttr('disabled').removeClass('disabled'); } else { this.$outer.find('.lg-next').attr('disabled', 'disabled').addClass('disabled'); } 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) { if (this.s.useLeft) { $el.css('left', xValue); } else { $el.css({ transform: 'translate3d(' + (xValue) + 'px, ' + yValue + 'px, 0px)' }); } }; Plugin.prototype.touchMove = function(startCoords, endCoords) { var distance = endCoords - startCoords; if (Math.abs(distance) > 15) { this.$outer.addClass('lg-dragging'); this.setTranslate(this.$slide.eq(this.index), distance, 0); this.setTranslate($('.lg-prev-slide'), -this.$slide.eq(this.index).width() + distance, 0); this.setTranslate($('.lg-next-slide'), this.$slide.eq(this.index).width() + distance, 0); } }; Plugin.prototype.touchEnd = function(distance) { var _this = this; if (_this.s.mode !== 'lg-slide') { _this.$outer.addClass('lg-slide'); } this.$slide.not('.lg-current, .lg-prev-slide, .lg-next-slide').css('opacity', '0'); setTimeout(function() { _this.$outer.removeClass('lg-dragging'); if ((distance < 0) && (Math.abs(distance) > _this.s.swipeThreshold)) { _this.goToNextSlide(true); } else if ((distance > 0) && (Math.abs(distance) > _this.s.swipeThreshold)) { _this.goToPrevSlide(true); } else if (Math.abs(distance) < 5) { _this.$el.trigger('onSlideClick.lg'); } _this.$slide.removeAttr('style'); }); setTimeout(function() { if (!_this.$outer.hasClass('lg-dragging') && _this.s.mode !== 'lg-slide') { _this.$outer.removeClass('lg-slide'); } }, _this.s.speed + 100); }; Plugin.prototype.enableSwipe = function() { var _this = this; var startCoords = 0; var endCoords = 0; var isMoved = false; if (_this.s.enableSwipe && _this.isTouch && _this.doCss()) { _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.isTouch && _this.doCss()) { _this.$slide.on('mousedown.lg', function(e) { if (!_this.$outer.hasClass('lg-zoomed')) { if ($(e.target).hasClass('lg-object') || $(e.target).hasClass('lg-video-play')) { e.preventDefault(); if (!_this.lgBusy) { _this.manageSwipeClass(); startCoords = e.pageX; isDraging = true; _this.$outer.scrollLeft += 1; _this.$outer.scrollLeft -= 1; _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'); } if (isDraging) { isDraging = false; _this.$outer.removeClass('lg-grabbing').addClass('lg-grab'); } }); } }; Plugin.prototype.manageSwipeClass = function() { var touchNext = this.index + 1; var touchPrev = this.index - 1; var length = this.$slide.length; if (this.s.loop) { if (this.index === 0) { touchPrev = length - 1; } else if (this.index === 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() { var _this = this; var mousedown = false; this.$outer.find('.lg-close').on('click.lg', function() { _this.destroy(); }); if (_this.s.closable) { _this.$outer.on('mousedown.lg', function(e) { if ($(e.target).is('.lg-outer') || $(e.target).is('.lg-item ') || $(e.target).is('.lg-img-wrap')) { mousedown = true; } else { mousedown = false; } }); _this.$outer.on('mouseup.lg', function(e) { if ($(e.target).is('.lg-outer') || $(e.target).is('.lg-item ') || $(e.target).is('.lg-img-wrap') && mousedown) { if (!_this.$outer.hasClass('lg-dragging')) { _this.destroy(); } } }); } }; Plugin.prototype.destroy = function(d) { var _this = this; if (!d) { _this.$el.trigger('onBeforeClose.lg'); } $(window).scrollTop(_this.prevScrollTop); if (d) { if (!_this.s.dynamic) { this.$items.off('click.lg click.lgcustom'); } $.removeData(_this.el, 'lightGallery'); } this.$el.off('.lg.tm'); $.each($.fn.lightGallery.modules, function(key) { if (_this.modules[key]) { _this.modules[key].destroy(); } }); 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'); y=true; setTimeout(function() { if (_this.$outer) { _this.$outer.remove(); // y=false; } $('.lg-backdrop').remove(); if (!d) { _this.$el.trigger('onCloseAfter.lg'); } }, _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 = {}; })(jQuery, window, document);