/*! * 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'+s+'')}),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=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=0Math.abs(r)&&(1
';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});