From 520d405042bdb4ad9b6b44a5ffe768c287fc80f1 Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Thu, 21 Dec 2023 19:07:00 +0000 Subject: [PATCH] Bug 35633: (follow-up) Custom style updates This patch adds custom CSS to the OPAC and staff interface to override the default style of Chocolat controls (for left arrow, right arrow, loading, and close window). These controls are given a green color matching Koha's color scheme. The bibliographic detail pages in the OPAC and staff interface have been revised so that the inclusion of Chocolat CSS comes before the inclusion of Koha's global CSS. We should do this with third-party CSS so that it can be more easily overridden by ours. The patch also makes a minor change to chocolat.js to correct a bug. See commit 6ac89ca8558. To test, apply the patch and rebuild the OPAC and staff interface CSS. - Go to Administration -> System preferences and enable the AllowMultipleCovers, OPACLocalCoverImages, and LocalCoverImages system preferences. - Add a local cover image to a bibliographic record: - Locate a bibliographic record. - From the detail page, click the "Images" tab and then "Upload." - Upload an image to attach to the record. - Upload another image. - Return to the bibliographic detail page fro that record, and click the image you uploaded. - The full-page image viewer should appear, and the controls should look correct, with green matching Koha's color scheme: - The close button in the upper-right - The right-arrow, and then when you click through to the second image, the left-arrow. - In the footer, the "edit" link should work correctly. - Test that the "Full screen" control works too. - Click the "OPAC view" link to load the record in the OPAC, and perform the same tests. Signed-off-by: Phan Tung Bui --- .../intranet-tmpl/lib/Chocolat/js/chocolat.js | 2 +- .../prog/css/src/staff-global.scss | 20 +++++++++++++++++++ .../intranet-tmpl/prog/en/modules/about.tt | 2 +- .../prog/en/modules/catalogue/detail.tt | 2 +- .../opac-tmpl/bootstrap/css/src/opac.scss | 13 ++++++++++++ .../bootstrap/en/modules/opac-detail.tt | 10 +++++----- .../opac-tmpl/lib/Chocolat/js/chocolat.js | 2 +- 7 files changed, 42 insertions(+), 9 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/lib/Chocolat/js/chocolat.js b/koha-tmpl/intranet-tmpl/lib/Chocolat/js/chocolat.js index 7a39da143d..37d615ba92 100644 --- a/koha-tmpl/intranet-tmpl/lib/Chocolat/js/chocolat.js +++ b/koha-tmpl/intranet-tmpl/lib/Chocolat/js/chocolat.js @@ -1 +1 @@ -!function(){"use strict";function e(e,t){for(var n=0;ne.length)&&(t=e.length);for(var n=0,i=new Array(t);n=74)&&(r=F.match(/Chrome\/(\d+)/))&&(o=r[1]);var N,G=o&&+o,D=!!Object.getOwnPropertySymbols&&!y((function(){var e=Symbol();return!String(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&G&&G<41})),q=D&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,B=E("wks"),Z=c.Symbol,V=q?Z:Z&&Z.withoutSetter||P,Y=function(e){return j(B,e)&&(D||"string"==typeof B[e])||(D&&j(Z,e)?B[e]=Z[e]:B[e]=V("Symbol."+e)),B[e]},U=function(e){if(h(e))return e;throw TypeError(String(e)+" is not an object")},X=!y((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),$=!X&&!y((function(){return 7!=Object.defineProperty(p("div"),"a",{get:function(){return 7}}).a})),K=q?function(e){return"symbol"==typeof e}:function(e){var t=W("Symbol");return u(t)&&Object(e)instanceof t},J=function(e){if(u(e))return e;throw TypeError(function(e){try{return String(e)}catch(e){return"Object"}}(e)+" is not a function")},Q=Y("toPrimitive"),ee=function(e,t){if(!h(e)||K(e))return e;var n,i,s=null==(n=e[Q])?void 0:J(n);if(s){if(void 0===t&&(t="default"),i=s.call(e,t),!h(i)||K(i))return i;throw TypeError("Can't convert object to primitive value")}return void 0===t&&(t="number"),function(e,t){var n,i;if("string"===t&&u(n=e.toString)&&!h(i=n.call(e)))return i;if(u(n=e.valueOf)&&!h(i=n.call(e)))return i;if("string"!==t&&u(n=e.toString)&&!h(i=n.call(e)))return i;throw TypeError("Can't convert object to primitive value")}(e,t)},te=function(e){var t=ee(e,"string");return K(t)?t:String(t)},ne=Object.defineProperty,ie={f:X?ne:function(e,t,n){if(U(e),t=te(t),U(n),$)try{return ne(e,t,n)}catch(e){}if("get"in n||"set"in n)throw TypeError("Accessors not supported");return"value"in n&&(e[t]=n.value),e}},se=Math.ceil,re=Math.floor,oe=function(e){var t=+e;return t!=t||0===t?0:(t>0?re:se)(t)},ae=Math.max,ce=Math.min,le=Math.min,ue=function(e){return(t=e.length)>0?le(oe(t),9007199254740991):0;var t},he=function(e){return function(t,n,i){var s,r=I(t),o=ue(r),a=function(e,t){var n=oe(e);return n<0?ae(n+t,0):ce(n,t)}(i,o);if(e&&n!=n){for(;o>a;)if((s=r[a++])!=s)return!0}else for(;o>a;a++)if((e||a in r)&&r[a]===n)return e||a||0;return!e&&-1}},me={includes:he(!0),indexOf:he(!1)},fe={},pe=me.indexOf,ge=function(e,t){var n,i=I(e),s=0,r=[];for(n in i)!j(fe,n)&&j(i,n)&&r.push(n);for(;t.length>s;)j(i,n=t[s++])&&(~pe(r,n)||r.push(n));return r},de=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],ve=Object.keys||function(e){return ge(e,de)},ye=X?Object.defineProperties:function(e,t){U(e);for(var n,i=ve(t),s=i.length,r=0;s>r;)ie.f(e,n=i[r++],t[n]);return e},be=W("document","documentElement"),we=E("keys"),Se=function(e){return we[e]||(we[e]=P(e))},Oe="prototype",Ie="script",Le=Se("IE_PROTO"),ke=function(){},Ce=function(e){return"<"+Ie+">"+e+""},Ee=function(e){e.write(Ce("")),e.close();var t=e.parentWindow.Object;return e=null,t},Ae=function(){try{N=new ActiveXObject("htmlfile")}catch(e){}var e,t,n;Ae="undefined"!=typeof document?document.domain&&N?Ee(N):(t=p("iframe"),n="java"+Ie+":",t.style.display="none",be.appendChild(t),t.src=String(n),(e=t.contentWindow.document).open(),e.write(Ce("document.F=Object")),e.close(),e.F):Ee(N);for(var i=de.length;i--;)delete Ae[Oe][de[i]];return Ae()};fe[Le]=!0;var Te=Object.create||function(e,t){var n;return null!==e?(ke[Oe]=U(e),n=new ke,ke[Oe]=null,n[Le]=e):n=Ae(),void 0===t?n:ye(n,t)},je=Y("unscopables"),ze=Array.prototype;null==ze[je]&&ie.f(ze,je,{configurable:!0,value:Te(null)});var xe=function(e){ze[je][e]=!0},Pe=Function.toString;u(C.inspectSource)||(C.inspectSource=function(e){return Pe.call(e)});var We,Fe,He,Me=C.inspectSource,_e=c.WeakMap,Re=u(_e)&&/native code/.test(Me(_e)),Ne=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}},Ge=X?function(e,t,n){return ie.f(e,t,Ne(1,n))}:function(e,t,n){return e[t]=n,e},De="Object already initialized",qe=c.WeakMap;if(Re||C.state){var Be=C.state||(C.state=new qe),Ze=Be.get,Ve=Be.has,Ye=Be.set;We=function(e,t){if(Ve.call(Be,e))throw new TypeError(De);return t.facade=e,Ye.call(Be,e,t),t},Fe=function(e){return Ze.call(Be,e)||{}},He=function(e){return Ve.call(Be,e)}}else{var Ue=Se("state");fe[Ue]=!0,We=function(e,t){if(j(e,Ue))throw new TypeError(De);return t.facade=e,Ge(e,Ue,t),t},Fe=function(e){return j(e,Ue)?e[Ue]:{}},He=function(e){return j(e,Ue)}}var Xe,$e,Ke,Je={set:We,get:Fe,has:He,enforce:function(e){return He(e)?Fe(e):We(e,{})},getterFor:function(e){return function(t){var n;if(!h(t)||(n=Fe(t)).type!==e)throw TypeError("Incompatible receiver, "+e+" required");return n}}},Qe={}.propertyIsEnumerable,et=Object.getOwnPropertyDescriptor,tt={f:et&&!Qe.call({1:2},1)?function(e){var t=et(this,e);return!!t&&t.enumerable}:Qe},nt=Object.getOwnPropertyDescriptor,it={f:X?nt:function(e,t){if(e=I(e),t=te(t),$)try{return nt(e,t)}catch(e){}if(j(e,t))return Ne(!tt.f.call(e,t),e[t])}},st=Function.prototype,rt=X&&Object.getOwnPropertyDescriptor,ot=j(st,"name"),at={EXISTS:ot,PROPER:ot&&"something"===function(){}.name,CONFIGURABLE:ot&&(!X||X&&rt(st,"name").configurable)},ct=s((function(e){var t=at.CONFIGURABLE,n=Je.get,i=Je.enforce,s=String(String).split("String");(e.exports=function(e,n,r,o){var a,l=!!o&&!!o.unsafe,h=!!o&&!!o.enumerable,m=!!o&&!!o.noTargetGet,f=o&&void 0!==o.name?o.name:n;u(r)&&("Symbol("===String(f).slice(0,7)&&(f="["+String(f).replace(/^Symbol\(([^)]*)\)/,"$1")+"]"),(!j(r,"name")||t&&r.name!==f)&&Ge(r,"name",f),(a=i(r)).source||(a.source=s.join("string"==typeof f?f:""))),e!==c?(l?!m&&e[n]&&(h=!0):delete e[n],h?e[n]=r:Ge(e,n,r)):h?e[n]=r:L(n,r)})(Function.prototype,"toString",(function(){return u(this)&&n(this).source||Me(this)}))})),lt=de.concat("length","prototype"),ut={f:Object.getOwnPropertyNames||function(e){return ge(e,lt)}},ht={f:Object.getOwnPropertySymbols},mt=W("Reflect","ownKeys")||function(e){var t=ut.f(U(e)),n=ht.f;return n?t.concat(n(e)):t},ft=function(e,t){for(var n=mt(t),i=ie.f,s=it.f,r=0;r=t.length?(e.target=void 0,{value:void 0,done:!0}):"keys"==n?{value:i,done:!1}:"values"==n?{value:t[i],done:!1}:{value:[i,t[i]],done:!1}}),"values");xe("keys"),xe("values"),xe("entries");var Yt=Y("iterator"),Ut=Y("toStringTag"),Xt=Vt.values,$t=function(e,t){if(e){if(e[Yt]!==Xt)try{Ge(e,Yt,Xt)}catch(t){e[Yt]=Xt}if(e[Ut]||Ge(e,Ut,t),l[t])for(var n in Vt)if(e[n]!==Vt[n])try{Ge(e,n,Vt[n])}catch(t){e[n]=Vt[n]}}};for(var Kt in l)$t(c[Kt]&&c[Kt].prototype,Kt);$t(v,"DOMTokenList");var Jt=void 0;function Qt(e,t){return new Promise((function(n){var i=function e(){t.removeEventListener("transitionend",e),n()};t.addEventListener("transitionend",i);var s=t.getAttribute("class"),r=t.getAttribute("style");e(),s===t.getAttribute("class")&&r===t.getAttribute("style")&&i(),0===parseFloat(getComputedStyle(t).transitionDuration)&&i()}))}function en(e){var t=e.src,n=e.srcset,i=e.sizes,s=new Image;return s.src=t,n&&(s.srcset=n),i&&(s.sizes=i),new Promise("decode"in s?function(e,t){s.decode().then((function(){e(s)})).catch((function(){t(s)}))}:function(e,t){s.onload=e(s),s.onerror=t(s)})}function tn(e){var t,n,i=e.imgHeight,s=e.imgWidth,r=e.containerHeight,o=e.containerWidth,a=e.canvasWidth,c=e.canvasHeight,l=e.imageSize,u=i/s;return"cover"==l?uc/a?n=(t=c)/u:t=(n=a)*u,"scale-down"===l&&(n>=s||t>=i)&&(n=s,t=i)),{height:t,width:n}}function nn(e){return e.requestFullscreen?e.requestFullscreen():e.webkitRequestFullscreen?e.webkitRequestFullscreen():e.msRequestFullscreen?e.msRequestFullscreen():Promise.reject()}function sn(){return document.exitFullscreen?document.exitFullscreen():document.webkitExitFullscreen?document.webkitExitFullscreen():document.msExitFullscreen?document.msExitFullscreen():Promise.reject()}var rn={container:document.body,className:void 0,imageSize:"scale-down",fullScreen:!1,loop:!1,linkImages:!0,setIndex:0,firstImageIndex:0,lastImageIndex:!1,currentImageIndex:void 0,allowZoom:!0,closeOnBackgroundClick:!0,imageSourceAttribute:"href",setTitle:function(){return""},description:function(){return this.images[this.settings.currentImageIndex].title},pagination:function(){var e=this.settings.lastImageIndex+1;return this.settings.currentImageIndex+1+"/"+e},afterInitialize:function(){},afterMarkup:function(){},afterImageLoad:function(){},afterClose:function(){},zoomedPaddingX:function(e,t){return 0},zoomedPaddingY:function(e,t){return 0}},on=function(){function n(e,t){var i=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,n),this.settings=t,this.elems={},this.images=[],this.events=[],this.state={fullScreenOpen:!1,initialZoomState:null,initialized:!1,timer:!1,visible:!1},this._cssClasses=["chocolat-open","chocolat-in-container","chocolat-cover","chocolat-zoomable","chocolat-zoomed","chocolat-zooming-in","chocolat-zooming-out"],NodeList.prototype.isPrototypeOf(e)||HTMLCollection.prototype.isPrototypeOf(e)?e.forEach((function(e,n){i.images.push({title:e.getAttribute("title"),src:e.getAttribute(t.imageSourceAttribute),srcset:e.getAttribute("data-srcset"),sizes:e.getAttribute("data-sizes")}),i.off(e,"click.chocolat"),i.on(e,"click.chocolat",(function(e){i.init(n),e.preventDefault()}))})):this.images=e,this.settings.container instanceof Element||this.settings.container instanceof HTMLElement?this.elems.container=this.settings.container:this.elems.container=document.body,this.api={open:function(e){return e=parseInt(e)||0,i.init(e)},close:function(){return i.close()},next:function(){return i.change(1)},prev:function(){return i.change(-1)},goto:function(e){return i.open(e)},current:function(){return i.settings.currentImageIndex},position:function(){return i.position(i.elems.img)},destroy:function(){return i.destroy()},set:function(e,t){return i.settings[e]=t,t},get:function(e){return i.settings[e]},getElem:function(e){return i.elems[e]}}}var i,s,r;return i=n,(s=[{key:"init",value:function(e){return this.state.initialized||(this.markup(),this.attachListeners(),this.settings.lastImageIndex=this.images.length-1,this.state.initialized=!0),this.settings.afterInitialize.call(this),this.load(e)}},{key:"load",value:function(e){var t=this;if(this.state.visible||(this.state.visible=!0,setTimeout((function(){t.elems.overlay.classList.add("chocolat-visible"),t.elems.wrapper.classList.add("chocolat-visible")}),0),this.elems.container.classList.add("chocolat-open")),this.settings.fullScreen&&nn(this.elems.wrapper),this.settings.currentImageIndex===e)return Promise.resolve();var n,i,s=setTimeout((function(){t.elems.loader.classList.add("chocolat-visible")}),1e3),r=setTimeout((function(){r=void 0,n=Qt((function(){t.elems.imageCanvas.classList.remove("chocolat-visible")}),t.elems.imageCanvas)}),80);return en(this.images[e]).then((function(e){return i=e,r?(clearTimeout(r),Promise.resolve()):n})).then((function(){var n=e+1;return null!=t.images[n]&&en(t.images[n]),t.settings.currentImageIndex=e,t.elems.description.textContent=t.settings.description.call(t),t.elems.pagination.textContent=t.settings.pagination.call(t),t.arrows(),t.position(i).then((function(){return t.elems.loader.classList.remove("chocolat-visible"),clearTimeout(s),t.appear(i)}))})).then((function(){t.elems.container.classList.toggle("chocolat-zoomable",t.zoomable(i,t.elems.wrapper)),t.settings.afterImageLoad.call(t)}))}},{key:"position",value:function(e){var t=this,n=tn({imgHeight:e.naturalHeight,imgWidth:e.naturalWidth,containerHeight:this.elems.container.clientHeight,containerWidth:this.elems.container.clientWidth,canvasWidth:this.elems.imageCanvas.clientWidth,canvasHeight:this.elems.imageCanvas.clientHeight,imageSize:this.settings.imageSize}),i=n.width,s=n.height;return Qt((function(){Object.assign(t.elems.imageWrapper.style,{width:i+"px",height:s+"px"})}),this.elems.imageWrapper)}},{key:"appear",value:function(e){var t=this;return this.elems.imageWrapper.removeChild(this.elems.img),this.elems.img=e,this.elems.img.setAttribute("class","chocolat-img"),this.elems.imageWrapper.appendChild(this.elems.img),Qt((function(){t.elems.imageCanvas.classList.add("chocolat-visible")}),this.elems.imageCanvas)}},{key:"change",value:function(e){if(this.state.visible&&this.settings.linkImages){this.zoomOut();var t=this.settings.currentImageIndex+parseInt(e);if(t>this.settings.lastImageIndex){if(this.settings.loop)return this.load(this.settings.firstImageIndex)}else{if(!(t=0;n--){var i=this.events[n],s=i.element,r=i.eventName;this.off(s,r)}this.state.initialized&&(this.state.fullScreenOpen&&sn(),this.settings.currentImageIndex=void 0,this.state.visible=!1,this.state.initialized=!1,(e=this.elems.container.classList).remove.apply(e,t(this._cssClasses)),this.elems.wrapper.parentNode.removeChild(this.elems.wrapper))}},{key:"markup",value:function(){this.elems.container.classList.add("chocolat-open",this.settings.className),"cover"==this.settings.imageSize&&this.elems.container.classList.add("chocolat-cover"),this.elems.container!==document.body&&this.elems.container.classList.add("chocolat-in-container"),this.elems.wrapper=document.createElement("div"),this.elems.wrapper.setAttribute("id","chocolat-content-"+this.settings.setIndex),this.elems.wrapper.setAttribute("class","chocolat-wrapper"),this.elems.container.appendChild(this.elems.wrapper),this.elems.overlay=document.createElement("div"),this.elems.overlay.setAttribute("class","chocolat-overlay"),this.elems.wrapper.appendChild(this.elems.overlay),this.elems.loader=document.createElement("div"),this.elems.loader.setAttribute("class","chocolat-loader"),this.elems.wrapper.appendChild(this.elems.loader),this.elems.layout=document.createElement("div"),this.elems.layout.setAttribute("class","chocolat-layout"),this.elems.wrapper.appendChild(this.elems.layout),this.elems.top=document.createElement("div"),this.elems.top.setAttribute("class","chocolat-top"),this.elems.layout.appendChild(this.elems.top),this.elems.center=document.createElement("div"),this.elems.center.setAttribute("class","chocolat-center"),this.elems.layout.appendChild(this.elems.center),this.elems.left=document.createElement("div"),this.elems.left.setAttribute("class","chocolat-left"),this.elems.center.appendChild(this.elems.left),this.elems.imageCanvas=document.createElement("div"),this.elems.imageCanvas.setAttribute("class","chocolat-image-canvas"),this.elems.center.appendChild(this.elems.imageCanvas),this.elems.imageWrapper=document.createElement("div"),this.elems.imageWrapper.setAttribute("class","chocolat-image-wrapper"),this.elems.imageCanvas.appendChild(this.elems.imageWrapper),this.elems.img=document.createElement("img"),this.elems.img.setAttribute("class","chocolat-img"),this.elems.imageWrapper.appendChild(this.elems.img),this.elems.right=document.createElement("div"),this.elems.right.setAttribute("class","chocolat-right"),this.elems.center.appendChild(this.elems.right),this.elems.bottom=document.createElement("div"),this.elems.bottom.setAttribute("class","chocolat-bottom"),this.elems.layout.appendChild(this.elems.bottom),this.elems.close=document.createElement("span"),this.elems.close.setAttribute("class","chocolat-close"),this.elems.top.appendChild(this.elems.close),this.elems.description=document.createElement("span"),this.elems.description.setAttribute("class","chocolat-description"),this.elems.bottom.appendChild(this.elems.description),this.elems.pagination=document.createElement("span"),this.elems.pagination.setAttribute("class","chocolat-pagination"),this.elems.bottom.appendChild(this.elems.pagination),this.elems.setTitle=document.createElement("span"),this.elems.setTitle.setAttribute("class","chocolat-set-title"),this.elems.setTitle.textContent=this.settings.setTitle(),this.elems.bottom.appendChild(this.elems.setTitle),this.elems.fullscreen=document.createElement("span"),this.elems.fullscreen.setAttribute("class","chocolat-fullscreen"),this.elems.bottom.appendChild(this.elems.fullscreen),this.settings.afterMarkup.call(this)}},{key:"attachListeners",value:function(){var e=this;this.off(document,"keydown.chocolat"),this.on(document,"keydown.chocolat",(function(t){e.state.initialized&&(37==t.keyCode?e.change(-1):39==t.keyCode?e.change(1):27==t.keyCode&&e.close())}));var t=this.elems.wrapper.querySelector(".chocolat-right");this.off(t,"click.chocolat"),this.on(t,"click.chocolat",(function(){e.change(1)}));var n=this.elems.wrapper.querySelector(".chocolat-left");this.off(n,"click.chocolat"),this.on(n,"click.chocolat",(function(){e.change(-1)})),this.off(this.elems.close,"click.chocolat"),this.on(this.elems.close,"click.chocolat",this.close.bind(this)),this.off(this.elems.fullscreen,"click.chocolat"),this.on(this.elems.fullscreen,"click.chocolat",(function(){e.state.fullScreenOpen?sn():nn(e.elems.wrapper)})),this.off(document,"fullscreenchange.chocolat"),this.on(document,"fullscreenchange.chocolat",(function(){document.fullscreenElement||document.webkitCurrentFullScreenElement||document.webkitFullscreenElement?e.state.fullScreenOpen=!0:e.state.fullScreenOpen=!1})),this.off(document,"webkitfullscreenchange.chocolat"),this.on(document,"webkitfullscreenchange.chocolat",(function(){document.fullscreenElement||document.webkitCurrentFullScreenElement||document.webkitFullscreenElement?e.state.fullScreenOpen=!0:e.state.fullScreenOpen=!1})),this.settings.closeOnBackgroundClick&&(this.off(this.elems.overlay,"click.chocolat"),this.on(this.elems.overlay,"click.chocolat",this.close.bind(this))),this.off(this.elems.wrapper,"click.chocolat"),this.on(this.elems.wrapper,"click.chocolat",(function(){null!==e.state.initialZoomState&&e.state.visible&&(e.elems.container.classList.add("chocolat-zooming-out"),e.zoomOut().then((function(){e.elems.container.classList.remove("chocolat-zoomed"),e.elems.container.classList.remove("chocolat-zooming-out")})))})),this.off(this.elems.imageWrapper,"click.chocolat"),this.on(this.elems.imageWrapper,"click.chocolat",(function(t){null===e.state.initialZoomState&&e.elems.container.classList.contains("chocolat-zoomable")&&(t.stopPropagation(),e.elems.container.classList.add("chocolat-zooming-in"),e.zoomIn(t).then((function(){e.elems.container.classList.add("chocolat-zoomed"),e.elems.container.classList.remove("chocolat-zooming-in")})))})),this.on(this.elems.wrapper,"mousemove.chocolat",(function(t){if(null!==e.state.initialZoomState&&e.state.visible){var n=e.elems.wrapper.getBoundingClientRect(),i=n.top+window.scrollY,s=n.left+window.scrollX,r=e.elems.wrapper.clientHeight,o=e.elems.wrapper.clientWidth,a=e.elems.img.width,c=e.elems.img.height,l=[t.pageX-o/2-s,t.pageY-r/2-i],u=0;if(a>o){var h=e.settings.zoomedPaddingX(a,o);u=l[0]/(o/2),u*=(a-o)/2+h}var m=0;if(c>r){var f=e.settings.zoomedPaddingY(c,r);m=l[1]/(r/2),m*=(c-r)/2+f}e.elems.img.style.marginLeft=-u+"px",e.elems.img.style.marginTop=-m+"px"}})),this.on(window,"resize.chocolat",(function(t){var n,i;e.state.initialized&&e.state.visible&&(n=50,i=function(){tn({imgHeight:e.elems.img.naturalHeight,imgWidth:e.elems.img.naturalWidth,containerHeight:e.elems.wrapper.clientHeight,containerWidth:e.elems.wrapper.clientWidth,canvasWidth:e.elems.imageCanvas.clientWidth,canvasHeight:e.elems.imageCanvas.clientHeight,imageSize:e.settings.imageSize}),e.position(e.elems.img).then((function(){e.elems.container.classList.toggle("chocolat-zoomable",e.zoomable(e.elems.img,e.elems.wrapper))}))},clearTimeout(Jt),Jt=setTimeout((function(){i()}),n))}))}},{key:"zoomable",value:function(e,t){var n=t.clientWidth,i=t.clientHeight,s=!(!this.settings.allowZoom||!(e.naturalWidth>n||e.naturalHeight>i)),r=e.clientWidth>e.naturalWidth||e.clientHeight>e.naturalHeight;return s&&!r}},{key:"zoomIn",value:function(e){return this.state.initialZoomState=this.settings.imageSize,this.settings.imageSize="native",this.position(this.elems.img)}},{key:"zoomOut",value:function(e){return this.settings.imageSize=this.state.initialZoomState||this.settings.imageSize,this.state.initialZoomState=null,this.elems.img.style.margin=0,this.position(this.elems.img)}},{key:"on",value:function(e,t,n){var i=this.events.push({element:e,eventName:t,cb:n});e.addEventListener(t.split(".")[0],this.events[i-1].cb)}},{key:"off",value:function(e,t){var n=this.events.findIndex((function(n){return n.element===e&&n.eventName===t}));this.events[n]&&(e.removeEventListener(t.split(".")[0],this.events[n].cb),this.events.splice(n,1))}}])&&e(i.prototype,s),r&&e(i,r),n}(),an=[];window.Chocolat=function(e,t){var n=Object.assign({},rn,{images:[]},t,{setIndex:an.length}),i=new on(e,n);return an.push(i),i}}(); +!function(){"use strict";function e(e,t){for(var n=0;ne.length)&&(t=e.length);for(var n=0,i=new Array(t);n=74)&&(r=F.match(/Chrome\/(\d+)/))&&(o=r[1]);var N,G=o&&+o,D=!!Object.getOwnPropertySymbols&&!y((function(){var e=Symbol();return!String(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&G&&G<41})),q=D&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,B=E("wks"),Z=c.Symbol,V=q?Z:Z&&Z.withoutSetter||P,Y=function(e){return j(B,e)&&(D||"string"==typeof B[e])||(D&&j(Z,e)?B[e]=Z[e]:B[e]=V("Symbol."+e)),B[e]},U=function(e){if(h(e))return e;throw TypeError(String(e)+" is not an object")},X=!y((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),$=!X&&!y((function(){return 7!=Object.defineProperty(p("div"),"a",{get:function(){return 7}}).a})),K=q?function(e){return"symbol"==typeof e}:function(e){var t=W("Symbol");return u(t)&&Object(e)instanceof t},J=function(e){if(u(e))return e;throw TypeError(function(e){try{return String(e)}catch(e){return"Object"}}(e)+" is not a function")},Q=Y("toPrimitive"),ee=function(e,t){if(!h(e)||K(e))return e;var n,i,s=null==(n=e[Q])?void 0:J(n);if(s){if(void 0===t&&(t="default"),i=s.call(e,t),!h(i)||K(i))return i;throw TypeError("Can't convert object to primitive value")}return void 0===t&&(t="number"),function(e,t){var n,i;if("string"===t&&u(n=e.toString)&&!h(i=n.call(e)))return i;if(u(n=e.valueOf)&&!h(i=n.call(e)))return i;if("string"!==t&&u(n=e.toString)&&!h(i=n.call(e)))return i;throw TypeError("Can't convert object to primitive value")}(e,t)},te=function(e){var t=ee(e,"string");return K(t)?t:String(t)},ne=Object.defineProperty,ie={f:X?ne:function(e,t,n){if(U(e),t=te(t),U(n),$)try{return ne(e,t,n)}catch(e){}if("get"in n||"set"in n)throw TypeError("Accessors not supported");return"value"in n&&(e[t]=n.value),e}},se=Math.ceil,re=Math.floor,oe=function(e){var t=+e;return t!=t||0===t?0:(t>0?re:se)(t)},ae=Math.max,ce=Math.min,le=Math.min,ue=function(e){return(t=e.length)>0?le(oe(t),9007199254740991):0;var t},he=function(e){return function(t,n,i){var s,r=I(t),o=ue(r),a=function(e,t){var n=oe(e);return n<0?ae(n+t,0):ce(n,t)}(i,o);if(e&&n!=n){for(;o>a;)if((s=r[a++])!=s)return!0}else for(;o>a;a++)if((e||a in r)&&r[a]===n)return e||a||0;return!e&&-1}},me={includes:he(!0),indexOf:he(!1)},fe={},pe=me.indexOf,ge=function(e,t){var n,i=I(e),s=0,r=[];for(n in i)!j(fe,n)&&j(i,n)&&r.push(n);for(;t.length>s;)j(i,n=t[s++])&&(~pe(r,n)||r.push(n));return r},de=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],ve=Object.keys||function(e){return ge(e,de)},ye=X?Object.defineProperties:function(e,t){U(e);for(var n,i=ve(t),s=i.length,r=0;s>r;)ie.f(e,n=i[r++],t[n]);return e},be=W("document","documentElement"),we=E("keys"),Se=function(e){return we[e]||(we[e]=P(e))},Oe="prototype",Ie="script",Le=Se("IE_PROTO"),ke=function(){},Ce=function(e){return"<"+Ie+">"+e+""},Ee=function(e){e.write(Ce("")),e.close();var t=e.parentWindow.Object;return e=null,t},Ae=function(){try{N=new ActiveXObject("htmlfile")}catch(e){}var e,t,n;Ae="undefined"!=typeof document?document.domain&&N?Ee(N):(t=p("iframe"),n="java"+Ie+":",t.style.display="none",be.appendChild(t),t.src=String(n),(e=t.contentWindow.document).open(),e.write(Ce("document.F=Object")),e.close(),e.F):Ee(N);for(var i=de.length;i--;)delete Ae[Oe][de[i]];return Ae()};fe[Le]=!0;var Te=Object.create||function(e,t){var n;return null!==e?(ke[Oe]=U(e),n=new ke,ke[Oe]=null,n[Le]=e):n=Ae(),void 0===t?n:ye(n,t)},je=Y("unscopables"),ze=Array.prototype;null==ze[je]&&ie.f(ze,je,{configurable:!0,value:Te(null)});var xe=function(e){ze[je][e]=!0},Pe=Function.toString;u(C.inspectSource)||(C.inspectSource=function(e){return Pe.call(e)});var We,Fe,He,Me=C.inspectSource,_e=c.WeakMap,Re=u(_e)&&/native code/.test(Me(_e)),Ne=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}},Ge=X?function(e,t,n){return ie.f(e,t,Ne(1,n))}:function(e,t,n){return e[t]=n,e},De="Object already initialized",qe=c.WeakMap;if(Re||C.state){var Be=C.state||(C.state=new qe),Ze=Be.get,Ve=Be.has,Ye=Be.set;We=function(e,t){if(Ve.call(Be,e))throw new TypeError(De);return t.facade=e,Ye.call(Be,e,t),t},Fe=function(e){return Ze.call(Be,e)||{}},He=function(e){return Ve.call(Be,e)}}else{var Ue=Se("state");fe[Ue]=!0,We=function(e,t){if(j(e,Ue))throw new TypeError(De);return t.facade=e,Ge(e,Ue,t),t},Fe=function(e){return j(e,Ue)?e[Ue]:{}},He=function(e){return j(e,Ue)}}var Xe,$e,Ke,Je={set:We,get:Fe,has:He,enforce:function(e){return He(e)?Fe(e):We(e,{})},getterFor:function(e){return function(t){var n;if(!h(t)||(n=Fe(t)).type!==e)throw TypeError("Incompatible receiver, "+e+" required");return n}}},Qe={}.propertyIsEnumerable,et=Object.getOwnPropertyDescriptor,tt={f:et&&!Qe.call({1:2},1)?function(e){var t=et(this,e);return!!t&&t.enumerable}:Qe},nt=Object.getOwnPropertyDescriptor,it={f:X?nt:function(e,t){if(e=I(e),t=te(t),$)try{return nt(e,t)}catch(e){}if(j(e,t))return Ne(!tt.f.call(e,t),e[t])}},st=Function.prototype,rt=X&&Object.getOwnPropertyDescriptor,ot=j(st,"name"),at={EXISTS:ot,PROPER:ot&&"something"===function(){}.name,CONFIGURABLE:ot&&(!X||X&&rt(st,"name").configurable)},ct=s((function(e){var t=at.CONFIGURABLE,n=Je.get,i=Je.enforce,s=String(String).split("String");(e.exports=function(e,n,r,o){var a,l=!!o&&!!o.unsafe,h=!!o&&!!o.enumerable,m=!!o&&!!o.noTargetGet,f=o&&void 0!==o.name?o.name:n;u(r)&&("Symbol("===String(f).slice(0,7)&&(f="["+String(f).replace(/^Symbol\(([^)]*)\)/,"$1")+"]"),(!j(r,"name")||t&&r.name!==f)&&Ge(r,"name",f),(a=i(r)).source||(a.source=s.join("string"==typeof f?f:""))),e!==c?(l?!m&&e[n]&&(h=!0):delete e[n],h?e[n]=r:Ge(e,n,r)):h?e[n]=r:L(n,r)})(Function.prototype,"toString",(function(){return u(this)&&n(this).source||Me(this)}))})),lt=de.concat("length","prototype"),ut={f:Object.getOwnPropertyNames||function(e){return ge(e,lt)}},ht={f:Object.getOwnPropertySymbols},mt=W("Reflect","ownKeys")||function(e){var t=ut.f(U(e)),n=ht.f;return n?t.concat(n(e)):t},ft=function(e,t){for(var n=mt(t),i=ie.f,s=it.f,r=0;r=t.length?(e.target=void 0,{value:void 0,done:!0}):"keys"==n?{value:i,done:!1}:"values"==n?{value:t[i],done:!1}:{value:[i,t[i]],done:!1}}),"values");xe("keys"),xe("values"),xe("entries");var Yt=Y("iterator"),Ut=Y("toStringTag"),Xt=Vt.values,$t=function(e,t){if(e){if(e[Yt]!==Xt)try{Ge(e,Yt,Xt)}catch(t){e[Yt]=Xt}if(e[Ut]||Ge(e,Ut,t),l[t])for(var n in Vt)if(e[n]!==Vt[n])try{Ge(e,n,Vt[n])}catch(t){e[n]=Vt[n]}}};for(var Kt in l)$t(c[Kt]&&c[Kt].prototype,Kt);$t(v,"DOMTokenList");var Jt=void 0;function Qt(e,t){return new Promise((function(n){var i=function e(){t.removeEventListener("transitionend",e),n()};t.addEventListener("transitionend",i);var s=t.getAttribute("class"),r=t.getAttribute("style");e(),s===t.getAttribute("class")&&r===t.getAttribute("style")&&i(),0===parseFloat(getComputedStyle(t).transitionDuration)&&i()}))}function en(e){var t=e.src,n=e.srcset,i=e.sizes,s=new Image;return s.src=t,n&&(s.srcset=n),i&&(s.sizes=i),new Promise("decode"in s?function(e,t){s.decode().then((function(){e(s)})).catch((function(){t(s)}))}:function(e,t){s.onload=e(s),s.onerror=t(s)})}function tn(e){var t,n,i=e.imgHeight,s=e.imgWidth,r=e.containerHeight,o=e.containerWidth,a=e.canvasWidth,c=e.canvasHeight,l=e.imageSize,u=i/s;return"cover"==l?uc/a?n=(t=c)/u:t=(n=a)*u,"scale-down"===l&&(n>=s||t>=i)&&(n=s,t=i)),{height:t,width:n}}function nn(e){return e.requestFullscreen?e.requestFullscreen():e.webkitRequestFullscreen?e.webkitRequestFullscreen():e.msRequestFullscreen?e.msRequestFullscreen():Promise.reject()}function sn(){return document.exitFullscreen?document.exitFullscreen():document.webkitExitFullscreen?document.webkitExitFullscreen():document.msExitFullscreen?document.msExitFullscreen():Promise.reject()}var rn={container:document.body,className:void 0,imageSize:"scale-down",fullScreen:!1,loop:!1,linkImages:!0,setIndex:0,firstImageIndex:0,lastImageIndex:!1,currentImageIndex:void 0,allowZoom:!0,closeOnBackgroundClick:!0,imageSourceAttribute:"href",setTitle:function(){return""},description:function(){return this.images[this.settings.currentImageIndex].title},pagination:function(){var e=this.settings.lastImageIndex+1;return this.settings.currentImageIndex+1+"/"+e},afterInitialize:function(){},afterMarkup:function(){},afterImageLoad:function(){},afterClose:function(){},zoomedPaddingX:function(e,t){return 0},zoomedPaddingY:function(e,t){return 0}},on=function(){function n(e,t){var i=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,n),this.settings=t,this.elems={},this.images=[],this.events=[],this.state={fullScreenOpen:!1,initialZoomState:null,initialized:!1,timer:!1,visible:!1},this._cssClasses=["chocolat-open","chocolat-in-container","chocolat-cover","chocolat-zoomable","chocolat-zoomed","chocolat-zooming-in","chocolat-zooming-out"],NodeList.prototype.isPrototypeOf(e)||HTMLCollection.prototype.isPrototypeOf(e)?e.forEach((function(e,n){i.images.push({title:e.getAttribute("title"),src:e.getAttribute(t.imageSourceAttribute),srcset:e.getAttribute("data-srcset"),sizes:e.getAttribute("data-sizes")}),i.off(e,"click.chocolat"),i.on(e,"click.chocolat",(function(e){i.init(n),e.preventDefault()}))})):this.images=e,this.settings.container instanceof Element||this.settings.container instanceof HTMLElement?this.elems.container=this.settings.container:this.elems.container=document.body,this.api={open:function(e){return e=parseInt(e)||0,i.init(e)},close:function(){return i.close()},next:function(){return i.change(1)},prev:function(){return i.change(-1)},goto:function(e){return i.open(e)},current:function(){return i.settings.currentImageIndex},position:function(){return i.position(i.elems.img)},destroy:function(){return i.destroy()},set:function(e,t){return i.settings[e]=t,t},get:function(e){return i.settings[e]},getElem:function(e){return i.elems[e]}}}var i,s,r;return i=n,(s=[{key:"init",value:function(e){return this.state.initialized||(this.markup(),this.attachListeners(),this.settings.lastImageIndex=this.images.length-1,this.state.initialized=!0),this.settings.afterInitialize.call(this),this.load(e)}},{key:"load",value:function(e){var t=this;if(this.state.visible||(this.state.visible=!0,setTimeout((function(){t.elems.overlay.classList.add("chocolat-visible"),t.elems.wrapper.classList.add("chocolat-visible")}),0),this.elems.container.classList.add("chocolat-open")),this.settings.fullScreen&&nn(this.elems.wrapper),this.settings.currentImageIndex===e)return Promise.resolve();var n,i,s=setTimeout((function(){t.elems.loader.classList.add("chocolat-visible")}),1e3),r=setTimeout((function(){r=void 0,n=Qt((function(){t.elems.imageCanvas.classList.remove("chocolat-visible")}),t.elems.imageCanvas)}),80);return en(this.images[e]).then((function(e){return i=e,r?(clearTimeout(r),Promise.resolve()):n})).then((function(){var n=e+1;return null!=t.images[n]&&en(t.images[n]),t.settings.currentImageIndex=e,t.elems.description.innerHTML=t.settings.description.call(t),t.elems.pagination.textContent=t.settings.pagination.call(t),t.arrows(),t.position(i).then((function(){return t.elems.loader.classList.remove("chocolat-visible"),clearTimeout(s),t.appear(i)}))})).then((function(){t.elems.container.classList.toggle("chocolat-zoomable",t.zoomable(i,t.elems.wrapper)),t.settings.afterImageLoad.call(t)}))}},{key:"position",value:function(e){var t=this,n=tn({imgHeight:e.naturalHeight,imgWidth:e.naturalWidth,containerHeight:this.elems.container.clientHeight,containerWidth:this.elems.container.clientWidth,canvasWidth:this.elems.imageCanvas.clientWidth,canvasHeight:this.elems.imageCanvas.clientHeight,imageSize:this.settings.imageSize}),i=n.width,s=n.height;return Qt((function(){Object.assign(t.elems.imageWrapper.style,{width:i+"px",height:s+"px"})}),this.elems.imageWrapper)}},{key:"appear",value:function(e){var t=this;return this.elems.imageWrapper.removeChild(this.elems.img),this.elems.img=e,this.elems.img.setAttribute("class","chocolat-img"),this.elems.imageWrapper.appendChild(this.elems.img),Qt((function(){t.elems.imageCanvas.classList.add("chocolat-visible")}),this.elems.imageCanvas)}},{key:"change",value:function(e){if(this.state.visible&&this.settings.linkImages){this.zoomOut();var t=this.settings.currentImageIndex+parseInt(e);if(t>this.settings.lastImageIndex){if(this.settings.loop)return this.load(this.settings.firstImageIndex)}else{if(!(t=0;n--){var i=this.events[n],s=i.element,r=i.eventName;this.off(s,r)}this.state.initialized&&(this.state.fullScreenOpen&&sn(),this.settings.currentImageIndex=void 0,this.state.visible=!1,this.state.initialized=!1,(e=this.elems.container.classList).remove.apply(e,t(this._cssClasses)),this.elems.wrapper.parentNode.removeChild(this.elems.wrapper))}},{key:"markup",value:function(){this.elems.container.classList.add("chocolat-open",this.settings.className),"cover"==this.settings.imageSize&&this.elems.container.classList.add("chocolat-cover"),this.elems.container!==document.body&&this.elems.container.classList.add("chocolat-in-container"),this.elems.wrapper=document.createElement("div"),this.elems.wrapper.setAttribute("id","chocolat-content-"+this.settings.setIndex),this.elems.wrapper.setAttribute("class","chocolat-wrapper"),this.elems.container.appendChild(this.elems.wrapper),this.elems.overlay=document.createElement("div"),this.elems.overlay.setAttribute("class","chocolat-overlay"),this.elems.wrapper.appendChild(this.elems.overlay),this.elems.loader=document.createElement("div"),this.elems.loader.setAttribute("class","chocolat-loader"),this.elems.wrapper.appendChild(this.elems.loader),this.elems.layout=document.createElement("div"),this.elems.layout.setAttribute("class","chocolat-layout"),this.elems.wrapper.appendChild(this.elems.layout),this.elems.top=document.createElement("div"),this.elems.top.setAttribute("class","chocolat-top"),this.elems.layout.appendChild(this.elems.top),this.elems.center=document.createElement("div"),this.elems.center.setAttribute("class","chocolat-center"),this.elems.layout.appendChild(this.elems.center),this.elems.left=document.createElement("div"),this.elems.left.setAttribute("class","chocolat-left"),this.elems.center.appendChild(this.elems.left),this.elems.imageCanvas=document.createElement("div"),this.elems.imageCanvas.setAttribute("class","chocolat-image-canvas"),this.elems.center.appendChild(this.elems.imageCanvas),this.elems.imageWrapper=document.createElement("div"),this.elems.imageWrapper.setAttribute("class","chocolat-image-wrapper"),this.elems.imageCanvas.appendChild(this.elems.imageWrapper),this.elems.img=document.createElement("img"),this.elems.img.setAttribute("class","chocolat-img"),this.elems.imageWrapper.appendChild(this.elems.img),this.elems.right=document.createElement("div"),this.elems.right.setAttribute("class","chocolat-right"),this.elems.center.appendChild(this.elems.right),this.elems.bottom=document.createElement("div"),this.elems.bottom.setAttribute("class","chocolat-bottom"),this.elems.layout.appendChild(this.elems.bottom),this.elems.close=document.createElement("span"),this.elems.close.setAttribute("class","chocolat-close"),this.elems.top.appendChild(this.elems.close),this.elems.description=document.createElement("span"),this.elems.description.setAttribute("class","chocolat-description"),this.elems.bottom.appendChild(this.elems.description),this.elems.pagination=document.createElement("span"),this.elems.pagination.setAttribute("class","chocolat-pagination"),this.elems.bottom.appendChild(this.elems.pagination),this.elems.setTitle=document.createElement("span"),this.elems.setTitle.setAttribute("class","chocolat-set-title"),this.elems.setTitle.textContent=this.settings.setTitle(),this.elems.bottom.appendChild(this.elems.setTitle),this.elems.fullscreen=document.createElement("span"),this.elems.fullscreen.setAttribute("class","chocolat-fullscreen"),this.elems.bottom.appendChild(this.elems.fullscreen),this.settings.afterMarkup.call(this)}},{key:"attachListeners",value:function(){var e=this;this.off(document,"keydown.chocolat"),this.on(document,"keydown.chocolat",(function(t){e.state.initialized&&(37==t.keyCode?e.change(-1):39==t.keyCode?e.change(1):27==t.keyCode&&e.close())}));var t=this.elems.wrapper.querySelector(".chocolat-right");this.off(t,"click.chocolat"),this.on(t,"click.chocolat",(function(){e.change(1)}));var n=this.elems.wrapper.querySelector(".chocolat-left");this.off(n,"click.chocolat"),this.on(n,"click.chocolat",(function(){e.change(-1)})),this.off(this.elems.close,"click.chocolat"),this.on(this.elems.close,"click.chocolat",this.close.bind(this)),this.off(this.elems.fullscreen,"click.chocolat"),this.on(this.elems.fullscreen,"click.chocolat",(function(){e.state.fullScreenOpen?sn():nn(e.elems.wrapper)})),this.off(document,"fullscreenchange.chocolat"),this.on(document,"fullscreenchange.chocolat",(function(){document.fullscreenElement||document.webkitCurrentFullScreenElement||document.webkitFullscreenElement?e.state.fullScreenOpen=!0:e.state.fullScreenOpen=!1})),this.off(document,"webkitfullscreenchange.chocolat"),this.on(document,"webkitfullscreenchange.chocolat",(function(){document.fullscreenElement||document.webkitCurrentFullScreenElement||document.webkitFullscreenElement?e.state.fullScreenOpen=!0:e.state.fullScreenOpen=!1})),this.settings.closeOnBackgroundClick&&(this.off(this.elems.overlay,"click.chocolat"),this.on(this.elems.overlay,"click.chocolat",this.close.bind(this))),this.off(this.elems.wrapper,"click.chocolat"),this.on(this.elems.wrapper,"click.chocolat",(function(){null!==e.state.initialZoomState&&e.state.visible&&(e.elems.container.classList.add("chocolat-zooming-out"),e.zoomOut().then((function(){e.elems.container.classList.remove("chocolat-zoomed"),e.elems.container.classList.remove("chocolat-zooming-out")})))})),this.off(this.elems.imageWrapper,"click.chocolat"),this.on(this.elems.imageWrapper,"click.chocolat",(function(t){null===e.state.initialZoomState&&e.elems.container.classList.contains("chocolat-zoomable")&&(t.stopPropagation(),e.elems.container.classList.add("chocolat-zooming-in"),e.zoomIn(t).then((function(){e.elems.container.classList.add("chocolat-zoomed"),e.elems.container.classList.remove("chocolat-zooming-in")})))})),this.on(this.elems.wrapper,"mousemove.chocolat",(function(t){if(null!==e.state.initialZoomState&&e.state.visible){var n=e.elems.wrapper.getBoundingClientRect(),i=n.top+window.scrollY,s=n.left+window.scrollX,r=e.elems.wrapper.clientHeight,o=e.elems.wrapper.clientWidth,a=e.elems.img.width,c=e.elems.img.height,l=[t.pageX-o/2-s,t.pageY-r/2-i],u=0;if(a>o){var h=e.settings.zoomedPaddingX(a,o);u=l[0]/(o/2),u*=(a-o)/2+h}var m=0;if(c>r){var f=e.settings.zoomedPaddingY(c,r);m=l[1]/(r/2),m*=(c-r)/2+f}e.elems.img.style.marginLeft=-u+"px",e.elems.img.style.marginTop=-m+"px"}})),this.on(window,"resize.chocolat",(function(t){var n,i;e.state.initialized&&e.state.visible&&(n=50,i=function(){tn({imgHeight:e.elems.img.naturalHeight,imgWidth:e.elems.img.naturalWidth,containerHeight:e.elems.wrapper.clientHeight,containerWidth:e.elems.wrapper.clientWidth,canvasWidth:e.elems.imageCanvas.clientWidth,canvasHeight:e.elems.imageCanvas.clientHeight,imageSize:e.settings.imageSize}),e.position(e.elems.img).then((function(){e.elems.container.classList.toggle("chocolat-zoomable",e.zoomable(e.elems.img,e.elems.wrapper))}))},clearTimeout(Jt),Jt=setTimeout((function(){i()}),n))}))}},{key:"zoomable",value:function(e,t){var n=t.clientWidth,i=t.clientHeight,s=!(!this.settings.allowZoom||!(e.naturalWidth>n||e.naturalHeight>i)),r=e.clientWidth>e.naturalWidth||e.clientHeight>e.naturalHeight;return s&&!r}},{key:"zoomIn",value:function(e){return this.state.initialZoomState=this.settings.imageSize,this.settings.imageSize="native",this.position(this.elems.img)}},{key:"zoomOut",value:function(e){return this.settings.imageSize=this.state.initialZoomState||this.settings.imageSize,this.state.initialZoomState=null,this.elems.img.style.margin=0,this.position(this.elems.img)}},{key:"on",value:function(e,t,n){var i=this.events.push({element:e,eventName:t,cb:n});e.addEventListener(t.split(".")[0],this.events[i-1].cb)}},{key:"off",value:function(e,t){var n=this.events.findIndex((function(n){return n.element===e&&n.eventName===t}));this.events[n]&&(e.removeEventListener(t.split(".")[0],this.events[n].cb),this.events.splice(n,1))}}])&&e(i.prototype,s),r&&e(i,r),n}(),an=[];window.Chocolat=function(e,t){var n=Object.assign({},rn,{images:[]},t,{setIndex:an.length}),i=new on(e,n);return an.push(i),i}}(); diff --git a/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss b/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss index 99b2ad0d89..e203bb8d23 100644 --- a/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss +++ b/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss @@ -4580,6 +4580,26 @@ div .suggestion_note { } } +.chocolat-wrapper { + z-index: 1050; + + --chocolat-icon-left: url( "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' stroke-linecap='round' stroke-linejoin='round' viewBox='0 0 32 32'%3E%3Ccircle fill='%23408540' cx='16' cy='16' r='16' fill-opacity='.9'/%3E%3Cpath fill='none' stroke='%23fff' stroke-width='1.3' d='M15.3 20.7 10.7 16l4.6-4.7m7.4 4.7h-12'/%3E%3C/svg%3E" ); + --chocolat-icon-right: url( "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle fill='%23408540' cx='16' cy='16' r='16' fill-opacity='.9'/%3E%3Cpath d='m16.7 11.3 4.6 4.7-4.6 4.7M9.3 16h12' fill='none' stroke='%23fff' stroke-width='1.3'/%3E%3C/svg%3E" ); + --chocolat-icon-loader: url( "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='38' height='38'%3E%3Cg transform='translate(1 1)' stroke-width='2' fill='none' fill-rule='evenodd'%3E%3Ccircle stroke='%23000' cx='18' cy='18' r='18'/%3E%3Cpath d='M36 18C36 8 28 0 18 0' stroke='%236faf44'%3E%3CanimateTransform attributeName='transform' type='rotate' from='0 18 18' to='360 18 18' dur='1s' repeatCount='indefinite'/%3E%3C/path%3E%3C/g%3E%3C/svg%3E" ); + --chocolat-icon-close: url( "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32' stroke-linecap='round'%3E%3Ccircle fill='%23408540' cx='16' cy='16' r='16' fill-opacity='.9'/%3E%3Cpath d='m12 12 8 8m0-8-8 8' fill='none' stroke='%23fff' stroke-width='1.3'/%3E%3C/svg%3E" ); + + a:link, + a:visited, + a:hover, + a:active { + color: #FFF; + } + + .chocolat-bottom { + background: rgba( 0, 0, 0, .7 ); + } +} + @import "header"; @import "toolbar"; @import "forms"; diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt index 3be8621f0c..5dfa8b4f82 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt @@ -965,7 +965,7 @@

