From 0dc09eb6b717558ba1b644d88b7351bf08325957 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Tue, 6 Feb 2018 12:52:47 +0100 Subject: Lightgallery: add plugins --- .../static/lightgallery/js/lg-fullscreen.js | 125 +++++ .../static/lightgallery/js/lg-fullscreen.min.js | 7 + .../static/lightgallery/js/lg-thumbnail.js | 491 ++++++++++++++++++ .../static/lightgallery/js/lg-thumbnail.min.js | 7 + ishtar_common/static/lightgallery/js/lg-zoom.js | 568 +++++++++++++++++++++ .../static/lightgallery/js/lg-zoom.min.js | 7 + 6 files changed, 1205 insertions(+) create mode 100644 ishtar_common/static/lightgallery/js/lg-fullscreen.js create mode 100644 ishtar_common/static/lightgallery/js/lg-fullscreen.min.js create mode 100644 ishtar_common/static/lightgallery/js/lg-thumbnail.js create mode 100644 ishtar_common/static/lightgallery/js/lg-thumbnail.min.js create mode 100644 ishtar_common/static/lightgallery/js/lg-zoom.js create mode 100644 ishtar_common/static/lightgallery/js/lg-zoom.min.js diff --git a/ishtar_common/static/lightgallery/js/lg-fullscreen.js b/ishtar_common/static/lightgallery/js/lg-fullscreen.js new file mode 100644 index 000000000..e99d54eb0 --- /dev/null +++ b/ishtar_common/static/lightgallery/js/lg-fullscreen.js @@ -0,0 +1,125 @@ +/**! + * lg-fullscreen.js | 1.0.0 | October 5th 2016 + * http://sachinchoolur.github.io/lg-fullscreen.js + * Copyright (c) 2016 Sachin N; + * @license GPLv3 + */(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.LgFullscreen = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o 1) { + if (this.core.s.showThumbByDefault) { + setTimeout(function () { + utils.addClass(_this.core.outer, 'lg-thumb-open'); + }, 700); + } + + if (this.core.s.pullCaptionUp) { + utils.addClass(this.core.outer, 'lg-pull-caption-up'); + } + + this.build(); + if (this.core.s.animateThumb) { + if (this.core.s.enableThumbDrag && !this.core.isTouch && this.core.doCss()) { + this.enableThumbDrag(); + } + + if (this.core.s.enableThumbSwipe && this.core.isTouch && this.core.doCss()) { + this.enableThumbSwipe(); + } + + this.thumbClickable = false; + } else { + this.thumbClickable = true; + } + + this.toggle(); + 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'; + } + + utils.addClass(_this.core.outer, 'lg-has-thumb'); + + _this.core.outer.querySelector('.lg').insertAdjacentHTML('beforeend', html); + + _this.thumbOuter = _this.core.outer.querySelector('.lg-thumb-outer'); + _this.thumbOuterWidth = _this.thumbOuter.offsetWidth; + + if (_this.core.s.animateThumb) { + _this.core.outer.querySelector('.lg-thumb').style.width = _this.thumbTotalWidth + 'px'; + _this.core.outer.querySelector('.lg-thumb').style.position = 'relative'; + } + + if (this.core.s.animateThumb) { + _this.thumbOuter.style.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 j = 0; j < _this.core.s.dynamicEl.length; j++) { + getThumb(_this.core.s.dynamicEl[j].src, _this.core.s.dynamicEl[j].thumb, j); + } + } else { + for (var i = 0; i < _this.core.items.length; i++) { + if (!_this.core.s.exThumbImage) { + getThumb(_this.core.items[i].getAttribute('href') || _this.core.items[i].getAttribute('data-src'), _this.core.items[i].querySelector('img').getAttribute('src'), i); + } else { + getThumb(_this.core.items[i].getAttribute('href') || _this.core.items[i].getAttribute('data-src'), _this.core.items[i].getAttribute(_this.core.s.exThumbImage), i); + } + } + } + + _this.core.outer.querySelector('.lg-thumb').innerHTML = thumbList; + + $thumb = _this.core.outer.querySelectorAll('.lg-thumb-item'); + + for (var n = 0; n < $thumb.length; n++) { + + /*jshint loopfunc: true */ + (function (index) { + var $this = $thumb[index]; + var vimeoVideoId = $this.getAttribute('data-vimeo-id'); + if (vimeoVideoId) { + + window['lgJsonP' + _this.el.getAttribute('lg-uid') + '' + n] = function (content) { + $this.querySelector('img').setAttribute('src', content[0][_this.core.s.vimeoThumbSize]); + }; + + var script = document.createElement('script'); + script.className = 'lg-script'; + script.src = '//www.vimeo.com/api/v2/video/' + vimeoVideoId + '.json?callback=lgJsonP' + _this.el.getAttribute('lg-uid') + '' + n; + document.body.appendChild(script); + } + })(n); + } + + // manage active class for thumbnail + utils.addClass($thumb[_this.core.index], 'active'); + utils.on(_this.core.el, 'onBeforeSlide.lgtm', function () { + + for (var j = 0; j < $thumb.length; j++) { + utils.removeClass($thumb[j], 'active'); + } + + utils.addClass($thumb[_this.core.index], 'active'); + }); + + for (var k = 0; k < $thumb.length; k++) { + + /*jshint loopfunc: true */ + (function (index) { + + utils.on($thumb[index], 'click.lg touchend.lg', function () { + + 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 = index; + _this.core.slide(_this.core.index, false, true); + } + }, 50); + }); + })(k); + } + + utils.on(_this.core.el, 'onBeforeSlide.lgtm', function () { + _this.animateThumb(_this.core.index); + }); + + utils.on(window, 'resize.lgthumb orientationchange.lgthumb', function () { + setTimeout(function () { + _this.animateThumb(_this.core.index); + _this.thumbOuterWidth = _this.thumbOuter.offsetWidth; + }, 200); + }); + }; + + Thumbnail.prototype.setTranslate = function (value) { + utils.setVendor(this.core.outer.querySelector('.lg-thumb'), 'Transform', 'translate3d(-' + value + 'px, 0px, 0px)'); + }; + + Thumbnail.prototype.animateThumb = function (index) { + var $thumb = this.core.outer.querySelector('.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 (!utils.hasClass($thumb, 'on')) { + utils.setVendor(this.core.outer.querySelector('.lg-thumb'), 'TransitionDuration', this.core.s.speed + 'ms'); + } + + if (!this.core.doCss()) { + $thumb.style.left = -this.left + 'px'; + } + } else { + if (!this.core.doCss()) { + $thumb.style.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; + + utils.addClass(_this.thumbOuter, 'lg-grab'); + + utils.on(_this.core.outer.querySelector('.lg-thumb'), 'mousedown.lgthumb', 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; + utils.removeClass(_this.thumbOuter, 'lg-grab'); + utils.addClass(_this.thumbOuter, 'lg-grabbing'); + } + }); + + utils.on(window, 'mousemove.lgthumb', function (e) { + if (isDraging) { + tempLeft = _this.left; + isMoved = true; + endCoords = e.pageX; + + utils.addClass(_this.thumbOuter, '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); + } + }); + + utils.on(window, 'mouseup.lgthumb', function () { + if (isMoved) { + isMoved = false; + utils.removeClass(_this.thumbOuter, '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; + utils.removeClass(_this.thumbOuter, 'lg-grabbing'); + utils.addClass(_this.thumbOuter, 'lg-grab'); + } + }); + }; + + Thumbnail.prototype.enableThumbSwipe = function () { + var _this = this; + var startCoords = 0; + var endCoords = 0; + var isMoved = false; + var tempLeft = 0; + + utils.on(_this.core.outer.querySelector('.lg-thumb'), 'touchstart.lg', function (e) { + if (_this.thumbTotalWidth > _this.thumbOuterWidth) { + e.preventDefault(); + startCoords = e.targetTouches[0].pageX; + _this.thumbClickable = false; + } + }); + + utils.on(_this.core.outer.querySelector('.lg-thumb'), 'touchmove.lg', function (e) { + if (_this.thumbTotalWidth > _this.thumbOuterWidth) { + e.preventDefault(); + endCoords = e.targetTouches[0].pageX; + isMoved = true; + + utils.addClass(_this.thumbOuter, '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); + } + }); + + utils.on(_this.core.outer.querySelector('.lg-thumb'), 'touchend.lg', function () { + if (_this.thumbTotalWidth > _this.thumbOuterWidth) { + + if (isMoved) { + isMoved = false; + utils.removeClass(_this.thumbOuter, '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.toggle = function () { + var _this = this; + if (_this.core.s.toggleThumb) { + utils.addClass(_this.core.outer, 'lg-can-toggle'); + _this.thumbOuter.insertAdjacentHTML('beforeend', ''); + utils.on(_this.core.outer.querySelector('.lg-toggle-thumb'), 'click.lg', function () { + if (utils.hasClass(_this.core.outer, 'lg-thumb-open')) { + utils.removeClass(_this.core.outer, 'lg-thumb-open'); + } else { + utils.addClass(_this.core.outer, 'lg-thumb-open'); + } + }); + } + }; + + Thumbnail.prototype.thumbkeyPress = function () { + var _this = this; + utils.on(window, 'keydown.lgthumb', function (e) { + if (e.keyCode === 38) { + e.preventDefault(); + utils.addClass(_this.core.outer, 'lg-thumb-open'); + } else if (e.keyCode === 40) { + e.preventDefault(); + utils.removeClass(_this.core.outer, 'lg-thumb-open'); + } + }); + }; + + Thumbnail.prototype.destroy = function () { + if (this.core.s.thumbnail && this.core.items.length > 1) { + utils.off(window, '.lgthumb'); + this.thumbOuter.parentNode.removeChild(this.thumbOuter); + utils.removeClass(this.core.outer, 'lg-has-thumb'); + + var lgScript = document.getElementsByClassName('lg-script'); + while (lgScript[0]) { + lgScript[0].parentNode.removeChild(lgScript[0]); + } + } + }; + + window.lgModules.thumbnail = Thumbnail; +}); + +},{}]},{},[1])(1) +}); \ No newline at end of file diff --git a/ishtar_common/static/lightgallery/js/lg-thumbnail.min.js b/ishtar_common/static/lightgallery/js/lg-thumbnail.min.js new file mode 100644 index 000000000..586165a6d --- /dev/null +++ b/ishtar_common/static/lightgallery/js/lg-thumbnail.min.js @@ -0,0 +1,7 @@ +/**! + * lg-thumbnail.js | 1.0.0 | October 5th 2016 + * http://sachinchoolur.github.io/lg-thumbnail.js + * Copyright (c) 2016 Sachin N; + * @license GPLv3 + */ +!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,e.LgThumbnail=t()}}(function(){var t,e,i;return function t(e,i,o){function u(s,l){if(!i[s]){if(!e[s]){var h="function"==typeof require&&require;if(!l&&h)return h(s,!0);if(r)return r(s,!0);var n=new Error("Cannot find module '"+s+"'");throw n.code="MODULE_NOT_FOUND",n}var a=i[s]={exports:{}};e[s][0].call(a.exports,function(t){var i=e[s][1][t];return u(i?i:t)},a,a.exports,t,e,i,o)}return i[s].exports}for(var r="function"==typeof require&&require,s=0;s1&&(this.core.s.showThumbByDefault&&setTimeout(function(){utils.addClass(t.core.outer,"lg-thumb-open")},700),this.core.s.pullCaptionUp&&utils.addClass(this.core.outer,"lg-pull-caption-up"),this.build(),this.core.s.animateThumb?(this.core.s.enableThumbDrag&&!this.core.isTouch&&this.core.doCss()&&this.enableThumbDrag(),this.core.s.enableThumbSwipe&&this.core.isTouch&&this.core.doCss()&&this.enableThumbSwipe(),this.thumbClickable=!1):this.thumbClickable=!0,this.toggle(),this.thumbkeyPress())},i.prototype.build=function(){function t(t,u,r){var s=e.core.isVideo(t,r)||{},l,h="";s.youtube||s.vimeo||s.dailymotion?s.youtube?l=e.core.s.loadYoutubeThumbnail?"//img.youtube.com/vi/"+s.youtube[1]+"/"+e.core.s.youtubeThumbSize+".jpg":u:s.vimeo?e.core.s.loadVimeoThumbnail?(l="//i.vimeocdn.com/video/error_"+o+".jpg",h=s.vimeo[1]):l=u:s.dailymotion&&(l=e.core.s.loadDailymotionThumbnail?"//www.dailymotion.com/thumbnail/video/"+s.dailymotion[1]:u):l=u,i+='
',h=""}var e=this,i="",o="",u,r='
';switch(this.core.s.vimeoThumbSize){case"thumbnail_large":o="640";break;case"thumbnail_medium":o="200x150";break;case"thumbnail_small":o="100x75"}if(utils.addClass(e.core.outer,"lg-has-thumb"),e.core.outer.querySelector(".lg").insertAdjacentHTML("beforeend",r),e.thumbOuter=e.core.outer.querySelector(".lg-thumb-outer"),e.thumbOuterWidth=e.thumbOuter.offsetWidth,e.core.s.animateThumb&&(e.core.outer.querySelector(".lg-thumb").style.width=e.thumbTotalWidth+"px",e.core.outer.querySelector(".lg-thumb").style.position="relative"),this.core.s.animateThumb&&(e.thumbOuter.style.height=e.core.s.thumbContHeight+"px"),e.core.s.dynamic)for(var s=0;sthis.thumbTotalWidth-this.thumbOuterWidth&&(this.left=this.thumbTotalWidth-this.thumbOuterWidth),this.left<0&&(this.left=0),this.core.lGalleryOn?(utils.hasClass(e,"on")||utils.setVendor(this.core.outer.querySelector(".lg-thumb"),"TransitionDuration",this.core.s.speed+"ms"),this.core.doCss()||(e.style.left=-this.left+"px")):this.core.doCss()||(e.style.left=-this.left+"px"),this.setTranslate(this.left)}},i.prototype.enableThumbDrag=function(){var t=this,e=0,i=0,o=!1,u=!1,r=0;utils.addClass(t.thumbOuter,"lg-grab"),utils.on(t.core.outer.querySelector(".lg-thumb"),"mousedown.lgthumb",function(i){t.thumbTotalWidth>t.thumbOuterWidth&&(i.preventDefault(),e=i.pageX,o=!0,t.core.outer.scrollLeft+=1,t.core.outer.scrollLeft-=1,t.thumbClickable=!1,utils.removeClass(t.thumbOuter,"lg-grab"),utils.addClass(t.thumbOuter,"lg-grabbing"))}),utils.on(window,"mousemove.lgthumb",function(s){o&&(r=t.left,u=!0,i=s.pageX,utils.addClass(t.thumbOuter,"lg-dragging"),r-=i-e,r>t.thumbTotalWidth-t.thumbOuterWidth&&(r=t.thumbTotalWidth-t.thumbOuterWidth),r<0&&(r=0),t.setTranslate(r))}),utils.on(window,"mouseup.lgthumb",function(){u?(u=!1,utils.removeClass(t.thumbOuter,"lg-dragging"),t.left=r,Math.abs(i-e)t.thumbOuterWidth&&(i.preventDefault(),e=i.targetTouches[0].pageX,t.thumbClickable=!1)}),utils.on(t.core.outer.querySelector(".lg-thumb"),"touchmove.lg",function(r){t.thumbTotalWidth>t.thumbOuterWidth&&(r.preventDefault(),i=r.targetTouches[0].pageX,o=!0,utils.addClass(t.thumbOuter,"lg-dragging"),u=t.left,u-=i-e,u>t.thumbTotalWidth-t.thumbOuterWidth&&(u=t.thumbTotalWidth-t.thumbOuterWidth),u<0&&(u=0),t.setTranslate(u))}),utils.on(t.core.outer.querySelector(".lg-thumb"),"touchend.lg",function(){t.thumbTotalWidth>t.thumbOuterWidth&&o?(o=!1,utils.removeClass(t.thumbOuter,"lg-dragging"),Math.abs(i-e)'),utils.on(t.core.outer.querySelector(".lg-toggle-thumb"),"click.lg",function(){utils.hasClass(t.core.outer,"lg-thumb-open")?utils.removeClass(t.core.outer,"lg-thumb-open"):utils.addClass(t.core.outer,"lg-thumb-open")}))},i.prototype.thumbkeyPress=function(){var t=this;utils.on(window,"keydown.lgthumb",function(e){38===e.keyCode?(e.preventDefault(),utils.addClass(t.core.outer,"lg-thumb-open")):40===e.keyCode&&(e.preventDefault(),utils.removeClass(t.core.outer,"lg-thumb-open"))})},i.prototype.destroy=function(){if(this.core.s.thumbnail&&this.core.items.length>1){utils.off(window,".lgthumb"),this.thumbOuter.parentNode.removeChild(this.thumbOuter),utils.removeClass(this.core.outer,"lg-has-thumb");for(var t=document.getElementsByClassName("lg-script");t[0];)t[0].parentNode.removeChild(t[0])}},window.lgModules.thumbnail=i})},{}]},{},[1])(1)}); \ No newline at end of file diff --git a/ishtar_common/static/lightgallery/js/lg-zoom.js b/ishtar_common/static/lightgallery/js/lg-zoom.js new file mode 100644 index 000000000..369b0442e --- /dev/null +++ b/ishtar_common/static/lightgallery/js/lg-zoom.js @@ -0,0 +1,568 @@ +/**! + * lg-zoom.js | 1.0.1 | December 22nd 2016 + * http://sachinchoolur.github.io/lg-zoom.js + * Copyright (c) 2016 Sachin N; + * @license GPLv3 + */(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.LgZoom = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o 1) { + utils.addClass(_this.core.outer, 'lg-zoomed'); + } else { + _this.resetZoom(); + } + + if (scale < 1) { + scale = 1; + } + + zoom(scale); + }; + + var actualSize = function actualSize(event, image, index, fromIcon) { + var w = image.clientWidth; + var nw; + if (_this.core.s.dynamic) { + nw = _this.core.s.dynamicEl[index].width || image.naturalWidth || w; + } else { + nw = _this.core.items[index].getAttribute('data-width') || image.naturalWidth || w; + } + + var _scale; + + if (utils.hasClass(_this.core.outer, 'lg-zoomed')) { + scale = 1; + } else { + if (nw > w) { + _scale = nw / w; + scale = _scale || 2; + } + } + + if (fromIcon) { + _this.pageX = window.innerWidth / 2; + _this.pageY = window.innerHeight / 2 + (document.documentElement.scrollTop || document.body.scrollTop); + } else { + _this.pageX = event.pageX || event.targetTouches[0].pageX; + _this.pageY = event.pageY || event.targetTouches[0].pageY; + } + + callScale(); + setTimeout(function () { + utils.removeClass(_this.core.outer, 'lg-grabbing'); + utils.addClass(_this.core.outer, 'lg-grab'); + }, 10); + }; + + var tapped = false; + + // event triggered after appending slide content + utils.on(_this.core.el, 'onAferAppendSlide.lgtmzoom', function (event) { + + var index = event.detail.index; + + // Get the current element + var image = _this.core.___slide[index].querySelector('.lg-image'); + + if (!_this.core.isTouch) { + utils.on(image, 'dblclick', function (event) { + actualSize(event, image, index); + }); + } + + if (_this.core.isTouch) { + utils.on(image, '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 + utils.on(window, 'resize.lgzoom scroll.lgzoom orientationchange.lgzoom', function () { + _this.pageX = window.innerWidth / 2; + _this.pageY = window.innerHeight / 2 + (document.documentElement.scrollTop || document.body.scrollTop); + zoom(scale); + }); + + utils.on(document.getElementById('lg-zoom-out'), 'click.lg', function () { + if (_this.core.outer.querySelector('.lg-current .lg-image')) { + scale -= _this.core.s.scale; + callScale(); + } + }); + + utils.on(document.getElementById('lg-zoom-in'), 'click.lg', function () { + if (_this.core.outer.querySelector('.lg-current .lg-image')) { + scale += _this.core.s.scale; + callScale(); + } + }); + + utils.on(document.getElementById('lg-actual-size'), 'click.lg', function (event) { + actualSize(event, _this.core.___slide[_this.core.index].querySelector('.lg-image'), _this.core.index, true); + }); + + // Reset zoom on slide change + utils.on(_this.core.el, 'onBeforeSlide.lgtm', function () { + scale = 1; + _this.resetZoom(); + }); + + // Drag option after zoom + if (!_this.core.isTouch) { + _this.zoomDrag(); + } + + if (_this.core.isTouch) { + _this.zoomSwipe(); + } + }; + + // Reset zoom effect + Zoom.prototype.resetZoom = function () { + utils.removeClass(this.core.outer, 'lg-zoomed'); + for (var i = 0; i < this.core.___slide.length; i++) { + if (this.core.___slide[i].querySelector('.lg-img-wrap')) { + this.core.___slide[i].querySelector('.lg-img-wrap').removeAttribute('style'); + this.core.___slide[i].querySelector('.lg-img-wrap').removeAttribute('data-x'); + this.core.___slide[i].querySelector('.lg-img-wrap').removeAttribute('data-y'); + } + } + + for (var j = 0; j < this.core.___slide.length; j++) { + if (this.core.___slide[j].querySelector('.lg-image')) { + this.core.___slide[j].querySelector('.lg-image').removeAttribute('style'); + this.core.___slide[j].querySelector('.lg-image').removeAttribute('data-scale'); + } + } + + // Reset pagx pagy values to center + this.pageX = window.innerWidth / 2; + this.pageY = window.innerHeight / 2 + (document.documentElement.scrollTop || document.body.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; + + for (var i = 0; i < _this.core.___slide.length; i++) { + + /*jshint loopfunc: true */ + utils.on(_this.core.___slide[i], 'touchstart.lg', function (e) { + + if (utils.hasClass(_this.core.outer, 'lg-zoomed')) { + var image = _this.core.___slide[_this.core.index].querySelector('.lg-object'); + + allowY = image.offsetHeight * image.getAttribute('data-scale') > _this.core.outer.querySelector('.lg').clientHeight; + allowX = image.offsetWidth * image.getAttribute('data-scale') > _this.core.outer.querySelector('.lg').clientWidth; + if (allowX || allowY) { + e.preventDefault(); + startCoords = { + x: e.targetTouches[0].pageX, + y: e.targetTouches[0].pageY + }; + } + } + }); + } + + for (var j = 0; j < _this.core.___slide.length; j++) { + + /*jshint loopfunc: true */ + utils.on(_this.core.___slide[j], 'touchmove.lg', function (e) { + + if (utils.hasClass(_this.core.outer, 'lg-zoomed')) { + + var _el = _this.core.___slide[_this.core.index].querySelector('.lg-img-wrap'); + var distanceX; + var distanceY; + + e.preventDefault(); + isMoved = true; + + endCoords = { + x: e.targetTouches[0].pageX, + y: e.targetTouches[0].pageY + }; + + // reset opacity and transition duration + utils.addClass(_this.core.outer, 'lg-zoom-dragging'); + + if (allowY) { + distanceY = -Math.abs(_el.getAttribute('data-y')) + (endCoords.y - startCoords.y); + } else { + distanceY = -Math.abs(_el.getAttribute('data-y')); + } + + if (allowX) { + distanceX = -Math.abs(_el.getAttribute('data-x')) + (endCoords.x - startCoords.x); + } else { + distanceX = -Math.abs(_el.getAttribute('data-x')); + } + + if (Math.abs(endCoords.x - startCoords.x) > 15 || Math.abs(endCoords.y - startCoords.y) > 15) { + + if (_this.core.s.useLeftForZoom) { + _el.style.left = distanceX + 'px'; + _el.style.top = distanceY + 'px'; + } else { + utils.setVendor(_el, 'Transform', 'translate3d(' + distanceX + 'px, ' + distanceY + 'px, 0)'); + } + } + } + }); + } + + for (var k = 0; k < _this.core.___slide.length; k++) { + + /*jshint loopfunc: true */ + utils.on(_this.core.___slide[k], 'touchend.lg', function () { + if (utils.hasClass(_this.core.outer, 'lg-zoomed')) { + if (isMoved) { + isMoved = false; + utils.removeClass(_this.core.outer, '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; + + for (var i = 0; i < _this.core.___slide.length; i++) { + + /*jshint loopfunc: true */ + utils.on(_this.core.___slide[i], 'mousedown.lgzoom', function (e) { + + // execute only on .lg-object + var image = _this.core.___slide[_this.core.index].querySelector('.lg-object'); + + allowY = image.offsetHeight * image.getAttribute('data-scale') > _this.core.outer.querySelector('.lg').clientHeight; + allowX = image.offsetWidth * image.getAttribute('data-scale') > _this.core.outer.querySelector('.lg').clientWidth; + + if (utils.hasClass(_this.core.outer, 'lg-zoomed')) { + if (utils.hasClass(e.target, '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; + + utils.removeClass(_this.core.outer, 'lg-grab'); + utils.addClass(_this.core.outer, 'lg-grabbing'); + } + } + }); + } + + utils.on(window, 'mousemove.lgzoom', function (e) { + if (isDraging) { + var _el = _this.core.___slide[_this.core.index].querySelector('.lg-img-wrap'); + var distanceX; + var distanceY; + + isMoved = true; + endCoords = { + x: e.pageX, + y: e.pageY + }; + + // reset opacity and transition duration + utils.addClass(_this.core.outer, 'lg-zoom-dragging'); + + if (allowY) { + distanceY = -Math.abs(_el.getAttribute('data-y')) + (endCoords.y - startCoords.y); + } else { + distanceY = -Math.abs(_el.getAttribute('data-y')); + } + + if (allowX) { + distanceX = -Math.abs(_el.getAttribute('data-x')) + (endCoords.x - startCoords.x); + } else { + distanceX = -Math.abs(_el.getAttribute('data-x')); + } + + if (_this.core.s.useLeftForZoom) { + _el.style.left = distanceX + 'px'; + _el.style.top = distanceY + 'px'; + } else { + utils.setVendor(_el, 'Transform', 'translate3d(' + distanceX + 'px, ' + distanceY + 'px, 0)'); + } + } + }); + + utils.on(window, 'mouseup.lgzoom', function (e) { + + if (isDraging) { + isDraging = false; + utils.removeClass(_this.core.outer, '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; + } + + utils.removeClass(_this.core.outer, 'lg-grabbing'); + utils.addClass(_this.core.outer, 'lg-grab'); + }); + }; + + Zoom.prototype.touchendZoom = function (startCoords, endCoords, allowX, allowY) { + + var _this = this; + var _el = _this.core.___slide[_this.core.index].querySelector('.lg-img-wrap'); + var image = _this.core.___slide[_this.core.index].querySelector('.lg-object'); + var distanceX = -Math.abs(_el.getAttribute('data-x')) + (endCoords.x - startCoords.x); + var distanceY = -Math.abs(_el.getAttribute('data-y')) + (endCoords.y - startCoords.y); + var minY = (_this.core.outer.querySelector('.lg').clientHeight - image.offsetHeight) / 2; + var maxY = Math.abs(image.offsetHeight * Math.abs(image.getAttribute('data-scale')) - _this.core.outer.querySelector('.lg').clientHeight + minY); + var minX = (_this.core.outer.querySelector('.lg').clientWidth - image.offsetWidth) / 2; + var maxX = Math.abs(image.offsetWidth * Math.abs(image.getAttribute('data-scale')) - _this.core.outer.querySelector('.lg').clientWidth + 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.setAttribute('data-y', Math.abs(distanceY)); + } else { + distanceY = -Math.abs(_el.getAttribute('data-y')); + } + + if (allowX) { + _el.setAttribute('data-x', Math.abs(distanceX)); + } else { + distanceX = -Math.abs(_el.getAttribute('data-x')); + } + + if (_this.core.s.useLeftForZoom) { + _el.style.left = distanceX + 'px'; + _el.style.top = distanceY + 'px'; + } else { + utils.setVendor(_el, 'Transform', 'translate3d(' + distanceX + 'px, ' + distanceY + 'px, 0)'); + } + } + }; + + Zoom.prototype.destroy = function () { + + var _this = this; + + // Unbind all events added by lightGallery zoom plugin + utils.off(_this.core.el, '.lgzoom'); + utils.off(window, '.lgzoom'); + for (var i = 0; i < _this.core.___slide.length; i++) { + utils.off(_this.core.___slide[i], '.lgzoom'); + } + + utils.off(_this.core.el, '.lgtmzoom'); + _this.resetZoom(); + clearTimeout(_this.zoomabletimeout); + _this.zoomabletimeout = false; + }; + + window.lgModules.zoom = Zoom; +}); + +},{}]},{},[1])(1) +}); \ No newline at end of file diff --git a/ishtar_common/static/lightgallery/js/lg-zoom.min.js b/ishtar_common/static/lightgallery/js/lg-zoom.min.js new file mode 100644 index 000000000..004a9e73c --- /dev/null +++ b/ishtar_common/static/lightgallery/js/lg-zoom.min.js @@ -0,0 +1,7 @@ +/**! + * lg-zoom.js | 1.0.1 | December 22nd 2016 + * http://sachinchoolur.github.io/lg-zoom.js + * Copyright (c) 2016 Sachin N; + * @license GPLv3 + */ +!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.LgZoom=e()}}(function(){var e,t,o;return function e(t,o,r){function l(s,a){if(!o[s]){if(!t[s]){var n="function"==typeof require&&require;if(!a&&n)return n(s,!0);if(i)return i(s,!0);var u=new Error("Cannot find module '"+s+"'");throw u.code="MODULE_NOT_FOUND",u}var c=o[s]={exports:{}};t[s][0].call(c.exports,function(e){var o=t[s][1][e];return l(o?o:e)},c,c.exports,e,t,o,r)}return o[s].exports}for(var i="function"==typeof require&&require,s=0;s';e.core.s.actualSize&&(t+=''),e.core.s.useLeftForZoom?utils.addClass(e.core.outer,"lg-use-left-for-zoom"):utils.addClass(e.core.outer,"lg-use-transition-for-zoom"),this.core.outer.querySelector(".lg-toolbar").insertAdjacentHTML("beforeend",t),utils.on(e.core.el,"onSlideItemLoad.lgtmzoom",function(t){var o=e.core.s.enableZoomAfter+t.detail.delay;utils.hasClass(document.body,"lg-from-hash")&&t.detail.delay?o=0:utils.removeClass(document.body,"lg-from-hash"),e.zoomabletimeout=setTimeout(function(){utils.addClass(e.core.___slide[t.detail.index],"lg-zoomable")},o+30)});var o=1,r=function t(o){var r=e.core.outer.querySelector(".lg-current .lg-image"),l,i,s=(window.innerWidth-r.clientWidth)/2,a=(window.innerHeight-r.clientHeight)/2+(document.documentElement.scrollTop||document.body.scrollTop);l=e.pageX-s,i=e.pageY-a;var n=(o-1)*l,u=(o-1)*i;utils.setVendor(r,"Transform","scale3d("+o+", "+o+", 1)"),r.setAttribute("data-scale",o),e.core.s.useLeftForZoom?(r.parentElement.style.left=-n+"px",r.parentElement.style.top=-u+"px"):utils.setVendor(r.parentElement,"Transform","translate3d(-"+n+"px, -"+u+"px, 0)"),r.parentElement.setAttribute("data-x",n),r.parentElement.setAttribute("data-y",u)},l=function t(){o>1?utils.addClass(e.core.outer,"lg-zoomed"):e.resetZoom(),o<1&&(o=1),r(o)},i=function t(r,i,s,a){var n=i.clientWidth,u;u=e.core.s.dynamic?e.core.s.dynamicEl[s].width||i.naturalWidth||n:e.core.items[s].getAttribute("data-width")||i.naturalWidth||n;var c;utils.hasClass(e.core.outer,"lg-zoomed")?o=1:u>n&&(c=u/n,o=c||2),a?(e.pageX=window.innerWidth/2,e.pageY=window.innerHeight/2+(document.documentElement.scrollTop||document.body.scrollTop)):(e.pageX=r.pageX||r.targetTouches[0].pageX,e.pageY=r.pageY||r.targetTouches[0].pageY),l(),setTimeout(function(){utils.removeClass(e.core.outer,"lg-grabbing"),utils.addClass(e.core.outer,"lg-grab")},10)},s=!1;utils.on(e.core.el,"onAferAppendSlide.lgtmzoom",function(t){var o=t.detail.index,r=e.core.___slide[o].querySelector(".lg-image");e.core.isTouch||utils.on(r,"dblclick",function(e){i(e,r,o)}),e.core.isTouch&&utils.on(r,"touchstart",function(e){s?(clearTimeout(s),s=null,i(e,r,o)):s=setTimeout(function(){s=null},300),e.preventDefault()})}),utils.on(window,"resize.lgzoom scroll.lgzoom orientationchange.lgzoom",function(){e.pageX=window.innerWidth/2,e.pageY=window.innerHeight/2+(document.documentElement.scrollTop||document.body.scrollTop),r(o)}),utils.on(document.getElementById("lg-zoom-out"),"click.lg",function(){e.core.outer.querySelector(".lg-current .lg-image")&&(o-=e.core.s.scale,l())}),utils.on(document.getElementById("lg-zoom-in"),"click.lg",function(){e.core.outer.querySelector(".lg-current .lg-image")&&(o+=e.core.s.scale,l())}),utils.on(document.getElementById("lg-actual-size"),"click.lg",function(t){i(t,e.core.___slide[e.core.index].querySelector(".lg-image"),e.core.index,!0)}),utils.on(e.core.el,"onBeforeSlide.lgtm",function(){o=1,e.resetZoom()}),e.core.isTouch||e.zoomDrag(),e.core.isTouch&&e.zoomSwipe()},r.prototype.resetZoom=function(){utils.removeClass(this.core.outer,"lg-zoomed");for(var e=0;ee.core.outer.querySelector(".lg").clientHeight,l=r.offsetWidth*r.getAttribute("data-scale")>e.core.outer.querySelector(".lg").clientWidth,(l||i)&&(o.preventDefault(),t={x:o.targetTouches[0].pageX,y:o.targetTouches[0].pageY})}});for(var a=0;a15||Math.abs(o.y-t.y)>15)&&(e.core.s.useLeftForZoom?(a.style.left=n+"px",a.style.top=u+"px"):utils.setVendor(a,"Transform","translate3d("+n+"px, "+u+"px, 0)"))}});for(var n=0;ne.core.outer.querySelector(".lg").clientHeight,i=l.offsetWidth*l.getAttribute("data-scale")>e.core.outer.querySelector(".lg").clientWidth,utils.hasClass(e.core.outer,"lg-zoomed")&&utils.hasClass(o.target,"lg-object")&&(i||s)&&(o.preventDefault(),t={x:o.pageX,y:o.pageY},r=!0,e.core.outer.scrollLeft+=1,e.core.outer.scrollLeft-=1,utils.removeClass(e.core.outer,"lg-grab"),utils.addClass(e.core.outer,"lg-grabbing"))});utils.on(window,"mousemove.lgzoom",function(a){if(r){var n=e.core.___slide[e.core.index].querySelector(".lg-img-wrap"),u,c;l=!0,o={x:a.pageX,y:a.pageY},utils.addClass(e.core.outer,"lg-zoom-dragging"),c=s?-Math.abs(n.getAttribute("data-y"))+(o.y-t.y):-Math.abs(n.getAttribute("data-y")),u=i?-Math.abs(n.getAttribute("data-x"))+(o.x-t.x):-Math.abs(n.getAttribute("data-x")),e.core.s.useLeftForZoom?(n.style.left=u+"px",n.style.top=c+"px"):utils.setVendor(n,"Transform","translate3d("+u+"px, "+c+"px, 0)")}}),utils.on(window,"mouseup.lgzoom",function(a){r&&(r=!1,utils.removeClass(e.core.outer,"lg-zoom-dragging"),!l||t.x===o.x&&t.y===o.y||(o={x:a.pageX,y:a.pageY},e.touchendZoom(t,o,i,s)),l=!1),utils.removeClass(e.core.outer,"lg-grabbing"),utils.addClass(e.core.outer,"lg-grab")})},r.prototype.touchendZoom=function(e,t,o,r){var l=this,i=l.core.___slide[l.core.index].querySelector(".lg-img-wrap"),s=l.core.___slide[l.core.index].querySelector(".lg-object"),a=-Math.abs(i.getAttribute("data-x"))+(t.x-e.x),n=-Math.abs(i.getAttribute("data-y"))+(t.y-e.y),u=(l.core.outer.querySelector(".lg").clientHeight-s.offsetHeight)/2,c=Math.abs(s.offsetHeight*Math.abs(s.getAttribute("data-scale"))-l.core.outer.querySelector(".lg").clientHeight+u),d=(l.core.outer.querySelector(".lg").clientWidth-s.offsetWidth)/2,g=Math.abs(s.offsetWidth*Math.abs(s.getAttribute("data-scale"))-l.core.outer.querySelector(".lg").clientWidth+d);(Math.abs(t.x-e.x)>15||Math.abs(t.y-e.y)>15)&&(r&&(n<=-c?n=-c:n>=-u&&(n=-u)),o&&(a<=-g?a=-g:a>=-d&&(a=-d)),r?i.setAttribute("data-y",Math.abs(n)):n=-Math.abs(i.getAttribute("data-y")),o?i.setAttribute("data-x",Math.abs(a)):a=-Math.abs(i.getAttribute("data-x")),l.core.s.useLeftForZoom?(i.style.left=a+"px",i.style.top=n+"px"):utils.setVendor(i,"Transform","translate3d("+a+"px, "+n+"px, 0)"))},r.prototype.destroy=function(){var e=this;utils.off(e.core.el,".lgzoom"),utils.off(window,".lgzoom");for(var t=0;t