From 46290225ee883bf444211000eb5fb6a1699db752 Mon Sep 17 00:00:00 2001 From: Michael Winter Date: Thu, 13 Feb 2020 15:56:03 -0600 Subject: [PATCH] adding new lightgallery modules --- public/lightgallery/js/lg-autoplay.js | 206 ++++++++ public/lightgallery/js/lg-autoplay.min.js | 4 + public/lightgallery/js/lg-fullscreen.js | 116 +++++ public/lightgallery/js/lg-fullscreen.min.js | 4 + public/lightgallery/js/lg-hash.js | 101 ++++ public/lightgallery/js/lg-hash.min.js | 4 + public/lightgallery/js/lg-pager.js | 105 ++++ public/lightgallery/js/lg-pager.min.js | 4 + public/lightgallery/js/lg-share.js | 107 ++++ public/lightgallery/js/lg-share.min.js | 4 + public/lightgallery/js/lg-thumbnail.js | 478 ++++++++++++++++++ public/lightgallery/js/lg-thumbnail.min.js | 4 + public/lightgallery/js/lg-video.js | 342 +++++++++++++ public/lightgallery/js/lg-video.min.js | 4 + public/lightgallery/js/lg-zoom.js | 527 ++++++++++++++++++++ public/lightgallery/js/lg-zoom.min.js | 4 + 16 files changed, 2014 insertions(+) create mode 100644 public/lightgallery/js/lg-autoplay.js create mode 100644 public/lightgallery/js/lg-autoplay.min.js create mode 100644 public/lightgallery/js/lg-fullscreen.js create mode 100644 public/lightgallery/js/lg-fullscreen.min.js create mode 100644 public/lightgallery/js/lg-hash.js create mode 100644 public/lightgallery/js/lg-hash.min.js create mode 100644 public/lightgallery/js/lg-pager.js create mode 100644 public/lightgallery/js/lg-pager.min.js create mode 100644 public/lightgallery/js/lg-share.js create mode 100644 public/lightgallery/js/lg-share.min.js create mode 100644 public/lightgallery/js/lg-thumbnail.js create mode 100644 public/lightgallery/js/lg-thumbnail.min.js create mode 100644 public/lightgallery/js/lg-video.js create mode 100644 public/lightgallery/js/lg-video.min.js create mode 100644 public/lightgallery/js/lg-zoom.js create mode 100644 public/lightgallery/js/lg-zoom.min.js diff --git a/public/lightgallery/js/lg-autoplay.js b/public/lightgallery/js/lg-autoplay.js new file mode 100644 index 0000000..d1e4683 --- /dev/null +++ b/public/lightgallery/js/lg-autoplay.js @@ -0,0 +1,206 @@ +/*! lg-autoplay - v1.0.4 - 2017-03-28 +* http://sachinchoolur.github.io/lightGallery +* Copyright (c) 2017 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 exports === 'object') { + // 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(jQuery); + } +}(this, function ($) { + + +(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); + + // Execute only if items are above 1 + if (this.core.$items.length < 2) { + return false; + } + + this.core.s = $.extend({}, defaults, this.core.s); + this.interval = false; + + // Identify if slide happened from autoplay + this.fromAuto = true; + + // Identify if autoplay canceled from touch/drag + this.canceledOnTouch = false; + + // save fourceautoplay value + this.fourceAutoplayTemp = this.core.s.fourceAutoplay; + + // 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; + + // append autoplay controls + if (_this.core.s.autoplayControls) { + _this.controls(); + } + + // Create progress bar + if (_this.core.s.progressBar) { + _this.core.$outer.find('.lg').append('
'); + } + + // set progress + _this.progress(); + + // Start autoplay + if (_this.core.s.autoplay) { + _this.$el.one('onSlideItemLoad.lg.tm', function() { + _this.startlAuto(); + }); + } + + // cancel interval on touchstart and dragstart + _this.$el.on('onDragstart.lg.tm touchstart.lg.tm', function() { + if (_this.interval) { + _this.cancelAuto(); + _this.canceledOnTouch = true; + } + }); + + // restore autoplay if autoplay canceled from touchstart / dragstart + _this.$el.on('onDragend.lg.tm touchend.lg.tm onSlideClick.lg.tm', function() { + if (!_this.interval && _this.canceledOnTouch) { + _this.startlAuto(); + _this.canceledOnTouch = false; + } + }); + + }; + + Autoplay.prototype.progress = function() { + + var _this = this; + var _$progressBar; + var _$progress; + + _this.$el.on('onBeforeSlide.lg.tm', function() { + + // start progress bar animation + if (_this.core.s.progressBar && _this.fromAuto) { + _$progressBar = _this.core.$outer.find('.lg-progress-bar'); + _$progress = _this.core.$outer.find('.lg-progress'); + if (_this.interval) { + _$progress.removeAttr('style'); + _$progressBar.removeClass('lg-start'); + setTimeout(function() { + _$progress.css('transition', 'width ' + (_this.core.s.speed + _this.core.s.pause) + 'ms ease 0s'); + _$progressBar.addClass('lg-start'); + }, 20); + } + } + + // Remove setinterval if slide is triggered manually and fourceautoplay is false + if (!_this.fromAuto && !_this.core.s.fourceAutoplay) { + _this.cancelAuto(); + } + + _this.fromAuto = false; + + }); + }; + + // Manage autoplay via play/stop buttons + Autoplay.prototype.controls = function() { + var _this = this; + var _html = ''; + + // Append autoplay controls + $(this.core.s.appendAutoplayControlsTo).append(_html); + + _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.core.$outer.find('.lg-progress').css('transition', 'width ' + (_this.core.s.speed + _this.core.s.pause) + 'ms ease 0s'); + _this.core.$outer.addClass('lg-show-autoplay'); + _this.core.$outer.find('.lg-progress-bar').addClass('lg-start'); + + _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; + +})(); + + +})); diff --git a/public/lightgallery/js/lg-autoplay.min.js b/public/lightgallery/js/lg-autoplay.min.js new file mode 100644 index 0000000..d8637d1 --- /dev/null +++ b/public/lightgallery/js/lg-autoplay.min.js @@ -0,0 +1,4 @@ +/*! lg-autoplay - v1.0.4 - 2017-03-28 +* http://sachinchoolur.github.io/lightGallery +* Copyright (c) 2017 Sachin N; Licensed GPLv3 */ +!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={autoplay:!1,pause:5e3,progressBar:!0,fourceAutoplay:!1,autoplayControls:!0,appendAutoplayControlsTo:".lg-toolbar"},c=function(c){return this.core=a(c).data("lightGallery"),this.$el=a(c),!(this.core.$items.length<2)&&(this.core.s=a.extend({},b,this.core.s),this.interval=!1,this.fromAuto=!0,this.canceledOnTouch=!1,this.fourceAutoplayTemp=this.core.s.fourceAutoplay,this.core.doCss()||(this.core.s.progressBar=!1),this.init(),this)};c.prototype.init=function(){var a=this;a.core.s.autoplayControls&&a.controls(),a.core.s.progressBar&&a.core.$outer.find(".lg").append('
'),a.progress(),a.core.s.autoplay&&a.$el.one("onSlideItemLoad.lg.tm",function(){a.startlAuto()}),a.$el.on("onDragstart.lg.tm touchstart.lg.tm",function(){a.interval&&(a.cancelAuto(),a.canceledOnTouch=!0)}),a.$el.on("onDragend.lg.tm touchend.lg.tm onSlideClick.lg.tm",function(){!a.interval&&a.canceledOnTouch&&(a.startlAuto(),a.canceledOnTouch=!1)})},c.prototype.progress=function(){var a,b,c=this;c.$el.on("onBeforeSlide.lg.tm",function(){c.core.s.progressBar&&c.fromAuto&&(a=c.core.$outer.find(".lg-progress-bar"),b=c.core.$outer.find(".lg-progress"),c.interval&&(b.removeAttr("style"),a.removeClass("lg-start"),setTimeout(function(){b.css("transition","width "+(c.core.s.speed+c.core.s.pause)+"ms ease 0s"),a.addClass("lg-start")},20))),c.fromAuto||c.core.s.fourceAutoplay||c.cancelAuto(),c.fromAuto=!1})},c.prototype.controls=function(){var b=this,c='';a(this.core.s.appendAutoplayControlsTo).append(c),b.core.$outer.find(".lg-autoplay-button").on("click.lg",function(){a(b.core.$outer).hasClass("lg-show-autoplay")?(b.cancelAuto(),b.core.s.fourceAutoplay=!1):b.interval||(b.startlAuto(),b.core.s.fourceAutoplay=b.fourceAutoplayTemp)})},c.prototype.startlAuto=function(){var a=this;a.core.$outer.find(".lg-progress").css("transition","width "+(a.core.s.speed+a.core.s.pause)+"ms ease 0s"),a.core.$outer.addClass("lg-show-autoplay"),a.core.$outer.find(".lg-progress-bar").addClass("lg-start"),a.interval=setInterval(function(){a.core.index+1-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}()}); \ No newline at end of file diff --git a/public/lightgallery/js/lg-pager.js b/public/lightgallery/js/lg-pager.js new file mode 100644 index 0000000..8097e82 --- /dev/null +++ b/public/lightgallery/js/lg-pager.js @@ -0,0 +1,105 @@ +/*! lg-pager - v1.0.2 - 2017-01-22 +* http://sachinchoolur.github.io/lightGallery +* Copyright (c) 2017 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 exports === 'object') { + // 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(jQuery); + } +}(this, function ($) { + +(function() { + + 'use strict'; + + var defaults = { + pager: false + }; + + var Pager = function(element) { + + 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('
'); + + if (_this.core.s.dynamic) { + for (var i = 0; i < _this.core.s.dynamicEl.length; i++) { + pagerList += '
'; + } + } else { + _this.core.$items.each(function() { + + if (!_this.core.s.exThumbImage) { + pagerList += '
'; + } else { + pagerList += '
'; + } + + }); + } + + $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'); + }); + }); + + _this.core.$el.on('onBeforeSlide.lg.tm', function(e, prevIndex, index) { + $pagerCont.removeClass('lg-pager-active'); + $pagerCont.eq(index).addClass('lg-pager-active'); + }); + + }; + + Pager.prototype.destroy = function() { + + }; + + $.fn.lightGallery.modules.pager = Pager; + +})(); + + +})); diff --git a/public/lightgallery/js/lg-pager.min.js b/public/lightgallery/js/lg-pager.min.js new file mode 100644 index 0000000..883e355 --- /dev/null +++ b/public/lightgallery/js/lg-pager.min.js @@ -0,0 +1,4 @@ +/*! lg-pager - v1.0.2 - 2017-01-22 +* http://sachinchoolur.github.io/lightGallery +* Copyright (c) 2017 Sachin N; Licensed GPLv3 */ +!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={pager:!1},c=function(c){return this.core=a(c).data("lightGallery"),this.$el=a(c),this.core.s=a.extend({},b,this.core.s),this.core.s.pager&&this.core.$items.length>1&&this.init(),this};c.prototype.init=function(){var b,c,d,e=this,f="";if(e.core.$outer.find(".lg").append('
'),e.core.s.dynamic)for(var g=0;g
';else e.core.$items.each(function(){f+=e.core.s.exThumbImage?'
':'
'});c=e.core.$outer.find(".lg-pager-outer"),c.html(f),b=e.core.$outer.find(".lg-pager-cont"),b.on("click.lg touchend.lg",function(){var b=a(this);e.core.index=b.index(),e.core.slide(e.core.index,!1,!0,!1)}),c.on("mouseover.lg",function(){clearTimeout(d),c.addClass("lg-pager-hover")}),c.on("mouseout.lg",function(){d=setTimeout(function(){c.removeClass("lg-pager-hover")})}),e.core.$el.on("onBeforeSlide.lg.tm",function(a,c,d){b.removeClass("lg-pager-active"),b.eq(d).addClass("lg-pager-active")})},c.prototype.destroy=function(){},a.fn.lightGallery.modules.pager=c}()}); \ No newline at end of file diff --git a/public/lightgallery/js/lg-share.js b/public/lightgallery/js/lg-share.js new file mode 100644 index 0000000..f5c7fe4 --- /dev/null +++ b/public/lightgallery/js/lg-share.js @@ -0,0 +1,107 @@ +/*! lg-share - v1.1.0 - 2017-10-03 +* http://sachinchoolur.github.io/lightGallery +* Copyright (c) 2017 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 exports === 'object') { + // 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(jQuery); + } +}(this, function ($) { + +(function() { + + 'use strict'; + + var defaults = { + share: true, + facebook: true, + facebookDropdownText: 'Facebook', + twitter: true, + twitterDropdownText: 'Twitter', + googlePlus: true, + googlePlusDropdownText: 'GooglePlus', + pinterest: true, + pinterestDropdownText: 'Pinterest' + }; + + var Share = function(element) { + + this.core = $(element).data('lightGallery'); + + this.core.s = $.extend({}, defaults, this.core.s); + if (this.core.s.share) { + this.init(); + } + + return this; + }; + + Share.prototype.init = function() { + var _this = this; + var shareHtml = '' + + ''; + + this.core.$outer.find('.lg-toolbar').append(shareHtml); + this.core.$outer.find('.lg').append('
'); + $('#lg-share').on('click.lg', function(){ + _this.core.$outer.toggleClass('lg-dropdown-active'); + }); + + $('#lg-dropdown-overlay').on('click.lg', function(){ + _this.core.$outer.removeClass('lg-dropdown-active'); + }); + + _this.core.$el.on('onAfterSlide.lg.tm', function(event, prevIndex, index) { + + 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); + }); + }; + + Share.prototype.getSahreProps = function(index, prop){ + var shareProp = ''; + if(this.core.s.dynamic) { + shareProp = this.core.s.dynamicEl[index][prop]; + } else { + var _href = this.core.$items.eq(index).attr('href'); + var _prop = this.core.$items.eq(index).data(prop); + shareProp = prop === 'src' ? _href || _prop : _prop; + } + return shareProp; + }; + + Share.prototype.destroy = function() { + + }; + + $.fn.lightGallery.modules.share = Share; + +})(); + + + +})); diff --git a/public/lightgallery/js/lg-share.min.js b/public/lightgallery/js/lg-share.min.js new file mode 100644 index 0000000..86a1121 --- /dev/null +++ b/public/lightgallery/js/lg-share.min.js @@ -0,0 +1,4 @@ +/*! lg-share - v1.1.0 - 2017-10-03 +* http://sachinchoolur.github.io/lightGallery +* Copyright (c) 2017 Sachin N; Licensed GPLv3 */ +!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={share:!0,facebook:!0,facebookDropdownText:"Facebook",twitter:!0,twitterDropdownText:"Twitter",googlePlus:!0,googlePlusDropdownText:"GooglePlus",pinterest:!0,pinterestDropdownText:"Pinterest"},c=function(c){return this.core=a(c).data("lightGallery"),this.core.s=a.extend({},b,this.core.s),this.core.s.share&&this.init(),this};c.prototype.init=function(){var b=this,c='",this.core.$outer.find(".lg-toolbar").append(c),this.core.$outer.find(".lg").append('
'),a("#lg-share").on("click.lg",function(){b.core.$outer.toggleClass("lg-dropdown-active")}),a("#lg-dropdown-overlay").on("click.lg",function(){b.core.$outer.removeClass("lg-dropdown-active")}),b.core.$el.on("onAfterSlide.lg.tm",function(c,d,e){setTimeout(function(){a("#lg-share-facebook").attr("href","https://www.facebook.com/sharer/sharer.php?u="+encodeURIComponent(b.getSahreProps(e,"facebookShareUrl")||window.location.href)),a("#lg-share-twitter").attr("href","https://twitter.com/intent/tweet?text="+b.getSahreProps(e,"tweetText")+"&url="+encodeURIComponent(b.getSahreProps(e,"twitterShareUrl")||window.location.href)),a("#lg-share-googleplus").attr("href","https://plus.google.com/share?url="+encodeURIComponent(b.getSahreProps(e,"googleplusShareUrl")||window.location.href)),a("#lg-share-pinterest").attr("href","http://www.pinterest.com/pin/create/button/?url="+encodeURIComponent(b.getSahreProps(e,"pinterestShareUrl")||window.location.href)+"&media="+encodeURIComponent(b.getSahreProps(e,"src"))+"&description="+b.getSahreProps(e,"pinterestText"))},100)})},c.prototype.getSahreProps=function(a,b){var c="";if(this.core.s.dynamic)c=this.core.s.dynamicEl[a][b];else{var d=this.core.$items.eq(a).attr("href"),e=this.core.$items.eq(a).data(b);c="src"===b?d||e:e}return c},c.prototype.destroy=function(){},a.fn.lightGallery.modules.share=c}()}); \ No newline at end of file diff --git a/public/lightgallery/js/lg-thumbnail.js b/public/lightgallery/js/lg-thumbnail.js new file mode 100644 index 0000000..05be5ba --- /dev/null +++ b/public/lightgallery/js/lg-thumbnail.js @@ -0,0 +1,478 @@ +/*! lg-thumbnail - v1.1.0 - 2017-08-08 +* http://sachinchoolur.github.io/lightGallery +* Copyright (c) 2017 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 exports === 'object') { + // 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(jQuery); + } +}(this, function ($) { + +(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 + }; + + var Thumbnail = function(element) { + + // get lightGallery core plugin data + this.core = $(element).data('lightGallery'); + + // extend module default settings with lightGallery core settings + this.core.s = $.extend({}, defaults, this.core.s); + + 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%'; + } + + // Thumbnail animation value + this.left = 0; + + 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 = '
' + + '
' + + '
' + + '
'; + + 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'); + } + + function getThumb(src, thumb, index) { + var isVideo = _this.core.isVideo(src, index) || {}; + var thumbImg; + var vimeoId = ''; + + if (isVideo.youtube || isVideo.vimeo || isVideo.dailymotion) { + if (isVideo.youtube) { + if (_this.core.s.loadYoutubeThumbnail) { + thumbImg = '//img.youtube.com/vi/' + isVideo.youtube[1] + '/' + _this.core.s.youtubeThumbSize + '.jpg'; + } else { + thumbImg = thumb; + } + } else if (isVideo.vimeo) { + if (_this.core.s.loadVimeoThumbnail) { + thumbImg = '//i.vimeocdn.com/video/error_' + vimeoErrorThumbSize + '.jpg'; + vimeoId = isVideo.vimeo[1]; + } else { + thumbImg = thumb; + } + } else if (isVideo.dailymotion) { + if (_this.core.s.loadDailymotionThumbnail) { + thumbImg = '//www.dailymotion.com/thumbnail/video/' + isVideo.dailymotion[1]; + } else { + thumbImg = thumb; + } + } + } else { + thumbImg = thumb; + } + + thumbList += '
'; + vimeoId = ''; + } + + 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'); + + // Load vimeo thumbnails + $thumb.each(function() { + var $this = $(this); + var vimeoVideoId = $this.attr('data-vimeo-id'); + + 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]); + }); + } + }); + + // manage active class for thumbnail + $thumb.eq(_this.core.index).addClass('active'); + _this.core.$el.on('onBeforeSlide.lg.tm', function() { + $thumb.removeClass('active'); + $thumb.eq(_this.core.index).addClass('active'); + }); + + $thumb.on('click.lg touchend.lg', function() { + var _$this = $(this); + setTimeout(function() { + + // In IE9 and bellow touch does not support + // Go to slide if browser does not support css transitions + if ((_this.thumbClickable && !_this.core.lgBusy) || !_this.core.doCss()) { + _this.core.index = _$this.index(); + _this.core.slide(_this.core.index, false, true, false); + } + }, 50); + }); + + _this.core.$el.on('onBeforeSlide.lg.tm', function() { + _this.animateThumb(_this.core.index); + }); + + $(window).on('resize.lg.thumb orientationchange.lg.thumb', function() { + setTimeout(function() { + _this.animateThumb(_this.core.index); + _this.thumbOuterWidth = _this.$thumbOuter.width(); + }, 200); + }); + + }; + + 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); + + } + }; + + // Enable thumbnail dragging and swiping + Thumbnail.prototype.enableThumbDrag = function() { + + var _this = this; + var startCoords = 0; + var endCoords = 0; + var isDraging = false; + var isMoved = false; + var tempLeft = 0; + + _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; + + // ** Fix for webkit cursor issue https://code.google.com/p/chromium/issues/detail?id=26723 + _this.core.$outer.scrollLeft += 1; + _this.core.$outer.scrollLeft -= 1; + + // * + _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'); + + tempLeft = tempLeft - (endCoords - startCoords); + + if (tempLeft > (_this.thumbTotalWidth - _this.thumbOuterWidth)) { + tempLeft = _this.thumbTotalWidth - _this.thumbOuterWidth; + } + + if (tempLeft < 0) { + tempLeft = 0; + } + + // move current slide + _this.setTranslate(tempLeft); + + } + }); + + $(window).on('mouseup.lg.thumb', function() { + if (isMoved) { + isMoved = false; + _this.$thumbOuter.removeClass('lg-dragging'); + + _this.left = tempLeft; + + if (Math.abs(endCoords - startCoords) < _this.core.s.swipeThreshold) { + _this.thumbClickable = true; + } + + } 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; + + tempLeft = tempLeft - (endCoords - startCoords); + + if (tempLeft > (_this.thumbTotalWidth - _this.thumbOuterWidth)) { + tempLeft = _this.thumbTotalWidth - _this.thumbOuterWidth; + } + + if (tempLeft < 0) { + tempLeft = 0; + } + + // move current slide + _this.setTranslate(tempLeft); + + } + }); + + _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(''); + _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; + +})(); + +})); diff --git a/public/lightgallery/js/lg-thumbnail.min.js b/public/lightgallery/js/lg-thumbnail.min.js new file mode 100644 index 0000000..f2ea2fc --- /dev/null +++ b/public/lightgallery/js/lg-thumbnail.min.js @@ -0,0 +1,4 @@ +/*! lg-thumbnail - v1.1.0 - 2017-08-08 +* http://sachinchoolur.github.io/lightGallery +* Copyright (c) 2017 Sachin N; Licensed GPLv3 */ +!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={thumbnail:!0,animateThumb:!0,currentPagerPosition:"middle",thumbWidth:100,thumbHeight:"80px",thumbContHeight:100,thumbMargin:5,exThumbImage:!1,showThumbByDefault:!0,toogleThumb:!0,pullCaptionUp:!0,enableThumbDrag:!0,enableThumbSwipe:!0,swipeThreshold:50,loadYoutubeThumbnail:!0,youtubeThumbSize:1,loadVimeoThumbnail:!0,vimeoThumbSize:"thumbnail_small",loadDailymotionThumbnail:!0},c=function(c){return this.core=a(c).data("lightGallery"),this.core.s=a.extend({},b,this.core.s),this.$el=a(c),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,this.core.s.animateThumb&&(this.core.s.thumbHeight="100%"),this.left=0,this.init(),this};c.prototype.init=function(){var a=this;this.core.s.thumbnail&&this.core.$items.length>1&&(this.core.s.showThumbByDefault&&setTimeout(function(){a.core.$outer.addClass("lg-thumb-open")},700),this.core.s.pullCaptionUp&&this.core.$outer.addClass("lg-pull-caption-up"),this.build(),this.core.s.animateThumb&&this.core.doCss()?(this.core.s.enableThumbDrag&&this.enableThumbDrag(),this.core.s.enableThumbSwipe&&this.enableThumbSwipe(),this.thumbClickable=!1):this.thumbClickable=!0,this.toogle(),this.thumbkeyPress())},c.prototype.build=function(){function b(a,b,c){var g,h=d.core.isVideo(a,c)||{},i="";h.youtube||h.vimeo||h.dailymotion?h.youtube?g=d.core.s.loadYoutubeThumbnail?"//img.youtube.com/vi/"+h.youtube[1]+"/"+d.core.s.youtubeThumbSize+".jpg":b:h.vimeo?d.core.s.loadVimeoThumbnail?(g="//i.vimeocdn.com/video/error_"+f+".jpg",i=h.vimeo[1]):g=b:h.dailymotion&&(g=d.core.s.loadDailymotionThumbnail?"//www.dailymotion.com/thumbnail/video/"+h.dailymotion[1]:b):g=b,e+='
',i=""}var c,d=this,e="",f="",g='
';switch(this.core.s.vimeoThumbSize){case"thumbnail_large":f="640";break;case"thumbnail_medium":f="200x150";break;case"thumbnail_small":f="100x75"}if(d.core.$outer.addClass("lg-has-thumb"),d.core.$outer.find(".lg").append(g),d.$thumbOuter=d.core.$outer.find(".lg-thumb-outer"),d.thumbOuterWidth=d.$thumbOuter.width(),d.core.s.animateThumb&&d.core.$outer.find(".lg-thumb").css({width:d.thumbTotalWidth+"px",position:"relative"}),this.core.s.animateThumb&&d.$thumbOuter.css("height",d.core.s.thumbContHeight+"px"),d.core.s.dynamic)for(var h=0;hthis.thumbTotalWidth-this.thumbOuterWidth&&(this.left=this.thumbTotalWidth-this.thumbOuterWidth),this.left<0&&(this.left=0),this.core.lGalleryOn?(b.hasClass("on")||this.core.$outer.find(".lg-thumb").css("transition-duration",this.core.s.speed+"ms"),this.core.doCss()||b.animate({left:-this.left+"px"},this.core.s.speed)):this.core.doCss()||b.css("left",-this.left+"px"),this.setTranslate(this.left)}},c.prototype.enableThumbDrag=function(){var b=this,c=0,d=0,e=!1,f=!1,g=0;b.$thumbOuter.addClass("lg-grab"),b.core.$outer.find(".lg-thumb").on("mousedown.lg.thumb",function(a){b.thumbTotalWidth>b.thumbOuterWidth&&(a.preventDefault(),c=a.pageX,e=!0,b.core.$outer.scrollLeft+=1,b.core.$outer.scrollLeft-=1,b.thumbClickable=!1,b.$thumbOuter.removeClass("lg-grab").addClass("lg-grabbing"))}),a(window).on("mousemove.lg.thumb",function(a){e&&(g=b.left,f=!0,d=a.pageX,b.$thumbOuter.addClass("lg-dragging"),g-=d-c,g>b.thumbTotalWidth-b.thumbOuterWidth&&(g=b.thumbTotalWidth-b.thumbOuterWidth),g<0&&(g=0),b.setTranslate(g))}),a(window).on("mouseup.lg.thumb",function(){f?(f=!1,b.$thumbOuter.removeClass("lg-dragging"),b.left=g,Math.abs(d-c)a.thumbOuterWidth&&(c.preventDefault(),b=c.originalEvent.targetTouches[0].pageX,a.thumbClickable=!1)}),a.core.$outer.find(".lg-thumb").on("touchmove.lg",function(f){a.thumbTotalWidth>a.thumbOuterWidth&&(f.preventDefault(),c=f.originalEvent.targetTouches[0].pageX,d=!0,a.$thumbOuter.addClass("lg-dragging"),e=a.left,e-=c-b,e>a.thumbTotalWidth-a.thumbOuterWidth&&(e=a.thumbTotalWidth-a.thumbOuterWidth),e<0&&(e=0),a.setTranslate(e))}),a.core.$outer.find(".lg-thumb").on("touchend.lg",function(){a.thumbTotalWidth>a.thumbOuterWidth&&d?(d=!1,a.$thumbOuter.removeClass("lg-dragging"),Math.abs(c-b)'),a.core.$outer.find(".lg-toogle-thumb").on("click.lg",function(){a.core.$outer.toggleClass("lg-thumb-open")}))},c.prototype.thumbkeyPress=function(){var b=this;a(window).on("keydown.lg.thumb",function(a){38===a.keyCode?(a.preventDefault(),b.core.$outer.addClass("lg-thumb-open")):40===a.keyCode&&(a.preventDefault(),b.core.$outer.removeClass("lg-thumb-open"))})},c.prototype.destroy=function(){this.core.s.thumbnail&&this.core.$items.length>1&&(a(window).off("resize.lg.thumb orientationchange.lg.thumb keydown.lg.thumb"),this.$thumbOuter.remove(),this.core.$outer.removeClass("lg-has-thumb"))},a.fn.lightGallery.modules.Thumbnail=c}()}); \ No newline at end of file diff --git a/public/lightgallery/js/lg-video.js b/public/lightgallery/js/lg-video.js new file mode 100644 index 0000000..b44ab89 --- /dev/null +++ b/public/lightgallery/js/lg-video.js @@ -0,0 +1,342 @@ +/*! lg-video - v1.2.2 - 2018-05-01 +* http://sachinchoolur.github.io/lightGallery +* Copyright (c) 2018 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 = { + videoMaxWidth: '855px', + + autoplayFirstVideo: true, + + youtubePlayerParams: false, + vimeoPlayerParams: false, + dailymotionPlayerParams: false, + vkPlayerParams: false, + + videojs: false, + videojsOptions: {} + }; + + var Video = function(element) { + + 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; + + // Event triggered when video url found without poster + _this.core.$el.on('hasVideo.lg.tm', onHasVideo.bind(this)); + + // Set max width for video + _this.core.$el.on('onAferAppendSlide.lg.tm', onAferAppendSlide.bind(this)); + + if (_this.core.doCss() && (_this.core.$items.length > 1) && (_this.core.s.enableSwipe || _this.core.s.enableDrag)) { + _this.core.$el.on('onSlideClick.lg.tm', function() { + var $el = _this.core.$slide.eq(_this.core.index); + _this.loadVideoOnclick($el); + }); + } else { + + // For IE 9 and bellow + _this.core.$slide.on('click.lg', function() { + _this.loadVideoOnclick($(this)); + }); + } + + _this.core.$el.on('onBeforeSlide.lg.tm', onBeforeSlide.bind(this)); + + _this.core.$el.on('onAfterSlide.lg.tm', function(event, prevIndex) { + _this.core.$slide.eq(prevIndex).removeClass('lg-video-playing'); + }); + + 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); + } + }); + } + }; + + Video.prototype.loadVideo = function(src, addClass, noPoster, index, html) { + var video = ''; + var autoplay = 1; + var a = ''; + var isVideo = this.core.isVideo(src, index) || {}; + + // Enable autoplay based on setting for first video if poster doesn't exist + if (noPoster) { + if (this.videoLoaded) { + autoplay = 0; + } else { + autoplay = this.core.s.autoplayFirstVideo ? 1 : 0; + } + } + + if (isVideo.youtube) { + + a = '?wmode=opaque&autoplay=' + autoplay + '&enablejsapi=1'; + if (this.core.s.youtubePlayerParams) { + a = a + '&' + $.param(this.core.s.youtubePlayerParams); + } + + video = ''; + + } else if (isVideo.vimeo) { + + a = '?autoplay=' + autoplay + '&api=1'; + if (this.core.s.vimeoPlayerParams) { + a = a + '&' + $.param(this.core.s.vimeoPlayerParams); + } + + video = ''; + + } else if (isVideo.dailymotion) { + + a = '?wmode=opaque&autoplay=' + autoplay + '&api=postMessage'; + if (this.core.s.dailymotionPlayerParams) { + a = a + '&' + $.param(this.core.s.dailymotionPlayerParams); + } + + video = ''; + + } 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); + } + + video = ''; + + } + + return video; + }; + + Video.prototype.loadVideoOnclick = function($el){ + + var _this = this; + // check slide has poster + if ($el.find('.lg-object').hasClass('lg-has-poster') && $el.find('.lg-object').is(':visible')) { + + // check already video element present + if (!$el.hasClass('lg-has-video')) { + + $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); + + } + + var $tempImg = $el.find('.lg-object'); + $el.find('.lg-video').append($tempImg); + + // @todo loading icon for html5 videos also + // for showing the loading indicator while loading video + if (!$el.find('.lg-video-object').hasClass('lg-html5')) { + $el.removeClass('lg-complete'); + $el.find('.lg-video-object').on('load.lg error.lg', function() { + $el.addClass('lg-complete'); + }); + } + + } else { + + var youtubePlayer = $el.find('.lg-youtube').get(0); + var vimeoPlayer = $el.find('.lg-vimeo').get(0); + var dailymotionPlayer = $el.find('.lg-dailymotion').get(0); + var html5Player = $el.find('.lg-html5').get(0); + if (youtubePlayer) { + youtubePlayer.contentWindow.postMessage('{"event":"command","func":"playVideo","args":""}', '*'); + } 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; + }; + + function onHasVideo(event, index, src, html) { + /*jshint validthis:true */ + var _this = this; + _this.core.$slide.eq(index).find('.lg-video').append(_this.loadVideo(src, 'lg-object', true, index, html)); + if (html) { + if (_this.core.s.videojs) { + try { + videojs(_this.core.$slide.eq(index).find('.lg-html5').get(0), _this.core.s.videojsOptions, function() { + if (!_this.videoLoaded && _this.core.s.autoplayFirstVideo) { + this.play(); + } + }); + } catch (e) { + console.error('Make sure you have included videojs'); + } + } else { + if(!_this.videoLoaded && _this.core.s.autoplayFirstVideo) { + _this.core.$slide.eq(index).find('.lg-html5').get(0).play(); + } + } + } + } + + function onAferAppendSlide(event, index) { + /*jshint validthis:true */ + var $videoCont = this.core.$slide.eq(index).find('.lg-video-cont'); + if (!$videoCont.hasClass('lg-has-iframe')) { + $videoCont.css('max-width', this.core.s.videoMaxWidth); + this.videoLoaded = true; + } + } + + function onBeforeSlide(event, prevIndex, index) { + /*jshint validthis:true */ + var _this = this; + + var $videoSlide = _this.core.$slide.eq(prevIndex); + var youtubePlayer = $videoSlide.find('.lg-youtube').get(0); + var vimeoPlayer = $videoSlide.find('.lg-vimeo').get(0); + var dailymotionPlayer = $videoSlide.find('.lg-dailymotion').get(0); + var vkPlayer = $videoSlide.find('.lg-vk').get(0); + var html5Player = $videoSlide.find('.lg-html5').get(0); + if (youtubePlayer) { + youtubePlayer.contentWindow.postMessage('{"event":"command","func":"pauseVideo","args":""}', '*'); + } 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'); + + } + + var _isVideo = _this.core.isVideo(_src, index) || {}; + if (_isVideo.youtube || _isVideo.vimeo || _isVideo.dailymotion || _isVideo.vk) { + _this.core.$outer.addClass('lg-hide-download'); + } + + } + + $.fn.lightGallery.modules.video = Video; + + })(); + +})); diff --git a/public/lightgallery/js/lg-video.min.js b/public/lightgallery/js/lg-video.min.js new file mode 100644 index 0000000..348fcc5 --- /dev/null +++ b/public/lightgallery/js/lg-video.min.js @@ -0,0 +1,4 @@ +/*! lg-video - v1.2.2 - 2018-05-01 +* http://sachinchoolur.github.io/lightGallery +* Copyright (c) 2018 Sachin N; Licensed GPLv3 */ +!function(a,b){"function"==typeof define&&define.amd?define(["jquery"],function(a){return b(a)}):"object"==typeof module&&module.exports?module.exports=b(require("jquery")):b(a.jQuery)}(this,function(a){!function(){"use strict";function b(a,b,c,d){var e=this;if(e.core.$slide.eq(b).find(".lg-video").append(e.loadVideo(c,"lg-object",!0,b,d)),d)if(e.core.s.videojs)try{videojs(e.core.$slide.eq(b).find(".lg-html5").get(0),e.core.s.videojsOptions,function(){!e.videoLoaded&&e.core.s.autoplayFirstVideo&&this.play()})}catch(a){console.error("Make sure you have included videojs")}else!e.videoLoaded&&e.core.s.autoplayFirstVideo&&e.core.$slide.eq(b).find(".lg-html5").get(0).play()}function c(a,b){var c=this.core.$slide.eq(b).find(".lg-video-cont");c.hasClass("lg-has-iframe")||(c.css("max-width",this.core.s.videoMaxWidth),this.videoLoaded=!0)}function d(b,c,d){var e=this,f=e.core.$slide.eq(c),g=f.find(".lg-youtube").get(0),h=f.find(".lg-vimeo").get(0),i=f.find(".lg-dailymotion").get(0),j=f.find(".lg-vk").get(0),k=f.find(".lg-html5").get(0);if(g)g.contentWindow.postMessage('{"event":"command","func":"pauseVideo","args":""}',"*");else if(h)try{$f(h).api("pause")}catch(a){console.error("Make sure you have included froogaloop2 js")}else if(i)i.contentWindow.postMessage("pause","*");else if(k)if(e.core.s.videojs)try{videojs(k).pause()}catch(a){console.error("Make sure you have included videojs")}else k.pause();j&&a(j).attr("src",a(j).attr("src").replace("&autoplay","&noplay"));var l;l=e.core.s.dynamic?e.core.s.dynamicEl[d].src:e.core.$items.eq(d).attr("href")||e.core.$items.eq(d).attr("data-src");var m=e.core.isVideo(l,d)||{};(m.youtube||m.vimeo||m.dailymotion||m.vk)&&e.core.$outer.addClass("lg-hide-download")}var e={videoMaxWidth:"855px",autoplayFirstVideo:!0,youtubePlayerParams:!1,vimeoPlayerParams:!1,dailymotionPlayerParams:!1,vkPlayerParams:!1,videojs:!1,videojsOptions:{}},f=function(b){return this.core=a(b).data("lightGallery"),this.$el=a(b),this.core.s=a.extend({},e,this.core.s),this.videoLoaded=!1,this.init(),this};f.prototype.init=function(){var e=this;e.core.$el.on("hasVideo.lg.tm",b.bind(this)),e.core.$el.on("onAferAppendSlide.lg.tm",c.bind(this)),e.core.doCss()&&e.core.$items.length>1&&(e.core.s.enableSwipe||e.core.s.enableDrag)?e.core.$el.on("onSlideClick.lg.tm",function(){var a=e.core.$slide.eq(e.core.index);e.loadVideoOnclick(a)}):e.core.$slide.on("click.lg",function(){e.loadVideoOnclick(a(this))}),e.core.$el.on("onBeforeSlide.lg.tm",d.bind(this)),e.core.$el.on("onAfterSlide.lg.tm",function(a,b){e.core.$slide.eq(b).removeClass("lg-video-playing")}),e.core.s.autoplayFirstVideo&&e.core.$el.on("onAferAppendSlide.lg.tm",function(a,b){if(!e.core.lGalleryOn){var c=e.core.$slide.eq(b);setTimeout(function(){e.loadVideoOnclick(c)},100)}})},f.prototype.loadVideo=function(b,c,d,e,f){var g="",h=1,i="",j=this.core.isVideo(b,e)||{};if(d&&(h=this.videoLoaded?0:this.core.s.autoplayFirstVideo?1:0),j.youtube)i="?wmode=opaque&autoplay="+h+"&enablejsapi=1",this.core.s.youtubePlayerParams&&(i=i+"&"+a.param(this.core.s.youtubePlayerParams)),g='';else if(j.vimeo)i="?autoplay="+h+"&api=1",this.core.s.vimeoPlayerParams&&(i=i+"&"+a.param(this.core.s.vimeoPlayerParams)),g='';else if(j.dailymotion)i="?wmode=opaque&autoplay="+h+"&api=postMessage",this.core.s.dailymotionPlayerParams&&(i=i+"&"+a.param(this.core.s.dailymotionPlayerParams)),g='';else if(j.html5){var k=f.substring(0,1);"."!==k&&"#"!==k||(f=a(f).html()),g=f}else j.vk&&(i="&autoplay="+h,this.core.s.vkPlayerParams&&(i=i+"&"+a.param(this.core.s.vkPlayerParams)),g='');return g},f.prototype.loadVideoOnclick=function(a){var b=this;if(a.find(".lg-object").hasClass("lg-has-poster")&&a.find(".lg-object").is(":visible"))if(a.hasClass("lg-has-video")){var c=a.find(".lg-youtube").get(0),d=a.find(".lg-vimeo").get(0),e=a.find(".lg-dailymotion").get(0),f=a.find(".lg-html5").get(0);if(c)c.contentWindow.postMessage('{"event":"command","func":"playVideo","args":""}',"*");else if(d)try{$f(d).api("play")}catch(a){console.error("Make sure you have included froogaloop2 js")}else if(e)e.contentWindow.postMessage("play","*");else if(f)if(b.core.s.videojs)try{videojs(f).play()}catch(a){console.error("Make sure you have included videojs")}else f.play();a.addClass("lg-video-playing")}else{a.addClass("lg-video-playing lg-has-video");var g,h,i=function(c,d){if(a.find(".lg-video").append(b.loadVideo(c,"",!1,b.core.index,d)),d)if(b.core.s.videojs)try{videojs(b.core.$slide.eq(b.core.index).find(".lg-html5").get(0),b.core.s.videojsOptions,function(){this.play()})}catch(a){console.error("Make sure you have included videojs")}else b.core.$slide.eq(b.core.index).find(".lg-html5").get(0).play()};b.core.s.dynamic?(g=b.core.s.dynamicEl[b.core.index].src,h=b.core.s.dynamicEl[b.core.index].html,i(g,h)):(g=b.core.$items.eq(b.core.index).attr("href")||b.core.$items.eq(b.core.index).attr("data-src"),h=b.core.$items.eq(b.core.index).attr("data-html"),i(g,h));var j=a.find(".lg-object");a.find(".lg-video").append(j),a.find(".lg-video-object").hasClass("lg-html5")||(a.removeClass("lg-complete"),a.find(".lg-video-object").on("load.lg error.lg",function(){a.addClass("lg-complete")}))}},f.prototype.destroy=function(){this.videoLoaded=!1},a.fn.lightGallery.modules.video=f}()}); \ No newline at end of file diff --git a/public/lightgallery/js/lg-zoom.js b/public/lightgallery/js/lg-zoom.js new file mode 100644 index 0000000..238c163 --- /dev/null +++ b/public/lightgallery/js/lg-zoom.js @@ -0,0 +1,527 @@ +/*! lg-zoom - v1.1.0 - 2017-08-08 +* http://sachinchoolur.github.io/lightGallery +* Copyright (c) 2017 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 exports === 'object') { + // 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(jQuery); + } +}(this, function ($) { + +(function() { + + 'use strict'; + + var getUseLeft = function() { + var useLeft = false; + var isChrome = navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./); + if (isChrome && parseInt(isChrome[2], 10) < 54) { + useLeft = true; + } + + return useLeft; + }; + + var defaults = { + scale: 1, + zoom: true, + actualSize: true, + enableZoomAfter: 300, + useLeftForZoom: getUseLeft() + }; + + var Zoom = function(element) { + + this.core = $(element).data('lightGallery'); + + this.core.s = $.extend({}, defaults, this.core.s); + + if (this.core.s.zoom && this.core.doCss()) { + this.init(); + + // Store the zoomable timeout value just to clear it while closing + this.zoomabletimeout = false; + + // Set the initial value center + this.pageX = $(window).width() / 2; + this.pageY = ($(window).height() / 2) + $(window).scrollTop(); + } + + return this; + }; + + Zoom.prototype.init = function() { + + var _this = this; + var zoomIcons = ''; + + if (_this.core.s.actualSize) { + zoomIcons += ''; + } + + 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); + + // Add zoomable class + _this.core.$el.on('onSlideItemLoad.lg.tm.zoom', function(event, index, delay) { + + // delay will be 0 except first time + var _speed = _this.core.s.enableZoomAfter + delay; + + // set _speed value 0 if gallery opened from direct url and if it is first slide + if ($('body').hasClass('lg-from-hash') && delay) { + + // will execute only once + _speed = 0; + } else { + + // Remove lg-from-hash to enable starting animation. + $('body').removeClass('lg-from-hash'); + } + + _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) { + + var $image = _this.core.$outer.find('.lg-current .lg-image'); + var _x; + var _y; + + // Find offset manually to avoid issue after zoom + var offsetX = ($(window).width() - $image.prop('offsetWidth')) / 2; + var offsetY = (($(window).height() - $image.prop('offsetHeight')) / 2) + $(window).scrollTop(); + + _x = _this.pageX - offsetX; + _y = _this.pageY - offsetY; + + var x = (scaleVal - 1) * (_x); + var y = (scaleVal - 1) * (_y); + + $image.css('transform', 'scale3d(' + scaleVal + ', ' + scaleVal + ', 1)').attr('data-scale', scaleVal); + + 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); + } + }; + + var callScale = function() { + if (scale > 1) { + _this.core.$outer.addClass('lg-zoomed'); + } else { + _this.resetZoom(); + } + + if (scale < 1) { + scale = 1; + } + + zoom(scale); + }; + + var actualSize = function(event, $image, index, fromIcon) { + var w = $image.prop('offsetWidth'); + var nw; + if (_this.core.s.dynamic) { + nw = _this.core.s.dynamicEl[index].width || $image[0].naturalWidth || w; + } else { + nw = _this.core.$items.eq(index).attr('data-width') || $image[0].naturalWidth || w; + } + + 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); + }; + + var tapped = false; + + // event triggered after appending slide content + _this.core.$el.on('onAferAppendSlide.lg.tm.zoom', function(event, index) { + + // Get the current element + var $image = _this.core.$slide.eq(index).find('.lg-image'); + + $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(); + }); + + }); + + // Update zoom on resize and orientationchange + $(window).on('resize.lg.zoom scroll.lg.zoom orientationchange.lg.zoom', function() { + _this.pageX = $(window).width() / 2; + _this.pageY = ($(window).height() / 2) + $(window).scrollTop(); + zoom(scale); + }); + + $('#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); + }); + + // Reset zoom on slide change + _this.core.$el.on('onBeforeSlide.lg.tm', function() { + scale = 1; + _this.resetZoom(); + }); + + // Drag option after zoom + _this.zoomDrag(); + + _this.zoomSwipe(); + + }; + + // Reset zoom effect + Zoom.prototype.resetZoom = function() { + this.core.$outer.removeClass('lg-zoomed'); + this.core.$slide.find('.lg-img-wrap').removeAttr('style data-x data-y'); + this.core.$slide.find('.lg-image').removeAttr('style data-scale'); + + // Reset pagx pagy values to center + this.pageX = $(window).width() / 2; + this.pageY = ($(window).height() / 2) + $(window).scrollTop(); + }; + + Zoom.prototype.zoomSwipe = function() { + var _this = this; + var startCoords = {}; + var endCoords = {}; + var isMoved = false; + + // Allow x direction drag + var allowX = false; + + // Allow Y direction drag + var allowY = 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'); + + allowY = $image.prop('offsetHeight') * $image.attr('data-scale') > _this.core.$outer.find('.lg').height(); + allowX = $image.prop('offsetWidth') * $image.attr('data-scale') > _this.core.$outer.find('.lg').width(); + if ((allowX || allowY)) { + e.preventDefault(); + startCoords = { + x: e.originalEvent.targetTouches[0].pageX, + y: e.originalEvent.targetTouches[0].pageY + }; + } + } + + }); + + _this.core.$slide.on('touchmove.lg', function(e) { + + if (_this.core.$outer.hasClass('lg-zoomed')) { + + var _$el = _this.core.$slide.eq(_this.core.index).find('.lg-img-wrap'); + var distanceX; + var distanceY; + + e.preventDefault(); + isMoved = true; + + endCoords = { + x: e.originalEvent.targetTouches[0].pageX, + y: e.originalEvent.targetTouches[0].pageY + }; + + // reset opacity and transition duration + _this.core.$outer.addClass('lg-zoom-dragging'); + + 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 ((Math.abs(endCoords.x - startCoords.x) > 15) || (Math.abs(endCoords.y - startCoords.y) > 15)) { + + 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() { + + var _this = this; + var startCoords = {}; + var endCoords = {}; + var isDraging = false; + var isMoved = false; + + // Allow x direction drag + var allowX = false; + + // Allow Y direction drag + var allowY = false; + + _this.core.$slide.on('mousedown.lg.zoom', function(e) { + + // execute only on .lg-object + var $image = _this.core.$slide.eq(_this.core.index).find('.lg-object'); + + allowY = $image.prop('offsetHeight') * $image.attr('data-scale') > _this.core.$outer.find('.lg').height(); + allowX = $image.prop('offsetWidth') * $image.attr('data-scale') > _this.core.$outer.find('.lg').width(); + + 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; + + // ** Fix for webkit cursor issue https://code.google.com/p/chromium/issues/detail?id=26723 + _this.core.$outer.scrollLeft += 1; + _this.core.$outer.scrollLeft -= 1; + + _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 + }; + + // reset opacity and transition duration + _this.core.$outer.addClass('lg-zoom-dragging'); + + 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'); + + // Fix for chrome mouse move on click + if (isMoved && ((startCoords.x !== endCoords.x) || (startCoords.y !== endCoords.y))) { + endCoords = { + x: e.pageX, + y: e.pageY + }; + _this.touchendZoom(startCoords, endCoords, allowX, allowY); + + } + + isMoved = false; + } + + _this.core.$outer.removeClass('lg-grabbing').addClass('lg-grab'); + + }); + }; + + Zoom.prototype.touchendZoom = function(startCoords, endCoords, allowX, allowY) { + + var _this = this; + var _$el = _this.core.$slide.eq(_this.core.index).find('.lg-img-wrap'); + var $image = _this.core.$slide.eq(_this.core.index).find('.lg-object'); + var distanceX = (-Math.abs(_$el.attr('data-x'))) + (endCoords.x - startCoords.x); + var distanceY = (-Math.abs(_$el.attr('data-y'))) + (endCoords.y - startCoords.y); + var minY = (_this.core.$outer.find('.lg').height() - $image.prop('offsetHeight')) / 2; + var maxY = Math.abs(($image.prop('offsetHeight') * Math.abs($image.attr('data-scale'))) - _this.core.$outer.find('.lg').height() + minY); + var minX = (_this.core.$outer.find('.lg').width() - $image.prop('offsetWidth')) / 2; + var maxX = Math.abs(($image.prop('offsetWidth') * Math.abs($image.attr('data-scale'))) - _this.core.$outer.find('.lg').width() + minX); + + if ((Math.abs(endCoords.x - startCoords.x) > 15) || (Math.abs(endCoords.y - startCoords.y) > 15)) { + if (allowY) { + if (distanceY <= -maxY) { + distanceY = -maxY; + } else if (distanceY >= -minY) { + distanceY = -minY; + } + } + + 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() { + + var _this = this; + + // Unbind all events added by lightGallery zoom plugin + _this.core.$el.off('.lg.zoom'); + $(window).off('.lg.zoom'); + _this.core.$slide.off('.lg.zoom'); + _this.core.$el.off('.lg.tm.zoom'); + _this.resetZoom(); + clearTimeout(_this.zoomabletimeout); + _this.zoomabletimeout = false; + }; + + $.fn.lightGallery.modules.zoom = Zoom; + +})(); + + +})); diff --git a/public/lightgallery/js/lg-zoom.min.js b/public/lightgallery/js/lg-zoom.min.js new file mode 100644 index 0000000..bb603eb --- /dev/null +++ b/public/lightgallery/js/lg-zoom.min.js @@ -0,0 +1,4 @@ +/*! lg-zoom - v1.1.0 - 2017-08-08 +* http://sachinchoolur.github.io/lightGallery +* Copyright (c) 2017 Sachin N; Licensed GPLv3 */ +!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=function(){var a=!1,b=navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./);return b&&parseInt(b[2],10)<54&&(a=!0),a},c={scale:1,zoom:!0,actualSize:!0,enableZoomAfter:300,useLeftForZoom:b()},d=function(b){return this.core=a(b).data("lightGallery"),this.core.s=a.extend({},c,this.core.s),this.core.s.zoom&&this.core.doCss()&&(this.init(),this.zoomabletimeout=!1,this.pageX=a(window).width()/2,this.pageY=a(window).height()/2+a(window).scrollTop()),this};d.prototype.init=function(){var b=this,c='';b.core.s.actualSize&&(c+=''),b.core.s.useLeftForZoom?b.core.$outer.addClass("lg-use-left-for-zoom"):b.core.$outer.addClass("lg-use-transition-for-zoom"),this.core.$outer.find(".lg-toolbar").append(c),b.core.$el.on("onSlideItemLoad.lg.tm.zoom",function(c,d,e){var f=b.core.s.enableZoomAfter+e;a("body").hasClass("lg-from-hash")&&e?f=0:a("body").removeClass("lg-from-hash"),b.zoomabletimeout=setTimeout(function(){b.core.$slide.eq(d).addClass("lg-zoomable")},f+30)});var d=1,e=function(c){var d,e,f=b.core.$outer.find(".lg-current .lg-image"),g=(a(window).width()-f.prop("offsetWidth"))/2,h=(a(window).height()-f.prop("offsetHeight"))/2+a(window).scrollTop();d=b.pageX-g,e=b.pageY-h;var i=(c-1)*d,j=(c-1)*e;f.css("transform","scale3d("+c+", "+c+", 1)").attr("data-scale",c),b.core.s.useLeftForZoom?f.parent().css({left:-i+"px",top:-j+"px"}).attr("data-x",i).attr("data-y",j):f.parent().css("transform","translate3d(-"+i+"px, -"+j+"px, 0)").attr("data-x",i).attr("data-y",j)},f=function(){d>1?b.core.$outer.addClass("lg-zoomed"):b.resetZoom(),d<1&&(d=1),e(d)},g=function(c,e,g,h){var i,j=e.prop("offsetWidth");i=b.core.s.dynamic?b.core.s.dynamicEl[g].width||e[0].naturalWidth||j:b.core.$items.eq(g).attr("data-width")||e[0].naturalWidth||j;var k;b.core.$outer.hasClass("lg-zoomed")?d=1:i>j&&(k=i/j,d=k||2),h?(b.pageX=a(window).width()/2,b.pageY=a(window).height()/2+a(window).scrollTop()):(b.pageX=c.pageX||c.originalEvent.targetTouches[0].pageX,b.pageY=c.pageY||c.originalEvent.targetTouches[0].pageY),f(),setTimeout(function(){b.core.$outer.removeClass("lg-grabbing").addClass("lg-grab")},10)},h=!1;b.core.$el.on("onAferAppendSlide.lg.tm.zoom",function(a,c){var d=b.core.$slide.eq(c).find(".lg-image");d.on("dblclick",function(a){g(a,d,c)}),d.on("touchstart",function(a){h?(clearTimeout(h),h=null,g(a,d,c)):h=setTimeout(function(){h=null},300),a.preventDefault()})}),a(window).on("resize.lg.zoom scroll.lg.zoom orientationchange.lg.zoom",function(){b.pageX=a(window).width()/2,b.pageY=a(window).height()/2+a(window).scrollTop(),e(d)}),a("#lg-zoom-out").on("click.lg",function(){b.core.$outer.find(".lg-current .lg-image").length&&(d-=b.core.s.scale,f())}),a("#lg-zoom-in").on("click.lg",function(){b.core.$outer.find(".lg-current .lg-image").length&&(d+=b.core.s.scale,f())}),a("#lg-actual-size").on("click.lg",function(a){g(a,b.core.$slide.eq(b.core.index).find(".lg-image"),b.core.index,!0)}),b.core.$el.on("onBeforeSlide.lg.tm",function(){d=1,b.resetZoom()}),b.zoomDrag(),b.zoomSwipe()},d.prototype.resetZoom=function(){this.core.$outer.removeClass("lg-zoomed"),this.core.$slide.find(".lg-img-wrap").removeAttr("style data-x data-y"),this.core.$slide.find(".lg-image").removeAttr("style data-scale"),this.pageX=a(window).width()/2,this.pageY=a(window).height()/2+a(window).scrollTop()},d.prototype.zoomSwipe=function(){var a=this,b={},c={},d=!1,e=!1,f=!1;a.core.$slide.on("touchstart.lg",function(c){if(a.core.$outer.hasClass("lg-zoomed")){var d=a.core.$slide.eq(a.core.index).find(".lg-object");f=d.prop("offsetHeight")*d.attr("data-scale")>a.core.$outer.find(".lg").height(),e=d.prop("offsetWidth")*d.attr("data-scale")>a.core.$outer.find(".lg").width(),(e||f)&&(c.preventDefault(),b={x:c.originalEvent.targetTouches[0].pageX,y:c.originalEvent.targetTouches[0].pageY})}}),a.core.$slide.on("touchmove.lg",function(g){if(a.core.$outer.hasClass("lg-zoomed")){var h,i,j=a.core.$slide.eq(a.core.index).find(".lg-img-wrap");g.preventDefault(),d=!0,c={x:g.originalEvent.targetTouches[0].pageX,y:g.originalEvent.targetTouches[0].pageY},a.core.$outer.addClass("lg-zoom-dragging"),i=f?-Math.abs(j.attr("data-y"))+(c.y-b.y):-Math.abs(j.attr("data-y")),h=e?-Math.abs(j.attr("data-x"))+(c.x-b.x):-Math.abs(j.attr("data-x")),(Math.abs(c.x-b.x)>15||Math.abs(c.y-b.y)>15)&&(a.core.s.useLeftForZoom?j.css({left:h+"px",top:i+"px"}):j.css("transform","translate3d("+h+"px, "+i+"px, 0)"))}}),a.core.$slide.on("touchend.lg",function(){a.core.$outer.hasClass("lg-zoomed")&&d&&(d=!1,a.core.$outer.removeClass("lg-zoom-dragging"),a.touchendZoom(b,c,e,f))})},d.prototype.zoomDrag=function(){var b=this,c={},d={},e=!1,f=!1,g=!1,h=!1;b.core.$slide.on("mousedown.lg.zoom",function(d){var f=b.core.$slide.eq(b.core.index).find(".lg-object");h=f.prop("offsetHeight")*f.attr("data-scale")>b.core.$outer.find(".lg").height(),g=f.prop("offsetWidth")*f.attr("data-scale")>b.core.$outer.find(".lg").width(),b.core.$outer.hasClass("lg-zoomed")&&a(d.target).hasClass("lg-object")&&(g||h)&&(d.preventDefault(),c={x:d.pageX,y:d.pageY},e=!0,b.core.$outer.scrollLeft+=1,b.core.$outer.scrollLeft-=1,b.core.$outer.removeClass("lg-grab").addClass("lg-grabbing"))}),a(window).on("mousemove.lg.zoom",function(a){if(e){var i,j,k=b.core.$slide.eq(b.core.index).find(".lg-img-wrap");f=!0,d={x:a.pageX,y:a.pageY},b.core.$outer.addClass("lg-zoom-dragging"),j=h?-Math.abs(k.attr("data-y"))+(d.y-c.y):-Math.abs(k.attr("data-y")),i=g?-Math.abs(k.attr("data-x"))+(d.x-c.x):-Math.abs(k.attr("data-x")),b.core.s.useLeftForZoom?k.css({left:i+"px",top:j+"px"}):k.css("transform","translate3d("+i+"px, "+j+"px, 0)")}}),a(window).on("mouseup.lg.zoom",function(a){e&&(e=!1,b.core.$outer.removeClass("lg-zoom-dragging"),!f||c.x===d.x&&c.y===d.y||(d={x:a.pageX,y:a.pageY},b.touchendZoom(c,d,g,h)),f=!1),b.core.$outer.removeClass("lg-grabbing").addClass("lg-grab")})},d.prototype.touchendZoom=function(a,b,c,d){var e=this,f=e.core.$slide.eq(e.core.index).find(".lg-img-wrap"),g=e.core.$slide.eq(e.core.index).find(".lg-object"),h=-Math.abs(f.attr("data-x"))+(b.x-a.x),i=-Math.abs(f.attr("data-y"))+(b.y-a.y),j=(e.core.$outer.find(".lg").height()-g.prop("offsetHeight"))/2,k=Math.abs(g.prop("offsetHeight")*Math.abs(g.attr("data-scale"))-e.core.$outer.find(".lg").height()+j),l=(e.core.$outer.find(".lg").width()-g.prop("offsetWidth"))/2,m=Math.abs(g.prop("offsetWidth")*Math.abs(g.attr("data-scale"))-e.core.$outer.find(".lg").width()+l);(Math.abs(b.x-a.x)>15||Math.abs(b.y-a.y)>15)&&(d&&(i<=-k?i=-k:i>=-j&&(i=-j)),c&&(h<=-m?h=-m:h>=-l&&(h=-l)),d?f.attr("data-y",Math.abs(i)):i=-Math.abs(f.attr("data-y")),c?f.attr("data-x",Math.abs(h)):h=-Math.abs(f.attr("data-x")),e.core.s.useLeftForZoom?f.css({left:h+"px",top:i+"px"}):f.css("transform","translate3d("+h+"px, "+i+"px, 0)"))},d.prototype.destroy=function(){var b=this;b.core.$el.off(".lg.zoom"),a(window).off(".lg.zoom"),b.core.$slide.off(".lg.zoom"),b.core.$el.off(".lg.tm.zoom"),b.resetZoom(),clearTimeout(b.zoomabletimeout),b.zoomabletimeout=!1},a.fn.lightGallery.modules.zoom=d}()}); \ No newline at end of file