Chocolat.js

- Chocolat.js v1.1.0: GNU General Public License v3.0 + Chocolat.js v1.1.2: GNU General Public License v3.0

CodeMirror

diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt index 19d15b726d..5f4f8f2a31 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt @@ -45,8 +45,8 @@ [% t("Catalog") | html %] › [% t("Koha") | html %] [% END %] -[% INCLUDE 'doc-head-close.inc' %] [% Asset.css("lib/Chocolat/css/chocolat.css") | $raw %] +[% INCLUDE 'doc-head-close.inc' %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/css/src/opac.scss b/koha-tmpl/opac-tmpl/bootstrap/css/src/opac.scss index 809383f7c7..7d0cc68aff 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/css/src/opac.scss +++ b/koha-tmpl/opac-tmpl/bootstrap/css/src/opac.scss @@ -2946,4 +2946,17 @@ $star-selected: #EDB867; font-size: 1.1rem; } +.chocolat-wrapper { + z-index: 1050; + + --chocolat-icon-left: url( "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' stroke-linecap='round' stroke-linejoin='round' viewBox='0 0 32 32'%3E%3Ccircle fill='%23408540' cx='16' cy='16' r='16' fill-opacity='.9'/%3E%3Cpath fill='none' stroke='%23fff' stroke-width='1.3' d='M15.3 20.7 10.7 16l4.6-4.7m7.4 4.7h-12'/%3E%3C/svg%3E" ); + --chocolat-icon-right: url( "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle fill='%23408540' cx='16' cy='16' r='16' fill-opacity='.9'/%3E%3Cpath d='m16.7 11.3 4.6 4.7-4.6 4.7M9.3 16h12' fill='none' stroke='%23fff' stroke-width='1.3'/%3E%3C/svg%3E" ); + --chocolat-icon-loader: url( "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='38' height='38'%3E%3Cg transform='translate(1 1)' stroke-width='2' fill='none' fill-rule='evenodd'%3E%3Ccircle stroke='%23000' cx='18' cy='18' r='18'/%3E%3Cpath d='M36 18C36 8 28 0 18 0' stroke='%236faf44'%3E%3CanimateTransform attributeName='transform' type='rotate' from='0 18 18' to='360 18 18' dur='1s' repeatCount='indefinite'/%3E%3C/path%3E%3C/g%3E%3C/svg%3E" ); + --chocolat-icon-close: url( "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32' stroke-linecap='round'%3E%3Ccircle fill='%23408540' cx='16' cy='16' r='16' fill-opacity='.9'/%3E%3Cpath d='m12 12 8 8m0-8-8 8' fill='none' stroke='%23fff' stroke-width='1.3'/%3E%3C/svg%3E" ); + + .chocolat-bottom { + background: rgba( 0, 0, 0, .7 ); + } +} + @import "responsive"; diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt index 789244f9d3..49d7d0d50e 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt @@ -31,12 +31,12 @@ [% INCLUDE 'doc-head-open.inc' %] Details for: [% INCLUDE 'biblio-title-head.inc' %] › [% IF ( LibraryNameTitle ) %][% LibraryNameTitle | html %][% ELSE %]Koha online[% END %] catalog +[% Asset.css("lib/emoji-picker/css/emoji.css") | $raw %] +[% IF ( Koha.Preference('OPACShowMusicalInscripts') ) %] + [% Asset.css("lib/verovio/midiplayer.css") | $raw %] +[% END %] +[% Asset.css("lib/Chocolat/css/chocolat.css") | $raw %] [% INCLUDE 'doc-head-close.inc' %] - [% Asset.css("lib/emoji-picker/css/emoji.css") | $raw %] - [% IF ( Koha.Preference('OPACShowMusicalInscripts') ) %] - [% Asset.css("lib/verovio/midiplayer.css") | $raw %] - [% END %] - [% Asset.css("lib/Chocolat/css/chocolat.css") | $raw %] [% BLOCK cssinclude %][% END %] [% INCLUDE 'bodytag.inc' bodyid='opac-detail' bodyclass='scrollto' %] diff --git a/koha-tmpl/opac-tmpl/lib/Chocolat/js/chocolat.js b/koha-tmpl/opac-tmpl/lib/Chocolat/js/chocolat.js index 7a39da143d..37d615ba92 100644 --- a/koha-tmpl/opac-tmpl/lib/Chocolat/js/chocolat.js +++ b/koha-tmpl/opac-tmpl/lib/Chocolat/js/chocolat.js @@ -1 +1 @@ -!function(){"use strict";function e(e,t){for(var n=0;ne.length)&&(t=e.length);for(var n=0,i=new Array(t);n=74)&&(r=F.match(/Chrome\/(\d+)/))&&(o=r[1]);var N,G=o&&+o,D=!!Object.getOwnPropertySymbols&&!y((function(){var e=Symbol();return!String(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&G&&G<41})),q=D&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,B=E("wks"),Z=c.Symbol,V=q?Z:Z&&Z.withoutSetter||P,Y=function(e){return j(B,e)&&(D||"string"==typeof B[e])||(D&&j(Z,e)?B[e]=Z[e]:B[e]=V("Symbol."+e)),B[e]},U=function(e){if(h(e))return e;throw TypeError(String(e)+" is not an object")},X=!y((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),$=!X&&!y((function(){return 7!=Object.defineProperty(p("div"),"a",{get:function(){return 7}}).a})),K=q?function(e){return"symbol"==typeof e}:function(e){var t=W("Symbol");return u(t)&&Object(e)instanceof t},J=function(e){if(u(e))return e;throw TypeError(function(e){try{return String(e)}catch(e){return"Object"}}(e)+" is not a function")},Q=Y("toPrimitive"),ee=function(e,t){if(!h(e)||K(e))return e;var n,i,s=null==(n=e[Q])?void 0:J(n);if(s){if(void 0===t&&(t="default"),i=s.call(e,t),!h(i)||K(i))return i;throw TypeError("Can't convert object to primitive value")}return void 0===t&&(t="number"),function(e,t){var n,i;if("string"===t&&u(n=e.toString)&&!h(i=n.call(e)))return i;if(u(n=e.valueOf)&&!h(i=n.call(e)))return i;if("string"!==t&&u(n=e.toString)&&!h(i=n.call(e)))return i;throw TypeError("Can't convert object to primitive value")}(e,t)},te=function(e){var t=ee(e,"string");return K(t)?t:String(t)},ne=Object.defineProperty,ie={f:X?ne:function(e,t,n){if(U(e),t=te(t),U(n),$)try{return ne(e,t,n)}catch(e){}if("get"in n||"set"in n)throw TypeError("Accessors not supported");return"value"in n&&(e[t]=n.value),e}},se=Math.ceil,re=Math.floor,oe=function(e){var t=+e;return t!=t||0===t?0:(t>0?re:se)(t)},ae=Math.max,ce=Math.min,le=Math.min,ue=function(e){return(t=e.length)>0?le(oe(t),9007199254740991):0;var t},he=function(e){return function(t,n,i){var s,r=I(t),o=ue(r),a=function(e,t){var n=oe(e);return n<0?ae(n+t,0):ce(n,t)}(i,o);if(e&&n!=n){for(;o>a;)if((s=r[a++])!=s)return!0}else for(;o>a;a++)if((e||a in r)&&r[a]===n)return e||a||0;return!e&&-1}},me={includes:he(!0),indexOf:he(!1)},fe={},pe=me.indexOf,ge=function(e,t){var n,i=I(e),s=0,r=[];for(n in i)!j(fe,n)&&j(i,n)&&r.push(n);for(;t.length>s;)j(i,n=t[s++])&&(~pe(r,n)||r.push(n));return r},de=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],ve=Object.keys||function(e){return ge(e,de)},ye=X?Object.defineProperties:function(e,t){U(e);for(var n,i=ve(t),s=i.length,r=0;s>r;)ie.f(e,n=i[r++],t[n]);return e},be=W("document","documentElement"),we=E("keys"),Se=function(e){return we[e]||(we[e]=P(e))},Oe="prototype",Ie="script",Le=Se("IE_PROTO"),ke=function(){},Ce=function(e){return"<"+Ie+">"+e+""},Ee=function(e){e.write(Ce("")),e.close();var t=e.parentWindow.Object;return e=null,t},Ae=function(){try{N=new ActiveXObject("htmlfile")}catch(e){}var e,t,n;Ae="undefined"!=typeof document?document.domain&&N?Ee(N):(t=p("iframe"),n="java"+Ie+":",t.style.display="none",be.appendChild(t),t.src=String(n),(e=t.contentWindow.document).open(),e.write(Ce("document.F=Object")),e.close(),e.F):Ee(N);for(var i=de.length;i--;)delete Ae[Oe][de[i]];return Ae()};fe[Le]=!0;var Te=Object.create||function(e,t){var n;return null!==e?(ke[Oe]=U(e),n=new ke,ke[Oe]=null,n[Le]=e):n=Ae(),void 0===t?n:ye(n,t)},je=Y("unscopables"),ze=Array.prototype;null==ze[je]&&ie.f(ze,je,{configurable:!0,value:Te(null)});var xe=function(e){ze[je][e]=!0},Pe=Function.toString;u(C.inspectSource)||(C.inspectSource=function(e){return Pe.call(e)});var We,Fe,He,Me=C.inspectSource,_e=c.WeakMap,Re=u(_e)&&/native code/.test(Me(_e)),Ne=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}},Ge=X?function(e,t,n){return ie.f(e,t,Ne(1,n))}:function(e,t,n){return e[t]=n,e},De="Object already initialized",qe=c.WeakMap;if(Re||C.state){var Be=C.state||(C.state=new qe),Ze=Be.get,Ve=Be.has,Ye=Be.set;We=function(e,t){if(Ve.call(Be,e))throw new TypeError(De);return t.facade=e,Ye.call(Be,e,t),t},Fe=function(e){return Ze.call(Be,e)||{}},He=function(e){return Ve.call(Be,e)}}else{var Ue=Se("state");fe[Ue]=!0,We=function(e,t){if(j(e,Ue))throw new TypeError(De);return t.facade=e,Ge(e,Ue,t),t},Fe=function(e){return j(e,Ue)?e[Ue]:{}},He=function(e){return j(e,Ue)}}var Xe,$e,Ke,Je={set:We,get:Fe,has:He,enforce:function(e){return He(e)?Fe(e):We(e,{})},getterFor:function(e){return function(t){var n;if(!h(t)||(n=Fe(t)).type!==e)throw TypeError("Incompatible receiver, "+e+" required");return n}}},Qe={}.propertyIsEnumerable,et=Object.getOwnPropertyDescriptor,tt={f:et&&!Qe.call({1:2},1)?function(e){var t=et(this,e);return!!t&&t.enumerable}:Qe},nt=Object.getOwnPropertyDescriptor,it={f:X?nt:function(e,t){if(e=I(e),t=te(t),$)try{return nt(e,t)}catch(e){}if(j(e,t))return Ne(!tt.f.call(e,t),e[t])}},st=Function.prototype,rt=X&&Object.getOwnPropertyDescriptor,ot=j(st,"name"),at={EXISTS:ot,PROPER:ot&&"something"===function(){}.name,CONFIGURABLE:ot&&(!X||X&&rt(st,"name").configurable)},ct=s((function(e){var t=at.CONFIGURABLE,n=Je.get,i=Je.enforce,s=String(String).split("String");(e.exports=function(e,n,r,o){var a,l=!!o&&!!o.unsafe,h=!!o&&!!o.enumerable,m=!!o&&!!o.noTargetGet,f=o&&void 0!==o.name?o.name:n;u(r)&&("Symbol("===String(f).slice(0,7)&&(f="["+String(f).replace(/^Symbol\(([^)]*)\)/,"$1")+"]"),(!j(r,"name")||t&&r.name!==f)&&Ge(r,"name",f),(a=i(r)).source||(a.source=s.join("string"==typeof f?f:""))),e!==c?(l?!m&&e[n]&&(h=!0):delete e[n],h?e[n]=r:Ge(e,n,r)):h?e[n]=r:L(n,r)})(Function.prototype,"toString",(function(){return u(this)&&n(this).source||Me(this)}))})),lt=de.concat("length","prototype"),ut={f:Object.getOwnPropertyNames||function(e){return ge(e,lt)}},ht={f:Object.getOwnPropertySymbols},mt=W("Reflect","ownKeys")||function(e){var t=ut.f(U(e)),n=ht.f;return n?t.concat(n(e)):t},ft=function(e,t){for(var n=mt(t),i=ie.f,s=it.f,r=0;r=t.length?(e.target=void 0,{value:void 0,done:!0}):"keys"==n?{value:i,done:!1}:"values"==n?{value:t[i],done:!1}:{value:[i,t[i]],done:!1}}),"values");xe("keys"),xe("values"),xe("entries");var Yt=Y("iterator"),Ut=Y("toStringTag"),Xt=Vt.values,$t=function(e,t){if(e){if(e[Yt]!==Xt)try{Ge(e,Yt,Xt)}catch(t){e[Yt]=Xt}if(e[Ut]||Ge(e,Ut,t),l[t])for(var n in Vt)if(e[n]!==Vt[n])try{Ge(e,n,Vt[n])}catch(t){e[n]=Vt[n]}}};for(var Kt in l)$t(c[Kt]&&c[Kt].prototype,Kt);$t(v,"DOMTokenList");var Jt=void 0;function Qt(e,t){return new Promise((function(n){var i=function e(){t.removeEventListener("transitionend",e),n()};t.addEventListener("transitionend",i);var s=t.getAttribute("class"),r=t.getAttribute("style");e(),s===t.getAttribute("class")&&r===t.getAttribute("style")&&i(),0===parseFloat(getComputedStyle(t).transitionDuration)&&i()}))}function en(e){var t=e.src,n=e.srcset,i=e.sizes,s=new Image;return s.src=t,n&&(s.srcset=n),i&&(s.sizes=i),new Promise("decode"in s?function(e,t){s.decode().then((function(){e(s)})).catch((function(){t(s)}))}:function(e,t){s.onload=e(s),s.onerror=t(s)})}function tn(e){var t,n,i=e.imgHeight,s=e.imgWidth,r=e.containerHeight,o=e.containerWidth,a=e.canvasWidth,c=e.canvasHeight,l=e.imageSize,u=i/s;return"cover"==l?uc/a?n=(t=c)/u:t=(n=a)*u,"scale-down"===l&&(n>=s||t>=i)&&(n=s,t=i)),{height:t,width:n}}function nn(e){return e.requestFullscreen?e.requestFullscreen():e.webkitRequestFullscreen?e.webkitRequestFullscreen():e.msRequestFullscreen?e.msRequestFullscreen():Promise.reject()}function sn(){return document.exitFullscreen?document.exitFullscreen():document.webkitExitFullscreen?document.webkitExitFullscreen():document.msExitFullscreen?document.msExitFullscreen():Promise.reject()}var rn={container:document.body,className:void 0,imageSize:"scale-down",fullScreen:!1,loop:!1,linkImages:!0,setIndex:0,firstImageIndex:0,lastImageIndex:!1,currentImageIndex:void 0,allowZoom:!0,closeOnBackgroundClick:!0,imageSourceAttribute:"href",setTitle:function(){return""},description:function(){return this.images[this.settings.currentImageIndex].title},pagination:function(){var e=this.settings.lastImageIndex+1;return this.settings.currentImageIndex+1+"/"+e},afterInitialize:function(){},afterMarkup:function(){},afterImageLoad:function(){},afterClose:function(){},zoomedPaddingX:function(e,t){return 0},zoomedPaddingY:function(e,t){return 0}},on=function(){function n(e,t){var i=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,n),this.settings=t,this.elems={},this.images=[],this.events=[],this.state={fullScreenOpen:!1,initialZoomState:null,initialized:!1,timer:!1,visible:!1},this._cssClasses=["chocolat-open","chocolat-in-container","chocolat-cover","chocolat-zoomable","chocolat-zoomed","chocolat-zooming-in","chocolat-zooming-out"],NodeList.prototype.isPrototypeOf(e)||HTMLCollection.prototype.isPrototypeOf(e)?e.forEach((function(e,n){i.images.push({title:e.getAttribute("title"),src:e.getAttribute(t.imageSourceAttribute),srcset:e.getAttribute("data-srcset"),sizes:e.getAttribute("data-sizes")}),i.off(e,"click.chocolat"),i.on(e,"click.chocolat",(function(e){i.init(n),e.preventDefault()}))})):this.images=e,this.settings.container instanceof Element||this.settings.container instanceof HTMLElement?this.elems.container=this.settings.container:this.elems.container=document.body,this.api={open:function(e){return e=parseInt(e)||0,i.init(e)},close:function(){return i.close()},next:function(){return i.change(1)},prev:function(){return i.change(-1)},goto:function(e){return i.open(e)},current:function(){return i.settings.currentImageIndex},position:function(){return i.position(i.elems.img)},destroy:function(){return i.destroy()},set:function(e,t){return i.settings[e]=t,t},get:function(e){return i.settings[e]},getElem:function(e){return i.elems[e]}}}var i,s,r;return i=n,(s=[{key:"init",value:function(e){return this.state.initialized||(this.markup(),this.attachListeners(),this.settings.lastImageIndex=this.images.length-1,this.state.initialized=!0),this.settings.afterInitialize.call(this),this.load(e)}},{key:"load",value:function(e){var t=this;if(this.state.visible||(this.state.visible=!0,setTimeout((function(){t.elems.overlay.classList.add("chocolat-visible"),t.elems.wrapper.classList.add("chocolat-visible")}),0),this.elems.container.classList.add("chocolat-open")),this.settings.fullScreen&&nn(this.elems.wrapper),this.settings.currentImageIndex===e)return Promise.resolve();var n,i,s=setTimeout((function(){t.elems.loader.classList.add("chocolat-visible")}),1e3),r=setTimeout((function(){r=void 0,n=Qt((function(){t.elems.imageCanvas.classList.remove("chocolat-visible")}),t.elems.imageCanvas)}),80);return en(this.images[e]).then((function(e){return i=e,r?(clearTimeout(r),Promise.resolve()):n})).then((function(){var n=e+1;return null!=t.images[n]&&en(t.images[n]),t.settings.currentImageIndex=e,t.elems.description.textContent=t.settings.description.call(t),t.elems.pagination.textContent=t.settings.pagination.call(t),t.arrows(),t.position(i).then((function(){return t.elems.loader.classList.remove("chocolat-visible"),clearTimeout(s),t.appear(i)}))})).then((function(){t.elems.container.classList.toggle("chocolat-zoomable",t.zoomable(i,t.elems.wrapper)),t.settings.afterImageLoad.call(t)}))}},{key:"position",value:function(e){var t=this,n=tn({imgHeight:e.naturalHeight,imgWidth:e.naturalWidth,containerHeight:this.elems.container.clientHeight,containerWidth:this.elems.container.clientWidth,canvasWidth:this.elems.imageCanvas.clientWidth,canvasHeight:this.elems.imageCanvas.clientHeight,imageSize:this.settings.imageSize}),i=n.width,s=n.height;return Qt((function(){Object.assign(t.elems.imageWrapper.style,{width:i+"px",height:s+"px"})}),this.elems.imageWrapper)}},{key:"appear",value:function(e){var t=this;return this.elems.imageWrapper.removeChild(this.elems.img),this.elems.img=e,this.elems.img.setAttribute("class","chocolat-img"),this.elems.imageWrapper.appendChild(this.elems.img),Qt((function(){t.elems.imageCanvas.classList.add("chocolat-visible")}),this.elems.imageCanvas)}},{key:"change",value:function(e){if(this.state.visible&&this.settings.linkImages){this.zoomOut();var t=this.settings.currentImageIndex+parseInt(e);if(t>this.settings.lastImageIndex){if(this.settings.loop)return this.load(this.settings.firstImageIndex)}else{if(!(t=0;n--){var i=this.events[n],s=i.element,r=i.eventName;this.off(s,r)}this.state.initialized&&(this.state.fullScreenOpen&&sn(),this.settings.currentImageIndex=void 0,this.state.visible=!1,this.state.initialized=!1,(e=this.elems.container.classList).remove.apply(e,t(this._cssClasses)),this.elems.wrapper.parentNode.removeChild(this.elems.wrapper))}},{key:"markup",value:function(){this.elems.container.classList.add("chocolat-open",this.settings.className),"cover"==this.settings.imageSize&&this.elems.container.classList.add("chocolat-cover"),this.elems.container!==document.body&&this.elems.container.classList.add("chocolat-in-container"),this.elems.wrapper=document.createElement("div"),this.elems.wrapper.setAttribute("id","chocolat-content-"+this.settings.setIndex),this.elems.wrapper.setAttribute("class","chocolat-wrapper"),this.elems.container.appendChild(this.elems.wrapper),this.elems.overlay=document.createElement("div"),this.elems.overlay.setAttribute("class","chocolat-overlay"),this.elems.wrapper.appendChild(this.elems.overlay),this.elems.loader=document.createElement("div"),this.elems.loader.setAttribute("class","chocolat-loader"),this.elems.wrapper.appendChild(this.elems.loader),this.elems.layout=document.createElement("div"),this.elems.layout.setAttribute("class","chocolat-layout"),this.elems.wrapper.appendChild(this.elems.layout),this.elems.top=document.createElement("div"),this.elems.top.setAttribute("class","chocolat-top"),this.elems.layout.appendChild(this.elems.top),this.elems.center=document.createElement("div"),this.elems.center.setAttribute("class","chocolat-center"),this.elems.layout.appendChild(this.elems.center),this.elems.left=document.createElement("div"),this.elems.left.setAttribute("class","chocolat-left"),this.elems.center.appendChild(this.elems.left),this.elems.imageCanvas=document.createElement("div"),this.elems.imageCanvas.setAttribute("class","chocolat-image-canvas"),this.elems.center.appendChild(this.elems.imageCanvas),this.elems.imageWrapper=document.createElement("div"),this.elems.imageWrapper.setAttribute("class","chocolat-image-wrapper"),this.elems.imageCanvas.appendChild(this.elems.imageWrapper),this.elems.img=document.createElement("img"),this.elems.img.setAttribute("class","chocolat-img"),this.elems.imageWrapper.appendChild(this.elems.img),this.elems.right=document.createElement("div"),this.elems.right.setAttribute("class","chocolat-right"),this.elems.center.appendChild(this.elems.right),this.elems.bottom=document.createElement("div"),this.elems.bottom.setAttribute("class","chocolat-bottom"),this.elems.layout.appendChild(this.elems.bottom),this.elems.close=document.createElement("span"),this.elems.close.setAttribute("class","chocolat-close"),this.elems.top.appendChild(this.elems.close),this.elems.description=document.createElement("span"),this.elems.description.setAttribute("class","chocolat-description"),this.elems.bottom.appendChild(this.elems.description),this.elems.pagination=document.createElement("span"),this.elems.pagination.setAttribute("class","chocolat-pagination"),this.elems.bottom.appendChild(this.elems.pagination),this.elems.setTitle=document.createElement("span"),this.elems.setTitle.setAttribute("class","chocolat-set-title"),this.elems.setTitle.textContent=this.settings.setTitle(),this.elems.bottom.appendChild(this.elems.setTitle),this.elems.fullscreen=document.createElement("span"),this.elems.fullscreen.setAttribute("class","chocolat-fullscreen"),this.elems.bottom.appendChild(this.elems.fullscreen),this.settings.afterMarkup.call(this)}},{key:"attachListeners",value:function(){var e=this;this.off(document,"keydown.chocolat"),this.on(document,"keydown.chocolat",(function(t){e.state.initialized&&(37==t.keyCode?e.change(-1):39==t.keyCode?e.change(1):27==t.keyCode&&e.close())}));var t=this.elems.wrapper.querySelector(".chocolat-right");this.off(t,"click.chocolat"),this.on(t,"click.chocolat",(function(){e.change(1)}));var n=this.elems.wrapper.querySelector(".chocolat-left");this.off(n,"click.chocolat"),this.on(n,"click.chocolat",(function(){e.change(-1)})),this.off(this.elems.close,"click.chocolat"),this.on(this.elems.close,"click.chocolat",this.close.bind(this)),this.off(this.elems.fullscreen,"click.chocolat"),this.on(this.elems.fullscreen,"click.chocolat",(function(){e.state.fullScreenOpen?sn():nn(e.elems.wrapper)})),this.off(document,"fullscreenchange.chocolat"),this.on(document,"fullscreenchange.chocolat",(function(){document.fullscreenElement||document.webkitCurrentFullScreenElement||document.webkitFullscreenElement?e.state.fullScreenOpen=!0:e.state.fullScreenOpen=!1})),this.off(document,"webkitfullscreenchange.chocolat"),this.on(document,"webkitfullscreenchange.chocolat",(function(){document.fullscreenElement||document.webkitCurrentFullScreenElement||document.webkitFullscreenElement?e.state.fullScreenOpen=!0:e.state.fullScreenOpen=!1})),this.settings.closeOnBackgroundClick&&(this.off(this.elems.overlay,"click.chocolat"),this.on(this.elems.overlay,"click.chocolat",this.close.bind(this))),this.off(this.elems.wrapper,"click.chocolat"),this.on(this.elems.wrapper,"click.chocolat",(function(){null!==e.state.initialZoomState&&e.state.visible&&(e.elems.container.classList.add("chocolat-zooming-out"),e.zoomOut().then((function(){e.elems.container.classList.remove("chocolat-zoomed"),e.elems.container.classList.remove("chocolat-zooming-out")})))})),this.off(this.elems.imageWrapper,"click.chocolat"),this.on(this.elems.imageWrapper,"click.chocolat",(function(t){null===e.state.initialZoomState&&e.elems.container.classList.contains("chocolat-zoomable")&&(t.stopPropagation(),e.elems.container.classList.add("chocolat-zooming-in"),e.zoomIn(t).then((function(){e.elems.container.classList.add("chocolat-zoomed"),e.elems.container.classList.remove("chocolat-zooming-in")})))})),this.on(this.elems.wrapper,"mousemove.chocolat",(function(t){if(null!==e.state.initialZoomState&&e.state.visible){var n=e.elems.wrapper.getBoundingClientRect(),i=n.top+window.scrollY,s=n.left+window.scrollX,r=e.elems.wrapper.clientHeight,o=e.elems.wrapper.clientWidth,a=e.elems.img.width,c=e.elems.img.height,l=[t.pageX-o/2-s,t.pageY-r/2-i],u=0;if(a>o){var h=e.settings.zoomedPaddingX(a,o);u=l[0]/(o/2),u*=(a-o)/2+h}var m=0;if(c>r){var f=e.settings.zoomedPaddingY(c,r);m=l[1]/(r/2),m*=(c-r)/2+f}e.elems.img.style.marginLeft=-u+"px",e.elems.img.style.marginTop=-m+"px"}})),this.on(window,"resize.chocolat",(function(t){var n,i;e.state.initialized&&e.state.visible&&(n=50,i=function(){tn({imgHeight:e.elems.img.naturalHeight,imgWidth:e.elems.img.naturalWidth,containerHeight:e.elems.wrapper.clientHeight,containerWidth:e.elems.wrapper.clientWidth,canvasWidth:e.elems.imageCanvas.clientWidth,canvasHeight:e.elems.imageCanvas.clientHeight,imageSize:e.settings.imageSize}),e.position(e.elems.img).then((function(){e.elems.container.classList.toggle("chocolat-zoomable",e.zoomable(e.elems.img,e.elems.wrapper))}))},clearTimeout(Jt),Jt=setTimeout((function(){i()}),n))}))}},{key:"zoomable",value:function(e,t){var n=t.clientWidth,i=t.clientHeight,s=!(!this.settings.allowZoom||!(e.naturalWidth>n||e.naturalHeight>i)),r=e.clientWidth>e.naturalWidth||e.clientHeight>e.naturalHeight;return s&&!r}},{key:"zoomIn",value:function(e){return this.state.initialZoomState=this.settings.imageSize,this.settings.imageSize="native",this.position(this.elems.img)}},{key:"zoomOut",value:function(e){return this.settings.imageSize=this.state.initialZoomState||this.settings.imageSize,this.state.initialZoomState=null,this.elems.img.style.margin=0,this.position(this.elems.img)}},{key:"on",value:function(e,t,n){var i=this.events.push({element:e,eventName:t,cb:n});e.addEventListener(t.split(".")[0],this.events[i-1].cb)}},{key:"off",value:function(e,t){var n=this.events.findIndex((function(n){return n.element===e&&n.eventName===t}));this.events[n]&&(e.removeEventListener(t.split(".")[0],this.events[n].cb),this.events.splice(n,1))}}])&&e(i.prototype,s),r&&e(i,r),n}(),an=[];window.Chocolat=function(e,t){var n=Object.assign({},rn,{images:[]},t,{setIndex:an.length}),i=new on(e,n);return an.push(i),i}}(); +!function(){"use strict";function e(e,t){for(var n=0;ne.length)&&(t=e.length);for(var n=0,i=new Array(t);n=74)&&(r=F.match(/Chrome\/(\d+)/))&&(o=r[1]);var N,G=o&&+o,D=!!Object.getOwnPropertySymbols&&!y((function(){var e=Symbol();return!String(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&G&&G<41})),q=D&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,B=E("wks"),Z=c.Symbol,V=q?Z:Z&&Z.withoutSetter||P,Y=function(e){return j(B,e)&&(D||"string"==typeof B[e])||(D&&j(Z,e)?B[e]=Z[e]:B[e]=V("Symbol."+e)),B[e]},U=function(e){if(h(e))return e;throw TypeError(String(e)+" is not an object")},X=!y((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),$=!X&&!y((function(){return 7!=Object.defineProperty(p("div"),"a",{get:function(){return 7}}).a})),K=q?function(e){return"symbol"==typeof e}:function(e){var t=W("Symbol");return u(t)&&Object(e)instanceof t},J=function(e){if(u(e))return e;throw TypeError(function(e){try{return String(e)}catch(e){return"Object"}}(e)+" is not a function")},Q=Y("toPrimitive"),ee=function(e,t){if(!h(e)||K(e))return e;var n,i,s=null==(n=e[Q])?void 0:J(n);if(s){if(void 0===t&&(t="default"),i=s.call(e,t),!h(i)||K(i))return i;throw TypeError("Can't convert object to primitive value")}return void 0===t&&(t="number"),function(e,t){var n,i;if("string"===t&&u(n=e.toString)&&!h(i=n.call(e)))return i;if(u(n=e.valueOf)&&!h(i=n.call(e)))return i;if("string"!==t&&u(n=e.toString)&&!h(i=n.call(e)))return i;throw TypeError("Can't convert object to primitive value")}(e,t)},te=function(e){var t=ee(e,"string");return K(t)?t:String(t)},ne=Object.defineProperty,ie={f:X?ne:function(e,t,n){if(U(e),t=te(t),U(n),$)try{return ne(e,t,n)}catch(e){}if("get"in n||"set"in n)throw TypeError("Accessors not supported");return"value"in n&&(e[t]=n.value),e}},se=Math.ceil,re=Math.floor,oe=function(e){var t=+e;return t!=t||0===t?0:(t>0?re:se)(t)},ae=Math.max,ce=Math.min,le=Math.min,ue=function(e){return(t=e.length)>0?le(oe(t),9007199254740991):0;var t},he=function(e){return function(t,n,i){var s,r=I(t),o=ue(r),a=function(e,t){var n=oe(e);return n<0?ae(n+t,0):ce(n,t)}(i,o);if(e&&n!=n){for(;o>a;)if((s=r[a++])!=s)return!0}else for(;o>a;a++)if((e||a in r)&&r[a]===n)return e||a||0;return!e&&-1}},me={includes:he(!0),indexOf:he(!1)},fe={},pe=me.indexOf,ge=function(e,t){var n,i=I(e),s=0,r=[];for(n in i)!j(fe,n)&&j(i,n)&&r.push(n);for(;t.length>s;)j(i,n=t[s++])&&(~pe(r,n)||r.push(n));return r},de=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],ve=Object.keys||function(e){return ge(e,de)},ye=X?Object.defineProperties:function(e,t){U(e);for(var n,i=ve(t),s=i.length,r=0;s>r;)ie.f(e,n=i[r++],t[n]);return e},be=W("document","documentElement"),we=E("keys"),Se=function(e){return we[e]||(we[e]=P(e))},Oe="prototype",Ie="script",Le=Se("IE_PROTO"),ke=function(){},Ce=function(e){return"<"+Ie+">"+e+""},Ee=function(e){e.write(Ce("")),e.close();var t=e.parentWindow.Object;return e=null,t},Ae=function(){try{N=new ActiveXObject("htmlfile")}catch(e){}var e,t,n;Ae="undefined"!=typeof document?document.domain&&N?Ee(N):(t=p("iframe"),n="java"+Ie+":",t.style.display="none",be.appendChild(t),t.src=String(n),(e=t.contentWindow.document).open(),e.write(Ce("document.F=Object")),e.close(),e.F):Ee(N);for(var i=de.length;i--;)delete Ae[Oe][de[i]];return Ae()};fe[Le]=!0;var Te=Object.create||function(e,t){var n;return null!==e?(ke[Oe]=U(e),n=new ke,ke[Oe]=null,n[Le]=e):n=Ae(),void 0===t?n:ye(n,t)},je=Y("unscopables"),ze=Array.prototype;null==ze[je]&&ie.f(ze,je,{configurable:!0,value:Te(null)});var xe=function(e){ze[je][e]=!0},Pe=Function.toString;u(C.inspectSource)||(C.inspectSource=function(e){return Pe.call(e)});var We,Fe,He,Me=C.inspectSource,_e=c.WeakMap,Re=u(_e)&&/native code/.test(Me(_e)),Ne=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}},Ge=X?function(e,t,n){return ie.f(e,t,Ne(1,n))}:function(e,t,n){return e[t]=n,e},De="Object already initialized",qe=c.WeakMap;if(Re||C.state){var Be=C.state||(C.state=new qe),Ze=Be.get,Ve=Be.has,Ye=Be.set;We=function(e,t){if(Ve.call(Be,e))throw new TypeError(De);return t.facade=e,Ye.call(Be,e,t),t},Fe=function(e){return Ze.call(Be,e)||{}},He=function(e){return Ve.call(Be,e)}}else{var Ue=Se("state");fe[Ue]=!0,We=function(e,t){if(j(e,Ue))throw new TypeError(De);return t.facade=e,Ge(e,Ue,t),t},Fe=function(e){return j(e,Ue)?e[Ue]:{}},He=function(e){return j(e,Ue)}}var Xe,$e,Ke,Je={set:We,get:Fe,has:He,enforce:function(e){return He(e)?Fe(e):We(e,{})},getterFor:function(e){return function(t){var n;if(!h(t)||(n=Fe(t)).type!==e)throw TypeError("Incompatible receiver, "+e+" required");return n}}},Qe={}.propertyIsEnumerable,et=Object.getOwnPropertyDescriptor,tt={f:et&&!Qe.call({1:2},1)?function(e){var t=et(this,e);return!!t&&t.enumerable}:Qe},nt=Object.getOwnPropertyDescriptor,it={f:X?nt:function(e,t){if(e=I(e),t=te(t),$)try{return nt(e,t)}catch(e){}if(j(e,t))return Ne(!tt.f.call(e,t),e[t])}},st=Function.prototype,rt=X&&Object.getOwnPropertyDescriptor,ot=j(st,"name"),at={EXISTS:ot,PROPER:ot&&"something"===function(){}.name,CONFIGURABLE:ot&&(!X||X&&rt(st,"name").configurable)},ct=s((function(e){var t=at.CONFIGURABLE,n=Je.get,i=Je.enforce,s=String(String).split("String");(e.exports=function(e,n,r,o){var a,l=!!o&&!!o.unsafe,h=!!o&&!!o.enumerable,m=!!o&&!!o.noTargetGet,f=o&&void 0!==o.name?o.name:n;u(r)&&("Symbol("===String(f).slice(0,7)&&(f="["+String(f).replace(/^Symbol\(([^)]*)\)/,"$1")+"]"),(!j(r,"name")||t&&r.name!==f)&&Ge(r,"name",f),(a=i(r)).source||(a.source=s.join("string"==typeof f?f:""))),e!==c?(l?!m&&e[n]&&(h=!0):delete e[n],h?e[n]=r:Ge(e,n,r)):h?e[n]=r:L(n,r)})(Function.prototype,"toString",(function(){return u(this)&&n(this).source||Me(this)}))})),lt=de.concat("length","prototype"),ut={f:Object.getOwnPropertyNames||function(e){return ge(e,lt)}},ht={f:Object.getOwnPropertySymbols},mt=W("Reflect","ownKeys")||function(e){var t=ut.f(U(e)),n=ht.f;return n?t.concat(n(e)):t},ft=function(e,t){for(var n=mt(t),i=ie.f,s=it.f,r=0;r=t.length?(e.target=void 0,{value:void 0,done:!0}):"keys"==n?{value:i,done:!1}:"values"==n?{value:t[i],done:!1}:{value:[i,t[i]],done:!1}}),"values");xe("keys"),xe("values"),xe("entries");var Yt=Y("iterator"),Ut=Y("toStringTag"),Xt=Vt.values,$t=function(e,t){if(e){if(e[Yt]!==Xt)try{Ge(e,Yt,Xt)}catch(t){e[Yt]=Xt}if(e[Ut]||Ge(e,Ut,t),l[t])for(var n in Vt)if(e[n]!==Vt[n])try{Ge(e,n,Vt[n])}catch(t){e[n]=Vt[n]}}};for(var Kt in l)$t(c[Kt]&&c[Kt].prototype,Kt);$t(v,"DOMTokenList");var Jt=void 0;function Qt(e,t){return new Promise((function(n){var i=function e(){t.removeEventListener("transitionend",e),n()};t.addEventListener("transitionend",i);var s=t.getAttribute("class"),r=t.getAttribute("style");e(),s===t.getAttribute("class")&&r===t.getAttribute("style")&&i(),0===parseFloat(getComputedStyle(t).transitionDuration)&&i()}))}function en(e){var t=e.src,n=e.srcset,i=e.sizes,s=new Image;return s.src=t,n&&(s.srcset=n),i&&(s.sizes=i),new Promise("decode"in s?function(e,t){s.decode().then((function(){e(s)})).catch((function(){t(s)}))}:function(e,t){s.onload=e(s),s.onerror=t(s)})}function tn(e){var t,n,i=e.imgHeight,s=e.imgWidth,r=e.containerHeight,o=e.containerWidth,a=e.canvasWidth,c=e.canvasHeight,l=e.imageSize,u=i/s;return"cover"==l?uc/a?n=(t=c)/u:t=(n=a)*u,"scale-down"===l&&(n>=s||t>=i)&&(n=s,t=i)),{height:t,width:n}}function nn(e){return e.requestFullscreen?e.requestFullscreen():e.webkitRequestFullscreen?e.webkitRequestFullscreen():e.msRequestFullscreen?e.msRequestFullscreen():Promise.reject()}function sn(){return document.exitFullscreen?document.exitFullscreen():document.webkitExitFullscreen?document.webkitExitFullscreen():document.msExitFullscreen?document.msExitFullscreen():Promise.reject()}var rn={container:document.body,className:void 0,imageSize:"scale-down",fullScreen:!1,loop:!1,linkImages:!0,setIndex:0,firstImageIndex:0,lastImageIndex:!1,currentImageIndex:void 0,allowZoom:!0,closeOnBackgroundClick:!0,imageSourceAttribute:"href",setTitle:function(){return""},description:function(){return this.images[this.settings.currentImageIndex].title},pagination:function(){var e=this.settings.lastImageIndex+1;return this.settings.currentImageIndex+1+"/"+e},afterInitialize:function(){},afterMarkup:function(){},afterImageLoad:function(){},afterClose:function(){},zoomedPaddingX:function(e,t){return 0},zoomedPaddingY:function(e,t){return 0}},on=function(){function n(e,t){var i=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,n),this.settings=t,this.elems={},this.images=[],this.events=[],this.state={fullScreenOpen:!1,initialZoomState:null,initialized:!1,timer:!1,visible:!1},this._cssClasses=["chocolat-open","chocolat-in-container","chocolat-cover","chocolat-zoomable","chocolat-zoomed","chocolat-zooming-in","chocolat-zooming-out"],NodeList.prototype.isPrototypeOf(e)||HTMLCollection.prototype.isPrototypeOf(e)?e.forEach((function(e,n){i.images.push({title:e.getAttribute("title"),src:e.getAttribute(t.imageSourceAttribute),srcset:e.getAttribute("data-srcset"),sizes:e.getAttribute("data-sizes")}),i.off(e,"click.chocolat"),i.on(e,"click.chocolat",(function(e){i.init(n),e.preventDefault()}))})):this.images=e,this.settings.container instanceof Element||this.settings.container instanceof HTMLElement?this.elems.container=this.settings.container:this.elems.container=document.body,this.api={open:function(e){return e=parseInt(e)||0,i.init(e)},close:function(){return i.close()},next:function(){return i.change(1)},prev:function(){return i.change(-1)},goto:function(e){return i.open(e)},current:function(){return i.settings.currentImageIndex},position:function(){return i.position(i.elems.img)},destroy:function(){return i.destroy()},set:function(e,t){return i.settings[e]=t,t},get:function(e){return i.settings[e]},getElem:function(e){return i.elems[e]}}}var i,s,r;return i=n,(s=[{key:"init",value:function(e){return this.state.initialized||(this.markup(),this.attachListeners(),this.settings.lastImageIndex=this.images.length-1,this.state.initialized=!0),this.settings.afterInitialize.call(this),this.load(e)}},{key:"load",value:function(e){var t=this;if(this.state.visible||(this.state.visible=!0,setTimeout((function(){t.elems.overlay.classList.add("chocolat-visible"),t.elems.wrapper.classList.add("chocolat-visible")}),0),this.elems.container.classList.add("chocolat-open")),this.settings.fullScreen&&nn(this.elems.wrapper),this.settings.currentImageIndex===e)return Promise.resolve();var n,i,s=setTimeout((function(){t.elems.loader.classList.add("chocolat-visible")}),1e3),r=setTimeout((function(){r=void 0,n=Qt((function(){t.elems.imageCanvas.classList.remove("chocolat-visible")}),t.elems.imageCanvas)}),80);return en(this.images[e]).then((function(e){return i=e,r?(clearTimeout(r),Promise.resolve()):n})).then((function(){var n=e+1;return null!=t.images[n]&&en(t.images[n]),t.settings.currentImageIndex=e,t.elems.description.innerHTML=t.settings.description.call(t),t.elems.pagination.textContent=t.settings.pagination.call(t),t.arrows(),t.position(i).then((function(){return t.elems.loader.classList.remove("chocolat-visible"),clearTimeout(s),t.appear(i)}))})).then((function(){t.elems.container.classList.toggle("chocolat-zoomable",t.zoomable(i,t.elems.wrapper)),t.settings.afterImageLoad.call(t)}))}},{key:"position",value:function(e){var t=this,n=tn({imgHeight:e.naturalHeight,imgWidth:e.naturalWidth,containerHeight:this.elems.container.clientHeight,containerWidth:this.elems.container.clientWidth,canvasWidth:this.elems.imageCanvas.clientWidth,canvasHeight:this.elems.imageCanvas.clientHeight,imageSize:this.settings.imageSize}),i=n.width,s=n.height;return Qt((function(){Object.assign(t.elems.imageWrapper.style,{width:i+"px",height:s+"px"})}),this.elems.imageWrapper)}},{key:"appear",value:function(e){var t=this;return this.elems.imageWrapper.removeChild(this.elems.img),this.elems.img=e,this.elems.img.setAttribute("class","chocolat-img"),this.elems.imageWrapper.appendChild(this.elems.img),Qt((function(){t.elems.imageCanvas.classList.add("chocolat-visible")}),this.elems.imageCanvas)}},{key:"change",value:function(e){if(this.state.visible&&this.settings.linkImages){this.zoomOut();var t=this.settings.currentImageIndex+parseInt(e);if(t>this.settings.lastImageIndex){if(this.settings.loop)return this.load(this.settings.firstImageIndex)}else{if(!(t=0;n--){var i=this.events[n],s=i.element,r=i.eventName;this.off(s,r)}this.state.initialized&&(this.state.fullScreenOpen&&sn(),this.settings.currentImageIndex=void 0,this.state.visible=!1,this.state.initialized=!1,(e=this.elems.container.classList).remove.apply(e,t(this._cssClasses)),this.elems.wrapper.parentNode.removeChild(this.elems.wrapper))}},{key:"markup",value:function(){this.elems.container.classList.add("chocolat-open",this.settings.className),"cover"==this.settings.imageSize&&this.elems.container.classList.add("chocolat-cover"),this.elems.container!==document.body&&this.elems.container.classList.add("chocolat-in-container"),this.elems.wrapper=document.createElement("div"),this.elems.wrapper.setAttribute("id","chocolat-content-"+this.settings.setIndex),this.elems.wrapper.setAttribute("class","chocolat-wrapper"),this.elems.container.appendChild(this.elems.wrapper),this.elems.overlay=document.createElement("div"),this.elems.overlay.setAttribute("class","chocolat-overlay"),this.elems.wrapper.appendChild(this.elems.overlay),this.elems.loader=document.createElement("div"),this.elems.loader.setAttribute("class","chocolat-loader"),this.elems.wrapper.appendChild(this.elems.loader),this.elems.layout=document.createElement("div"),this.elems.layout.setAttribute("class","chocolat-layout"),this.elems.wrapper.appendChild(this.elems.layout),this.elems.top=document.createElement("div"),this.elems.top.setAttribute("class","chocolat-top"),this.elems.layout.appendChild(this.elems.top),this.elems.center=document.createElement("div"),this.elems.center.setAttribute("class","chocolat-center"),this.elems.layout.appendChild(this.elems.center),this.elems.left=document.createElement("div"),this.elems.left.setAttribute("class","chocolat-left"),this.elems.center.appendChild(this.elems.left),this.elems.imageCanvas=document.createElement("div"),this.elems.imageCanvas.setAttribute("class","chocolat-image-canvas"),this.elems.center.appendChild(this.elems.imageCanvas),this.elems.imageWrapper=document.createElement("div"),this.elems.imageWrapper.setAttribute("class","chocolat-image-wrapper"),this.elems.imageCanvas.appendChild(this.elems.imageWrapper),this.elems.img=document.createElement("img"),this.elems.img.setAttribute("class","chocolat-img"),this.elems.imageWrapper.appendChild(this.elems.img),this.elems.right=document.createElement("div"),this.elems.right.setAttribute("class","chocolat-right"),this.elems.center.appendChild(this.elems.right),this.elems.bottom=document.createElement("div"),this.elems.bottom.setAttribute("class","chocolat-bottom"),this.elems.layout.appendChild(this.elems.bottom),this.elems.close=document.createElement("span"),this.elems.close.setAttribute("class","chocolat-close"),this.elems.top.appendChild(this.elems.close),this.elems.description=document.createElement("span"),this.elems.description.setAttribute("class","chocolat-description"),this.elems.bottom.appendChild(this.elems.description),this.elems.pagination=document.createElement("span"),this.elems.pagination.setAttribute("class","chocolat-pagination"),this.elems.bottom.appendChild(this.elems.pagination),this.elems.setTitle=document.createElement("span"),this.elems.setTitle.setAttribute("class","chocolat-set-title"),this.elems.setTitle.textContent=this.settings.setTitle(),this.elems.bottom.appendChild(this.elems.setTitle),this.elems.fullscreen=document.createElement("span"),this.elems.fullscreen.setAttribute("class","chocolat-fullscreen"),this.elems.bottom.appendChild(this.elems.fullscreen),this.settings.afterMarkup.call(this)}},{key:"attachListeners",value:function(){var e=this;this.off(document,"keydown.chocolat"),this.on(document,"keydown.chocolat",(function(t){e.state.initialized&&(37==t.keyCode?e.change(-1):39==t.keyCode?e.change(1):27==t.keyCode&&e.close())}));var t=this.elems.wrapper.querySelector(".chocolat-right");this.off(t,"click.chocolat"),this.on(t,"click.chocolat",(function(){e.change(1)}));var n=this.elems.wrapper.querySelector(".chocolat-left");this.off(n,"click.chocolat"),this.on(n,"click.chocolat",(function(){e.change(-1)})),this.off(this.elems.close,"click.chocolat"),this.on(this.elems.close,"click.chocolat",this.close.bind(this)),this.off(this.elems.fullscreen,"click.chocolat"),this.on(this.elems.fullscreen,"click.chocolat",(function(){e.state.fullScreenOpen?sn():nn(e.elems.wrapper)})),this.off(document,"fullscreenchange.chocolat"),this.on(document,"fullscreenchange.chocolat",(function(){document.fullscreenElement||document.webkitCurrentFullScreenElement||document.webkitFullscreenElement?e.state.fullScreenOpen=!0:e.state.fullScreenOpen=!1})),this.off(document,"webkitfullscreenchange.chocolat"),this.on(document,"webkitfullscreenchange.chocolat",(function(){document.fullscreenElement||document.webkitCurrentFullScreenElement||document.webkitFullscreenElement?e.state.fullScreenOpen=!0:e.state.fullScreenOpen=!1})),this.settings.closeOnBackgroundClick&&(this.off(this.elems.overlay,"click.chocolat"),this.on(this.elems.overlay,"click.chocolat",this.close.bind(this))),this.off(this.elems.wrapper,"click.chocolat"),this.on(this.elems.wrapper,"click.chocolat",(function(){null!==e.state.initialZoomState&&e.state.visible&&(e.elems.container.classList.add("chocolat-zooming-out"),e.zoomOut().then((function(){e.elems.container.classList.remove("chocolat-zoomed"),e.elems.container.classList.remove("chocolat-zooming-out")})))})),this.off(this.elems.imageWrapper,"click.chocolat"),this.on(this.elems.imageWrapper,"click.chocolat",(function(t){null===e.state.initialZoomState&&e.elems.container.classList.contains("chocolat-zoomable")&&(t.stopPropagation(),e.elems.container.classList.add("chocolat-zooming-in"),e.zoomIn(t).then((function(){e.elems.container.classList.add("chocolat-zoomed"),e.elems.container.classList.remove("chocolat-zooming-in")})))})),this.on(this.elems.wrapper,"mousemove.chocolat",(function(t){if(null!==e.state.initialZoomState&&e.state.visible){var n=e.elems.wrapper.getBoundingClientRect(),i=n.top+window.scrollY,s=n.left+window.scrollX,r=e.elems.wrapper.clientHeight,o=e.elems.wrapper.clientWidth,a=e.elems.img.width,c=e.elems.img.height,l=[t.pageX-o/2-s,t.pageY-r/2-i],u=0;if(a>o){var h=e.settings.zoomedPaddingX(a,o);u=l[0]/(o/2),u*=(a-o)/2+h}var m=0;if(c>r){var f=e.settings.zoomedPaddingY(c,r);m=l[1]/(r/2),m*=(c-r)/2+f}e.elems.img.style.marginLeft=-u+"px",e.elems.img.style.marginTop=-m+"px"}})),this.on(window,"resize.chocolat",(function(t){var n,i;e.state.initialized&&e.state.visible&&(n=50,i=function(){tn({imgHeight:e.elems.img.naturalHeight,imgWidth:e.elems.img.naturalWidth,containerHeight:e.elems.wrapper.clientHeight,containerWidth:e.elems.wrapper.clientWidth,canvasWidth:e.elems.imageCanvas.clientWidth,canvasHeight:e.elems.imageCanvas.clientHeight,imageSize:e.settings.imageSize}),e.position(e.elems.img).then((function(){e.elems.container.classList.toggle("chocolat-zoomable",e.zoomable(e.elems.img,e.elems.wrapper))}))},clearTimeout(Jt),Jt=setTimeout((function(){i()}),n))}))}},{key:"zoomable",value:function(e,t){var n=t.clientWidth,i=t.clientHeight,s=!(!this.settings.allowZoom||!(e.naturalWidth>n||e.naturalHeight>i)),r=e.clientWidth>e.naturalWidth||e.clientHeight>e.naturalHeight;return s&&!r}},{key:"zoomIn",value:function(e){return this.state.initialZoomState=this.settings.imageSize,this.settings.imageSize="native",this.position(this.elems.img)}},{key:"zoomOut",value:function(e){return this.settings.imageSize=this.state.initialZoomState||this.settings.imageSize,this.state.initialZoomState=null,this.elems.img.style.margin=0,this.position(this.elems.img)}},{key:"on",value:function(e,t,n){var i=this.events.push({element:e,eventName:t,cb:n});e.addEventListener(t.split(".")[0],this.events[i-1].cb)}},{key:"off",value:function(e,t){var n=this.events.findIndex((function(n){return n.element===e&&n.eventName===t}));this.events[n]&&(e.removeEventListener(t.split(".")[0],this.events[n].cb),this.events.splice(n,1))}}])&&e(i.prototype,s),r&&e(i,r),n}(),an=[];window.Chocolat=function(e,t){var n=Object.assign({},rn,{images:[]},t,{setIndex:an.length}),i=new on(e,n);return an.push(i),i}}(); -- 2.34.1