diff --git a/plugin.json b/plugin.json index ca11d5e..717f4ea 100644 --- a/plugin.json +++ b/plugin.json @@ -1,6 +1,6 @@ { "name": "PhotoSwipe", - "version": "1.7.0", + "version": "1.7.1", "description": "Replaces default Lightbox with Photoswipe (http://photoswipe.com)", "author": { "name": "Daniel Muller", diff --git a/pswp/pswp.min.js b/pswp/pswp.min.js index 8f40493..3a9a8c3 100644 --- a/pswp/pswp.min.js +++ b/pswp/pswp.min.js @@ -1 +1 @@ -var initPhotoSwipeFromDOM=function(options){var parseThumbnailElements=function(el){var items=[];el.children("img").each(function(){if(typeof $(this).attr("data-base")!="undefined"&&typeof $(this).attr("data-extension")!="undefined"&&typeof $(this).attr("data-presets")!="undefined"){var item={};var base=$(this).attr("data-base");var ext=$(this).attr("data-extension");item["_common"]={msrc:$(this).attr("data-src")||$(this).attr("src")};item["title"]=$(this).attr("data-alt")||$(this).attr("alt");item["caption"]=$(this).nextAll(".item-caption:first").html();item.pid=base.split("/").slice(-3).join("-").slice(0,-1).toLowerCase();jQuery.each($(this).attr("data-presets").split(" "),function(i,val){var preset_info=val.split(",");var name=preset_info[0];var size_factor=isHighDensity()?2:1;var retina=isHighDensity()?".2x.":".";var w=parseInt(preset_info[1]);var h=parseInt(preset_info[2]);var src=base+name+retina+ext;item[name]={src:src,w:size_factor*w,h:size_factor*h}});items.push(item)}});return items};var photoswipeParseHash=function(){var hash=window.location.hash.substring(1),params={};if(hash.length<5){return params}var vars=hash.split("&");for(var i=0;i0,getDoubleTapZoom:function(){if(window.devicePixelRatio>1){return.5}else{return 1}},galleryPIDs:true,addCaptionHTMLFn:function(item,captionEl,isFake){if(!koken_options.showTitle||!item.title){captionEl.children[0].innerHTML="";return false}captionEl.children[0].innerHTML=item.title+(item.caption?"
"+item.caption+"":"");return true}};if(fromURL){if(options.galleryPIDs){for(var j=0;j=1600&&max_size>=1600&&"huge"in items[0]){neededSize="huge"}else if(realViewportWidth>=1024&&max_size>=1024&&"xlarge"in items[0]){neededSize="xlarge"}else if(realViewportWidth>=800&&max_size>=800&&"large"in items[0]){neededSize="large"}else{neededSize="medium_large"}if(useImageSize!=neededSize){useImageSize=neededSize;if(!firstResize){gallery.invalidateCurrItems()}}firstResize=false});gallery.listen("gettingData",function(index,item){item.src=item[useImageSize].src;item.msrc=item["_common"].msrc;item.w=item[useImageSize].w;item.h=item[useImageSize].h});var scroll_move=null;var bind_move=false;if(typeof $K=="object"){if(typeof $K.keyboard=="object"){if(typeof $K.keyboard.scroll=="object"){if(typeof $K.keyboard.scroll.move=="function"){scroll_move=$K.keyboard.scroll.move;$K.keyboard.scroll.move=function(){return true}}}$("[data-bind-to-key]").each(function(){bind_move=true;var t=$(this),e=t.attr("data-bind-to-key");key.unbind(e)})}}gallery.listen("destroy",function(){if(bind_move===true){$K.keyboard.bind()}if(scroll_move){$K.keyboard.scroll.move=scroll_move;scroll_move=null}pswp_open=false;$(".pswp")[0].className="pswp";if(pswp_open_orientation!=window.orientation){initPS()}if(pswp_open_width!=$(window).width()||pswp_open_height!=$(window).height()){initPS()}});gallery.init();pswp_open=true;pswp_open_orientation=window.orientation;pswp_open_width=$(window).width();pswp_open_height=$(window).height()};var isHighDensity=function(){if(koken_options.hidpi===false){return false}return window.matchMedia&&(window.matchMedia("only screen and (min-resolution: 144dpi), only screen and (min-resolution: 1.3dppx), only screen and (min-resolution: 48.8dpcm)").matches||window.matchMedia("only screen and (-webkit-min-device-pixel-ratio: 1.3), only screen and (-o-min-device-pixel-ratio: 2.6/2), only screen and (min--moz-device-pixel-ratio: 1.3), only screen and (min-device-pixel-ratio: 1.3)").matches)||window.devicePixelRatio&&window.devicePixelRatio>1.3};var initPS=function(){if(koken_options.usingPillar){setTimeout(runInitPS,500)}else{runInitPS()}};var runInitPS=function(){if(!pswp_open){$(".pswp")[0].className="pswp";$("a[data-pswp-uid]").removeAttr("data-pswp-upid")}var i=0;if(koken_options.usingPillar){if(size_group=="size_0"&&typeof start_size_group=="undefined"){old_size_group=size_group;class_attr=$("div.pillar").attr("class");if(class_attr){start_size_group=$.grep(class_attr.split(" "),function(v){return v!="pillar"})[0]}}if(orientation_changed){if(size_group=="size_0"){size_group=start_size_group}old_size_group=size_group;class_attr=$("div.pillar:not(."+old_size_group+")").attr("class");if(class_attr){size_group=$.grep(class_attr.split(" "),function(v){return v!="pillar"})[0]}orientation_changed=false}galleryElements=$("div.pillar:not(."+old_size_group+") "+koken_options.triggerEl)}else{galleryElements=$(koken_options.triggerEl)}if(!pswp_open){galleryElements.each(function(){if($(this).children("img").length>0){set_link($(this),i);i++}});galleryElements.each(function(){if($(this).attr("title")=="View in lightbox"){lb_url=$(this).attr("href");if(typeof lb_url!="undefined"&&lb_url.length>0){lb_element=$(this);$('a[href="'+lb_url+'"]').each(function(){if($(this).attr("data-pswp-uid")&&$(this).children("img").length>0){set_link(lb_element,$(this).attr("data-pswp-uid"))}})}}})}};var set_link=function(el,i){if(!el.parent().hasClass("type_video")){el.click(function(e){openPhotoSwipe(el.first().attr("data-pswp-uid"));return false})}el.attr("data-pswp-uid",i)};var koken_options=options;var pswp_open=false;var pswp_open_orientation;var orientation_changed=false;var orientation=window.orientation;var size_group="size_0",old_size_group,start_size_group;var galleryElements=$(koken_options.triggerEl);var last_resize=0;$(window).on("k-resize",function(){if(Date.now()-last_resize>1e3){last_resize=Date.now();initPS()}});if(koken_options.usingPillar){$(document).on("pjax:end",function(){initPS()});$(window).on("orientationchange",function(){if(window.orientation!=orientation){orientation_changed=true;orientation=window.orientation;initPS()}else{orientation_changed=false}});$(window).on("k-infinite-loaded",function(){initPS()});initPS()}else{initPS()}var hashData=photoswipeParseHash();if(hashData.pid&&hashData.gid){openPhotoSwipe(hashData.pid,true,true)}}; \ No newline at end of file +var initPhotoSwipeFromDOM=function(options){var parseThumbnailElements=function(el){var items=[];el.children("img").each(function(){if(typeof $(this).attr("data-base")!="undefined"&&typeof $(this).attr("data-extension")!="undefined"&&typeof $(this).attr("data-presets")!="undefined"){var item={};var base=$(this).attr("data-base");var ext=$(this).attr("data-extension");item["_common"]={msrc:$(this).attr("data-src")||$(this).attr("src")};item["title"]=$(this).attr("data-alt")||$(this).attr("alt");item["caption"]=$(this).nextAll(".item-caption:first").html();item.pid=base.split("/").slice(-3).join("-").slice(0,-1).toLowerCase();jQuery.each($(this).attr("data-presets").split(" "),function(i,val){var preset_info=val.split(",");var name=preset_info[0];var size_factor=isHighDensity()?2:1;var retina=isHighDensity()?".2x.":".";var w=parseInt(preset_info[1]);var h=parseInt(preset_info[2]);var src=base+name+retina+ext;item[name]={src:src,w:size_factor*w,h:size_factor*h};if(name=="huge"){item["huge.2x"]={src:base+name+".2x."+ext,w:2*w,h:2*h}}});itemExists=false;$.each(items,function(index,value){if(value.pid==item.pid){itemExists=true;return false}});if(!itemExists){items.push(item)}}});return items};var photoswipeParseHash=function(){var hash=window.location.hash.substring(1),params={};if(hash.length<5){return params}var vars=hash.split("&");for(var i=0;i0,getDoubleTapZoom:function(){if(window.devicePixelRatio>1){return.5}else{return 1}},galleryPIDs:true,addCaptionHTMLFn:function(item,captionEl,isFake){if(!koken_options.showTitle||!item.title){captionEl.children[0].innerHTML="";return false}captionEl.children[0].innerHTML=item.title+(item.caption?"
"+item.caption+"":"");return true}};if(fromURL){if(options.galleryPIDs){for(var j=0;j=1600&&max_size>=1600&&"huge"in items[0]){neededSize="huge";if(realViewportWidth>=2048&&max_size>=2048&&koken_options.hidpi===true&&size_factor==1){neededSize="huge.2x"}}else if(realViewportWidth>=1024&&max_size>=1024&&"xlarge"in items[0]){neededSize="xlarge"}else if(realViewportWidth>=800&&max_size>=800&&"large"in items[0]){neededSize="large"}else{neededSize="medium_large"}if(useImageSize!=neededSize){useImageSize=neededSize;if(!firstResize){gallery.invalidateCurrItems()}}firstResize=false});gallery.listen("gettingData",function(index,item){item.src=item[useImageSize].src;item.msrc=item["_common"].msrc;item.w=item[useImageSize].w;item.h=item[useImageSize].h});var scroll_move=null;var bind_move=false;if(typeof $K=="object"){if(typeof $K.keyboard=="object"){if(typeof $K.keyboard.scroll=="object"){if(typeof $K.keyboard.scroll.move=="function"){scroll_move=$K.keyboard.scroll.move;$K.keyboard.scroll.move=function(){return true}}}$("[data-bind-to-key]").each(function(){bind_move=true;var t=$(this),e=t.attr("data-bind-to-key");key.unbind(e)})}}gallery.listen("destroy",function(){if(bind_move===true){$K.keyboard.bind()}if(scroll_move){$K.keyboard.scroll.move=scroll_move;scroll_move=null}pswp_open=false;$(".pswp")[0].className="pswp";if(pswp_open_orientation!=window.orientation){initPS()}if(pswp_open_width!=$(window).width()||pswp_open_height!=$(window).height()){initPS()}});gallery.init();pswp_open=true;pswp_open_orientation=window.orientation;pswp_open_width=$(window).width();pswp_open_height=$(window).height()};var isHighDensity=function(){if(koken_options.hidpi===false){return false}return window.matchMedia&&(window.matchMedia("only screen and (min-resolution: 144dpi), only screen and (min-resolution: 1.3dppx), only screen and (min-resolution: 48.8dpcm)").matches||window.matchMedia("only screen and (-webkit-min-device-pixel-ratio: 1.3), only screen and (-o-min-device-pixel-ratio: 2.6/2), only screen and (min--moz-device-pixel-ratio: 1.3), only screen and (min-device-pixel-ratio: 1.3)").matches)||window.devicePixelRatio&&window.devicePixelRatio>1.3};var initPS=function(){if(koken_options.usingPillar){setTimeout(runInitPS,500)}else{runInitPS()}};var runInitPS=function(){if(!pswp_open){$(".pswp")[0].className="pswp";$("a[data-pswp-uid]").removeAttr("data-pswp-upid")}var i=0;if(koken_options.usingPillar){if(size_group=="size_0"&&typeof start_size_group=="undefined"){old_size_group=size_group;class_attr=$("div.pillar").attr("class");if(class_attr){start_size_group=$.grep(class_attr.split(" "),function(v){return v!="pillar"})[0]}}if(orientation_changed){if(size_group=="size_0"){size_group=start_size_group}old_size_group=size_group;class_attr=$("div.pillar:not(."+old_size_group+")").attr("class");if(class_attr){size_group=$.grep(class_attr.split(" "),function(v){return v!="pillar"})[0]}orientation_changed=false}galleryElements=$("div.pillar:not(."+old_size_group+") "+koken_options.triggerEl)}else{galleryElements=$(koken_options.triggerEl)}if(!pswp_open){galleryElements.each(function(){if($(this).children("img").length>0){set_link($(this),i);i++}});galleryElements.each(function(){if($(this).attr("title")=="View in lightbox"){lb_url=$(this).attr("href");if(typeof lb_url!="undefined"&&lb_url.length>0){lb_element=$(this);$('a[href="'+lb_url+'"]').each(function(){if($(this).attr("data-pswp-uid")&&$(this).children("img").length>0){set_link(lb_element,$(this).attr("data-pswp-uid"))}})}}})}};var set_link=function(el,i){if(!el.parent().hasClass("type_video")){el.click(function(e){openPhotoSwipe(el.first().attr("data-pswp-uid"));return false})}el.attr("data-pswp-uid",i)};var koken_options=options;var pswp_open=false;var pswp_open_orientation;var orientation_changed=false;var orientation=window.orientation;var size_group="size_0",old_size_group,start_size_group;var galleryElements=$(koken_options.triggerEl);var last_resize=0;$(window).on("k-resize",function(){if(Date.now()-last_resize>1e3){last_resize=Date.now();initPS()}});if(koken_options.usingPillar){$(document).on("pjax:end",function(){initPS()});$(window).on("orientationchange",function(){if(window.orientation!=orientation){orientation_changed=true;orientation=window.orientation;initPS()}else{orientation_changed=false}});$(window).on("k-infinite-loaded",function(){initPS()});initPS()}else{initPS()}var hashData=photoswipeParseHash();if(hashData.pid&&hashData.gid){openPhotoSwipe(hashData.pid,true,true)}}; \ No newline at end of file