akkoma/priv/static/packs/features/account_gallery.js

2 lines
7.9 KiB
JavaScript
Raw Normal View History

2020-05-19 23:55:14 -06:00
(window.webpackJsonp=window.webpackJsonp||[]).push([[15],{863:function(t,e,a){"use strict";a.r(e),a.d(e,"default",(function(){return z}));var n=a(0),o=a(2),c=a(9),i=a(6),s=a(8),r=a(1),l=a(3),d=a.n(l),p=a(15),u=a(16),h=a.n(u),b=a(5),m=a.n(b),f=a(26),O=a(36),g=a(306),j=a(757),v=a(764),y=a(21),_=a(210),I=a(215),M=a(14),L=a.n(M),w=a(27),R=a(22),x=a(120);var S=function(t){Object(s.a)(a,t);var e;e=a;function a(){for(var e,a=arguments.length,n=new Array(a),c=0;c<a;c++)n[c]=arguments[c];return e=t.call.apply(t,[this].concat(n))||this,Object(r.a)(Object(o.a)(e),"state",{visible:"hide_all"!==R.g&&!e.props.attachment.getIn(["status","sensitive"])||"show_all"===R.g,loaded:!1}),Object(r.a)(Object(o.a)(e),"setCanvasRef",(function(t){e.canvas=t})),Object(r.a)(Object(o.a)(e),"handleImageLoad",(function(){e.setState({loaded:!0})})),Object(r.a)(Object(o.a)(e),"handleMouseEnter",(function(t){e.hoverToPlay()&&t.target.play()})),Object(r.a)(Object(o.a)(e),"handleMouseLeave",(function(t){e.hoverToPlay()&&(t.target.pause(),t.target.currentTime=0)})),Object(r.a)(Object(o.a)(e),"handleClick",(function(t){0!==t.button||t.ctrlKey||t.metaKey||(t.preventDefault(),e.state.visible?e.props.onOpenMedia(e.props.attachment):e.setState({visible:!0}))})),e}var c=a.prototype;return c.componentDidMount=function(){this.props.attachment.get("blurhash")&&this._decode()},c.componentDidUpdate=function(t){t.attachment.get("blurhash")!==this.props.attachment.get("blurhash")&&this.props.attachment.get("blurhash")&&this._decode()},c._decode=function(){var t=this.props.attachment.get("blurhash"),e=Object(I.decode)(t,32,32);if(e){var a=this.canvas.getContext("2d"),n=new ImageData(e,32,32);a.putImageData(n,0,0)}},c.hoverToPlay=function(){return!R.a&&-1!==["gifv","video"].indexOf(this.props.attachment.get("type"))},c.render=function(){var t,e=this.props,a=e.attachment,o=e.displayWidth,c=this.state,i=c.visible,s=c.loaded,r=Math.floor((o-4)/3)-4+"px",l=r,p=a.get("status"),u=p.get("spoiler_text")||a.get("description"),h="";if("unknown"===a.get("type"));else if("audio"===a.get("type"))h=Object(n.a)("span",{className:"account-gallery__item__icons"},void 0,Object(n.a)(w.a,{id:"music"}));else if("image"===a.get("type")){var b=100*((a.getIn(["meta","focus","x"])||0)/2+.5),m=100*((a.getIn(["meta","focus","y"])||0)/-2+.5);h=Object(n.a)("img",{src:a.get("preview_url"),alt:a.get("description"),title:a.get("description"),style:{objectPosition:b+"% "+m+"%"},onLoad:this.handleImageLoad})}else if(-1!==["gifv","video"].indexOf(a.get("type"))){var f=!Object(x.a)()&&R.a,O="video"===a.get("type")?Object(n.a)(w.a,{id:"play"}):"GIF";h=Object(n.a)("div",{className:L()("media-gallery__gifv",{autoplay:f})},void 0,Object(n.a)("video",{className:"media-gallery__item-gifv-thumbnail","aria-label":a.get("description"),title:a.get("description"),role:"application",src:a.get("url"),onMouseEnter:this.handleMouseEnter,onMouseLeave:this.handleMouseLeave,autoPlay:f,loop:!0,muted:!0}),Object(n.a)("span",{className:"media-gallery__gifv__label"},void 0,O))}return i||(t=Object(n.a)("span",{className:"account-gallery__item__icons"},void 0,Object(n.a)(w.a,{id:"eye-slash"}))),Object(n.a)("div",{className:"account-gallery__item",style:{width:r,height:l}},void 0,Object(n.a)("a",{className:"media-gallery__item-thumbnail",href:p.get("url"),onClick:this.handleClick,title:u,target:"_blank",rel:"noopener noreferrer"},void 0,d.a.createElement("canvas",{width:32,height:32,ref:this.setCanvasRef,className:L()("media-gallery__preview",{"media-gallery__preview--hidden":i&&s})}),i&&h,!i&&t))},a}(y.a);Object(r.a)(S,"propTypes",{attachment:h.a.map.isRequired,displayWidth:m.a.number.isRequired,onOpenMedia:m.a.func.isRequired});var D,C,N,T=a(1084),A=a(472),k=a(1081),q=a(1057),E=a(48);function P(t){return function(){var e,a=Object(i.a)(t);if(U()){var n=Object(i.a)(this).constructor;e=Reflect.construct(a,arguments,n)}else e=a.apply(this,arguments);return Object(c.a)(this,e)}}function U(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date
//# sourceMappingURL=account_gallery.js.map