1 |
- (window.webpackJsonp=window.webpackJsonp||[]).push([[8],{aSvP:function(t,e,i){"use strict";var n=i("CcnG"),s=i("Ip0R"),o=i("dq50");i.d(e,"a",(function(){return a})),i.d(e,"b",(function(){return l}));var r=[[".imgViewHelp[_ngcontent-%COMP%] img[_ngcontent-%COMP%]{margin-right:8px}"]],a=n.Kb({encapsulation:0,styles:r,data:{}});function h(t){return n.ic(0,[(t()(),n.Mb(0,0,null,null,0,"img",[["class","image"]],[[8,"src",4]],null,null,null,null))],null,(function(t,e){t(e,0,0,e.context.$implicit)}))}function l(t){return n.ic(0,[n.ec(671088640,1,{ljImgViewer:0}),(t()(),n.Mb(1,0,null,null,3,"div",[["class","imgViewHelp"]],null,null,null,null,null)),(t()(),n.Mb(2,0,[[1,0],["ljImgViewerId",1]],null,2,"div",[["class","list"],["id","ljImgViewerId"]],null,null,null,null,null)),(t()(),n.Bb(16777216,null,null,1,null,h)),n.Lb(4,278528,null,0,s.l,[n.gb,n.ab,n.C],{ngForOf:[0,"ngForOf"]},null)],(function(t,e){t(e,4,0,e.component.imageUrl)}),null)}n.Ib("app-image-viewer",o.a,(function(t){return n.ic(0,[(t()(),n.Mb(0,0,null,null,1,"app-image-viewer",[],null,null,null,l,a)),n.Lb(1,4440064,null,0,o.a,[],null,null)],(function(t,e){t(e,1,0)}),null)}),{imageUrl:"imageUrl",isPreviewNow:"isPreviewNow",initialViewIndex:"initialViewIndex"},{},[])},dq50:function(t,e,i){"use strict";i.d(e,"a",(function(){return o}));var n=i("yCxO"),s=i.n(n),o=function(){function t(){this.imageUrl=[],this.isPreviewNow=!1,this.initialViewIndex=0,this.viewer=null}return t.prototype.ngOnInit=function(){console.log("\u521d\u59cb\u5316")},t.prototype.ngAfterViewInit=function(){var t=this;this.viewer=new s.a(this.ljImgViewer.nativeElement,{inlineStyle:{width:"100px",height:"auto"},viewed:function(){var e=this;setTimeout((function(){e.viewer.view(t.initialViewIndex)}),0)},hide:function(){console.log("\u9690\u85cf"),this.viewer&&this.viewer.destroy()}}),this.isPreviewNow&&this.viewer.show()},t.prototype.ngOnDestroy=function(){this.viewer&&this.viewer.destroy()},t}()},yCxO:function(t,e,i){t.exports=function(){"use strict";var t={inline:!1,button:!0,navbar:!0,title:!0,toolbar:!0,tooltip:!0,movable:!0,zoomable:!0,rotatable:!0,scalable:!0,transition:!0,fullscreen:!0,keyboard:!0,loop:!1,minWidth:200,minHeight:100,zoomRatio:.1,minZoomRatio:.01,maxZoomRatio:100,zIndex:2015,zIndexInline:0,url:"src",filter:null,ready:null,show:null,shown:null,hide:null,hidden:null,view:null,viewed:null},e="undefined"!=typeof window?window:{},i="viewer-in",n="viewer-transition",s=e.PointerEvent?"pointerdown":"touchstart mousedown",o=e.PointerEvent?"pointermove":"mousemove touchmove",r=e.PointerEvent?"pointerup pointercancel":"touchend touchcancel mouseup",a=["zoom-in","zoom-out","one-to-one","reset","prev","play","next","rotate-left","rotate-right","flip-horizontal","flip-vertical"],h="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};function l(t){return"string"==typeof t}var u=Number.isNaN||e.isNaN;function c(t){return"number"==typeof t&&!u(t)}function d(t){return void 0===t}function v(t){return"object"===(void 0===t?"undefined":h(t))&&null!==t}var f=Object.prototype.hasOwnProperty;function m(t){if(!v(t))return!1;try{var e=t.constructor,i=e.prototype;return e&&i&&f.call(i,"isPrototypeOf")}catch(n){return!1}}function w(t){return"function"==typeof t}function g(t,e){if(t&&w(e))if(Array.isArray(t)||c(t.length)){var i=t.length,n=void 0;for(n=0;n<i&&!1!==e.call(t,t[n],n,t);n+=1);}else v(t)&&Object.keys(t).forEach((function(i){e.call(t,t[i],i,t)}));return t}function p(t){for(var e=arguments.length,i=Array(e>1?e-1:0),n=1;n<e;n++)i[n-1]=arguments[n];if(v(t)&&i.length>0){if(Object.assign)return Object.assign.apply(Object,[t].concat(i));i.forEach((function(e){v(e)&&Object.keys(e).forEach((function(i){t[i]=e[i]}))}))}return t}function b(t,e){for(var i=arguments.length,n=Array(i>2?i-2:0),s=2;s<i;s++)n[s-2]=arguments[s];return function(){for(var i=arguments.length,s=Array(i),o=0;o<i;o++)s[o]=arguments[o];return t.apply(e,n.concat(s))}}var y=/^(width|height|left|top|marginLeft|marginTop)$/;function x(t,e){var i=t.style;g(e,(function(t,e){y.test(e)&&c(t)&&(t+="px"),i[e]=t}))}function D(t){return window.getComputedStyle?window.getComputedStyle(t,null):t.currentStyle}function I(t,e){return t.classList?t.classList.contains(e):t.className.indexOf(e)>-1}function k(t,e){if(e)if(c(t.length))g(t,(function(t){k(t,e)}));else if(t.classList)t.classList.add(e);else{var i=t.className.trim();i?i.indexOf(e)<0&&(t.className=i+" "+e):t.className=e}}function E(t,e){e&&(c(t.length)?g(t,(function(t){E(t,e)})):t.classList?t.classList.remove(e):t.className.indexOf(e)>=0&&(t.className=t.className.replace(e,"")))}function z(t,e,i){e&&(c(t.length)?g(t,(function(t){z(t,e,i)})):i?k(t,e):E(t,e))}var T=/([a-z\d])([A-Z])/g;function C(t){return t.replace(T,"$1-$2").toLowerCase()}function S(t,e){return v(t[e])?t[e]:t.dataset?t.dataset[e]:t.getAttribute("data-"+C(e))}function N(t,e,i){v(i)?t[e]=i:t.dataset?t.dataset[e]=i:t.setAttribute("data-"+C(e),i)}var L=/\s+/;function M(t,e,i){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};if(w(i)){var s=e.trim().split(L);s.length>1?g(s,(function(e){M(t,e,i,n)})):t.removeEventListener?t.removeEventListener(e,i,n):t.detachEvent&&t.detachEvent("on"+e,i)}}function O(t,e,i){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};if(w(i)){var s=e.trim().split(L);if(s.length>1)g(s,(function(e){O(t,e,i,n)}));else{if(n.once){var o=i;i=function(){for(var s=arguments.length,r=Array(s),a=0;a<s;a++)r[a]=arguments[a];return M(t,e,i,n),o.apply(t,r)}}t.addEventListener?t.addEventListener(e,i,n):t.attachEvent&&t.attachEvent("on"+e,i)}}}function q(t,e,i){if(t.dispatchEvent){var n=void 0;return w(Event)&&w(CustomEvent)?n=d(i)?new Event(e,{bubbles:!0,cancelable:!0}):new CustomEvent(e,{detail:i,bubbles:!0,cancelable:!0}):d(i)?(n=document.createEvent("Event")).initEvent(e,!0,!0):(n=document.createEvent("CustomEvent")).initCustomEvent(e,!0,!0,i),t.dispatchEvent(n)}return!t.fireEvent||t.fireEvent("on"+e)}function Y(t){var e=document.documentElement,i=t.getBoundingClientRect();return{left:i.left+((window.scrollX||e&&e.scrollLeft||0)-(e&&e.clientLeft||0)),top:i.top+((window.scrollY||e&&e.scrollTop||0)-(e&&e.clientTop||0))}}function F(t){for(;t.firstChild;)t.removeChild(t.firstChild)}var P=e.navigator,A=P&&/(Macintosh|iPhone|iPod|iPad).*AppleWebKit/i.test(P.userAgent);function X(t,e){if(!t.naturalWidth||A){var i=document.createElement("img");i.onload=function(){e(i.width,i.height)},i.src=t.src}else e(t.naturalWidth,t.naturalHeight)}function R(t){switch(t){case 2:return"viewer-hide-xs-down";case 3:return"viewer-hide-sm-down";case 4:return"viewer-hide-md-down";default:return""}}function W(t,e){var i=t.pageX,n=t.pageY,s={endX:i,endY:n};return e?s:p({startX:i,startY:n},s)}function V(t){var e=0,i=0,n=0;return g(t,(function(t){var s=t.startX,o=t.startY;e+=s,i+=o,n+=1})),{pageX:e/=n,pageY:i/=n}}var j={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,e=this.parent,i=void 0;t.inline&&(i={width:Math.max(e.offsetWidth,t.minWidth),height:Math.max(e.offsetHeight,t.minHeight)},this.parentData=i),!this.fulled&&i||(i=this.containerData),this.viewerData=p({},i)},renderViewer:function(){this.options.inline&&!this.fulled&&x(this.viewer,this.viewerData)},initList:function(){var t=this,e=this.element,i=this.options,s=this.list,o=[];g(this.images,(function(t,e){var n=t.src,s=t.alt||function(t){return l(t)?t.replace(/^.*\//,"").replace(/[?&#].*$/,""):""}(n),r=i.url;l(r)?r=t.getAttribute(r):w(r)&&(r=r.call(t,t)),(n||r)&&o.push('<li><img src="'+(n||r)+'" role="button" data-action="view" data-index="'+e+'" data-original-url="'+(r||n)+'" alt="'+s+'"></li>')})),s.innerHTML=o.join(""),g(s.getElementsByTagName("img"),(function(e){N(e,"filled",!0),O(e,"load",b(t.loadImage,t),{once:!0})})),this.items=s.getElementsByTagName("li"),i.transition&&O(e,"viewed",(function(){k(s,n)}),{once:!0})},renderList:function(t){var e=t||this.index,i=this.items[e].offsetWidth||30,n=i+1;x(this.list,{width:n*this.length,marginLeft:(this.viewerData.width-i)/2-n*e})},resetList:function(){F(this.list),E(this.list,n),x({marginLeft:0})},initImage:function(t){var e=this,i=this.options,n=this.image,s=this.viewerData,o=this.footer.offsetHeight,r=s.width,a=Math.max(s.height-o,o),h=this.ImageData||{};X(n,(function(n,s){var o=n/s,l=r,u=a;a*o>r?u=r/o:l=a*o;var c={naturalWidth:n,naturalHeight:s,aspectRatio:o,ratio:(l=Math.min(.9*l,n))/n,width:l,height:u=Math.min(.9*u,s),left:(r-l)/2,top:(a-u)/2},d=p({},c);i.rotatable&&(c.rotate=h.rotate||0,d.rotate=0),i.scalable&&(c.scaleX=h.scaleX||1,c.scaleY=h.scaleY||1,d.scaleX=1,d.scaleY=1),e.imageData=c,e.initialImageData=d,w(t)&&t()}))},renderImage:function(t){var e=this.image,i=this.imageData;x(e,p({width:i.width,height:i.height,marginLeft:i.left,marginTop:i.top},function(t){var e=t.rotate,i=t.scaleX,n=t.scaleY,s=[];c(e)&&0!==e&&s.push("rotate("+e+"deg)"),c(i)&&1!==i&&s.push("scaleX("+i+")"),c(n)&&1!==n&&s.push("scaleY("+n+")");var o=s.length?s.join(" "):"none";return{WebkitTransform:o,msTransform:o,transform:o}}(i))),w(t)&&(this.transitioning?O(e,"transitionend",t,{once:!0}):t())},resetImage:function(){var t=this.image;t&&(t.parentNode.removeChild(t),this.image=null)}},H={bind:function(){var t=this.element,e=this.options,i=this.viewer;w(e.view)&&O(t,"view",e.view),w(e.viewed)&&O(t,"viewed",e.viewed),O(i,"click",this.onClick=b(this.click,this)),O(i,"wheel mousewheel DOMMouseScroll",this.onWheel=b(this.wheel,this)),O(i,"dragstart",this.onDragStart=b(this.dragstart,this)),O(this.canvas,s,this.onPointerDown=b(this.pointerdown,this)),O(t.ownerDocument,o,this.onPointerMove=b(this.pointermove,this)),O(t.ownerDocument,r,this.onPointerUp=b(this.pointerup,this)),O(t.ownerDocument,"keydown",this.onKeyDown=b(this.keydown,this)),O(window,"resize",this.onResize=b(this.resize,this))},unbind:function(){var t=this.element,e=this.options,i=this.viewer;w(e.view)&&M(t,"view",e.view),w(e.viewed)&&M(t,"viewed",e.viewed),M(i,"click",this.onClick),M(i,"wheel mousewheel DOMMouseScroll",this.onWheel),M(i,"dragstart",this.onDragStart),M(this.canvas,s,this.onPointerDown),M(t.ownerDocument,o,this.onPointerMove),M(t.ownerDocument,r,this.onPointerUp),M(t.ownerDocument,"keydown",this.onKeyDown),M(window,"resize",this.onResize)}},B={click:function(t){var e=t.target,i=this.options,n=this.imageData;switch(S(e,"action")){case"mix":this.played?this.stop():i.inline?this.fulled?this.exit():this.full():this.hide();break;case"view":this.view(S(e,"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(i.loop);break;case"play":this.play();break;case"next":this.next(i.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,e=this.options,i=this.image,s=this.index,o=this.viewerData;this.timeout&&(clearTimeout(this.timeout),this.timeout=!1),i&&(E(i,"viewer-invisible"),i.style.cssText="width:0;height:0;margin-left:"+o.width/2+"px;margin-top:"+o.height/2+"px;max-width:none!important;visibility:visible;",this.initImage((function(){z(i,n,e.transition),z(i,"viewer-move",e.movable),t.renderImage((function(){t.viewed=!0,q(t.element,"viewed",{originalImage:t.images[s],index:s,image:i})}))})))},loadImage:function(t){var e=t.target,i=e.parentNode,n=i.offsetWidth||30,s=i.offsetHeight||50,o=!!S(e,"filled");X(e,(function(t,i){var r=t/i,a=n,h=s;s*r>n?o?a=s*r:h=n/r:o?h=n/r:a=s*r,x(e,{width:a,height:h,marginLeft:(n-a)/2,marginTop:(s-h)/2})}))},keydown:function(t){var e=this.options,i=t.keyCode||t.which||t.charCode;if(this.fulled&&e.keyboard)switch(i){case 27:this.played?this.stop():e.inline?this.fulled&&this.exit():this.hide();break;case 32:this.played&&this.stop();break;case 37:this.prev(e.loop);break;case 38:t.preventDefault(),this.zoom(e.zoomRatio,!0);break;case 39:this.next(e.loop);break;case 40:t.preventDefault(),this.zoom(-e.zoomRatio,!0);break;case 48:case 49:(t.ctrlKey||t.shiftKey)&&(t.preventDefault(),this.toggle())}},dragstart:function(t){"img"===t.target.tagName.toLowerCase()&&t.preventDefault()},pointerdown:function(t){var e=this.options,i=this.pointers;if(this.viewed&&!this.transitioning){t.changedTouches?g(t.changedTouches,(function(t){i[t.identifier]=W(t)})):i[t.pointerId||0]=W(t);var n=!!e.movable&&"move";Object.keys(i).length>1?n="zoom":"touch"!==t.pointerType&&"touchstart"!==t.type||!this.isSwitchable()||(n="switch"),this.action=n}},pointermove:function(t){var e=this.options,i=this.pointers,s=this.action,o=this.image;this.viewed&&s&&(t.preventDefault(),t.changedTouches?g(t.changedTouches,(function(t){p(i[t.identifier],W(t,!0))})):p(i[t.pointerId||0],W(t,!0)),"move"===s&&e.transition&&I(o,n)&&E(o,n),this.change(t))},pointerup:function(t){var e=this.action,i=this.pointers;t.changedTouches?g(t.changedTouches,(function(t){delete i[t.identifier]})):delete i[t.pointerId||0],e&&("move"===e&&this.options.transition&&k(this.image,n),this.action=!1)},resize:function(){var t=this;if(this.initContainer(),this.initViewer(),this.renderViewer(),this.renderList(),this.viewed&&this.initImage((function(){t.renderImage()})),this.played){if(this.options.fullscreen&&this.fulled&&!document.fullscreenElement&&!document.mozFullScreenElement&&!document.webkitFullscreenElement&&!document.msFullscreenElement)return void this.stop();g(this.player.getElementsByTagName("img"),(function(e){O(e,"load",b(t.loadImage,t),{once:!0}),q(e,"load")}))}},start:function(t){var e=t.target;"img"===e.tagName.toLowerCase()&&-1!==this.images.indexOf(e)&&(this.target=e,this.show())},wheel:function(t){var e=this;if(this.viewed&&(t.preventDefault(),!this.wheeling)){this.wheeling=!0,setTimeout((function(){e.wheeling=!1}),50);var i=Number(this.options.zoomRatio)||.1,n=1;t.deltaY?n=t.deltaY>0?1:-1:t.wheelDelta?n=-t.wheelDelta/120:t.detail&&(n=t.detail>0?1:-1),this.zoom(-n*i,!0,t)}}},U={show:function(){var t=this,e=this.element,s=this.options;if(s.inline||this.transitioning||this.visible)return this;if(this.ready||this.build(),w(s.show)&&O(e,"show",s.show,{once:!0}),!1===q(e,"show"))return this;this.open();var o=this.viewer;return E(o,"viewer-hide"),O(e,"shown",(function(){t.view(t.target?[].concat(function(t){if(Array.isArray(t)){for(var e=0,i=Array(t.length);e<t.length;e++)i[e]=t[e];return i}return Array.from(t)}(t.images)).indexOf(t.target):t.index),t.target=!1}),{once:!0}),s.transition?(this.transitioning=!0,k(o,n),o.offsetWidth,O(o,"transitionend",b(this.shown,this),{once:!0}),k(o,i)):(k(o,i),this.shown()),this},hide:function(){var t=this,e=this.element,n=this.options,s=this.viewer;return n.inline||this.transitioning||!this.visible||(w(n.hide)&&O(e,"hide",n.hide,{once:!0}),!1===q(e,"hide")||(this.viewed&&n.transition?(this.transitioning=!0,O(this.image,"transitionend",(function(){O(s,"transitionend",b(t.hidden,t),{once:!0}),E(s,i)}),{once:!0}),this.zoomTo(0,!1,!1,!0)):(E(s,i),this.hidden()))),this},view:function(t){var e=this,i=this.element,n=this.title,s=this.canvas;if(t=Number(t)||0,!this.ready||!this.visible||this.played||t<0||t>=this.length||this.viewed&&t===this.index)return this;var o=this.items[t],r=o.querySelector("img"),a=S(r,"originalUrl"),h=r.getAttribute("alt"),l=document.createElement("img");return l.src=a,l.alt=h,!1===q(i,"view",{originalImage:this.images[t],index:t,image:l})||(this.image=l,E(this.items[this.index],"viewer-active"),k(o,"viewer-active"),this.viewed=!1,this.index=t,this.imageData=null,k(l,"viewer-invisible"),F(s),s.appendChild(l),this.renderList(),F(n),O(i,"viewed",(function(){var t=e.imageData;n.textContent=h+" ("+t.naturalWidth+" \xd7 "+t.naturalHeight+")"}),{once:!0}),l.complete?this.load():(O(l,"load",b(this.load,this),{once:!0}),this.timeout&&clearTimeout(this.timeout),this.timeout=setTimeout((function(){E(l,"viewer-invisible"),e.timeout=!1}),1e3))),this},prev:function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],e=this.index-1;return e<0&&(e=t?this.length-1:0),this.view(e),this},next:function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],e=this.length-1,i=this.index+1;return i>e&&(i=t?0:e),this.view(i),this},move:function(t,e){var i=this.imageData;return this.moveTo(d(t)?t:i.left+Number(t),d(e)?e:i.top+Number(e)),this},moveTo:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t,i=this.imageData;if(t=Number(t),e=Number(e),this.viewed&&!this.played&&this.options.movable){var n=!1;c(t)&&(i.left=t,n=!0),c(e)&&(i.top=e,n=!0),n&&this.renderImage()}return this},zoom:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=arguments.length>2&&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,e,i),this},zoomTo:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,n=arguments.length>3&&void 0!==arguments[3]&&arguments[3],s=this.options,o=this.pointers,r=this.imageData;if(c(t=Math.max(0,t))&&this.viewed&&!this.played&&(n||s.zoomable)){if(!n){var a=Math.max(.01,s.minZoomRatio),h=Math.min(100,s.maxZoomRatio);t=Math.min(Math.max(t,a),h)}i&&t>.95&&t<1.05&&(t=1);var l=r.naturalWidth*t,u=r.naturalHeight*t;if(i){var d=Y(this.viewer),v=o&&Object.keys(o).length?V(o):{pageX:i.pageX,pageY:i.pageY};r.left-=(l-r.width)*((v.pageX-d.left-r.left)/r.width),r.top-=(u-r.height)*((v.pageY-d.top-r.top)/r.height)}else r.left-=(l-r.width)/2,r.top-=(u-r.height)/2;r.width=l,r.height=u,r.ratio=t,this.renderImage(),e&&this.tooltip()}return this},rotate:function(t){return this.rotateTo((this.imageData.rotate||0)+Number(t)),this},rotateTo:function(t){var e=this.imageData;return c(t=Number(t))&&this.viewed&&!this.played&&this.options.rotatable&&(e.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 e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t,i=this.imageData;if(t=Number(t),e=Number(e),this.viewed&&!this.played&&this.options.scalable){var n=!1;c(t)&&(i.scaleX=t,n=!0),c(e)&&(i.scaleY=e,n=!0),n&&this.renderImage()}return this},play:function(){var t=this,e=this.options,s=this.player,o=b(this.loadImage,this),r=[],a=0,h=0;return!this.visible||this.played||(e.fullscreen&&this.requestFullscreen(),this.played=!0,this.onLoadWhenPlay=o,k(s,"viewer-show"),g(this.items,(function(t,l){var u=t.querySelector("img"),c=document.createElement("img");c.src=S(u,"originalUrl"),c.alt=u.getAttribute("alt"),a+=1,k(c,"viewer-fade"),z(c,n,e.transition),I(t,"viewer-active")&&(k(c,i),h=l),r.push(c),O(c,"load",o,{once:!0}),s.appendChild(c)})),c(e.interval)&&e.interval>0&&a>1&&function n(){t.playing=setTimeout((function(){E(r[h],i),k(r[h=(h+=1)<a?h:0],i),n()}),e.interval)}()),this},stop:function(){var t=this,e=this.player;return this.played?(this.options.fullscreen&&this.exitFullscreen(),this.played=!1,clearTimeout(this.playing),g(this.player.getElementsByTagName("img"),(function(e){e.complete||M(e,"load",t.onLoadWhenPlay)})),E(e,"viewer-show"),F(e),this):this},full:function(){var t=this,e=this.options,i=this.viewer,s=this.image,o=this.list;return!this.visible||this.played||this.fulled||!e.inline||(this.fulled=!0,this.open(),k(this.button,"viewer-fullscreen-exit"),e.transition&&(E(s,n),E(o,n)),k(i,"viewer-fixed"),i.setAttribute("style",""),x(i,{zIndex:e.zIndex}),this.initContainer(),this.viewerData=p({},this.containerData),this.renderList(),this.initImage((function(){t.renderImage((function(){e.transition&&setTimeout((function(){k(s,n),k(o,n)}),0)}))}))),this},exit:function(){var t=this,e=this.options,i=this.viewer,s=this.image,o=this.list;return this.fulled?(this.fulled=!1,this.close(),E(this.button,"viewer-fullscreen-exit"),e.transition&&(E(s,n),E(o,n)),E(i,"viewer-fixed"),x(i,{zIndex:e.zIndexInline}),this.viewerData=p({},this.parentData),this.renderViewer(),this.renderList(),this.initImage((function(){t.renderImage((function(){e.transition&&setTimeout((function(){k(s,n),k(o,n)}),0)}))})),this):this},tooltip:function(){var t=this,e=this.options,s=this.tooltipBox,o=this.imageData;return this.viewed&&!this.played&&e.tooltip?(s.textContent=Math.round(100*o.ratio)+"%",this.tooltiping?clearTimeout(this.tooltiping):e.transition?(this.fading&&q(s,"transitionend"),k(s,"viewer-show"),k(s,"viewer-fade"),k(s,n),s.offsetWidth,k(s,i)):k(s,"viewer-show"),this.tooltiping=setTimeout((function(){e.transition?(O(s,"transitionend",(function(){E(s,"viewer-show"),E(s,"viewer-fade"),E(s,n),t.fading=!1}),{once:!0}),E(s,i),t.fading=!0):E(s,"viewer-show"),t.tooltiping=!1}),1e3),this):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=p({},this.initialImageData),this.renderImage()),this},update:function(){var t=this.element,e=this.options,i=this.isImg,n=[];if(i&&!t.parentNode)return this.destroy();var s=[];if(g(i?[t]:t.querySelectorAll("img"),(function(t){e.filter?e.filter(t)&&s.push(t):s.push(t)})),this.images=s,this.length=s.length,this.ready&&(g(this.items,(function(t,e){var i=t.querySelector("img"),o=s[e];o?o.src!==i.src&&n.push(e):n.push(e)})),x(this.list,{width:"auto"}),this.initList(),this.visible))if(this.length){if(this.viewed){var o=n.indexOf(this.index);o>=0?(this.viewed=!1,this.view(Math.max(this.index-(o+1),0))):k(this.items[this.index],"viewer-active")}}else this.image=null,this.viewed=!1,this.index=0,this.imageData=null,F(this.canvas),F(this.title);return this},destroy:function(){var t=this.element;return S(t,"viewer")?(this.options.inline?this.unbind():(this.visible&&this.unbind(),M(t,"click",this.onStart)),this.close(),this.unbuild(),function(t,e){if(v(t[e]))delete t[e];else if(t.dataset)try{delete t.dataset[e]}catch(i){t.dataset[e]=null}else t.removeAttribute("data-"+C(e))}(t,"viewer"),this):this}},K={open:function(){var t=this.body;k(t,"viewer-open"),t.style.paddingRight=this.scrollbarWidth+(parseFloat(this.initialBodyPaddingRight)||0)+"px"},close:function(){var t=this.body;E(t,"viewer-open"),t.style.paddingRight=this.initialBodyPaddingRight},shown:function(){var t=this.element,e=this.options;this.transitioning=!1,this.fulled=!0,this.visible=!0,this.render(),this.bind(),w(e.shown)&&O(t,"shown",e.shown,{once:!0}),q(t,"shown")},hidden:function(){var t=this.element,e=this.options;this.transitioning=!1,this.viewed=!1,this.fulled=!1,this.visible=!1,this.close(),this.unbind(),k(this.viewer,"viewer-hide"),this.resetList(),this.resetImage(),w(e.hidden)&&O(t,"hidden",e.hidden,{once:!0}),q(t,"hidden")},requestFullscreen:function(){var t=window.document;if(this.fulled&&!t.fullscreenElement&&!t.mozFullScreenElement&&!t.webkitFullscreenElement&&!t.msFullscreenElement){var e=t.documentElement;e.requestFullscreen?e.requestFullscreen():e.msRequestFullscreen?e.msRequestFullscreen():e.mozRequestFullScreen?e.mozRequestFullScreen():e.webkitRequestFullscreen&&e.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT)}},exitFullscreen:function(){this.fulled&&(document.exitFullscreen?document.exitFullscreen():document.msExitFullscreen?document.msExitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.webkitExitFullscreen&&document.webkitExitFullscreen())},change:function(t){var e=this.options,i=this.pointers,n=i[Object.keys(i)[0]],s=n.endX-n.startX,o=n.endY-n.startY;switch(this.action){case"move":this.move(s,o);break;case"zoom":this.zoom(function(t){var e=p({},t),i=[];return g(t,(function(t,n){delete e[n],g(e,(function(e){var n=Math.abs(t.startX-e.startX),s=Math.abs(t.startY-e.startY),o=Math.abs(t.endX-e.endX),r=Math.abs(t.endY-e.endY),a=Math.sqrt(n*n+s*s),h=(Math.sqrt(o*o+r*r)-a)/a;i.push(h)}))})),i.sort((function(t,e){return Math.abs(t)<Math.abs(e)})),i[0]}(i),!1,t);break;case"switch":this.action="switched",Math.abs(s)>Math.abs(o)&&(s>1?this.prev(e.loop):s<-1&&this.next(e.loop))}g(i,(function(t){t.startX=t.endX,t.startY=t.endY}))},isSwitchable:function(){var t=this.imageData,e=this.viewerData;return this.length>1&&t.left>=0&&t.top>=0&&t.width<=e.width&&t.height<=e.height}},Z=function(){function t(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,i,n){return i&&t(e.prototype,i),n&&t(e,n),e}}();function $(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var _=e.Viewer,J=function(){function e(i){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if($(this,e),!i||1!==i.nodeType)throw new Error("The first argument is required and must be an element.");this.element=i,this.options=p({},t,m(n)&&n),this.isImg=!1,this.ready=!1,this.visible=!1,this.viewed=!1,this.fulled=!1,this.played=!1,this.wheeling=!1,this.playing=!1,this.fading=!1,this.tooltiping=!1,this.transitioning=!1,this.action=!1,this.target=!1,this.timeout=!1,this.index=0,this.length=0,this.pointers={},this.init()}return Z(e,[{key:"init",value:function(){var t=this,e=this.element,i=this.options;if(!S(e,"viewer")){N(e,"viewer",this);var n="img"===e.tagName.toLowerCase(),s=[];g(n?[e]:e.querySelectorAll("img"),(function(t){i.filter?i.filter(t)&&s.push(t):s.push(t)}));var o=s.length;if(o){w(i.ready)&&O(e,"ready",i.ready,{once:!0}),d(document.createElement("viewer").style.transition)&&(i.transition=!1),this.isImg=n,this.length=o,this.count=0,this.images=s;var r=document.body;if(this.body=r,this.scrollbarWidth=window.innerWidth-document.documentElement.clientWidth,this.initialBodyPaddingRight=D(r).paddingRight,i.inline){var a=b(this.progress,this);O(e,"ready",(function(){t.view()}),{once:!0}),g(s,(function(t){t.complete?a():O(t,"load",a,{once:!0})}))}else O(e,"click",this.onStart=b(this.start,this))}}}},{key:"progress",value:function(){this.count+=1,this.count===this.length&&this.build()}},{key:"build",value:function(){var t=this.options,e=this.element;if(!this.ready){var i=e.parentNode,n=document.createElement("div");n.innerHTML='<div class="viewer-container"><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 s=n.querySelector(".viewer-container"),o=s.querySelector(".viewer-title"),r=s.querySelector(".viewer-toolbar"),h=s.querySelector(".viewer-navbar"),l=s.querySelector(".viewer-button");if(this.parent=i,this.viewer=s,this.title=o,this.toolbar=r,this.navbar=h,this.button=l,this.canvas=s.querySelector(".viewer-canvas"),this.footer=s.querySelector(".viewer-footer"),this.tooltipBox=s.querySelector(".viewer-tooltip"),this.player=s.querySelector(".viewer-player"),this.list=s.querySelector(".viewer-list"),k(o,t.title?R(t.title):"viewer-hide"),k(h,t.navbar?R(t.navbar):"viewer-hide"),z(l,"viewer-hide",!t.button),t.toolbar){var u=document.createElement("ul"),v=m(t.toolbar),f=a.slice(0,3),p=a.slice(7,9),b=a.slice(9);v||k(r,R(t.toolbar)),g(v?t.toolbar:a,(function(e,i){var n=v&&m(e),s=v?C(i):e,o=n&&!d(e.show)?e.show:e;if(o&&(t.zoomable||-1===f.indexOf(s))&&(t.rotatable||-1===p.indexOf(s))&&(t.scalable||-1===b.indexOf(s))){var r=n&&!d(e.size)?e.size:e,a=n&&!d(e.click)?e.click:e,h=document.createElement("li");h.setAttribute("role","button"),k(h,"viewer-"+s),w(a)||N(h,"action",s),c(o)&&k(h,R(o)),-1!==["small","large"].indexOf(r)?k(h,"viewer-"+r):"play"===s&&k(h,"viewer-large"),w(a)&&O(h,"click",a),u.appendChild(h)}})),r.appendChild(u)}else k(r,"viewer-hide");if(!t.rotatable){var y=r.querySelectorAll('li[class*="rotate"]');k(y,"viewer-invisible"),g(y,(function(t){r.appendChild(t)}))}t.inline?(k(l,"viewer-fullscreen"),x(s,{zIndex:t.zIndexInline}),"static"===D(i).position&&x(i,{position:"relative"}),i.insertBefore(s,e.nextSibling)):(k(l,"viewer-close"),k(s,"viewer-fixed"),k(s,"viewer-fade"),k(s,"viewer-hide"),x(s,{zIndex:t.zIndex}),this.body.appendChild(s)),t.inline&&(this.render(),this.bind(),this.visible=!0),this.ready=!0,q(e,"ready")}}},{key:"unbuild",value:function(){this.ready&&(this.ready=!1,this.viewer.parentNode.removeChild(this.viewer))}}],[{key:"noConflict",value:function(){return window.Viewer=_,e}},{key:"setDefaults",value:function(e){p(t,m(e)&&e)}}]),e}();return p(J.prototype,j,H,B,U,K),J}()}}]);
|