{"size": 8252, "ext": "js", "max_stars_repo_path": "puntoe/puntoe_files/fileUploader.js", "max_stars_repo_name": "GlobalShapersRosario/web", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "puntoe/puntoe_files/fileUploader.js", "max_issues_repo_name": "GlobalShapersRosario/web", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "puntoe/puntoe_files/fileUploader.js", "max_forks_repo_name": "GlobalShapersRosario/web", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 4126.0, "max_line_length": 8207, "alphanum_fraction": 0.7998061076}
"use strict";define("fileUploader/components/fileUploader",["santaProps","lodash","reactDOM","core","textCommon","siteUtils"],function(e,t,i,o,s,n){function a(e){return t.assign(o.compMixins.validatableWithSyncMixin.getPublicState(e),{value:t.get(e,["value"],[]),uploadStatus:t.get(e,"uploadStatus",u.NOT_STARTED),serverMessage:t.get(e,"serverMessage","")})}function l(e){var i=t.get(e,"valid"),o=t.get(e,"fileNotUploaded");return!i&&!o}var r=o.compMixins,p=e.Types,c=n.fileUploadManager,u={NOT_STARTED:"NOT_STARTED",STARTED:"STARTED",FAILED:"FAILED",DONE:"DONE"};return{displayName:"FileUploader",mixins:[r.skinBasedComp,s.textScaleMixin,o.compMixins.inputFocusMixin,o.compMixins.validatableWithSyncMixin.validatableWithSync,o.compMixins.compStateMixin(a)],statics:{useSantaTypes:!0,behaviors:t.assign({reset:{methodName:"reset"}},o.compMixins.inputFocusMixin.INPUT_FOCUS_BEHAVIORS,o.compMixins.validatableWithSyncMixin.VALIDATABLE_WITH_SYNC_BEHAVIORS)},propTypes:{compData:e.Types.Component.compData.isRequired,scale:e.Types.Component.scale,compProp:e.Types.Component.compProp.isRequired,siteMediaToken:p.RendererModel.siteMediaToken.isRequired,windowKeyboardEvent:e.Types.SiteAspects.windowKeyboardEvent.isRequired,getMediaFullStaticUrl:e.Types.ServiceTopology.getMediaFullStaticUrl,shouldResetComponent:e.Types.RenderFlags.shouldResetComponent.isRequired},getInitialState:function(){return this.uploadCounter=0,a()},isUploading:function(){return this.state.uploadStatus===u.STARTED},componentDidMount:function(){this.props.windowKeyboardEvent.registerToKeyDownWithFocus(this,this.refs.chooseFileButton)},componentWillReceiveProps:function(e){e.shouldResetComponent&&this.props.shouldResetComponent!==e.shouldResetComponent&&(this.hideValidityIndication(),this.removeFile(!1))},onKeyDown:function(e){var i=[13,32];if(!this.props.compProp.isDisabled&&t.includes(i,e.keyCode)){var o=t.includes(e.target.className,"chooseFileButton"),s=t.includes(e.target.classList[0],"uploadName");o?(this.refs.fileInput.click(),this.refs.chooseFileButton.blur()):s&&this.removeFile()}},focus:function(){this.refs.chooseFileButton.focus()},blur:function(){this.refs.chooseFileButton.blur()},createFileNodes:function(e){var i=this.props.compProp.showPlaceholder,o=this.props.compProp.filesAlignment,s=this.props.compData.placeholderLabel,n=t.cloneDeep(this.state.value),a={isPlaceholder:!!t.isEmpty(n)&&i,alignment:o,previewState:e,errorState:this.hasErrorIndication()&&this.shouldShowValidityIndication(),removeFunction:this.removeFile,scale:this.props.scale,uploading:this.isUploading()};return t.isEmpty(n)&&(t.isUndefined(e)?(s=""===s?" ":s,n.push({name:s}),i&&" "!==s||(a.hidePlaceholder=!0)):(n.push({name:"Example.txt"}),a.isPlaceholder=!1)),t.map(n,function(e,t){return this.createChildComponent({id:"uploadName"+t,fileName:e.name},"wysiwyg.viewer.components.inputs.uploadName","uploadName",a)}.bind(this))},removeFile:function(e){this.isUploading()||(e=t.isNil(e)||e,this.setState(a(),function(){i.findDOMNode(this.refs.fileInput).value="",e&&this.handleAction(n.constants.ACTION_TYPES.CHANGE)}))},setUserCallback:function(e){this.userCallback=e},clearUserCallback:function(){this.userCallback=null},applyUserCallback:function(e,t){this.userCallback&&this.userCallback(e,t),this.clearUserCallback()},reset:function(){this.resetValidity(),this.setState(a(),function(){i.findDOMNode(this.refs.fileInput).value="",this.uploadCounter++,this.applyUserCallback(null,{errorCode:-1,errorDescription:"Upload Reset"})})},shouldExecuteUploadCb:function(e){return e===this.uploadCounter},getUploadCompleteCB:function(e){return function(t){if(this.shouldExecuteUploadCb(e)){var i=t[0];"Image"===this.props.compProp.filesType&&(i.uri=i.file_name,i.title=i.file_name),"Document"===this.props.compProp.filesType&&(i.uri=i.file_name,i.filename=i.original_file_name),this.uploadCounter++,this.setState({uploadStatus:u.DONE},function(){this.handleAction(n.constants.ACTION_TYPES.VALIDATE),this.applyUserCallback(i,null)})}}.bind(this)},getUploadFailedCB:function(e){return function(t){if(this.shouldExecuteUploadCb(e)){var i={errorCode:t.error_code,errorDescription:t.error_description};this.uploadCounter++,this.setState({uploadStatus:u.FAILED,serverMessage:i.errorDescription},function(){this.handleAction(n.constants.ACTION_TYPES.VALIDATE),this.applyUserCallback(null,i)})}}.bind(this)},isReadyToUpload:function(){return!this.isUploading()&&!t.isEmpty(this.state.value)&&!l(this.getValidity())},uploadFiles:function(e){if(this.isReadyToUpload()){var i=this.props.siteMediaToken,o=this.props.compProp.filesType;this.setUserCallback(e);var s=this.getUploadCompleteCB(this.uploadCounter),n=this.getUploadFailedCB(this.uploadCounter);this.setState({uploadStatus:u.STARTED},function(){t.forEach(this.refs.fileInput.files,function(e){c.uploadFile(e,i,o,s,n)})})}},onFileSelectionChange:function(){if(this.refs.fileInput.files.length>0){var e=t.map(this.refs.fileInput.files,function(e){return{name:e.name,size:e.size}});this.setState({value:e,uploadStatus:u.NOT_STARTED},function(){this.handleAction(n.constants.ACTION_TYPES.CHANGE)})}},getAcceptableFileTypes:function(){switch(this.props.compProp.filesType){case"Image":return".jpeg,.png,.jpg";case"Document":return".pdf,.doc,.docx,.ppt,.pptx,.xls,.xlsx,.odp,.odt,.epub"}},handleButtonFocus:function(e){this.handleAction(n.constants.ACTION_TYPES.FOCUS,e)},handleButtonBlur:function(e){this.handleAction(n.constants.ACTION_TYPES.BLUR,e)},hasErrorIndication:function(){if(this.isValid())return!1;var e=this.getValidity();return t.some(t.omit(e,"fileNotUploaded","valid"))||this.state.uploadStatus===u.FAILED},getSkinProperties:function(){var e=this.props.compData,t=this.props.compProp,i={"no-label":""===e.buttonLabel};i[t.buttonAlignment]=!0;var o=this.getComponentPreviewState()||this.props.previewState,s=!!this.props.compProp.isDisabled||this.isUploading();return{"":{},chooseFileButton:{className:this.classSet(i),onClick:function(){s||(this.refs.fileInput.click(),this.refs.chooseFileButton.blur())}.bind(this),onFocus:s?null:this.handleButtonFocus,onBlur:s?null:this.handleButtonBlur,"data-preview":o,"data-disabled":s,"data-error":this.hasErrorIndication()&&this.shouldShowValidityIndication()},buttonLabel:{children:[e.buttonLabel],style:this.getFontSize("btn_fnt")},fileInput:{onChange:this.onFileSelectionChange,accept:this.getAcceptableFileTypes()},files:{children:this.createFileNodes(o),"data-preview":o}}}}}),define("fileUploader/components/uploadName",["santaProps","react","lodash","core","textCommon"],function(e,t,i,o,s){return{displayName:"UploadName",mixins:[o.compMixins.skinBasedComp,s.textScaleMixin],statics:{useSantaTypes:!0},propTypes:i.assign({compData:e.Types.Component.compData.isRequired,compProp:e.Types.Component.compProp.isRequired,alignment:t.PropTypes.string.isRequired,removeFunction:t.PropTypes.func.isRequired,isPlaceholder:t.PropTypes.bool.isRequired,scale:t.PropTypes.number.isRequired,previewState:t.PropTypes.string,errorState:t.PropTypes.bool,uploading:t.PropTypes.bool,windowKeyboardEvent:e.Types.SiteAspects.windowKeyboardEvent.isRequired}),componentDidMount:function(){var e=this.props.id.split("uploadName")[0];this.props.windowKeyboardEvent.registerToKeyDownWithFocus({props:{id:e}},this.refs["x-icon"])},getSkinProperties:function(){var e=this.props.compData,t={};t["align-"+this.props.alignment]=!0,t["hide-placeholder"]=this.props.hidePlaceholder;var i=!!this.props.compProp.isDisabled||this.props.uploading,o=this.getComponentPreviewState()||this.props.previewState,s=this.props.errorState;return{"":{className:this.classSet(t),"data-preview":o,"data-error":s},"x-icon":{style:this.props.isPlaceholder?{display:"none"}:{},onClick:function(){this.props.removeFunction&&!this.props.uploading&&this.props.removeFunction(e.fileName)}.bind(this),"data-preview":o,"data-disabled":i},"file-name":{className:this.classSet({"file-name-placeholder":this.props.isPlaceholder}),children:[e.fileName],"data-preview":o,"data-disabled":i,style:this.getFontSize("file_fnt",this.props.scale)}}}}}),define("fileUploader",["fileUploader/components/fileUploader","fileUploader/components/uploadName"],function(e,t){return{fileUploader:e,uploadName:t}});
//# sourceMappingURL=fileUploader.min.js.map