TagSpaces is an offline, open source, document manager with tagging support
PhotoSwipe perspective implementation
Borislav Sapundzhiev75d424644b6f
diff --git a/data/ext/perspectiveImageSwiper/galleryTMPL.html b/data/ext/perspectiveImageSwiper/galleryTMPL.htmlindex 1d07e5507..8aae61ce9 100644--- a/data/ext/perspectiveImageSwiper/galleryTMPL.html+++ b/data/ext/perspectiveImageSwiper/galleryTMPL.html@@ -1,69 +1,20 @@-<h2>First gallery:</h2>- <div class="my-gallery" itemscope itemtype="http://schema.org/ImageGallery">-- <figure itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject">- <a href="https://farm3.staticflickr.com/2567/5697107145_a4c2eaa0cd_o.jpg" itemprop="contentUrl" data-size="1024x1024">- <img src="https://farm3.staticflickr.com/2567/5697107145_3c27ff3cd1_m.jpg" itemprop="thumbnail" alt="Image description" />- </a>- <figcaption itemprop="caption description">Image caption 1</figcaption>-- </figure>-- <figure itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject">- <a href="https://farm2.staticflickr.com/1043/5186867718_06b2e9e551_b.jpg" itemprop="contentUrl" data-size="964x1024">- <img src="https://farm2.staticflickr.com/1043/5186867718_06b2e9e551_m.jpg" itemprop="thumbnail" alt="Image description" />- </a>- <figcaption itemprop="caption description">Image caption 2</figcaption>- </figure>-- <figure itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject">- <a href="https://farm7.staticflickr.com/6175/6176698785_7dee72237e_b.jpg" itemprop="contentUrl" data-size="1024x683">- <img src="https://farm7.staticflickr.com/6175/6176698785_7dee72237e_m.jpg" itemprop="thumbnail" alt="Image description" />- </a>- <figcaption itemprop="caption description">Image caption 3</figcaption>- </figure>-- <figure itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject">- <a href="https://farm6.staticflickr.com/5023/5578283926_822e5e5791_b.jpg" itemprop="contentUrl" data-size="1024x768">- <img src="https://farm6.staticflickr.com/5023/5578283926_822e5e5791_m.jpg" itemprop="thumbnail" alt="Image description" />- </a>- <figcaption itemprop="caption description">Image caption 4</figcaption>- </figure>--- </div>--<h2>Second gallery:</h2>+<div>+<h4></h4><div class="my-gallery" itemscope itemtype="http://schema.org/ImageGallery">--- <figure itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject">- <a href="https://farm2.staticflickr.com/1043/5186867718_06b2e9e551_b.jpg" itemprop="contentUrl" data-size="964x1024">- <img src="https://farm2.staticflickr.com/1043/5186867718_06b2e9e551_m.jpg" itemprop="thumbnail" alt="Image description" />- </a>- <figcaption itemprop="caption description">Image caption 2.1</figcaption>- </figure>-- <figure itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject">- <a href="https://farm7.staticflickr.com/6175/6176698785_7dee72237e_b.jpg" itemprop="contentUrl" data-size="1024x683">- <img src="https://farm7.staticflickr.com/6175/6176698785_7dee72237e_m.jpg" itemprop="thumbnail" alt="Image description" />- </a>- <figcaption itemprop="caption description">Image caption 2.2</figcaption>- </figure>-- <figure itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject">- <a href="https://farm6.staticflickr.com/5023/5578283926_822e5e5791_b.jpg" itemprop="contentUrl" data-size="1024x768">- <img src="https://farm6.staticflickr.com/5023/5578283926_822e5e5791_m.jpg" itemprop="thumbnail" alt="Image description" />- </a>- <figcaption itemprop="caption description">Image caption 2.3</figcaption>- </figure>-+ {{#each data}}+ <figure itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject">+ <a href={{path}} itemprop="contentUrl" >+ <img src={{thumbnail}} itemprop="thumbnail" alt={{name}} />+ </a>+ <figcaption itemprop="caption description">{{name}}</figcaption>+ </figure>+ {{/each}}</div>-+</div><!-- Root element of PhotoSwipe. Must have class pswp. -->diff --git a/data/ext/perspectiveImageSwiper/perspectiveUI.js b/data/ext/perspectiveImageSwiper/perspectiveUI.jsindex 8ba67cad9..8d3db55fd 100644--- a/data/ext/perspectiveImageSwiper/perspectiveUI.js+++ b/data/ext/perspectiveImageSwiper/perspectiveUI.js@@ -3,14 +3,34 @@ define(function(require, exports, module) {var TSCORE = require("tscore");var extDir;+ var supportedFileTypesThumbs = ['jpg','jpeg','png','gif','bmp','svg'];+ var defaultThumnailPath;function initUI(dir) {extDir = dir;+ defaultThumnailPath = extDir + "/default.png";}- function load(container, template) {- var compiledTemplate = Handlebars.compile( template );- container.append(compiledTemplate);+ function load(container, template, files) {+ var data = [];+ var compiledTemplate = Handlebars.compile(template);+ files.forEach(function(fileInfo) {+ var ext = fileInfo[TSCORE.fileListFILEEXT];++ if(supportedFileTypesThumbs.indexOf(ext) !== -1) {++ var doc = {+ name: fileInfo[TSCORE.fileListFILENAME],+ path: fileInfo[TSCORE.fileListFILEPATH],+ thumbnail: defaultThumnailPath,+ title: fileInfo[TSCORE.fileListTITLE]+ }+ data.push(doc);+ }+ });++ var html = compiledTemplate({data: data});+ container.append(html);initPhotoSwipeFromDOM('.my-gallery');}@@ -41,17 +61,19 @@ define(function(require, exports, module) {linkEl = figureEl.children[0]; // <a> element- size = linkEl.getAttribute('data-size').split('x');+ //size = linkEl.getAttribute('data-size').split('x');+ var img = new Image();+ img.src = linkEl.getAttribute('href');+ size = [img.width, img.height];+// create slide objectitem = {src: linkEl.getAttribute('href'),w: parseInt(size[0], 10),h: parseInt(size[1], 10)};---+if(figureEl.children.length > 1) {// <figcaption> contentitem.title = figureEl.children[1].innerHTML;