diff --git a/package-lock.json b/package-lock.json index 9a5e2f247..30956b6c7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4886,7 +4886,8 @@ }, "ini": { "version": "1.3.5", - "resolved": "", + "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz", + "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==", "dev": true, "optional": true }, diff --git a/src/assets/css/tainacan-gutenberg-block-item-gallery.css b/src/assets/css/tainacan-gutenberg-block-item-gallery.css index 3e202a5fe..6618c94fb 100644 --- a/src/assets/css/tainacan-gutenberg-block-item-gallery.css +++ b/src/assets/css/tainacan-gutenberg-block-item-gallery.css @@ -290,114 +290,137 @@ .tainacan-media-component__swiper-main + .tainacan-media-component__swiper-thumbs li.swiper-slide { cursor: pointer; } -.tainacan-photoswipe-layer .pswp__bg { - background-color: rgba(0, 0, 0, 0.85); } -.tainacan-photoswipe-layer .pswp__ui--fit .pswp__top-bar, -.tainacan-photoswipe-layer .pswp__ui--fit .pswp__caption { - background-color: rgba(0, 0, 0, 0.7); } -.tainacan-photoswipe-layer .pswp__button--arrow--left::before, -.tainacan-photoswipe-layer .pswp__button--arrow--right::before { - background-color: transparent; } -.tainacan-photoswipe-layer .pswp__container { - width: 100%; - height: 100%; - display: flex; - align-items: center; - justify-content: center; } - .tainacan-photoswipe-layer .pswp__container .attachment-without-image { +.tainacan-photoswipe-layer { + --pswp-bg: var(--tainacan-lightbox-background, #000); + --pswp-error-text-color: var(--tainacan-lightbox-text-color, #f7f7f7); + --pswp-icon-color: var(--tainacan-lightbox-text-color, #fff); } + .tainacan-photoswipe-layer .pswp__caption { + bottom: 0; + position: fixed; + padding: 8px; width: 100%; - height: calc(100% - 44px); display: flex; - justify-content: center; - align-items: center; + justify-content: center; } + .tainacan-photoswipe-layer .pswp__caption-inner { + opacity: 0.75; + background-color: var(--pswp-bg); + color: var(--pswp-icon-color); + text-shadow: 1px 1px 3px var(--pswp-icon-color-secondary); + max-width: 920px; + padding: 12px; + line-height: 20px; text-align: center; - padding: 44px; - margin-top: 22px; - margin-bottom: 22px; } - .tainacan-photoswipe-layer .pswp__container .attachment-without-image > iframe:not(.wp-embedded-content) { + font-size: 1em; + border-radius: 3px; + transition: opacity 0.4s ease; } + .tainacan-photoswipe-layer .pswp__caption-inner:hover { + opacity: 1.0; } + .tainacan-photoswipe-layer.pswp--zoomed-in .pswp__caption-inner { + opacity: 0.0; } + .tainacan-photoswipe-layer .pswp__button--arrow--left::before, + .tainacan-photoswipe-layer .pswp__button--arrow--right::before { + background-color: transparent; } + .tainacan-photoswipe-layer .pswp__container { + width: 100%; + height: 100%; + display: flex; + align-items: center; + justify-content: center; } + .tainacan-photoswipe-layer .pswp__container .attachment-without-image { + width: 100%; + height: calc(100% - 44px); + display: flex; + justify-content: center; + align-items: center; + text-align: center; + padding: 44px; + margin-top: 22px; + margin-bottom: 22px; } + .tainacan-photoswipe-layer .pswp__container .attachment-without-image > iframe:not(.wp-embedded-content) { + width: 90vw; + height: 90vh; + border: none; + margin: 44px; + display: block; + background-image: url("../images/preloader.gif"); + background-repeat: no-repeat; + background-position: center; } + .tainacan-photoswipe-layer .pswp__container .pswp__zoom-wrap > iframe#iframePDF { width: 90vw; height: 90vh; border: none; - margin: 44px; + margin: 44px auto; display: block; background-image: url("../images/preloader.gif"); background-repeat: no-repeat; background-position: center; } - .tainacan-photoswipe-layer .pswp__container .pswp__zoom-wrap > iframe#iframePDF { - width: 90vw; - height: 90vh; - border: none; - margin: 44px auto; + .tainacan-photoswipe-layer .pswp__container .pswp__zoom-wrap { + display: flex; + justify-content: center; + align-items: center; } + .tainacan-photoswipe-layer .pswp__container .tainacan-content-embed { + width: 100%; + height: auto; } + .tainacan-photoswipe-layer .pswp__container .tainacan-content-embed.tainacan-has-aspect-ratio { + max-width: calc((90vh * 2) / 1); + /* Default to 2:1 aspect ratio. */ + margin-left: auto; + margin-right: auto; } + .tainacan-photoswipe-layer .pswp__container .tainacan-content-embed.tainacan-embed-aspect-21-9 { + max-width: calc((90vh * 21) / 9); } + .tainacan-photoswipe-layer .pswp__container .tainacan-content-embed.tainacan-embed-aspect-18-9 { + max-width: calc((90vh * 18) / 9); } + .tainacan-photoswipe-layer .pswp__container .tainacan-content-embed.tainacan-embed-aspect-16-9 { + max-width: calc((90vh * 16) / 9); } + .tainacan-photoswipe-layer .pswp__container .tainacan-content-embed.tainacan-embed-aspect-4-3 { + max-width: calc((90vh * 4) / 3); } + .tainacan-photoswipe-layer .pswp__container .tainacan-content-embed.tainacan-embed-aspect-1-1 { + max-width: 90vh; } + .tainacan-photoswipe-layer .pswp__container .tainacan-content-embed.tainacan-embed-aspect-9-16 { + max-width: calc((90vh * 9) / 16); } + .tainacan-photoswipe-layer .pswp__container .tainacan-content-embed.tainacan-embed-aspect-1-2 { + max-width: calc((90vh * 1) / 2); } + .tainacan-photoswipe-layer .pswp__container a:first-of-type, + .tainacan-photoswipe-layer .pswp__container p:first-of-type, + .tainacan-photoswipe-layer .pswp__container article:first-of-type { + z-index: 99; + padding: 1rem 4.33337vw; + background: var(--tainacan-media-background, #ffffff); + border-radius: 3px; + word-wrap: break-word; } + .tainacan-photoswipe-layer .pswp__container audio { + background: black; + min-height: 38px; + border-radius: 20px; + min-width: 80%; + max-width: 80%; } + .tainacan-photoswipe-layer .pswp__container video { + min-height: 56px; + max-width: 80%; } + .tainacan-photoswipe-layer .pswp__top-bar .pswp__name { + color: var(--pswp-icon-color); + text-shadow: 1px 1px 3px var(--pswp-icon-color-secondary); + text-align: center; + font-size: 1.125em; display: block; - background-image: url("../images/preloader.gif"); - background-repeat: no-repeat; - background-position: center; } - .tainacan-photoswipe-layer .pswp__container .pswp__zoom-wrap { - display: flex; - justify-content: center; - align-items: center; } - .tainacan-photoswipe-layer .pswp__container .tainacan-content-embed { + height: 44px; + max-width: calc(100% - 240px); width: 100%; - height: auto; } - .tainacan-photoswipe-layer .pswp__container .tainacan-content-embed.tainacan-has-aspect-ratio { - max-width: calc((90vh * 2) / 1); - /* Default to 2:1 aspect ratio. */ - margin-left: auto; - margin-right: auto; } - .tainacan-photoswipe-layer .pswp__container .tainacan-content-embed.tainacan-embed-aspect-21-9 { - max-width: calc((90vh * 21) / 9); } - .tainacan-photoswipe-layer .pswp__container .tainacan-content-embed.tainacan-embed-aspect-18-9 { - max-width: calc((90vh * 18) / 9); } - .tainacan-photoswipe-layer .pswp__container .tainacan-content-embed.tainacan-embed-aspect-16-9 { - max-width: calc((90vh * 16) / 9); } - .tainacan-photoswipe-layer .pswp__container .tainacan-content-embed.tainacan-embed-aspect-4-3 { - max-width: calc((90vh * 4) / 3); } - .tainacan-photoswipe-layer .pswp__container .tainacan-content-embed.tainacan-embed-aspect-1-1 { - max-width: 90vh; } - .tainacan-photoswipe-layer .pswp__container .tainacan-content-embed.tainacan-embed-aspect-9-16 { - max-width: calc((90vh * 9) / 16); } - .tainacan-photoswipe-layer .pswp__container .tainacan-content-embed.tainacan-embed-aspect-1-2 { - max-width: calc((90vh * 1) / 2); } - .tainacan-photoswipe-layer .pswp__container a:first-of-type, - .tainacan-photoswipe-layer .pswp__container p:first-of-type, - .tainacan-photoswipe-layer .pswp__container article:first-of-type { - z-index: 99; - padding: 1rem 4.33337vw; - background: var(--tainacan-media-background, #ffffff); - border-radius: var(--borderRadius, 3px); - word-wrap: break-word; } - .tainacan-photoswipe-layer .pswp__container audio { - background: black; - min-height: 38px; - border-radius: 20px; - min-width: 80%; - max-width: 80%; } - .tainacan-photoswipe-layer .pswp__container video { - min-height: 56px; - max-width: 80%; } -.tainacan-photoswipe-layer .pswp__top-bar .pswp__name { - color: white; - text-align: center; - font-size: 1.125em; - display: block; - height: 44px; - max-width: calc(100% - 240px); - width: 100%; - left: 44px; - position: absolute; - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; - line-height: 44px; - padding: 0 10px; } -.tainacan-photoswipe-layer .pswp__figure_caption { - font-size: 0.875em; - font-style: italic; } -.tainacan-photoswipe-layer .pswp__description { - font-size: 0.9375em; } -.tainacan-photoswipe-layer .pswp__caption__center { - text-align: center; - font-size: 1em; - max-width: 800px; } + left: 44px; + position: absolute; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + line-height: 44px; + padding: 0 10px; } + .tainacan-photoswipe-layer .pswp__figure_caption { + font-size: 0.875em; + font-style: italic; } + .tainacan-photoswipe-layer .pswp__description { + font-size: 0.9375em; } + .tainacan-photoswipe-layer .pswp__caption__center { + text-align: center; + font-size: 1em; + max-width: 800px; } /*# sourceMappingURL=tainacan-gutenberg-block-item-gallery.css.map */ diff --git a/src/assets/css/tainacan-gutenberg-block-item-gallery.css.map b/src/assets/css/tainacan-gutenberg-block-item-gallery.css.map index f9eeb69f0..275bbe61d 100644 --- a/src/assets/css/tainacan-gutenberg-block-item-gallery.css.map +++ b/src/assets/css/tainacan-gutenberg-block-item-gallery.css.map @@ -1,6 +1,6 @@ { "version": 3, -"mappings": "AAcQ;;0EAEoB;EAChB,MAAM,EAAE,sBAAsB;AAGtC,6CAAiB;EACb,KAAK,EAAE,IAAI;EACX,SAAS,EAAE,QAAQ;EACnB,UAAU,EAAE,MAAM;EAClB,KAAK,EAAE,OAAO;EACd,UAAU,EAAE,MAAM;EAClB,MAAM,EAAE,MAAM;EACd,OAAO,EAAE,eAAe;;AAGhC,yBAA0B;EACtB,oBAAoB,CAAC,mCAAmC;EACxD,wBAAwB,CAAC,KAAK;EAC9B,+BAA+B,CAAC,qCAAqC;EACrE,2BAA2B,CAAC,8CAA8C;EAC1E,qCAAqC,CAAC,KAAK;EAC3C,oCAAoC,CAAC,KAAK;EAC1C,sCAAsC,CAAC,KAAK;EAC5C,0CAA0C,CAAC,MAAM;EAEjD,MAAM,EAAE,IAAI;EACZ,OAAO,EAAE,KAAK;EACd,gBAAgB,EAAE,6CAA6C;EAC/D,UAAU,EAAE,UAAU;EAEtB,yDAAkC;IAC9B,KAAK,EAAE,IAAI;EAGf;;iDA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AAa,EAAE,QAAQ;IACvB,WAAW,EAAE,MAAM;IACnB,WAAW,EAAE,IAAI;IACjB,OAAO,EAAE,MAAM;EAEnB,gDAAsB;IAClB,SAAS,EAAE,OAAO;IAClB,UAAU,EAAE,MAAM;EAEtB,6CAAmB;IACf,SAAS,EAAE,QAAQ;EAEvB,iDAAuB;IACnB,UAAU,EAAE,MAAM;IAClB,SAAS,EAAE,GAAG;IACd,SAAS,EAAE,KAAK", "sources": ["../../views/gutenberg-blocks/blocks/item-gallery/style.scss"], "names": [], "file": "tainacan-gutenberg-block-item-gallery.css" diff --git a/src/classes/theme-helper/template-tags.php b/src/classes/theme-helper/template-tags.php index 527ad7d10..3fc1b018f 100644 --- a/src/classes/theme-helper/template-tags.php +++ b/src/classes/theme-helper/template-tags.php @@ -346,10 +346,6 @@ function tainacan_get_the_media_component( ob_start(); if ( $args['has_media_main'] || $args['has_media_thumbs'] ) : - - // Modal lightbox layer for rendering photoswipe - if (!$args['disable_lightbox']) - add_action('wp_footer', 'tainacan_get_the_media_modal_layer'); wp_enqueue_style( 'tainacan-media-component', $TAINACAN_BASE_URL . '/assets/css/tainacan-gutenberg-block-item-gallery.css', array(), TAINACAN_VERSION); @@ -583,75 +579,6 @@ function tainacan_get_the_media_component_slide( $args = array() ) { return $content; } -/** - * Div with content necessay to render the photowipe modal - * - * @return string - */ -function tainacan_get_the_media_modal_layer() { -?> - -
- this.onThumbnailsClick(event, this); - - // Parse URL and open gallery if it contains #&pid=3&gid=1 - let hashData = this.photoswipeParseHash(); + console.log(this.options.media_id); - if (hashData.pid && hashData.gid) - this.openPhotoSwipe(hashData.pid, galleryElement, true, true); + let items = this.parseThumbnailElements(galleryElement); + let photoswipeOptions = { + loop: false, + preloadFirstSlide: false, + mainClass: 'tainacan-photoswipe-layer', + bgOpacity: 0.85, + clickToCloseNonZoomable: false, + closeTitle: __( 'Close lightbox', 'tainacan'), + zoomTitle: __( 'Zoom', 'tainacan'), + arrowPrevTitle: __( 'Previous slide', 'tainacan'), + arrowNextTitle: __( 'Next slide', 'tainacan'), + getClickedIndexFn: (clickedElement) => { + return items.findIndex(anItem => anItem.el.contains(clickedElement.target)); + }, + padding: { top: 60, bottom: 60, left: 40, right: 40 }, + // paddingFn: (viewportSize, itemData, index) => { + // console.log(viewportSize, itemData, index) + // return { + // // check based on slide index + // top: 60, + // bottom: 0, + // left: 0, + // right: 0 + // }; + // } + }; + + // Pass data to PhotoSwipe and initialize it + this.lightbox = new PhotoSwipeLightbox({ + gallery: galleryElement, + children: items, + pswpModule: PhotoSwipe, + ...photoswipeOptions + }); + this.lightbox.init(); + + /* Updates Swiper instance from Photoswipe */ + const swiperInstance = this.mainSwiper ? this.mainSwiper : this.thumbsSwiper; + const thisLightbox = this.lightbox; + + // Parse URL and open gallery from it if contains #&pid=3&gid=1 + const hashData = this.photoswipeParseHash(); + if (hashData.pid && hashData.gid && this.options.media_id == hashData.gid) { + // in URL indexes start from 1 + photoswipeOptions.index = parseInt(hashData.pid, 10) - 1; + + if (!isNaN(photoswipeOptions.index) && items[photoswipeOptions.index] && items[photoswipeOptions.index].el) + items[photoswipeOptions.index].el.click(); + } + + // On destroy we make a copy of the inner content to clear it + // and set again. This stops YouTube player, for example. + this.lightbox.on('destroy', () => { + let actualGalleryContainer = document.getElementsByClassName("pswp__container")[0]; + if (actualGalleryContainer) { + let currentData = actualGalleryContainer.innerHTML; + actualGalleryContainer.innerHTML = ''; + actualGalleryContainer.innerHTML = currentData; + } + }); + + // Swiper autoplay stop when image zoom */ + this.lightbox.on('initialZoomInEnd', () => { + if (swiperInstance.params && swiperInstance.params.autoplay && swiperInstance.params.autoplay.enabled && swiperInstance.autoplay.running) + swiperInstance.autoplay.stop(); + }); + + // Update position of the slider + this.lightbox.on("change", () => { + + if (thisLightbox.pswp && thisLightbox.pswp.currIndex) { + // This is the index of current photoswipe slide + swiperInstance.slideTo(thisLightbox.pswp.currIndex); + + // Also updates URL for history navigation + // We only add to the history if it is the first time opening + let currentURL = window.location.toString(); + if (currentURL.indexOf("#") > 0) { + currentURL = currentURL.substring(0, currentURL.indexOf("#")); + window.history.replaceState({}, '', currentURL + '#gid=' + this.options.media_id + '&pid=' + (thisLightbox.pswp.currIndex + 1)); + } else { + window.history.pushState({}, '', currentURL + '#gid=' + this.options.media_id + '&pid=' + (thisLightbox.pswp.currIndex + 1)); + } + } + }); + + // Re-starts autoplay, if needed + this.lightbox.on("close", () => { + // Start swiper autoplay (on close - if swiper autoplay is true) + if (swiperInstance.params && swiperInstance.params.autoplay && swiperInstance.params.autoplay.enabled) + swiperInstance.autoplay.start(); + + // Clears URL hash as we no longer need history navigation + let currentURL = window.location.toString(); + if (currentURL.indexOf("#") > 0) + window.history.replaceState({},'', currentURL.substring(0, currentURL.indexOf("#"))); + }); + + // Adds caption + this.lightbox.on('uiRegister', () => { + thisLightbox.pswp.ui.registerElement({ + name: 'caption', + order: 15, + isButton: false, + appendTo: 'root', + onInit: (el, pswp) => { + thisLightbox.pswp.on('change', () => { + const item = pswp.currSlide.data; + if (item && item.title) { + let innerHTML = ''; + + innerHTML += ' '; + + el.innerHTML = innerHTML; + } + }); + } + }); + }); } - // parse slide data (url, title, size ...) from DOM elements + // Parse slide data (url, title, size ...) from DOM elements // (children of gallerySelector) parseThumbnailElements(el) { let items = []; @@ -181,190 +307,9 @@ tainacan_plugin.classes.TainacanMediaGallery = class TainacanMediaGallery { return items; }; + - openPhotoSwipe( - index, - galleryElement, - disableAnimation, - fromURL - ) { - let pswpElement = document.querySelectorAll(".pswp")[0], - gallery, - options, - items; - items = this.parseThumbnailElements(galleryElement); - - // Photoswipe options - // https://photoswipe.com/documentation/options.html // - options = { - showHideOpacity: true, - loop: false, - timeToIdle: 6000, - timeToIdleOutside: 3000, - closeEl: true, - captionEl: true, - fullscreenEl: true, - zoomEl: true, - counterEl: true, - arrowEl: true, - preloadFirstSlide: false, - preload: [0,0], - shareEl: this.options.show_share_button ? this.options.show_share_button : false, - bgOpacity: 1, - // define gallery index (for URL) - galleryUID: galleryElement.getAttribute("data-pswp-uid"), - getThumbBoundsFn: (index) => { - let thumbnail = items[index].el, - pageYScroll = window.pageYOffset || document.documentElement.scrollTop, - rect = thumbnail.getBoundingClientRect(); - - return { x: rect.left, y: rect.top + pageYScroll, w: rect.width }; - }, - // Function builds caption markup - addCaptionHTMLFn: (item, captionEl, isFake) => { - // item - slide object - // captionEl - caption DOM element - // isFake - true when content is added to fake caption container - // (used to get size of next or previous caption) - - captionEl.children[0].innerHTML = ''; - - if(!item.title) - return false; - - if (item.title.caption) - captionEl.children[0].innerHTML += ' '; - - if (item.title.name && item.title.caption || (!item.title.name && item.title.caption && item.title.description) ) - captionEl.children[0].innerHTML += '