pleroma/priv/static/packs/status/media_gallery.js

2 lines
4.9 KiB
JavaScript
Raw Normal View History

2018-08-12 09:29:30 -04:00
webpackJsonp([33],{805:function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),i.d(t,"default",function(){return P});var a,n,l,s,o,r=i(2),d=i.n(r),p=i(1),c=i.n(p),u=i(3),h=i.n(u),g=i(4),m=i.n(g),v=i(0),f=i.n(v),y=i(8),b=(i.n(y),i(23)),_=i(7),k=i(43),x=i(10),C=i.n(x),M=i(13),w=Object(_.f)({toggle_visible:{id:"media_gallery.toggle_visible",defaultMessage:"Toggle visibility"}}),N=(n=a=function(e){function t(){var i,a,n;c()(this,t);for(var l=arguments.length,s=Array(l),o=0;o<l;o++)s[o]=arguments[o];return i=a=h()(this,e.call.apply(e,[this].concat(s))),a.handleMouseEnter=function(e){a.hoverToPlay()&&e.target.play()},a.handleMouseLeave=function(e){a.hoverToPlay()&&(e.target.pause(),e.target.currentTime=0)},a.handleClick=function(e){var t=a.props,i=t.index,n=t.onClick;0===e.button&&(e.preventDefault(),n(i)),e.stopPropagation()},n=i,h()(a,n)}return m()(t,e),t.prototype.hoverToPlay=function(){var e=this.props.attachment;return!M.a&&"gifv"===e.get("type")},t.prototype.render=function(){var e=this.props,t=e.attachment,i=e.index,a=e.size,n=e.standalone,l=e.displayWidth,s=50,o=100,r="auto",p="auto",c="auto",u="auto";1===a&&(s=100),(4===a||3===a&&i>0)&&(o=50),2===a?0===i?u="2px":p="2px":3===a?(0===i?u="2px":i>0&&(p="2px"),1===i?c="2px":i>1&&(r="2px")):4===a&&(0!==i&&2!==i||(u="2px"),1!==i&&3!==i||(p="2px"),i<2?c="2px":r="2px");var h="";if("image"===t.get("type")){var g=t.get("preview_url"),m=t.getIn(["meta","small","width"]),v=t.get("url"),f=t.getIn(["meta","original","width"]),y="number"==typeof f&&"number"==typeof m,b=y?v+" "+f+"w, "+g+" "+m+"w":null,_=y?l*(s/100)+"px":null,x=t.getIn(["meta","focus","x"])||0,w=t.getIn(["meta","focus","y"])||0,N=100*(x/2+.5),P=100*(w/-2+.5);h=d()("a",{className:"media-gallery__item-thumbnail",href:t.get("remote_url")||v,onClick:this.handleClick,target:"_blank"},void 0,d()("img",{src:g,srcSet:b,sizes:_,alt:t.get("description"),title:t.get("description"),style:{objectPosition:N+"% "+P+"%"}}))}else if("audio"===t.get("type"))h=d()("div",{className:"media-gallery__audio"},void 0,d()("audio",{className:"media-gallery__item-audio-thumbnail","aria-label":t.get("description"),role:"application",src:t.get("url"),loop:!0,controls:!0}));else if("gifv"===t.get("type")){var O=!Object(k.a)()&&M.a;h=d()("div",{className:C()("media-gallery__gifv",{autoplay:O})},void 0,d()("video",{className:"media-gallery__item-gifv-thumbnail","aria-label":t.get("description"),role:"application",src:t.get("url"),onClick:this.handleClick,onMouseEnter:this.handleMouseEnter,onMouseLeave:this.handleMouseLeave,autoPlay:O,loop:!0,muted:!0}),d()("span",{className:"media-gallery__gifv__label"},void 0,"GIF"))}return d()("div",{className:C()("media-gallery__item",{standalone:n}),style:{left:p,top:r,right:u,bottom:c,width:s+"%",height:o+"%"}},t.get("id"),h)},t}(f.a.PureComponent),a.defaultProps={standalone:!1,index:0,size:1},n),P=Object(_.g)((o=s=function(e){function t(){var i,a,n;c()(this,t);for(var l=arguments.length,s=Array(l),o=0;o<l;o++)s[o]=arguments[o];return i=a=h()(this,e.call.apply(e,[this].concat(s))),a.state={visible:!a.props.sensitive||M.f},a.handleOpen=function(){a.setState({visible:!a.state.visible})},a.handleClick=function(e){a.props.onOpenMedia(a.props.media,e)},a.handleRef=function(e){e&&a.setState({width:e.offsetWidth})},n=i,h()(a,n)}return m()(t,e),t.prototype.componentWillReceiveProps=function(e){Object(y.is)(e.media,this.props.media)||this.setState({visible:!e.sensitive})},t.prototype.isStandaloneEligible=function(){var e=this.props,t=e.media;return e.standalone&&1===t.size&&t.getIn([0,"meta","small","aspect"])},t.prototype.render=function(){var e=this,t=this.props,i=t.media,a=t.intl,n=t.sensitive,l=t.height,s=this.state,o=s.width,r=s.visible,p=void 0,c={};if(this.isStandaloneEligible()?o&&(c.height=o/this.props.media.getIn([0,"meta","small","aspect"])):c.height=o?o/(16/9):l,r){var u=i.take(4).size;p=this.isStandaloneEligible()?d()(N,{standalone:!0,onClick:this.handleClick,attachment:i.get(0),displayWidth:o}):i.take(4).map(function(t,i){return d()(N,{onClick:e.handleClick,attachment:t,index:i,size:u
//# sourceMappingURL=media_gallery.js.map