// Copyright (c) 2015 Spinpunch, Inc. All Rights Reserved. // See License.txt for license information. export default class SettingPicture extends React.Component { constructor(props) { super(props); this.setPicture = this.setPicture.bind(this); } setPicture(file) { if (file) { var reader = new FileReader(); var img = React.findDOMNode(this.refs.image); reader.onload = function load(e) { $(img).attr('src', e.target.result); }; reader.readAsDataURL(file); } } componentWillReceiveProps(nextProps) { if (nextProps.picture) { this.setPicture(nextProps.picture); } } render() { var clientError = null; if (this.props.client_error) { clientError =
; } var serverError = null; if (this.props.server_error) { serverError = ; } var img = null; if (this.props.picture) { img = ( ); } else { img = ( ); } var confirmButton; if (this.props.loadingPicture) { confirmButton = ( ); } else { var confirmButtonClass = 'btn btn-sm'; if (this.props.submitActive) { confirmButtonClass += ' btn-primary'; } else { confirmButtonClass += ' btn-inactive disabled'; } confirmButton = ( Save ); } var helpText = 'Upload a profile picture in either JPG or PNG format, at least ' + global.window.config.ProfileWidth + 'px in width and ' + global.window.config.ProfileHeight + 'px height.'; var self = this; return (