2 lines
7.2 KiB
JavaScript
2 lines
7.2 KiB
JavaScript
this.primereact=this.primereact||{},this.primereact.image=function(e,t,n,i,o,a){"use strict";function r(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var l=r(t),s=r(a);function c(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function u(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function p(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function m(e,t){return m=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},m(e,t)}function f(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&m(e,t)}function d(e){return d="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},d(e)}function h(e,t){if(t&&("object"===d(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return p(e)}function y(e){return y=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},y(e)}function b(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}var v,k,g,E=function(e){f(k,e);var t,a,r,m,d,v=(t=k,a=b(),function(){var e,n=y(t);if(a){var i=y(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return h(this,e)});function k(e){var t;return c(this,k),(t=v.call(this,e)).state={maskVisible:!1,previewVisible:!1,rotate:0,scale:1},t.onImageClick=t.onImageClick.bind(p(t)),t.onMaskClick=t.onMaskClick.bind(p(t)),t.onDownload=t.onDownload.bind(p(t)),t.rotateRight=t.rotateRight.bind(p(t)),t.rotateLeft=t.rotateLeft.bind(p(t)),t.zoomIn=t.zoomIn.bind(p(t)),t.zoomOut=t.zoomOut.bind(p(t)),t.onEntering=t.onEntering.bind(p(t)),t.onEntered=t.onEntered.bind(p(t)),t.onPreviewImageClick=t.onPreviewImageClick.bind(p(t)),t.onExit=t.onExit.bind(p(t)),t.onExiting=t.onExiting.bind(p(t)),t.onExited=t.onExited.bind(p(t)),t.previewRef=l.default.createRef(),t}return r=k,(m=[{key:"onImageClick",value:function(){var e=this;this.props.preview&&(this.setState({maskVisible:!0}),setTimeout((function(){e.setState({previewVisible:!0})}),25))}},{key:"onPreviewImageClick",value:function(){this.previewClick=!0}},{key:"onMaskClick",value:function(){this.previewClick||(this.setState({previewVisible:!1}),this.setState({rotate:0}),this.setState({scale:1})),this.previewClick=!1}},{key:"onDownload",value:function(){var e=this.props;i.DomHandler.saveAs({name:e.alt,src:e.src}),this.previewClick=!0}},{key:"rotateRight",value:function(){this.setState((function(e){return{rotate:e.rotate+90}})),this.previewClick=!0}},{key:"rotateLeft",value:function(){this.setState((function(e){return{rotate:e.rotate-90}})),this.previewClick=!0}},{key:"zoomIn",value:function(){this.setState((function(e){return{scale:e.scale+.1}})),this.previewClick=!0}},{key:"zoomOut",value:function(){this.setState((function(e){return{scale:e.scale-.1}})),this.previewClick=!0}},{key:"onEntering",value:function(){i.ZIndexUtils.set("modal",this.mask,s.default.autoZIndex,s.default.zIndex.modal)}},{key:"onEntered",value:function(){this.props.onShow&&this.props.onShow()}},{key:"onExit",value:function(){i.DomHandler.addClass(this.mask,"p-component-overlay-leave")}},{key:"onExiting",value:function(){this.props.onHide&&this.props.onHide()}},{key:"onExited",value:function(e){i.ZIndexUtils.clear(e),this.setState({maskVisible:!1})}},{key:"componentWillUnmount",value:function(){this.mask&&i.ZIndexUtils.clear(this.container)}},{key:"renderElement",value:function(){var e=this,t={transform:"rotate("+this.state.rotate+"deg) scale("+this.state.scale+")"},i=this.state.scale<=.5||this.state.scale>=1.5;return l.default.createElement("div",{ref:function(t){return e.mask=t},className:"p-image-mask p-component-overlay p-component-overlay-enter",onClick:this.onMaskClick},l.default.createElement("div",{className:"p-image-toolbar"},this.props.downloadable&&l.default.createElement("button",{className:"p-image-action p-link",onClick:this.onDownload,type:"button"},l.default.createElement("i",{className:"pi pi-download"})),l.default.createElement("button",{className:"p-image-action p-link",onClick:this.rotateRight,type:"button"},l.default.createElement("i",{className:"pi pi-refresh"})),l.default.createElement("button",{className:"p-image-action p-link",onClick:this.rotateLeft,type:"button"},l.default.createElement("i",{className:"pi pi-undo"})),l.default.createElement("button",{className:"p-image-action p-link",onClick:this.zoomOut,type:"button",disabled:i},l.default.createElement("i",{className:"pi pi-search-minus"})),l.default.createElement("button",{className:"p-image-action p-link",onClick:this.zoomIn,type:"button",disabled:i},l.default.createElement("i",{className:"pi pi-search-plus"})),l.default.createElement("button",{className:"p-image-action p-link",type:"button",onClick:this.hidePreview},l.default.createElement("i",{className:"pi pi-times"}))),l.default.createElement(n.CSSTransition,{nodeRef:this.previewRef,classNames:"p-image-preview",in:this.state.previewVisible,timeout:{enter:150,exit:150},unmountOnExit:!0,onEntering:this.onEntering,onEntered:this.onEntered,onExit:this.onExit,onExiting:this.onExiting,onExited:this.onExited},l.default.createElement("div",{ref:this.previewRef},l.default.createElement("img",{src:this.props.src,className:"p-image-preview",style:t,onClick:this.onPreviewImageClick,alt:this.props.alt}))))}},{key:"render",value:function(){var e=this,t=i.classNames("p-image p-component",this.props.className,{"p-image-preview-container":this.props.preview}),n=this.renderElement(),a=this.props.template?i.ObjectUtils.getJSXElement(this.props.template,this.props):l.default.createElement("i",{className:"p-image-preview-icon pi pi-eye"}),r=this.props;return l.default.createElement("span",{ref:function(t){return e.container=t},className:t,style:this.props.style},l.default.createElement("img",{src:r.src,className:this.props.imageClassName,width:r.width,height:r.height,style:this.props.imageStyle,alt:r.alt}),this.props.preview&&l.default.createElement("div",{className:"p-image-preview-indicator",onClick:this.onImageClick},a),this.state.maskVisible&&l.default.createElement(o.Portal,{element:n,appendTo:document.body}))}}])&&u(r.prototype,m),d&&u(r,d),Object.defineProperty(r,"prototype",{writable:!1}),k}(t.Component);return g={preview:!1,className:null,downloadable:!1,style:null,imageStyle:null,imageClassName:null,template:null,src:null,alt:null,width:null,height:null},(k="defaultProps")in(v=E)?Object.defineProperty(v,k,{value:g,enumerable:!0,configurable:!0,writable:!0}):v[k]=g,e.Image=E,Object.defineProperty(e,"__esModule",{value:!0}),e}({},React,primereact.csstransition,primereact.utils,primereact.portal,primereact.api);
|