photoswipe-simplify
Advanced tools
Comparing version 0.0.1 to 0.0.2
/*! | ||
* photoswipe-simplify v0.0.1: PhotoSwipe.js simplfy the VanillaJS. | ||
* photoswipe-simplify v0.0.1: PhotoSwipe.js simplify by the VanillaJS. | ||
* (c) 2018 Mineo Okuda | ||
@@ -59,3 +59,3 @@ * MIT License | ||
// Loop through each object and conduct a merge | ||
for ( ; i < length; i++ ) { | ||
for ( i = 0; i < length; i++ ) { | ||
var obj = arguments[i]; | ||
@@ -86,3 +86,2 @@ merge(obj); | ||
self.options = extend(defaults, options || {}); | ||
console.log(self.options) | ||
if(!self.initialized){ | ||
@@ -92,3 +91,3 @@ self.append_template(); | ||
} | ||
self.initPhotoSwipe(self.options.target) | ||
self.initPhotoSwipe(self.options.target); | ||
}, | ||
@@ -133,9 +132,9 @@ | ||
self.galleryLoaded(); | ||
})) | ||
})); | ||
if(self.thumbnails[i].length > 0){ | ||
for(var l = 0; l < self.thumbnails[i].length; l++) { | ||
self.thumbnails[i][l].setAttribute('data-pswp-index',i) | ||
self.thumbnails[i][l].classList.add('pswp--item'); | ||
for(var n = 0; n < self.thumbnails[i].length; n++) { | ||
self.thumbnails[i][n].setAttribute('data-pswp-index',i); | ||
self.thumbnails[i][n].classList.add('pswp--item'); | ||
self.attachEvent(self.thumbnails[i][l],i,l); | ||
self.attachEvent(self.thumbnails[i][n],i,n); | ||
} | ||
@@ -161,3 +160,3 @@ } | ||
e.preventDefault(); | ||
document.body.classList.add('pswp--launched') | ||
document.body.classList.add('pswp--launched'); | ||
var active = document.querySelector('.pswp--active'); | ||
@@ -168,3 +167,3 @@ if(active){ | ||
self.galleries[galleryIndex].classList.add('pswp--active'); | ||
self.galleries[galleryIndex].setAttribute('data-pswp-index',index) | ||
self.galleries[galleryIndex].setAttribute('data-pswp-index',index); | ||
if(self.galleries[galleryIndex].classList.contains('pswp--loaded')){ | ||
@@ -194,3 +193,3 @@ if(index >= 0) { | ||
author : author | ||
} | ||
}; | ||
resolve(); | ||
@@ -197,0 +196,0 @@ }; |
/*! photoswipe-simplify v0.0.1 | (c) 2018 Mineo Okuda | MIT License | git+ssh://git@github.com:min30327/photoswipe-simplify.git */ | ||
!(function(t,e){"use strict";"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?module.exports=e():t.photoswipeSimplify=e()})(this,(function(){"use strict";var t={target:"[data-pswp]"},e=function(){for(var t={},e=0,i=arguments.length;e<i;e++){var s=arguments[e];!(function(e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i])})(s)}return t},i=function(){};return i.prototype={initialized:!1,pswpElement:"",galleries:[],thumbnails:[],tmps:[],items:[],options:{},ImagesLoaded:!1,init:function(i){var s=this;s.options=e(t,i||{}),console.log(s.options),s.initialized||(s.append_template(),s.initialized=!0),s.initPhotoSwipe(s.options.target)},append_template:function(){var t=document.getElementsByTagName("body")[0],e=document.createElement("div");e.innerHTML='<div class="pswp" tabindex="-1" role="dialog" aria-hidden="true"><div class="pswp__bg"></div><div class="pswp__scroll-wrap"><div class="pswp__container"><div class="pswp__item"></div><div class="pswp__item"></div><div class="pswp__item"></div></div><div class="pswp__ui pswp__ui--hidden"><div class="pswp__top-bar"><div class="pswp__counter"></div><button class="pswp__button pswp__button--close" title="Close (Esc)"></button><button class="pswp__button pswp__button--share" title="Share"></button><button class="pswp__button pswp__button--fs" title="Toggle fullscreen"></button><button class="pswp__button pswp__button--zoom" title="Zoom in/out"></button><div class="pswp__preloader"><div class="pswp__preloader__icn"><div class="pswp__preloader__cut"><div class="pswp__preloader__donut"></div></div></div></div></div><div class="pswp__share-modal pswp__share-modal--hidden pswp__single-tap"><div class="pswp__share-tooltip"></div> </div><button class="pswp__button pswp__button--arrow--left" title="Previous (arrow left)"></button><button class="pswp__button pswp__button--arrow--right" title="Next (arrow right)"></button><div class="pswp__caption"><div class="pswp__caption__center"></div></div></div></div></div>',t.appendChild(e)},initPhotoSwipe:function(t){var e=this;if(e.pswpElement=document.querySelectorAll(".pswp")[0],e.galleries=document.querySelectorAll(t),e.galleries.length>0)for(var i=0;i<e.galleries.length;i++){if(e.items[i]=[],e.thumbnails[i]=[],e.tmps[i]=e.galleries[i].getElementsByTagName("a"),e.tmps[i]=Array.prototype.slice.call(e.tmps[i]),e.tmps[i].length>0)for(var s=0;s<e.tmps[i].length;s++){var n=e.tmps[i][s].getAttribute("href");/(.gif|.jpe?g|.png|.bmp)/.test(n.toLowerCase())&&e.thumbnails[i].push(e.tmps[i][s])}var a=new Promise(function(t){e.parseItems(t,i)});if(a.then((function(){e.galleryLoaded()})),e.thumbnails[i].length>0)for(var s=0;s<e.thumbnails[i].length;s++)e.thumbnails[i][s].setAttribute("data-pswp-index",i),e.thumbnails[i][s].classList.add("pswp--item"),e.attachEvent(e.thumbnails[i][s],i,s)}},galleryLoaded:function(){var t=this;if(t.galleries.length>0)for(var e=0;e<t.galleries.length;e++)t.galleries[e].classList.add("pswp--loaded")},attachEvent:function(t,e,i){var s=this;t.addEventListener("click",(function(t){t.preventDefault(),document.body.classList.add("pswp--launched");var n=document.querySelector(".pswp--active");return n&&n.classList.remove("pswp--active"),s.galleries[e].classList.add("pswp--active"),s.galleries[e].setAttribute("data-pswp-index",i),s.galleries[e].classList.contains("pswp--loaded")&&i>=0&&s.open(e,i),!1}))},getImageSizes:function(t,e,i,s,n){var a=this;new Promise(function(o,l){var p=new Image;p.src=t,p.onload=function(){a.items[e][i]={src:t,w:p.naturalWidth,h:p.naturalHeight,title:s,author:n},o()}})},open:function(t,e){var i,s=this;s.galleries[t];s.options.galleryUID=t,s.options.index=e,s.options.getThumbBoundsFn=function(t){var e=document.querySelector(".pswp--active");if(e){var i=e.querySelectorAll(".pswp--item")[t].getElementsByTagName("img")[0],s=window.pageYOffset||document.documentElement.scrollTop,n=i.getBoundingClientRect();return{x:n.left,y:n.top+s,w:n.width}}},s.options.addCaptionHTMLFn=function(t,e,i){return t.title?(e.children[0].innerHTML=t.title,t.author&&(e.children[0].innerHTML+="<br><small>"+t.author+"</small>"),!0):(e.children[0].innerText="",!1)},document.body.classList.remove("pswp--launched"),i=new PhotoSwipe(s.pswpElement,PhotoSwipeUI_Default,s.items[t],s.options),i.init()},parseItems:function(t,e){var i=this,s=[];if(i.thumbnails[e].length>0)for(var n=0;n<i.thumbnails[e].length;n++){var a=i.thumbnails[e][n].getAttribute("href"),o=i.thumbnails[e][n].getAttribute("data-caption"),l=i.thumbnails[e][n].getAttribute("data-author");s.push(i.getImageSizes(a,e,n,o,l)),Promise.all(s).then((function(){t()}))}}},new i})); | ||
!(function(t,e){"use strict";"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?module.exports=e():t.photoswipeSimplify=e()})(this,(function(){"use strict";var t={target:"[data-pswp]"},e=function(){var t={},e=0,i=arguments.length;for(e=0;e<i;e++){var s=arguments[e];!(function(e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i])})(s)}return t},i=function(){};return i.prototype={initialized:!1,pswpElement:"",galleries:[],thumbnails:[],tmps:[],items:[],options:{},ImagesLoaded:!1,init:function(i){var s=this;s.options=e(t,i||{}),s.initialized||(s.append_template(),s.initialized=!0),s.initPhotoSwipe(s.options.target)},append_template:function(){var t=document.getElementsByTagName("body")[0],e=document.createElement("div");e.innerHTML='<div class="pswp" tabindex="-1" role="dialog" aria-hidden="true"><div class="pswp__bg"></div><div class="pswp__scroll-wrap"><div class="pswp__container"><div class="pswp__item"></div><div class="pswp__item"></div><div class="pswp__item"></div></div><div class="pswp__ui pswp__ui--hidden"><div class="pswp__top-bar"><div class="pswp__counter"></div><button class="pswp__button pswp__button--close" title="Close (Esc)"></button><button class="pswp__button pswp__button--share" title="Share"></button><button class="pswp__button pswp__button--fs" title="Toggle fullscreen"></button><button class="pswp__button pswp__button--zoom" title="Zoom in/out"></button><div class="pswp__preloader"><div class="pswp__preloader__icn"><div class="pswp__preloader__cut"><div class="pswp__preloader__donut"></div></div></div></div></div><div class="pswp__share-modal pswp__share-modal--hidden pswp__single-tap"><div class="pswp__share-tooltip"></div> </div><button class="pswp__button pswp__button--arrow--left" title="Previous (arrow left)"></button><button class="pswp__button pswp__button--arrow--right" title="Next (arrow right)"></button><div class="pswp__caption"><div class="pswp__caption__center"></div></div></div></div></div>',t.appendChild(e)},initPhotoSwipe:function(t){var e=this;if(e.pswpElement=document.querySelectorAll(".pswp")[0],e.galleries=document.querySelectorAll(t),e.galleries.length>0)for(var i=0;i<e.galleries.length;i++){if(e.items[i]=[],e.thumbnails[i]=[],e.tmps[i]=e.galleries[i].getElementsByTagName("a"),e.tmps[i]=Array.prototype.slice.call(e.tmps[i]),e.tmps[i].length>0)for(var s=0;s<e.tmps[i].length;s++){var n=e.tmps[i][s].getAttribute("href");/(.gif|.jpe?g|.png|.bmp)/.test(n.toLowerCase())&&e.thumbnails[i].push(e.tmps[i][s])}var a=new Promise(function(t){e.parseItems(t,i)});if(a.then((function(){e.galleryLoaded()})),e.thumbnails[i].length>0)for(var o=0;o<e.thumbnails[i].length;o++)e.thumbnails[i][o].setAttribute("data-pswp-index",i),e.thumbnails[i][o].classList.add("pswp--item"),e.attachEvent(e.thumbnails[i][o],i,o)}},galleryLoaded:function(){var t=this;if(t.galleries.length>0)for(var e=0;e<t.galleries.length;e++)t.galleries[e].classList.add("pswp--loaded")},attachEvent:function(t,e,i){var s=this;t.addEventListener("click",(function(t){t.preventDefault(),document.body.classList.add("pswp--launched");var n=document.querySelector(".pswp--active");return n&&n.classList.remove("pswp--active"),s.galleries[e].classList.add("pswp--active"),s.galleries[e].setAttribute("data-pswp-index",i),s.galleries[e].classList.contains("pswp--loaded")&&i>=0&&s.open(e,i),!1}))},getImageSizes:function(t,e,i,s,n){var a=this;new Promise(function(o,l){var p=new Image;p.src=t,p.onload=function(){a.items[e][i]={src:t,w:p.naturalWidth,h:p.naturalHeight,title:s,author:n},o()}})},open:function(t,e){var i,s=this;s.galleries[t];s.options.galleryUID=t,s.options.index=e,s.options.getThumbBoundsFn=function(t){var e=document.querySelector(".pswp--active");if(e){var i=e.querySelectorAll(".pswp--item")[t].getElementsByTagName("img")[0],s=window.pageYOffset||document.documentElement.scrollTop,n=i.getBoundingClientRect();return{x:n.left,y:n.top+s,w:n.width}}},s.options.addCaptionHTMLFn=function(t,e,i){return t.title?(e.children[0].innerHTML=t.title,t.author&&(e.children[0].innerHTML+="<br><small>"+t.author+"</small>"),!0):(e.children[0].innerText="",!1)},document.body.classList.remove("pswp--launched"),i=new PhotoSwipe(s.pswpElement,PhotoSwipeUI_Default,s.items[t],s.options),i.init()},parseItems:function(t,e){var i=this,s=[];if(i.thumbnails[e].length>0)for(var n=0;n<i.thumbnails[e].length;n++){var a=i.thumbnails[e][n].getAttribute("href"),o=i.thumbnails[e][n].getAttribute("data-caption"),l=i.thumbnails[e][n].getAttribute("data-author");s.push(i.getImageSizes(a,e,n,o,l)),Promise.all(s).then((function(){t()}))}}},new i})); |
/*! | ||
* photoswipe-simplify v0.0.1: PhotoSwipe.js simplfy the VanillaJS. | ||
* photoswipe-simplify v0.0.1: PhotoSwipe.js simplify by the VanillaJS. | ||
* (c) 2018 Mineo Okuda | ||
@@ -59,3 +59,3 @@ * MIT License | ||
// Loop through each object and conduct a merge | ||
for ( ; i < length; i++ ) { | ||
for ( i = 0; i < length; i++ ) { | ||
var obj = arguments[i]; | ||
@@ -86,3 +86,2 @@ merge(obj); | ||
self.options = extend(defaults, options || {}); | ||
console.log(self.options) | ||
if(!self.initialized){ | ||
@@ -92,3 +91,3 @@ self.append_template(); | ||
} | ||
self.initPhotoSwipe(self.options.target) | ||
self.initPhotoSwipe(self.options.target); | ||
}, | ||
@@ -133,9 +132,9 @@ | ||
self.galleryLoaded(); | ||
})) | ||
})); | ||
if(self.thumbnails[i].length > 0){ | ||
for(var l = 0; l < self.thumbnails[i].length; l++) { | ||
self.thumbnails[i][l].setAttribute('data-pswp-index',i) | ||
self.thumbnails[i][l].classList.add('pswp--item'); | ||
for(var n = 0; n < self.thumbnails[i].length; n++) { | ||
self.thumbnails[i][n].setAttribute('data-pswp-index',i); | ||
self.thumbnails[i][n].classList.add('pswp--item'); | ||
self.attachEvent(self.thumbnails[i][l],i,l); | ||
self.attachEvent(self.thumbnails[i][n],i,n); | ||
} | ||
@@ -161,3 +160,3 @@ } | ||
e.preventDefault(); | ||
document.body.classList.add('pswp--launched') | ||
document.body.classList.add('pswp--launched'); | ||
var active = document.querySelector('.pswp--active'); | ||
@@ -168,3 +167,3 @@ if(active){ | ||
self.galleries[galleryIndex].classList.add('pswp--active'); | ||
self.galleries[galleryIndex].setAttribute('data-pswp-index',index) | ||
self.galleries[galleryIndex].setAttribute('data-pswp-index',index); | ||
if(self.galleries[galleryIndex].classList.contains('pswp--loaded')){ | ||
@@ -194,3 +193,3 @@ if(index >= 0) { | ||
author : author | ||
} | ||
}; | ||
resolve(); | ||
@@ -197,0 +196,0 @@ }; |
/*! photoswipe-simplify v0.0.1 | (c) 2018 Mineo Okuda | MIT License | git+ssh://git@github.com:min30327/photoswipe-simplify.git */ | ||
!(function(t,e){"use strict";"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?module.exports=e():t.photoswipeSimplify=e()})(this,(function(){"use strict";var t={target:"[data-pswp]"},e=function(){for(var t={},e=0,i=arguments.length;e<i;e++){var s=arguments[e];!(function(e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i])})(s)}return t},i=function(){};return i.prototype={initialized:!1,pswpElement:"",galleries:[],thumbnails:[],tmps:[],items:[],options:{},ImagesLoaded:!1,init:function(i){var s=this;s.options=e(t,i||{}),console.log(s.options),s.initialized||(s.append_template(),s.initialized=!0),s.initPhotoSwipe(s.options.target)},append_template:function(){var t=document.getElementsByTagName("body")[0],e=document.createElement("div");e.innerHTML='<div class="pswp" tabindex="-1" role="dialog" aria-hidden="true"><div class="pswp__bg"></div><div class="pswp__scroll-wrap"><div class="pswp__container"><div class="pswp__item"></div><div class="pswp__item"></div><div class="pswp__item"></div></div><div class="pswp__ui pswp__ui--hidden"><div class="pswp__top-bar"><div class="pswp__counter"></div><button class="pswp__button pswp__button--close" title="Close (Esc)"></button><button class="pswp__button pswp__button--share" title="Share"></button><button class="pswp__button pswp__button--fs" title="Toggle fullscreen"></button><button class="pswp__button pswp__button--zoom" title="Zoom in/out"></button><div class="pswp__preloader"><div class="pswp__preloader__icn"><div class="pswp__preloader__cut"><div class="pswp__preloader__donut"></div></div></div></div></div><div class="pswp__share-modal pswp__share-modal--hidden pswp__single-tap"><div class="pswp__share-tooltip"></div> </div><button class="pswp__button pswp__button--arrow--left" title="Previous (arrow left)"></button><button class="pswp__button pswp__button--arrow--right" title="Next (arrow right)"></button><div class="pswp__caption"><div class="pswp__caption__center"></div></div></div></div></div>',t.appendChild(e)},initPhotoSwipe:function(t){var e=this;if(e.pswpElement=document.querySelectorAll(".pswp")[0],e.galleries=document.querySelectorAll(t),e.galleries.length>0)for(var i=0;i<e.galleries.length;i++){if(e.items[i]=[],e.thumbnails[i]=[],e.tmps[i]=e.galleries[i].getElementsByTagName("a"),e.tmps[i]=Array.prototype.slice.call(e.tmps[i]),e.tmps[i].length>0)for(var s=0;s<e.tmps[i].length;s++){var n=e.tmps[i][s].getAttribute("href");/(.gif|.jpe?g|.png|.bmp)/.test(n.toLowerCase())&&e.thumbnails[i].push(e.tmps[i][s])}var a=new Promise(function(t){e.parseItems(t,i)});if(a.then((function(){e.galleryLoaded()})),e.thumbnails[i].length>0)for(var s=0;s<e.thumbnails[i].length;s++)e.thumbnails[i][s].setAttribute("data-pswp-index",i),e.thumbnails[i][s].classList.add("pswp--item"),e.attachEvent(e.thumbnails[i][s],i,s)}},galleryLoaded:function(){var t=this;if(t.galleries.length>0)for(var e=0;e<t.galleries.length;e++)t.galleries[e].classList.add("pswp--loaded")},attachEvent:function(t,e,i){var s=this;t.addEventListener("click",(function(t){t.preventDefault(),document.body.classList.add("pswp--launched");var n=document.querySelector(".pswp--active");return n&&n.classList.remove("pswp--active"),s.galleries[e].classList.add("pswp--active"),s.galleries[e].setAttribute("data-pswp-index",i),s.galleries[e].classList.contains("pswp--loaded")&&i>=0&&s.open(e,i),!1}))},getImageSizes:function(t,e,i,s,n){var a=this;new Promise(function(o,l){var p=new Image;p.src=t,p.onload=function(){a.items[e][i]={src:t,w:p.naturalWidth,h:p.naturalHeight,title:s,author:n},o()}})},open:function(t,e){var i,s=this;s.galleries[t];s.options.galleryUID=t,s.options.index=e,s.options.getThumbBoundsFn=function(t){var e=document.querySelector(".pswp--active");if(e){var i=e.querySelectorAll(".pswp--item")[t].getElementsByTagName("img")[0],s=window.pageYOffset||document.documentElement.scrollTop,n=i.getBoundingClientRect();return{x:n.left,y:n.top+s,w:n.width}}},s.options.addCaptionHTMLFn=function(t,e,i){return t.title?(e.children[0].innerHTML=t.title,t.author&&(e.children[0].innerHTML+="<br><small>"+t.author+"</small>"),!0):(e.children[0].innerText="",!1)},document.body.classList.remove("pswp--launched"),i=new PhotoSwipe(s.pswpElement,PhotoSwipeUI_Default,s.items[t],s.options),i.init()},parseItems:function(t,e){var i=this,s=[];if(i.thumbnails[e].length>0)for(var n=0;n<i.thumbnails[e].length;n++){var a=i.thumbnails[e][n].getAttribute("href"),o=i.thumbnails[e][n].getAttribute("data-caption"),l=i.thumbnails[e][n].getAttribute("data-author");s.push(i.getImageSizes(a,e,n,o,l)),Promise.all(s).then((function(){t()}))}}},new i})); | ||
!(function(t,e){"use strict";"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?module.exports=e():t.photoswipeSimplify=e()})(this,(function(){"use strict";var t={target:"[data-pswp]"},e=function(){var t={},e=0,i=arguments.length;for(e=0;e<i;e++){var s=arguments[e];!(function(e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i])})(s)}return t},i=function(){};return i.prototype={initialized:!1,pswpElement:"",galleries:[],thumbnails:[],tmps:[],items:[],options:{},ImagesLoaded:!1,init:function(i){var s=this;s.options=e(t,i||{}),s.initialized||(s.append_template(),s.initialized=!0),s.initPhotoSwipe(s.options.target)},append_template:function(){var t=document.getElementsByTagName("body")[0],e=document.createElement("div");e.innerHTML='<div class="pswp" tabindex="-1" role="dialog" aria-hidden="true"><div class="pswp__bg"></div><div class="pswp__scroll-wrap"><div class="pswp__container"><div class="pswp__item"></div><div class="pswp__item"></div><div class="pswp__item"></div></div><div class="pswp__ui pswp__ui--hidden"><div class="pswp__top-bar"><div class="pswp__counter"></div><button class="pswp__button pswp__button--close" title="Close (Esc)"></button><button class="pswp__button pswp__button--share" title="Share"></button><button class="pswp__button pswp__button--fs" title="Toggle fullscreen"></button><button class="pswp__button pswp__button--zoom" title="Zoom in/out"></button><div class="pswp__preloader"><div class="pswp__preloader__icn"><div class="pswp__preloader__cut"><div class="pswp__preloader__donut"></div></div></div></div></div><div class="pswp__share-modal pswp__share-modal--hidden pswp__single-tap"><div class="pswp__share-tooltip"></div> </div><button class="pswp__button pswp__button--arrow--left" title="Previous (arrow left)"></button><button class="pswp__button pswp__button--arrow--right" title="Next (arrow right)"></button><div class="pswp__caption"><div class="pswp__caption__center"></div></div></div></div></div>',t.appendChild(e)},initPhotoSwipe:function(t){var e=this;if(e.pswpElement=document.querySelectorAll(".pswp")[0],e.galleries=document.querySelectorAll(t),e.galleries.length>0)for(var i=0;i<e.galleries.length;i++){if(e.items[i]=[],e.thumbnails[i]=[],e.tmps[i]=e.galleries[i].getElementsByTagName("a"),e.tmps[i]=Array.prototype.slice.call(e.tmps[i]),e.tmps[i].length>0)for(var s=0;s<e.tmps[i].length;s++){var n=e.tmps[i][s].getAttribute("href");/(.gif|.jpe?g|.png|.bmp)/.test(n.toLowerCase())&&e.thumbnails[i].push(e.tmps[i][s])}var a=new Promise(function(t){e.parseItems(t,i)});if(a.then((function(){e.galleryLoaded()})),e.thumbnails[i].length>0)for(var o=0;o<e.thumbnails[i].length;o++)e.thumbnails[i][o].setAttribute("data-pswp-index",i),e.thumbnails[i][o].classList.add("pswp--item"),e.attachEvent(e.thumbnails[i][o],i,o)}},galleryLoaded:function(){var t=this;if(t.galleries.length>0)for(var e=0;e<t.galleries.length;e++)t.galleries[e].classList.add("pswp--loaded")},attachEvent:function(t,e,i){var s=this;t.addEventListener("click",(function(t){t.preventDefault(),document.body.classList.add("pswp--launched");var n=document.querySelector(".pswp--active");return n&&n.classList.remove("pswp--active"),s.galleries[e].classList.add("pswp--active"),s.galleries[e].setAttribute("data-pswp-index",i),s.galleries[e].classList.contains("pswp--loaded")&&i>=0&&s.open(e,i),!1}))},getImageSizes:function(t,e,i,s,n){var a=this;new Promise(function(o,l){var p=new Image;p.src=t,p.onload=function(){a.items[e][i]={src:t,w:p.naturalWidth,h:p.naturalHeight,title:s,author:n},o()}})},open:function(t,e){var i,s=this;s.galleries[t];s.options.galleryUID=t,s.options.index=e,s.options.getThumbBoundsFn=function(t){var e=document.querySelector(".pswp--active");if(e){var i=e.querySelectorAll(".pswp--item")[t].getElementsByTagName("img")[0],s=window.pageYOffset||document.documentElement.scrollTop,n=i.getBoundingClientRect();return{x:n.left,y:n.top+s,w:n.width}}},s.options.addCaptionHTMLFn=function(t,e,i){return t.title?(e.children[0].innerHTML=t.title,t.author&&(e.children[0].innerHTML+="<br><small>"+t.author+"</small>"),!0):(e.children[0].innerText="",!1)},document.body.classList.remove("pswp--launched"),i=new PhotoSwipe(s.pswpElement,PhotoSwipeUI_Default,s.items[t],s.options),i.init()},parseItems:function(t,e){var i=this,s=[];if(i.thumbnails[e].length>0)for(var n=0;n<i.thumbnails[e].length;n++){var a=i.thumbnails[e][n].getAttribute("href"),o=i.thumbnails[e][n].getAttribute("data-caption"),l=i.thumbnails[e][n].getAttribute("data-author");s.push(i.getImageSizes(a,e,n,o,l)),Promise.all(s).then((function(){t()}))}}},new i})); |
{ | ||
"_args": [ | ||
[ | ||
"photoswipe-simplify@0.0.1", | ||
"photoswipe-simplify@0.0.2", | ||
"/Users/mineo/workspace/DEMO/photoswipe-simplify/" | ||
] | ||
], | ||
"_from": "photoswipe-simplify@0.0.1", | ||
"_id": "photoswipe-simplify@0.0.1", | ||
"_from": "photoswipe-simplify@0.0.2", | ||
"_id": "photoswipe-simplify@0.0.2", | ||
"_inBundle": false, | ||
@@ -16,8 +16,8 @@ "_location": "/photoswipe-simplify", | ||
"registry": true, | ||
"raw": "photoswipe-simplify@0.0.1", | ||
"raw": "photoswipe-simplify@0.0.2", | ||
"name": "photoswipe-simplify", | ||
"escapedName": "photoswipe-simplify", | ||
"rawSpec": "0.0.1", | ||
"rawSpec": "0.0.2", | ||
"saveSpec": null, | ||
"fetchSpec": "0.0.1" | ||
"fetchSpec": "0.0.2" | ||
}, | ||
@@ -27,3 +27,3 @@ "_requiredBy": [ | ||
], | ||
"_spec": "0.0.1", | ||
"_spec": "0.0.2", | ||
"_where": "/Users/mineo/workspace/DEMO/photoswipe-simplify/", | ||
@@ -34,3 +34,3 @@ "author": { | ||
}, | ||
"description": "PhotoSwipe.js simplfy the VanillaJS.", | ||
"description": "PhotoSwipe.js simplify by the VanillaJS.", | ||
"devDependencies": { | ||
@@ -65,3 +65,3 @@ "del": "^2.2.2", | ||
}, | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"dependencies": { | ||
@@ -68,0 +68,0 @@ "photoswipe": "^4.1.2" |
# photoswipe-simplify.js | ||
PhotoSwipe.js simplfy the VanillaJS. | ||
PhotoSwipe.js simplify by the VanillaJS. | ||
@@ -20,3 +20,3 @@ | ||
```html | ||
<script src="path/to/photoswipe.js" charset="utf-8"></script> | ||
<script src="path/to/photoswipe.js" charset="utf-8"></script> | ||
<script src="path/to/photoswipe-ui-default.js" charset="utf-8"></script> | ||
@@ -57,3 +57,3 @@ <script src="path/to/photoswipe-simplify.js" charset="utf-8"></script> | ||
PhotoSwipe options can be used as they are. | ||
Please see this page for details. | ||
Please see [this page](http://photoswipe.com/documentation/options.html) for details. | ||
Specify the option as follows. | ||
@@ -60,0 +60,0 @@ |
@@ -52,3 +52,3 @@ /** | ||
// Loop through each object and conduct a merge | ||
for ( ; i < length; i++ ) { | ||
for ( i = 0; i < length; i++ ) { | ||
var obj = arguments[i]; | ||
@@ -79,3 +79,2 @@ merge(obj); | ||
self.options = extend(defaults, options || {}); | ||
console.log(self.options) | ||
if(!self.initialized){ | ||
@@ -85,3 +84,3 @@ self.append_template(); | ||
} | ||
self.initPhotoSwipe(self.options.target) | ||
self.initPhotoSwipe(self.options.target); | ||
}, | ||
@@ -126,9 +125,9 @@ | ||
self.galleryLoaded(); | ||
}) | ||
}); | ||
if(self.thumbnails[i].length > 0){ | ||
for(var l = 0; l < self.thumbnails[i].length; l++) { | ||
self.thumbnails[i][l].setAttribute('data-pswp-index',i) | ||
self.thumbnails[i][l].classList.add('pswp--item'); | ||
for(var n = 0; n < self.thumbnails[i].length; n++) { | ||
self.thumbnails[i][n].setAttribute('data-pswp-index',i); | ||
self.thumbnails[i][n].classList.add('pswp--item'); | ||
self.attachEvent(self.thumbnails[i][l],i,l); | ||
self.attachEvent(self.thumbnails[i][n],i,n); | ||
} | ||
@@ -154,3 +153,3 @@ } | ||
e.preventDefault(); | ||
document.body.classList.add('pswp--launched') | ||
document.body.classList.add('pswp--launched'); | ||
var active = document.querySelector('.pswp--active'); | ||
@@ -161,3 +160,3 @@ if(active){ | ||
self.galleries[galleryIndex].classList.add('pswp--active'); | ||
self.galleries[galleryIndex].setAttribute('data-pswp-index',index) | ||
self.galleries[galleryIndex].setAttribute('data-pswp-index',index); | ||
if(self.galleries[galleryIndex].classList.contains('pswp--loaded')){ | ||
@@ -187,3 +186,3 @@ if(index >= 0) { | ||
author : author | ||
} | ||
}; | ||
resolve(); | ||
@@ -190,0 +189,0 @@ }; |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4227815
1026