2020-01-06 16:41:38 +00:00
|
|
|
<div class="modal micromodal-slide" id="modal" aria-hidden="true">
|
|
|
|
<div class="modal__overlay" tabindex="-1" data-micromodal-close>
|
|
|
|
<div class="modal__container" role="dialog" aria-modal="true" aria-labelledby="modal-title">
|
|
|
|
|
|
|
|
<div class="modal__content" id="modal-content">
|
|
|
|
<div id="mySwipe" class="swipe">
|
|
|
|
<div class="swipe-wrap">
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2019-12-11 02:18:44 +00:00
|
|
|
|
2020-01-06 16:41:38 +00:00
|
|
|
<span class="modal__items">
|
|
|
|
|
|
|
|
<span class="modal__header">
|
|
|
|
<div class="modal__paging" title="Page Info" aria-label="Current Page">
|
|
|
|
</div>
|
|
|
|
<div class="modal__icon modal__toolbar modal__toolbar--close" title="Close" aria-label="Close Button" data-micromodal-close>
|
|
|
|
{{ partial "svgs/etc/close.svg" (dict "width" 25 "height" 25) }}
|
|
|
|
</div>
|
|
|
|
<div class="modal__icon modal__toolbar modal__toolbar--full" title="Full Screen" aria-label="Full Screen Button">
|
|
|
|
{{ partial "svgs/etc/full-screen.svg" (dict "width" 25 "height" 25) }}
|
|
|
|
</div>
|
|
|
|
<div class="modal__icon modal__toolbar modal__toolbar--normal" title="Normal Screen" aria-label="Normal Screen Button">
|
|
|
|
{{ partial "svgs/etc/normal-screen.svg" (dict "width" 25 "height" 25) }}
|
|
|
|
</div>
|
|
|
|
</span>
|
|
|
|
|
|
|
|
<div class="modal__icon modal__arrow modal__arrow--left" title="Arrow Left" aria-label="Arrow Left Button">
|
|
|
|
{{ partial "svgs/arrow/arrow-left.svg" (dict "width" 28 "height" 28) }}
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="modal__icon modal__arrow modal__arrow--right" title="Arrow Right" aria-label="Arrow Right Button">
|
2019-12-11 02:18:44 +00:00
|
|
|
|
2020-01-06 16:41:38 +00:00
|
|
|
{{ partial "svgs/arrow/arrow-right.svg" (dict "width" 28 "height" 28) }}
|
|
|
|
</div>
|
2019-12-11 02:18:44 +00:00
|
|
|
|
2020-01-06 16:41:38 +00:00
|
|
|
<div class="modal__caption">
|
|
|
|
<div class="modal__caption--text">
|
|
|
|
</div>
|
|
|
|
</div>
|
2019-12-11 02:18:44 +00:00
|
|
|
|
2020-01-06 16:41:38 +00:00
|
|
|
</span>
|
2019-12-11 02:18:44 +00:00
|
|
|
</div>
|
2020-01-06 16:41:38 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2019-12-11 02:18:44 +00:00
|
|
|
|
2020-01-06 16:41:38 +00:00
|
|
|
{{ $swipe := resources.Get "js/swipe.js" | resources.Minify | resources.Fingerprint }}
|
|
|
|
<script defer src="{{ $swipe.RelPermalink }}"></script>
|
|
|
|
{{ $micromodal := resources.Get "js/micromodal.min.js" | resources.Fingerprint }}
|
|
|
|
<script defer src="{{ $micromodal.RelPermalink }}"></script>
|
|
|
|
{{ $fadeinout := resources.Get "js/helper/fadeinout.js" | resources.Minify }}
|
|
|
|
<script defer src="{{ $fadeinout.RelPermalink }}"></script>
|
2019-12-11 02:18:44 +00:00
|
|
|
|
2020-01-06 16:41:38 +00:00
|
|
|
<script>
|
|
|
|
document.addEventListener('DOMContentLoaded', function () {
|
|
|
|
// ============================ gallery ============================
|
|
|
|
/* Get the documentElement (<html>) to display the page in fullscreen */
|
|
|
|
var docElem = document.documentElement;
|
2019-12-11 02:18:44 +00:00
|
|
|
|
2020-01-06 16:41:38 +00:00
|
|
|
/* View in fullscreen */
|
|
|
|
function openFullscreen() {
|
|
|
|
if (docElem.requestFullscreen) {
|
|
|
|
docElem.requestFullscreen();
|
|
|
|
} else if (docElem.mozRequestFullScreen) { /* Firefox */
|
|
|
|
docElem.mozRequestFullScreen();
|
|
|
|
} else if (docElem.webkitRequestFullscreen) { /* Chrome, Safari and Opera */
|
|
|
|
docElem.webkitRequestFullscreen();
|
|
|
|
} else if (docElem.msRequestFullscreen) { /* IE/Edge */
|
|
|
|
docElem.msRequestFullscreen();
|
|
|
|
}
|
|
|
|
}
|
2019-12-11 02:18:44 +00:00
|
|
|
|
2020-01-06 16:41:38 +00:00
|
|
|
/* Close fullscreen */
|
|
|
|
function closeFullscreen() {
|
|
|
|
if (document.fullscreenElement ||
|
|
|
|
document.webkitFullscreenElement ||
|
|
|
|
document.mozFullScreenElement) {
|
|
|
|
if (document.exitFullscreen) {
|
|
|
|
document.exitFullscreen();
|
|
|
|
} else if (document.mozCancelFullScreen) { /* Firefox */
|
|
|
|
document.mozCancelFullScreen();
|
|
|
|
} else if (document.webkitExitFullscreen) { /* Chrome, Safari and Opera */
|
|
|
|
document.webkitExitFullscreen();
|
|
|
|
} else if (document.msExitFullscreen) { /* IE/Edge */
|
|
|
|
document.msExitFullscreen();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-12-11 02:18:44 +00:00
|
|
|
|
2020-01-12 14:31:32 +00:00
|
|
|
var modal = document.getElementById('modal');
|
2020-01-17 07:16:39 +00:00
|
|
|
var galleryContainerElem = document.querySelector('.gallery__container');
|
2020-01-06 16:41:38 +00:00
|
|
|
var swipeWrapElem = document.querySelector('.swipe-wrap');
|
|
|
|
var mySwipeElem = document.getElementById('mySwipe');
|
|
|
|
var arrowLeftElem = document.querySelector('.modal__arrow--left');
|
|
|
|
var arrowRightElem = document.querySelector('.modal__arrow--right');
|
|
|
|
var closeElem = document.querySelector('.modal__toolbar--close');
|
|
|
|
var fullElem = document.querySelector('.modal__toolbar--full');
|
|
|
|
var normalElem = document.querySelector('.modal__toolbar--normal');
|
|
|
|
var captionElem = document.querySelector('.modal__caption');
|
|
|
|
var pagingElem = document.querySelector('.modal__paging');
|
|
|
|
var itemsElem = document.querySelector('.modal__items');
|
2020-01-17 07:16:39 +00:00
|
|
|
var imgTotalNum = null;
|
2020-01-06 16:41:38 +00:00
|
|
|
var myFadeTimeout = null;
|
|
|
|
var mySwipe = null;
|
|
|
|
var keydownFunction = function (e) {
|
|
|
|
if (e.key === 'ArrowRight') {
|
2020-01-12 14:31:32 +00:00
|
|
|
if (modal && modal.classList.contains('is-open')) {
|
|
|
|
mySwipe.next();
|
|
|
|
}
|
2020-01-06 16:41:38 +00:00
|
|
|
} else if (e.key === 'ArrowLeft') {
|
2020-01-12 14:31:32 +00:00
|
|
|
if (modal && modal.classList.contains('is-open')) {
|
|
|
|
mySwipe.prev();
|
|
|
|
}
|
2020-01-06 16:41:38 +00:00
|
|
|
}
|
|
|
|
}
|
2019-12-11 02:18:44 +00:00
|
|
|
|
2020-01-17 07:16:39 +00:00
|
|
|
if (galleryContainerElem) {
|
|
|
|
imgTotalNum = galleryContainerElem.querySelectorAll('img').length;
|
|
|
|
} else {
|
|
|
|
galleryContainerElem = document.querySelector('.single__contents');
|
|
|
|
imgTotalNum = galleryContainerElem.querySelectorAll('img').length;
|
|
|
|
}
|
|
|
|
|
2020-01-06 16:41:38 +00:00
|
|
|
MicroModal.init({
|
|
|
|
onClose: () => {
|
|
|
|
if (mySwipe) {
|
|
|
|
mySwipe.kill();
|
|
|
|
mySwipe = null;
|
|
|
|
closeFullscreen();
|
|
|
|
}
|
|
|
|
window.removeEventListener('keydown', keydownFunction);
|
|
|
|
},
|
|
|
|
disableScroll: true,
|
|
|
|
disableFocus: true,
|
|
|
|
awaitOpenAnimation: false,
|
|
|
|
awaitCloseAnimation: false,
|
|
|
|
debugMode: false,
|
|
|
|
});
|
2019-12-11 02:18:44 +00:00
|
|
|
|
2020-01-07 17:05:51 +00:00
|
|
|
var imageLoad = function(src) {
|
|
|
|
return new Promise(function(resolve, reject) {
|
|
|
|
var newImg = new Image;
|
|
|
|
newImg.onload = function() {
|
|
|
|
resolve(newImg);
|
|
|
|
}
|
|
|
|
newImg.onerror = reject;
|
|
|
|
newImg.src = src;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-01-17 07:16:39 +00:00
|
|
|
galleryContainerElem.querySelectorAll('img').forEach(function (elem, idx) {
|
2020-01-06 16:41:38 +00:00
|
|
|
elem.style.cursor = 'pointer';
|
2019-12-11 02:18:44 +00:00
|
|
|
|
2020-01-06 16:41:38 +00:00
|
|
|
var clonedElem = elem.cloneNode(true);
|
2020-01-07 17:05:51 +00:00
|
|
|
clonedElem.style.maxHeight = '100%';
|
|
|
|
clonedElem.style.maxWidth = '100%';
|
2020-01-06 16:41:38 +00:00
|
|
|
clonedElem.onclick = function (e) {
|
|
|
|
e.stopPropagation();
|
|
|
|
}
|
2019-12-11 02:18:44 +00:00
|
|
|
|
2020-01-06 16:41:38 +00:00
|
|
|
var wrapper = document.createElement('div');
|
|
|
|
wrapper.style.width = '100%';
|
|
|
|
wrapper.style.height = '100vh';
|
|
|
|
wrapper.setAttribute('data-micromodal-close', '');
|
|
|
|
wrapper.onclick = function () {
|
|
|
|
if (mySwipe) {
|
|
|
|
mySwipe.kill();
|
|
|
|
mySwipe = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
wrapper.onmouseenter = function () {
|
|
|
|
clearTimeout(myFadeTimeout);
|
|
|
|
fadeIn(itemsElem, 200);
|
|
|
|
};
|
|
|
|
wrapper.onmouseleave = function () {
|
|
|
|
myFadeTimeout = setTimeout(function () {
|
|
|
|
fadeOut(itemsElem, 200);
|
2020-01-07 17:05:51 +00:00
|
|
|
}, 2500);
|
2020-01-06 16:41:38 +00:00
|
|
|
}
|
2020-01-22 08:31:10 +00:00
|
|
|
wrapper.ontouchstart = function() {
|
|
|
|
fadeIn(itemsElem, 200);
|
|
|
|
}
|
2020-01-06 16:41:38 +00:00
|
|
|
wrapper.append(clonedElem);
|
|
|
|
swipeWrapElem.append(wrapper);
|
2019-12-11 02:18:44 +00:00
|
|
|
|
2020-01-07 17:05:51 +00:00
|
|
|
elem.addEventListener('click', async function (e) {
|
2020-01-06 16:41:38 +00:00
|
|
|
MicroModal.show('modal');
|
|
|
|
if (mySwipe) {
|
|
|
|
mySwipe.kill();
|
|
|
|
mySwipe = null;
|
|
|
|
}
|
2019-12-11 02:18:44 +00:00
|
|
|
|
2020-01-07 17:05:51 +00:00
|
|
|
var imgSrc = e.target.getAttribute('data-src') || e.target.getAttribute('src');
|
|
|
|
var img = await imageLoad(imgSrc);
|
|
|
|
clonedElem.style.width = img.width + 'px';
|
|
|
|
clonedElem.style.height = img.height + 'px';
|
|
|
|
|
2020-01-06 16:41:38 +00:00
|
|
|
// swipe initialize
|
|
|
|
mySwipe = new Swipe(mySwipeElem, {
|
|
|
|
startSlide: idx,
|
|
|
|
draggable: true,
|
|
|
|
autoRestart: false,
|
|
|
|
continuous: false,
|
|
|
|
disableScroll: true,
|
|
|
|
stopPropagation: true,
|
2020-01-07 17:05:51 +00:00
|
|
|
callback: async function (index, element) {
|
|
|
|
// original image size
|
2020-01-06 16:41:38 +00:00
|
|
|
var imgElem = element.querySelector('img');
|
2020-01-07 17:05:51 +00:00
|
|
|
var imgSrc = imgElem.getAttribute('data-src') || imgElem.getAttribute('src');
|
|
|
|
var img = await imageLoad(imgSrc);
|
|
|
|
imgElem.style.width = img.width + 'px';
|
|
|
|
imgElem.style.height = img.height + 'px';
|
|
|
|
|
|
|
|
// caption
|
2020-01-06 16:41:38 +00:00
|
|
|
if (captionElem && imgElem) {
|
|
|
|
var caption = null;
|
|
|
|
if (imgElem.getAttribute('data-caption')) {
|
|
|
|
caption = imgElem.getAttribute('data-caption');
|
|
|
|
} else if (imgElem.getAttribute('title')) {
|
|
|
|
caption = imgElem.getAttribute('title');
|
|
|
|
} else if (imgElem.getAttribute('alt')) {
|
|
|
|
caption = imgElem.getAttribute('alt');
|
|
|
|
} else {
|
|
|
|
caption = imgElem.getAttribute('src');
|
|
|
|
}
|
2019-12-11 02:18:44 +00:00
|
|
|
|
2020-01-06 16:41:38 +00:00
|
|
|
captionElem.querySelector('.modal__caption--text').innerText = caption;
|
|
|
|
pagingElem.innerText = (index + 1) + ' / ' + imgTotalNum;
|
2020-01-07 17:05:51 +00:00
|
|
|
|
|
|
|
clearTimeout(myFadeTimeout);
|
|
|
|
fadeIn(itemsElem, 200);
|
2020-01-06 16:41:38 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
});
|
2019-12-11 02:18:44 +00:00
|
|
|
|
2020-01-06 16:41:38 +00:00
|
|
|
fadeIn(itemsElem);
|
2019-12-11 02:18:44 +00:00
|
|
|
|
2020-01-06 16:41:38 +00:00
|
|
|
// caption
|
|
|
|
if (captionElem) {
|
|
|
|
var caption = null;
|
|
|
|
if (e.target.getAttribute('data-caption')) {
|
|
|
|
caption = e.target.getAttribute('data-caption');
|
|
|
|
} else if (e.target.getAttribute('title')) {
|
|
|
|
caption = e.target.getAttribute('title');
|
|
|
|
} else if (e.target.getAttribute('alt')) {
|
|
|
|
caption = e.target.getAttribute('alt');
|
|
|
|
} else {
|
|
|
|
caption = e.target.getAttribute('src');
|
|
|
|
}
|
2019-12-11 02:18:44 +00:00
|
|
|
|
2020-01-06 16:41:38 +00:00
|
|
|
captionElem.querySelector('.modal__caption--text').innerText = caption;
|
|
|
|
pagingElem.innerText = (idx + 1) + ' / ' + imgTotalNum;
|
|
|
|
}
|
2019-12-11 02:18:44 +00:00
|
|
|
|
2020-01-06 16:41:38 +00:00
|
|
|
if (normalElem && fullElem) {
|
|
|
|
normalElem.style.zIndex = -1;
|
|
|
|
normalElem.style.opacity = 0;
|
|
|
|
fullElem.style.zIndex = 25;
|
|
|
|
fullElem.style.opacity = 1;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
window.addEventListener('keydown', keydownFunction);
|
|
|
|
});
|
|
|
|
|
|
|
|
arrowLeftElem ?
|
2020-01-07 17:05:51 +00:00
|
|
|
arrowLeftElem.addEventListener('click', function (e) {
|
2020-01-06 16:41:38 +00:00
|
|
|
if (mySwipe) {
|
|
|
|
mySwipe.prev();
|
|
|
|
}
|
|
|
|
}) : null;
|
|
|
|
arrowRightElem ?
|
2020-01-07 17:05:51 +00:00
|
|
|
arrowRightElem.addEventListener('click', function (e) {
|
2020-01-06 16:41:38 +00:00
|
|
|
if (mySwipe) {
|
|
|
|
mySwipe.next();
|
|
|
|
}
|
|
|
|
}) : null;
|
|
|
|
|
|
|
|
closeElem ?
|
|
|
|
closeElem.addEventListener('click', function () {
|
|
|
|
if (mySwipe) {
|
|
|
|
mySwipe.kill();
|
|
|
|
mySwipe = null;
|
|
|
|
}
|
|
|
|
closeFullscreen();
|
|
|
|
MicroModal.close('modal');
|
|
|
|
}) : null;
|
|
|
|
|
|
|
|
fullElem ?
|
|
|
|
fullElem.addEventListener('click', function (e) {
|
|
|
|
openFullscreen();
|
|
|
|
if (normalElem) {
|
|
|
|
normalElem.style.zIndex = 25;
|
|
|
|
normalElem.style.opacity = 1;
|
|
|
|
fullElem.style.zIndex = -1;
|
|
|
|
fullElem.style.opacity = 0;
|
|
|
|
}
|
|
|
|
}) : null;
|
2019-12-11 02:18:44 +00:00
|
|
|
|
2020-01-06 16:41:38 +00:00
|
|
|
normalElem ?
|
|
|
|
normalElem.addEventListener('click', function (e) {
|
|
|
|
closeFullscreen();
|
|
|
|
if (fullElem) {
|
|
|
|
fullElem.style.zIndex = 25;
|
|
|
|
fullElem.style.opacity = 1;
|
|
|
|
normalElem.style.zIndex = -1;
|
|
|
|
normalElem.style.opacity = 0;
|
|
|
|
}
|
|
|
|
}) : null;
|
|
|
|
// =================================================================
|
|
|
|
});
|
|
|
|
</script>
|