/*!
* Viewer.js v1.0.0
* https://github.com/fengyuanchen/viewerjs
*
* Copyright (c) 2015-2018 Chen Fengyuan
* Released under the MIT license
*
* Date: 2018-04-01T05:33:18.955Z
*/
!function(t,i){"object"==typeof exports&&"undefined"!=typeof module?module.exports=i():"function"==typeof define&&define.amd?define(i):t.Viewer=i()}(this,function(){"use strict";var n={inline:!1,button:!0,navbar:!0,title:!0,toolbar:!0,tooltip:!0,movable:!0,zoomable:!0,rotatable:!0,scalable:!0,transition:!0,fullscreen:!0,interval:5e3,keyboard:!0,backdrop:!0,loading:!0,loop:!0,minWidth:200,minHeight:100,zoomRatio:.1,minZoomRatio:.01,maxZoomRatio:100,zIndex:2015,zIndexInline:0,url:"src",container:"body",filter:null,ready:null,show:null,shown:null,hide:null,hidden:null,view:null,viewed:null},s="undefined"!=typeof window,o=s?window:{},p="viewer",l="move",d="switch",c="zoom",m=p+"-active",w=p+"-fade",b=p+"-fixed",a=p+"-fullscreen-exit",y=p+"-hide",i=p+"-hide-md-down",e=p+"-hide-sm-down",r=p+"-hide-xs-down",u=p+"-in",x=p+"-invisible",f=p+"-loading",h=p+"-open",g=p+"-show",v=p+"-transition",D="ready",z="show",k="shown",E="hide",S="hidden",I="view",T="viewed",L="click",C="dragstart",M="keydown",N="load",Y=o.PointerEvent?"pointerdown":"touchstart mousedown",X=o.PointerEvent?"pointermove":"touchmove mousemove",R=o.PointerEvent?"pointerup pointercancel":"touchend touchcancel mouseup",q="resize",F="transitionend",O="wheel mousewheel DOMMouseScroll",W=["zoom-in","zoom-out","one-to-one","reset","prev","play","next","rotate-left","rotate-right","flip-horizontal","flip-vertical"],P="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},A=function(t,i){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")},t=function(){function n(t,i){for(var e=0;e<i.length;e++){var n=i[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(t,i,e){return i&&n(t.prototype,i),e&&n(t,e),t}}();function H(t){return"string"==typeof t}var j=Number.isNaN||o.isNaN;function B(t){return"number"==typeof t&&!j(t)}function V(t){return void 0===t}function K(t){return"object"===(void 0===t?"undefined":P(t))&&null!==t}var U=Object.prototype.hasOwnProperty;function Z(t){if(!K(t))return!1;try{var i=t.constructor,e=i.prototype;return i&&e&&U.call(e,"isPrototypeOf")}catch(t){return!1}}function $(t){return"function"==typeof t}function _(i,e){if(i&&$(e))if(Array.isArray(i)||B(i.length)){var t=i.length,n=void 0;for(n=0;n<t&&!1!==e.call(i,i[n],n,i);n+=1);}else K(i)&&Object.keys(i).forEach(function(t){e.call(i,i[t],t,i)});return i}var G=Object.assign||function(e){for(var t=arguments.length,i=Array(1<t?t-1:0),n=1;n<t;n++)i[n-1]=arguments[n];return K(e)&&0<i.length&&i.forEach(function(i){K(i)&&Object.keys(i).forEach(function(t){e[t]=i[t]})}),e},J=/^(?:width|height|left|top|marginLeft|marginTop)$/;function Q(t,i){var e=t.style;_(i,function(t,i){J.test(i)&&B(t)&&(t+="px"),e[i]=t})}function tt(t,i){return t.classList?t.classList.contains(i):-1<t.className.indexOf(i)}function it(t,i){if(i)if(B(t.length))_(t,function(t){it(t,i)});else if(t.classList)t.classList.add(i);else{var e=t.className.trim();e?e.indexOf(i)<0&&(t.className=e+" "+i):t.className=i}}function et(t,i){i&&(B(t.length)?_(t,function(t){et(t,i)}):t.classList?t.classList.remove(i):0<=t.className.indexOf(i)&&(t.className=t.className.replace(i,"")))}function nt(t,i,e){i&&(B(t.length)?_(t,function(t){nt(t,i,e)}):e?it(t,i):et(t,i))}var st=/([a-z\d])([A-Z])/g;function ot(t){return t.replace(st,"$1-$2").toLowerCase()}function at(t,i){return K(t[i])?t[i]:t.dataset?t.dataset[i]:t.getAttribute("data-"+ot(i))}function rt(t,i,e){K(e)?t[i]=e:t.dataset?t.dataset[i]=e:t.setAttribute("data-"+ot(i),e)}var ht=/\s\s*/,lt=function(){var t=!1;if(s){var i=!1,e=function(){},n=Object.defineProperty({},"once",{get:function(){return t=!0,i},set:function(t){i=t}});o.addEventListener("test",e,n),o.removeEventListener("test",e,n)}return t}();function dt(e,t,n){var s=3<arguments.length&&void 0!==arguments[3]?arguments[3]:{},o=n;t.trim().split(ht).forEach(function(t){if(!lt){var i=e.listeners;i&&i[t]&&i[t][n]&&(o=i[t][n],delete i[t][n],0===Object.keys(i[t]).length&&delete i[t],0===Object.keys(i).length&&delete e.listeners)}e.removeEventListener(t,o,s)})}function ct(o,t,a){var r=3<arguments.length&&void 0!==arguments[3]?arguments[3]:{},h=a;t.trim().split(ht).forEach(function(n){if(r.once&&!lt){var t=o.listeners,s=void 0===t?{}:t;h=function(){for(var t=arguments.length,i=Array(t),e=0;e<t;e++)i[e]=arguments[e];delete s[n][a],o.removeEventListener(n,h,r),a.apply(o,i)},s[n]||(s[n]={}),s[n][a]&&o.removeEventListener(n,s[n][a],r),s[n][a]=h,o.listeners=s}o.addEventListener(n,h,r)})}function ut(t,i,e){var n=void 0;return $(Event)&&$(CustomEvent)?n=new CustomEvent(i,{detail:e,bubbles:!0,cancelable:!0}):(n=document.createEvent("CustomEvent")).initCustomEvent(i,!0,!0,e),t.dispatchEvent(n)}function mt(t){var i=t.rotate,e=t.scaleX,n=t.scaleY,s=t.translateX,o=t.translateY,a=[];B(s)&&0!==s&&a.push("translateX("+s+"px)"),B(o)&&0!==o&&a.push("translateY("+o+"px)"),B(i)&&0!==i&&a.push("rotate("+i+"deg)"),B(e)&&1!==e&&a.push("scaleX("+e+")"),B(n)&&1!==n&&a.push("scaleY("+n+")");var r=a.length?a.join(" "):"none";return{WebkitTransform:r,msTransform:r,transform:r}}var ft=o.navigator&&/(Macintosh|iPhone|iPod|iPad).*AppleWebKit/i.test(o.navigator.userAgent);function gt(t,i){var e=document.createElement("img");if(t.naturalWidth&&!ft)return i(t.naturalWidth,t.naturalHeight),e;var n=document.body||document.documentElement;return e.onload=function(){i(e.width,e.height),ft||n.removeChild(e)},e.src=t.src,ft||(e.style.cssText="left:0;max-height:none!important;max-width:none!important;min-height:0!important;min-width:0!important;opacity:0;position:absolute;top:0;z-index:-1;",n.appendChild(e)),e}function vt(t){switch(t){case 2:return r;case 3:return e;case 4:return i;default:return""}}function pt(t,i){var e=t.pageX,n=t.pageY,s={endX:e,endY:n};return i?s:G({startX:e,startY:n},s)}var wt={render:function(){this.initContainer(),this.initViewer(),this.initList(),this.renderViewer()},initContainer:function(){this.containerData={width:window.innerWidth,height:window.innerHeight}},initViewer:function(){var t=this.options,i=this.parent,e=void 0;t.inline&&(e={width:Math.max(i.offsetWidth,t.minWidth),height:Math.max(i.offsetHeight,t.minHeight)},this.parentData=e),!this.fulled&&e||(e=this.containerData),this.viewerData=G({},e)},renderViewer:function(){this.options.inline&&!this.fulled&&Q(this.viewer,this.viewerData)},initList:function(){var a=this,t=this.element,r=this.options,i=this.list,h=[];_(this.images,function(t,i){var e,n=t.src,s=t.alt||(H(e=n)?e.replace(/^.*\//,"").replace(/[?&#].*$/,""):""),o=r.url;H(o)?o=t.getAttribute(o):$(o)&&(o=o.call(a,t)),(n||o)&&h.push('<li><img src="'+(n||o)+'" role="button" data-action="view" data-index="'+i+'" data-original-url="'+(o||n)+'" alt="'+s+'"></li>')}),i.innerHTML=h.join(""),this.items=i.getElementsByTagName("li"),_(this.items,function(i){var t=i.firstElementChild;rt(t,"filled",!0),r.loading&&it(i,f),ct(t,N,function(t){r.loading&&et(i,f),a.loadImage(t)},{once:!0})}),r.transition&&ct(t,T,function(){it(i,v)},{once:!0})},renderList:function(t){var i=t||this.index,e=this.items[i].offsetWidth||30,n=e+1;Q(this.list,G({width:n*this.length},mt({translateX:(this.viewerData.width-e)/2-n*i})))},resetList:function(){var t=this.list;t.innerHTML="",et(t,v),Q(t,mt({translateX:0}))},initImage:function(r){var h=this,l=this.options,t=this.image,i=this.viewerData,e=this.footer.offsetHeight,d=i.width,c=Math.max(i.height-e,e),u=this.imageData||{},n=void 0;this.imageInitializing={abort:function(){n.onload=null}},n=gt(t,function(t,i){var e=t/i,n=d,s=c;h.imageInitializing=!1,d<c*e?s=d/e:n=c*e;var o={naturalWidth:t,naturalHeight:i,aspectRatio:e,ratio:(n=Math.min(.9*n,t))/t,width:n,height:s=Math.min(.9*s,i),left:(d-n)/2,top:(c-s)/2},a=G({},o);l.rotatable&&(o.rotate=u.rotate||0,a.rotate=0),l.scalable&&(o.scaleX=u.scaleX||1,o.scaleY=u.scaleY||1,a.scaleX=1,a.scaleY=1),h.imageData=o,h.initialImageData=a,r&&r()})},renderImage:function(t){var i=this,e=this.image,n=this.imageData;if(Q(e,G({width:n.width,height:n.height,marginLeft:n.left,marginTop:n.top},mt(n))),t)if(this.viewing&&this.options.transition){var s=function(){i.imageRendering=!1,t()};this.imageRendering={abort:function(){dt(e,F,s)}},ct(e,F,s,{once:!0})}else t()},resetImage:function(){if(this.viewing||this.viewed){var t=this.image;this.viewing&&this.viewing.abort(),t.parentNode.removeChild(t),this.image=null}}},bt={bind:function(){var t=this.element,i=this.viewer;ct(i,L,this.onClick=this.click.bind(this)),ct(i,O,this.onWheel=this.wheel.bind(this)),ct(i,C,this.onDragStart=this.dragstart.bind(this)),ct(this.canvas,Y,this.onPointerDown=this.pointerdown.bind(this)),ct(t.ownerDocument,X,this.onPointerMove=this.pointermove.bind(this)),ct(t.ownerDocument,R,this.onPointerUp=this.pointerup.bind(this)),ct(t.ownerDocument,M,this.onKeyDown=this.keydown.bind(this)),ct(window,q,this.onResize=this.resize.bind(this))},unbind:function(){var t=this.element,i=this.viewer;dt(i,L,this.onClick),dt(i,O,this.onWheel),dt(i,C,this.onDragStart),dt(this.canvas,Y,this.onPointerDown),dt(t.ownerDocument,X,this.onPointerMove),dt(t.ownerDocument,R,this.onPointerUp),dt(t.ownerDocument,M,this.onKeyDown),dt(window,q,this.onResize)}},yt={click:function(t){var i=t.target,e=this.options,n=this.imageData;switch(at(i,"action")){case"mix":this.played?this.stop():e.inline?this.fulled?this.exit():this.full():this.hide();break;case"hide":this.hide();break;case"view":this.view(at(i,"index"));break;case"zoom-in":this.zoom(.1,!0);break;case"zoom-out":this.zoom(-.1,!0);break;case"one-to-one":this.toggle();break;case"reset":this.reset();break;case"prev":this.prev(e.loop);break;case"play":this.play(e.fullscreen);break;case"next":this.next(e.loop);break;case"rotate-left":this.rotate(-90);break;case"rotate-right":this.rotate(90);break;case"flip-horizontal":this.scaleX(-n.scaleX||-1);break;case"flip-vertical":this.scaleY(-n.scaleY||-1);break;default:this.played&&this.stop()}},load:function(){var t=this;this.timeout&&(clearTimeout(this.timeout),this.timeout=!1);var i=this.element,e=this.options,n=this.image,s=this.index,o=this.viewerData;et(n,x),e.loading&&et(this.canvas,f),n.style.cssText="height:0;margin-left:"+o.width/2+"px;margin-top:"+o.height/2+"px;max-width:none!important;position:absolute;width:0;",this.initImage(function(){nt(n,"viewer-move",e.movable),nt(n,v,e.transition),t.renderImage(function(){t.viewed=!0,t.viewing=!1,$(e.viewed)&&ct(i,T,e.viewed,{once:!0}),ut(i,T,{originalImage:t.images[s],index:s,image:n})})})},loadImage:function(t){var o=t.target,i=o.parentNode,a=i.offsetWidth||30,r=i.offsetHeight||50,h=!!at(o,"filled");gt(o,function(t,i){var e=t/i,n=a,s=r;a<r*e?h?n=r*e:s=a/e:h?s=a/e:n=r*e,Q(o,G({width:n,height:s},mt({translateX:(a-n)/2,translateY:(r-s)/2})))})},keydown:function(t){var i=this.options;if(this.fulled&&i.keyboard)switch(t.keyCode||t.which||t.charCode){case 27:this.played?this.stop():i.inline?this.fulled&&this.exit():this.hide();break;case 32:this.played&&this.stop();break;case 37:this.prev(i.loop);break;case 38:t.preventDefault(),this.zoom(i.zoomRatio,!0);break;case 39:this.next(i.loop);break;case 40:t.preventDefault(),this.zoom(-i.zoomRatio,!0);break;case 48:case 49:t.ctrlKey&&(t.preventDefault(),this.toggle())}},dragstart:function(t){"img"===t.target.tagName.toLowerCase()&&t.preventDefault()},pointerdown:function(t){var i=this.options,e=this.pointers;if(this.viewed&&!this.showing&&!this.viewing&&!this.hiding){t.changedTouches?_(t.changedTouches,function(t){e[t.identifier]=pt(t)}):e[t.pointerId||0]=pt(t);var n=!!i.movable&&l;1<Object.keys(e).length?n=c:"touch"!==t.pointerType&&"touchstart"!==t.type||!this.isSwitchable()||(n=d),this.action=n}},pointermove:function(t){var i=this.options,e=this.pointers,n=this.action,s=this.image;this.viewed&&n&&(t.preventDefault(),t.changedTouches?_(t.changedTouches,function(t){G(e[t.identifier],pt(t,!0))}):G(e[t.pointerId||0],pt(t,!0)),n===l&&i.transition&&tt(s,v)&&et(s,v),this.change(t))},pointerup:function(t){var i=this.action,e=this.pointers;t.changedTouches?_(t.changedTouches,function(t){delete e[t.identifier]}):delete e[t.pointerId||0],i&&(i===l&&this.options.transition&&it(this.image,v),this.action=!1)},resize:function(){var i=this;if(this.isShown&&!this.hiding&&(this.initContainer(),this.initViewer(),this.renderViewer(),this.renderList(),this.viewed&&this.initImage(function(){i.renderImage()}),this.played)){if(this.options.fullscreen&&this.fulled&&!document.fullscreenElement&&!document.mozFullScreenElement&&!document.webkitFullscreenElement&&!document.msFullscreenElement)return void this.stop();_(this.player.getElementsByTagName("img"),function(t){ct(t,N,i.loadImage.bind(i),{once:!0}),ut(t,N)})}},wheel:function(t){var i=this;if(this.viewed&&(t.preventDefault(),!this.wheeling)){this.wheeling=!0,setTimeout(function(){i.wheeling=!1},50);var e=Number(this.options.zoomRatio)||.1,n=1;t.deltaY?n=0<t.deltaY?1:-1:t.wheelDelta?n=-t.wheelDelta/120:t.detail&&(n=0<t.detail?1:-1),this.zoom(-n*e,!0,t)}}},xt={show:function(){var t=0<arguments.length&&void 0!==arguments[0]&&arguments[0],i=this.element,e=this.options;if(e.inline||this.showing||this.isShown||this.showing)return this;if(!this.ready)return this.build(),this.ready&&this.show(t),this;if($(e.show)&&ct(i,z,e.show,{once:!0}),!1===ut(i,z)||!this.ready)return this;this.hiding&&this.transitioning.abort(),this.showing=!0,this.open();var n=this.viewer;if(et(n,y),e.transition&&!t){var s=this.shown.bind(this);this.transitioning={abort:function(){dt(n,F,s),et(n,u)}},it(n,v),n.offsetWidth,ct(n,F,s,{once:!0}),it(n,u)}else it(n,u),this.shown();return this},hide:function(){var t=0<arguments.length&&void 0!==arguments[0]&&arguments[0],i=this.element,e=this.options;if(e.inline||this.hiding||!this.isShown&&!this.showing)return this;if($(e.hide)&&ct(i,E,e.hide,{once:!0}),!1===ut(i,E))return this;this.showing&&this.transitioning.abort(),this.hiding=!0,this.played?this.stop():this.viewing&&this.viewing.abort();var n=this.viewer;if(e.transition&&!t){var s=this.hidden.bind(this),o=function(){ct(n,F,s,{once:!0}),et(n,u)};this.transitioning={abort:function(){this.viewed?dt(this.image,F,o):dt(n,F,s)}},this.viewed?(ct(this.image,F,o,{once:!0}),this.zoomTo(0,!1,!1,!0)):o()}else et(n,u),this.hidden();return this},view:function(){var i=this,t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:0;if(t=Number(t)||0,!this.isShown)return this.index=t,this.show();if(this.hiding||this.played||t<0||t>=this.length||this.viewed&&t===this.index)return this;this.viewing&&this.viewing.abort();var e=this.element,n=this.options,s=this.title,o=this.canvas,a=this.items[t],r=a.querySelector("img"),h=at(r,"originalUrl"),l=r.getAttribute("alt"),d=document.createElement("img");if(d.src=h,d.alt=l,$(n.view)&&ct(e,I,n.view,{once:!0}),!1===ut(e,I,{originalImage:this.images[t],index:t,image:d})||!this.isShown||this.hiding||this.played)return this;this.image=d,et(this.items[this.index],m),it(a,m),this.viewed=!1,this.index=t,this.imageData={},it(d,x),n.loading&&it(o,f),o.innerHTML="",o.appendChild(d),this.renderList(),s.innerHTML="";var c=function(){var t=i.imageData;s.textContent=l+" ("+t.naturalWidth+" × "+t.naturalHeight+")"},u=void 0;return ct(e,T,c,{once:!0}),this.viewing={abort:function(){dt(e,T,c),d.complete?this.imageRendering?this.imageRendering.abort():this.imageInitializing&&this.imageInitializing.abort():(dt(d,N,u),this.timeout&&clearTimeout(this.timeout))}},d.complete?this.load():(ct(d,N,u=this.load.bind(this),{once:!0}),this.timeout&&clearTimeout(this.timeout),this.timeout=setTimeout(function(){et(d,x),i.timeout=!1},1e3)),this},prev:function(){var t=0<arguments.length&&void 0!==arguments[0]&&arguments[0],i=this.index-1;return i<0&&(i=t?this.length-1:0),this.view(i),this},next:function(){var t=0<arguments.length&&void 0!==arguments[0]&&arguments[0],i=this.length-1,e=this.index+1;return i<e&&(e=t?0:i),this.view(e),this},move:function(t,i){var e=this.imageData;return this.moveTo(V(t)?t:e.left+Number(t),V(i)?i:e.top+Number(i)),this},moveTo:function(t){var i=1<arguments.length&&void 0!==arguments[1]?arguments[1]:t,e=this.imageData;if(t=Number(t),i=Number(i),this.viewed&&!this.played&&this.options.movable){var n=!1;B(t)&&(e.left=t,n=!0),B(i)&&(e.top=i,n=!0),n&&this.renderImage()}return this},zoom:function(t){var i=1<arguments.length&&void 0!==arguments[1]&&arguments[1],e=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null,n=this.imageData;return t=(t=Number(t))<0?1/(1-t):1+t,this.zoomTo(n.width*t/n.naturalWidth,i,e),this},zoomTo:function(t){var n,s,o,i,e,a=1<arguments.length&&void 0!==arguments[1]&&arguments[1],r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null,h=3<arguments.length&&void 0!==arguments[3]&&arguments[3],l=this.options,d=this.pointers,c=this.imageData;if(B(t=Math.max(0,t))&&this.viewed&&!this.played&&(h||l.zoomable)){if(!h){var u=Math.max(.01,l.minZoomRatio),m=Math.min(100,l.maxZoomRatio);t=Math.min(Math.max(t,u),m)}r&&.95<t&&t<1.05&&(t=1);var f=c.naturalWidth*t,g=c.naturalHeight*t;if(r){var v=(i=this.viewer,{left:(e=i.getBoundingClientRect()).left+(window.pageXOffset-document.documentElement.clientLeft),top:e.top+(window.pageYOffset-document.documentElement.clientTop)}),p=d&&Object.keys(d).length?(o=s=n=0,_(d,function(t){var i=t.startX,e=t.startY;n+=i,s+=e,o+=1}),{pageX:n/=o,pageY:s/=o}):{pageX:r.pageX,pageY:r.pageY};c.left-=(f-c.width)*((p.pageX-v.left-c.left)/c.width),c.top-=(g-c.height)*((p.pageY-v.top-c.top)/c.height)}else c.left-=(f-c.width)/2,c.top-=(g-c.height)/2;c.width=f,c.height=g,c.ratio=t,this.renderImage(),a&&this.tooltip()}return this},rotate:function(t){return this.rotateTo((this.imageData.rotate||0)+Number(t)),this},rotateTo:function(t){var i=this.imageData;return B(t=Number(t))&&this.viewed&&!this.played&&this.options.rotatable&&(i.rotate=t,this.renderImage()),this},scaleX:function(t){return this.scale(t,this.imageData.scaleY),this},scaleY:function(t){return this.scale(this.imageData.scaleX,t),this},scale:function(t){var i=1<arguments.length&&void 0!==arguments[1]?arguments[1]:t,e=this.imageData;if(t=Number(t),i=Number(i),this.viewed&&!this.played&&this.options.scalable){var n=!1;B(t)&&(e.scaleX=t,n=!0),B(i)&&(e.scaleY=i,n=!0),n&&this.renderImage()}return this},play:function(){var i=this,t=0<arguments.length&&void 0!==arguments[0]&&arguments[0];if(!this.isShown||this.played)return this;var s=this.options,o=this.player,a=this.loadImage.bind(this),r=[],h=0,l=0;if(this.played=!0,this.onLoadWhenPlay=a,t&&this.requestFullscreen(),it(o,g),_(this.items,function(t,i){var e=t.querySelector("img"),n=document.createElement("img");n.src=at(e,"originalUrl"),n.alt=e.getAttribute("alt"),h+=1,it(n,w),nt(n,v,s.transition),tt(t,m)&&(it(n,u),l=i),r.push(n),ct(n,N,a,{once:!0}),o.appendChild(n)}),B(s.interval)&&0<s.interval){var e=function t(){i.playing=setTimeout(function(){et(r[l],u),it(r[l=(l+=1)<h?l:0],u),t()},s.interval)};1<h&&e()}return this},stop:function(){var i=this;if(!this.played)return this;var t=this.player;return this.played=!1,clearTimeout(this.playing),_(t.getElementsByTagName("img"),function(t){dt(t,N,i.onLoadWhenPlay)}),et(t,g),t.innerHTML="",this.exitFullscreen(),this},full:function(){var t=this,i=this.options,e=this.viewer,n=this.image,s=this.list;return!this.isShown||this.played||this.fulled||!i.inline||(this.fulled=!0,this.open(),it(this.button,a),i.transition&&(et(s,v),this.viewed&&et(n,v)),it(e,b),e.setAttribute("style",""),Q(e,{zIndex:i.zIndex}),this.initContainer(),this.viewerData=G({},this.containerData),this.renderList(),this.viewed&&this.initImage(function(){t.renderImage(function(){i.transition&&setTimeout(function(){it(n,v),it(s,v)},0)})})),this},exit:function(){var t=this,i=this.options,e=this.viewer,n=this.image,s=this.list;return this.isShown&&!this.played&&this.fulled&&i.inline&&(this.fulled=!1,this.close(),et(this.button,a),i.transition&&(et(s,v),this.viewed&&et(n,v)),et(e,b),Q(e,{zIndex:i.zIndexInline}),this.viewerData=G({},this.parentData),this.renderViewer(),this.renderList(),this.viewed&&this.initImage(function(){t.renderImage(function(){i.transition&&setTimeout(function(){it(n,v),it(s,v)},0)})})),this},tooltip:function(){var t=this,i=this.options,e=this.tooltipBox,n=this.imageData;return this.viewed&&!this.played&&i.tooltip&&(e.textContent=Math.round(100*n.ratio)+"%",this.tooltipping?clearTimeout(this.tooltipping):i.transition?(this.fading&&ut(e,F),it(e,g),it(e,w),it(e,v),e.offsetWidth,it(e,u)):it(e,g),this.tooltipping=setTimeout(function(){i.transition?(ct(e,F,function(){et(e,g),et(e,w),et(e,v),t.fading=!1},{once:!0}),et(e,u),t.fading=!0):et(e,g),t.tooltipping=!1},1e3)),this},toggle:function(){return 1===this.imageData.ratio?this.zoomTo(this.initialImageData.ratio,!0):this.zoomTo(1,!0),this},reset:function(){return this.viewed&&!this.played&&(this.imageData=G({},this.initialImageData),this.renderImage()),this},update:function(){var t=this.element,i=this.options,e=this.isImg;if(e&&!t.parentNode)return this.destroy();var s=[];if(_(e?[t]:t.querySelectorAll("img"),function(t){i.filter?i.filter(t)&&s.push(t):s.push(t)}),!s.length)return this;if(this.images=s,this.length=s.length,this.ready){var o=[];if(_(this.items,function(t,i){var e=t.querySelector("img"),n=s[i];n?n.src!==e.src&&o.push(i):o.push(i)}),Q(this.list,{width:"auto"}),this.initList(),this.isShown)if(this.length){if(this.viewed){var n=o.indexOf(this.index);0<=n?(this.viewed=!1,this.view(Math.max(this.index-(n+1),0))):it(this.items[this.index],m)}}else this.image=null,this.viewed=!1,this.index=0,this.imageData=null,this.canvas.innerHTML="",this.title.innerHTML=""}else this.build();return this},destroy:function(){var t=this.element,i=this.options;return at(t,p)&&(this.destroyed=!0,this.ready?(this.played&&this.stop(),i.inline?(this.fulled&&this.exit(),this.unbind()):this.isShown?(this.viewing&&(this.imageRendering?this.imageRendering.abort():this.imageInitializing&&this.imageInitializing.abort()),this.hiding&&this.transitioning.abort(),this.hidden()):this.showing&&(this.transitioning.abort(),this.hidden()),this.ready=!1,this.viewer.parentNode.removeChild(this.viewer)):i.inline&&(this.delaying?this.delaying.abort():this.initializing&&this.initializing.abort()),i.inline||dt(t,L,this.onStart),function(i,e){if(K(i[e]))try{delete i[e]}catch(t){i[e]=void 0}else if(i.dataset)try{delete i.dataset[e]}catch(t){i.dataset[e]=void 0}else i.removeAttribute("data-"+ot(e))}(t,p)),this}},Dt={open:function(){var t=this.body;it(t,h),t.style.paddingRight=this.scrollbarWidth+(parseFloat(this.initialBodyPaddingRight)||0)+"px"},close:function(){var t=this.body;et(t,h),t.style.paddingRight=this.initialBodyPaddingRight},shown:function(){var t=this.element,i=this.options;this.fulled=!0,this.isShown=!0,this.render(),this.bind(),this.showing=!1,$(i.shown)&&ct(t,k,i.shown,{once:!0}),!1!==ut(t,k)&&this.ready&&this.isShown&&!this.hiding&&this.view(this.index)},hidden:function(){var t=this.element,i=this.options;this.fulled=!1,this.viewed=!1,this.isShown=!1,this.close(),this.unbind(),it(this.viewer,y),this.resetList(),this.resetImage(),this.hiding=!1,this.destroyed||($(i.hidden)&&ct(t,S,i.hidden,{once:!0}),ut(t,S))},requestFullscreen:function(){var t=this.element.ownerDocument;if(this.fulled&&!t.fullscreenElement&&!t.mozFullScreenElement&&!t.webkitFullscreenElement&&!t.msFullscreenElement){var i=t.documentElement;i.requestFullscreen?i.requestFullscreen():i.msRequestFullscreen?i.msRequestFullscreen():i.mozRequestFullScreen?i.mozRequestFullScreen():i.webkitRequestFullscreen&&i.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT)}},exitFullscreen:function(){if(this.fulled){var t=this.element.ownerDocument;t.exitFullscreen?t.exitFullscreen():t.msExitFullscreen?t.msExitFullscreen():t.mozCancelFullScreen?t.mozCancelFullScreen():t.webkitExitFullscreen&&t.webkitExitFullscreen()}},change:function(t){var i,e,h,n=this.options,s=this.pointers,o=s[Object.keys(s)[0]],a=o.endX-o.startX,r=o.endY-o.startY;switch(this.action){case l:this.move(a,r);break;case c:this.zoom((e=G({},i=s),h=[],_(i,function(r,t){delete e[t],_(e,function(t){var i=Math.abs(r.startX-t.startX),e=Math.abs(r.startY-t.startY),n=Math.abs(r.endX-t.endX),s=Math.abs(r.endY-t.endY),o=Math.sqrt(i*i+e*e),a=(Math.sqrt(n*n+s*s)-o)/o;h.push(a)})}),h.sort(function(t,i){return Math.abs(t)<Math.abs(i)}),h[0]),!1,t);break;case d:this.action="switched",this.pointers={},Math.abs(a)>Math.abs(r)&&(1<a?this.prev(n.loop):a<-1&&this.next(n.loop))}_(s,function(t){t.startX=t.endX,t.startY=t.endY})},isSwitchable:function(){var t=this.imageData,i=this.viewerData;return 1<this.length&&0<=t.left&&0<=t.top&&t.width<=i.width&&t.height<=i.height}},zt=o.Viewer,kt=function(){function e(t){var i=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};if(A(this,e),!t||1!==t.nodeType)throw new Error("The first argument is required and must be an element.");this.element=t,this.options=G({},n,Z(i)&&i),this.action=!1,this.fading=!1,this.fulled=!1,this.hiding=!1,this.index=0,this.isImg=!1,this.length=0,this.played=!1,this.playing=!1,this.pointers={},this.ready=!1,this.showing=!1,this.timeout=!1,this.tooltipping=!1,this.viewed=!1,this.viewing=!1,this.isShown=!1,this.wheeling=!1,this.init()}return t(e,[{key:"init",value:function(){var e=this,t=this.element,i=this.options;if(!at(t,p)){rt(t,p,this);var n="img"===t.tagName.toLowerCase(),s=[];if(_(n?[t]:t.querySelectorAll("img"),function(t){$(i.filter)?i.filter.call(e,t)&&s.push(t):s.push(t)}),s.length){this.isImg=n,this.length=s.length,this.images=s;var o=t.ownerDocument,a=o.body||o.documentElement;if(this.body=a,this.scrollbarWidth=window.innerWidth-o.documentElement.clientWidth,this.initialBodyPaddingRight=window.getComputedStyle(a).paddingRight,V(document.createElement(p).style.transition)&&(i.transition=!1),i.inline){var r=0,h=function(){if((r+=1)===e.length){var t=void 0;e.initializing=!1,e.delaying={abort:function(){clearTimeout(t)}},t=setTimeout(function(){e.delaying=!1,e.build()},0)}};this.initializing={abort:function(){_(s,function(t){t.complete||dt(t,N,h)})}},_(s,function(t){t.complete?h():ct(t,N,h,{once:!0})})}else ct(t,L,this.onStart=function(t){var i=t.target;"img"===i.tagName.toLowerCase()&&e.view(e.images.indexOf(i))})}}}},{key:"build",value:function(){if(!this.ready){var t=this.element,h=this.options,i=t.parentNode,e=document.createElement("div");e.innerHTML='<div class="viewer-container" touch-action="none"><div class="viewer-canvas"></div><div class="viewer-footer"><div class="viewer-title"></div><div class="viewer-toolbar"></div><div class="viewer-navbar"><ul class="viewer-list"></ul></div></div><div class="viewer-tooltip"></div><div role="button" class="viewer-button" data-action="mix"></div><div class="viewer-player"></div></div>';var n=e.querySelector("."+p+"-container"),s=n.querySelector("."+p+"-title"),o=n.querySelector("."+p+"-toolbar"),a=n.querySelector("."+p+"-navbar"),r=n.querySelector("."+p+"-button"),l=n.querySelector("."+p+"-canvas");if(this.parent=i,this.viewer=n,this.title=s,this.toolbar=o,this.navbar=a,this.button=r,this.canvas=l,this.footer=n.querySelector("."+p+"-footer"),this.tooltipBox=n.querySelector("."+p+"-tooltip"),this.player=n.querySelector("."+p+"-player"),this.list=n.querySelector("."+p+"-list"),it(s,h.title?vt(h.title):y),it(a,h.navbar?vt(h.navbar):y),nt(r,y,!h.button),h.backdrop&&(it(n,p+"-backdrop"),h.inline||!0!==h.backdrop||rt(l,"action","hide")),h.toolbar){var d=document.createElement("ul"),c=Z(h.toolbar),u=W.slice(0,3),m=W.slice(7,9),f=W.slice(9);c||it(o,vt(h.toolbar)),_(c?h.toolbar:W,function(t,i){var e=c&&Z(t),n=c?ot(i):t,s=e&&!V(t.show)?t.show:t;if(s&&(h.zoomable||-1===u.indexOf(n))&&(h.rotatable||-1===m.indexOf(n))&&(h.scalable||-1===f.indexOf(n))){var o=e&&!V(t.size)?t.size:t,a=e&&!V(t.click)?t.click:t,r=document.createElement("li");r.setAttribute("role","button"),it(r,p+"-"+n),$(a)||rt(r,"action",n),B(s)&&it(r,vt(s)),-1!==["small","large"].indexOf(o)?it(r,p+"-"+o):"play"===n&&it(r,p+"-large"),$(a)&&ct(r,L,a),d.appendChild(r)}}),o.appendChild(d)}else it(o,y);if(!h.rotatable){var g=o.querySelectorAll('li[class*="rotate"]');it(g,x),_(g,function(t){o.appendChild(t)})}if(h.inline)it(r,"viewer-fullscreen"),Q(n,{zIndex:h.zIndexInline}),"static"===window.getComputedStyle(i).position&&Q(i,{position:"relative"}),i.insertBefore(n,t.nextSibling);else{it(r,"viewer-close"),it(n,b),it(n,w),it(n,y),Q(n,{zIndex:h.zIndex});var v=h.container;H(v)&&(v=t.ownerDocument.querySelector(v)),v||(v=this.body),v.appendChild(n)}h.inline&&(this.render(),this.bind(),this.isShown=!0),this.ready=!0,$(h.ready)&&ct(t,D,h.ready,{once:!0}),!1!==ut(t,D)?this.ready&&h.inline&&this.view():this.ready=!1}}}],[{key:"noConflict",value:function(){return window.Viewer=zt,e}},{key:"setDefaults",value:function(t){G(n,Z(t)&&t)}}]),e}();return G(kt.prototype,wt,bt,yt,xt,Dt),kt});
|