From df0b0ec976dbc582477aadf7148df9c8c94a0543 Mon Sep 17 00:00:00 2001 From: Jon Uhlmann Date: Tue, 11 Sep 2018 10:01:07 +0200 Subject: [PATCH] :bug: Better handling of `figcaption` --- Resources/Private/Assets/Main.js | 6 +++++- Resources/Public/Main.js | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Resources/Private/Assets/Main.js b/Resources/Private/Assets/Main.js index 2910bbc..44537c6 100644 --- a/Resources/Private/Assets/Main.js +++ b/Resources/Private/Assets/Main.js @@ -82,7 +82,11 @@ neosPhotoSwipe.init = function(selector) { } } - figcaption = element.parentNode.querySelector("figcaption"); + var figure = closest(element, function(el) { + return el.tagName && el.tagName.toLowerCase() === 'figure'; + }); + + figcaption = figure ? figure.querySelector("figcaption") : element.querySelector("figcaption"); figcaption = figcaption ? figcaption.innerHTML || false : false; image = element.querySelector("img"); diff --git a/Resources/Public/Main.js b/Resources/Public/Main.js index 8e7c120..f16581e 100644 --- a/Resources/Public/Main.js +++ b/Resources/Public/Main.js @@ -1 +1 @@ -!function r(a,l,s){function u(n,e){if(!l[n]){if(!a[n]){var t="function"==typeof require&&require;if(!e&&t)return t(n,!0);if(c)return c(n,!0);var o=new Error("Cannot find module '"+n+"'");throw o.code="MODULE_NOT_FOUND",o}var i=l[n]={exports:{}};a[n][0].call(i.exports,function(e){var t=a[n][1][e];return u(t||e)},i,i.exports,r,a,l,s)}return l[n].exports}for(var c="function"==typeof require&&require,e=0;e"+e.label+"",w.parseShareButtonOut&&(i=w.parseShareButtonOut(e,i));u.children[0].innerHTML=i,u.children[0].onclick=O},M=function(e){for(var t=0;tw.fitControlsWidth){var n=w.barsSize;if(w.captionEl&&"auto"===n.bottom)if(a||((a=l.createEl("pswp__caption pswp__caption--fake")).appendChild(l.createEl("pswp__caption__center")),s.insertBefore(a,r),l.addClass(s,"pswp__ui--fit")),w.addCaptionHTMLFn(e,a,!0)){var o=a.clientHeight;t.bottom=parseInt(o,10)||44}else t.bottom=n.top;else t.bottom="auto"===n.bottom?0:n.bottom;t.top=n.top}else t.top=t.bottom=0},z=[{name:"caption",option:"captionEl",onInit:function(e){r=e}},{name:"share-modal",option:"shareEl",onInit:function(e){u=e},onTap:function(){_()}},{name:"button--share",option:"shareEl",onInit:function(e){o=e},onTap:function(){_()}},{name:"button--zoom",option:"zoomEl",onTap:i.toggleDesktopZoom},{name:"counter",option:"counterEl",onInit:function(e){t=e}},{name:"button--close",option:"closeEl",onTap:i.close},{name:"button--arrow--left",option:"arrowEl",onTap:i.prev},{name:"button--arrow--right",option:"arrowEl",onTap:i.next},{name:"button--fs",option:"fullscreenEl",onTap:function(){n.isFullscreen()?n.exit():n.enter()}},{name:"preloader",option:"preloaderEl",onInit:function(e){p=e}}];x.init=function(){var t;l.extend(i.options,T,!0),w=i.options,s=l.getChildByClass(i.scrollWrap,"pswp__ui"),(e=i.listen)("onVerticalDrag",function(e){I&&e<.95?x.hideControls():!I&&.95<=e&&x.showControls()}),e("onPinchClose",function(e){I&&e<.9?(x.hideControls(),t=!0):t&&!I&&.9h.currItem.fitRatio?xe||(Xt(h.currItem,!1,!0),xe=!0):xe&&(Xt(h.currItem),xe=!1)),Ae(te,de.x,de.y,v))},Oe=function(e){e.container&&Ae(e.container.style,e.initialPosition.x,e.initialPosition.y,e.initialZoomLevel,e)},ke=function(e,t){t[_]=y+e+"px, 0px"+x},Me=function(e,t){if(!w.loop&&t){var n=g+(he.x*me-e)/he.x,o=Math.round(e-ct.x);(n<0&&0=Kt()-1&&o<0)&&(e=ct.x+o*w.mainScrollEndFriction)}ct.x=e,ke(e,a)},Fe=function(e,t){var n=dt[e]-fe[e];return ce[e]+ue[e]+n-n*(t/p)},Pe=function(e,t){e.x=t.x,e.y=t.y,t.id&&(e.id=t.id)},Re=function(e){e.x=Math.round(e.x),e.y=Math.round(e.y)},Le=null,Ze=function(){Le&&(f.unbind(document,"mousemove",Ze),f.addClass(m,"pswp--has_mouse"),w.mouseUsed=!0,Se("mouseUsed")),Le=setTimeout(function(){Le=null},100)},ze=function(e,t){var n=Yt(h.currItem,pe,e);return t&&(ee=n),n},Ne=function(e){return e||(e=h.currItem),e.initialZoomLevel},Ue=function(e){return e||(e=h.currItem),0t.min[e]?(n[e]=t.min[e],!0):n[e]=Kt())&&(g=0),h.currItem=Ut(g),(z.isOldIOSPhone||z.isOldAndroid)&&(ge=!1),m.setAttribute("aria-hidden","false"),w.modal&&(ge?m.style.position="fixed":(m.style.position="absolute",m.style.top=f.getScrollY()+"px")),void 0===Z&&(Se("initialLayout"),Z=R=f.getScrollY());var n="pswp--open ";for(w.mainClass&&(n+=w.mainClass+" "),w.showHideOpacity&&(n+="pswp--animate_opacity "),n+=k?"pswp--touch":"pswp--notouch",n+=z.animationName?" pswp--css_animation":"",n+=z.svg?" pswp--svg":"",f.addClass(m,n),h.updateSize(),l=-1,we=null,e=0;e<3;e++)ke((e+l)*he.x,C[e].el.style);L||f.bind(h.scrollWrap,c,h),Te("initialZoomInEnd",function(){h.setContent(C[0],g-1),h.setContent(C[2],g+1),C[0].el.style.display=C[2].el.style.display="block",w.focus&&m.focus(),f.bind(document,"keydown",h),z.transform&&f.bind(h.scrollWrap,"click",h),w.mouseUsed||f.bind(document,"mousemove",Ze),f.bind(window,"resize scroll orientationchange",h),Se("bindEvents")}),h.setContent(C[1],g),h.updateCurrItem(),Se("afterInit"),ge||(b=setInterval(function(){Ye||Y||J||v!==h.currItem.initialZoomLevel||h.updateSize()},1e3)),f.addClass(m,"pswp--visible")}},close:function(){s&&(i=!(s=!1),Se("close"),f.unbind(window,"resize scroll orientationchange",h),f.unbind(window,"scroll",d.scroll),f.unbind(document,"keydown",h),f.unbind(document,"mousemove",Ze),z.transform&&f.unbind(h.scrollWrap,"click",h),Y&&f.unbind(window,u,h),clearTimeout(N),Se("unbindEvents"),Ht(h.currItem,null,!0,h.destroy))},destroy:function(){Se("destroy"),Lt&&clearTimeout(Lt),m.setAttribute("aria-hidden","true"),m.className=P,b&&clearInterval(b),f.unbind(h.scrollWrap,c,h),f.unbind(window,"scroll",h),ft(),Ve(),Ce=null},panTo:function(e,t,n){n||(e>ee.min.x?e=ee.min.x:eee.min.y?t=ee.min.y:tee.min[e]||aee.min[e]&&(n=w.panEndFriction,ee.min[e],o=ee.min[e]-ce[e]),(o<=0||u<0)&&1it.x&&(r=it.x)):ee.min.x!==ee.max.x&&(i=a)):(ah.currItem.fitRatio&&(de[e]+=t[e]*n)},Dt=function(e){if(!("mousedown"===e.type&&0h.currItem.initialZoomLevel+h.currItem.initialZoomLevel/15&&(le=!0);var r=1,a=Ne(),l=Ue();if(ih.currItem.fitRatio&&Mt(H):Rt())}},kt=function(){var t,n,o={lastFlickOffset:{},lastFlickDist:{},lastFlickSpeed:{},slowDownRatio:{},slowDownRatioReverse:{},speedDecelerationRatio:{},speedDecelerationRatioAbs:{},distanceOffset:{},backAnimDestination:{},backAnimStarted:{},calculateSwipeSpeed:function(e){1ee.min[t]?o.backAnimDestination[t]=ee.min[t]:de[t]=Kt()&&(g=w.loop?0:Kt()-1,i=!0),i&&!w.loop||(we+=o,me-=o,n=!0));var l,s=he.x*me,u=Math.abs(s-ct.x);return n||s>ct.x==0The image could not be loaded.',forceProgressiveLoading:!1,preload:[1,1],getNumItemsFn:function(){return Zt.length}},Yt=function(e,t,n){if(e.src&&!e.loadError){var o=!n;if(o&&(e.vGap||(e.vGap={top:0,bottom:0}),Se("parseVerticalMargin",e)),Bt.x=t.x,Bt.y=t.y-e.vGap.top-e.vGap.bottom,o){var i=Bt.x/e.w,r=Bt.y/e.h;e.fitRatio=iBt.x?Math.round(Bt.x-s):c.center.x,c.max.y=u>Bt.y?Math.round(Bt.y-u)+l.vGap.top:c.center.y,c.min.x=s>Bt.x?0:c.center.x,c.min.y=u>Bt.y?l.vGap.top:c.center.y,o&&n===e.initialZoomLevel&&(e.initialPosition=e.bounds.center),e.bounds}return e.w=e.h=0,e.initialZoomLevel=e.fitRatio=1,e.bounds={center:{x:0,y:0},max:{x:0,y:0},min:{x:0,y:0}},e.initialPosition=e.bounds.center,e.bounds;var l,s,u,c},Gt=function(e,t,n,o,i,r){t.loadError||o&&(t.imageAppended=!0,Xt(t,o,t===h.currItem&&xe),n.appendChild(o),r&&setTimeout(function(){t&&t.loaded&&t.placeholder&&(t.placeholder.style.display="none",t.placeholder=null)},500))},jt=function(e){e.loading=!0,e.loaded=!1;var t=e.img=f.createEl("pswp__img","img"),n=function(){e.loading=!1,e.loaded=!0,e.loadComplete?e.loadComplete(e):e.img=null,t.onload=t.onerror=null,t=null};return t.onload=n,t.onerror=function(){e.loadError=!0,n()},t.src=e.src,t},Vt=function(e,t){if(e.src&&e.loadError&&e.container)return t&&(e.container.innerHTML=""),e.container.innerHTML=w.errorMsg.replace("%url%",e.src),!0},Xt=function(e,t,n){if(e.src){t||(t=e.container.lastChild);var o=n?e.w:Math.round(e.w*e.fitRatio),i=n?e.h:Math.round(e.h*e.fitRatio);e.placeholder&&!e.loaded&&(e.placeholder.style.width=o+"px",e.placeholder.style.height=i+"px"),t.style.width=o+"px",t.style.height=i+"px"}},$t=function(){if(Wt.length){for(var e,t=0;t=ee.max.x&&n<=ee.min.y&&n>=ee.max.y)&&e.preventDefault(),h.panTo(t,n)},toggleDesktopZoom:function(e){e=e||{x:pe.x/2+fe.x,y:pe.y/2+fe.y};var t=w.getDoubleTapZoom(!0,h.currItem),n=v===t;h.mouseZoomedIn=!n,h.zoomTo(n?h.currItem.initialZoomLevel:t,e,333),f[(n?"remove":"add")+"Class"](m,"pswp--zoomed-in")}}});var nn,on,rn,an,ln,sn,un,cn,dn,pn,mn,fn,hn={history:!0,galleryUID:1},wn=function(){return mn.hash.substring(1)},gn=function(){nn&&clearTimeout(nn),rn&&clearTimeout(rn)},vn=function(){var e=wn(),t={};if(e.length<5)return t;var n,o=e.split("&");for(n=0;n