Added singlequotes around 'Edit' and did cosmetic refactoring

Этот коммит содержится в:
nickago
2015-07-30 14:51:31 -07:00
родитель 8265e5ed82
Коммит f7e5ac1db0

Просмотреть файл

@@ -638,8 +638,8 @@ var GeneralTab = React.createClass({
var username = this.state.username.trim(); var username = this.state.username.trim();
var username_error = utils.isValidUsername(username); var username_error = utils.isValidUsername(username);
if (username_error === "Cannot use a reserved word as a username.") { if (username_error === 'Cannot use a reserved word as a username.') {
this.setState({client_error: "This username is reserved, please choose a new one." }); this.setState({client_error: 'This username is reserved, please choose a new one.' });
return; return;
} else if (username_error) { } else if (username_error) {
this.setState({client_error: "Username must begin with a letter, and contain between 3 to 15 lowercase characters made up of numbers, letters, and the symbols '.', '-' and '_'." }); this.setState({client_error: "Username must begin with a letter, and contain between 3 to 15 lowercase characters made up of numbers, letters, and the symbols '.', '-' and '_'." });
@@ -647,7 +647,7 @@ var GeneralTab = React.createClass({
} }
if (user.username === username) { if (user.username === username) {
this.setState({client_error: "You must submit a new username"}); this.setState({client_error: 'You must submit a new username'});
return; return;
} }
@@ -662,7 +662,7 @@ var GeneralTab = React.createClass({
var nickname = this.state.nickname.trim(); var nickname = this.state.nickname.trim();
if (user.nickname === nickname) { if (user.nickname === nickname) {
this.setState({client_error: "You must submit a new nickname"}) this.setState({client_error: 'You must submit a new nickname'})
return; return;
} }
@@ -678,7 +678,7 @@ var GeneralTab = React.createClass({
var lastName = this.state.last_name.trim(); var lastName = this.state.last_name.trim();
if (user.first_name === firstName && user.last_name === lastName) { if (user.first_name === firstName && user.last_name === lastName) {
this.setState({client_error: "You must submit a new first or last name"}) this.setState({client_error: 'You must submit a new first or last name'})
return; return;
} }
@@ -698,7 +698,7 @@ var GeneralTab = React.createClass({
} }
if (email === '' || !utils.isEmail(email)) { if (email === '' || !utils.isEmail(email)) {
this.setState({ email_error: "Please enter a valid email address" }); this.setState({ email_error: 'Please enter a valid email address' });
return; return;
} }
@@ -708,8 +708,8 @@ var GeneralTab = React.createClass({
}, },
submitUser: function(user) { submitUser: function(user) {
client.updateUser(user, client.updateUser(user,
function(data) { function() {
this.updateSection(""); this.updateSection('');
AsyncClient.getMe(); AsyncClient.getMe();
}.bind(this), }.bind(this),
function(err) { function(err) {
@@ -717,7 +717,7 @@ var GeneralTab = React.createClass({
if (err.message) { if (err.message) {
state.server_error = err.message; state.server_error = err.message;
} else { } else {
state.server_error = err state.server_error = err;
} }
this.setState(state); this.setState(state);
}.bind(this) }.bind(this)
@@ -726,22 +726,26 @@ var GeneralTab = React.createClass({
submitPicture: function(e) { submitPicture: function(e) {
e.preventDefault(); e.preventDefault();
if (!this.state.picture) return; if (!this.state.picture) {
if(!this.submitActive) return;
var picture = this.state.picture;
if(picture.type !== "image/jpeg" && picture.type !== "image/png") {
this.setState({client_error: "Only JPG or PNG images may be used for profile pictures"});
return; return;
} }
formData = new FormData(); if (!this.submitActive) {
return;
}
var picture = this.state.picture;
if (picture.type !== 'image/jpeg' && picture.type !== 'image/png') {
this.setState({client_error: 'Only JPG or PNG images may be used for profile pictures'});
return;
}
var formData = new FormData();
formData.append('image', picture, picture.name); formData.append('image', picture, picture.name);
client.uploadProfileImage(formData, client.uploadProfileImage(formData,
function(data) { function() {
this.submitActive = false; this.submitActive = false;
AsyncClient.getMe(); AsyncClient.getMe();
window.location.reload(); window.location.reload();
@@ -773,20 +777,20 @@ var GeneralTab = React.createClass({
this.setState({ picture: e.target.files[0] }); this.setState({ picture: e.target.files[0] });
this.submitActive = true; this.submitActive = true;
this.setState({client_error:null}) this.setState({client_error: null});
} else { } else {
this.setState({picture: null}); this.setState({picture: null});
} }
}, },
updateSection: function(section) { updateSection: function(section) {
this.setState({client_error:""}) this.setState({client_error:''});
this.submitActive = false this.submitActive = false;
this.props.updateSection(section); this.props.updateSection(section);
}, },
handleClose: function() { handleClose: function() {
$(this.getDOMNode()).find(".form-control").each(function() { $(this.getDOMNode()).find('.form-control').each(function() {
this.value = ""; this.value = '';
}); });
this.setState(assign({}, this.getInitialState(), {client_error: null, server_error: null, email_error: null})); this.setState(assign({}, this.getInitialState(), {client_error: null, server_error: null, email_error: null}));
@@ -812,43 +816,45 @@ var GeneralTab = React.createClass({
var nameSection; var nameSection;
var self = this; var self = this;
if (this.props.activeSection === 'name') {
var inputs = []; var inputs = [];
if (this.props.activeSection === 'name') {
inputs.push( inputs.push(
<div className="form-group"> <div className='form-group'>
<label className="col-sm-5 control-label">First Name</label> <label className='col-sm-5 control-label'>First Name</label>
<div className="col-sm-7"> <div className='col-sm-7'>
<input className="form-control" type="text" onChange={this.updateFirstName} value={this.state.first_name}/> <input className='form-control' type='text' onChange={this.updateFirstName} value={this.state.first_name}/>
</div> </div>
</div> </div>
); );
inputs.push( inputs.push(
<div className="form-group"> <div className='form-group'>
<label className="col-sm-5 control-label">Last Name</label> <label className='col-sm-5 control-label'>Last Name</label>
<div className="col-sm-7"> <div className='col-sm-7'>
<input className="form-control" type="text" onChange={this.updateLastName} value={this.state.last_name}/> <input className='form-control' type='text' onChange={this.updateLastName} value={this.state.last_name}/>
</div> </div>
</div> </div>
); );
nameSection = ( nameSection = (
<SettingItemMax <SettingItemMax
title="Full Name" title='Full Name'
inputs={inputs} inputs={inputs}
submit={this.submitName} submit={this.submitName}
server_error={server_error} server_error={server_error}
client_error={client_error} client_error={client_error}
updateSection={function(e){self.updateSection("");e.preventDefault();}} updateSection={function(e) {
self.updateSection('');
e.preventDefault();
}}
/> />
); );
} else { } else {
var full_name = ""; var full_name = '';
if (user.first_name && user.last_name) { if (user.first_name && user.last_name) {
full_name = user.first_name + " " + user.last_name; full_name = user.first_name + ' ' + user.last_name;
} else if (user.first_name) { } else if (user.first_name) {
full_name = user.first_name; full_name = user.first_name;
} else if (user.last_name) { } else if (user.last_name) {
@@ -857,107 +863,119 @@ var GeneralTab = React.createClass({
nameSection = ( nameSection = (
<SettingItemMin <SettingItemMin
title="Full Name" title='Full Name'
describe={full_name} describe={full_name}
updateSection={function(){self.updateSection("name");}} updateSection={function() {
self.updateSection('name');
}}
/> />
); );
} }
var nicknameSection; var nicknameSection;
if (this.props.activeSection === 'nickname') { if (this.props.activeSection === 'nickname') {
var inputs = [];
inputs.push( inputs.push(
<div className="form-group"> <div className='form-group'>
<label className="col-sm-5 control-label">{utils.isMobile() ? "": "Nickname"}</label> <label className='col-sm-5 control-label'>{utils.isMobile() ? '' : 'Nickname'}</label>
<div className="col-sm-7"> <div className='col-sm-7'>
<input className="form-control" type="text" onChange={this.updateNickname} value={this.state.nickname}/> <input className='form-control' type='text' onChange={this.updateNickname} value={this.state.nickname}/>
</div> </div>
</div> </div>
); );
nicknameSection = ( nicknameSection = (
<SettingItemMax <SettingItemMax
title="Nickname" title='Nickname'
inputs={inputs} inputs={inputs}
submit={this.submitNickname} submit={this.submitNickname}
server_error={server_error} server_error={server_error}
client_error={client_error} client_error={client_error}
updateSection={function(e){self.updateSection("");e.preventDefault();}} updateSection={function(e) {
self.updateSection('');
e.preventDefault();
}}
/> />
); );
} else { } else {
nicknameSection = ( nicknameSection = (
<SettingItemMin <SettingItemMin
title="Nickname" title='Nickname'
describe={UserStore.getCurrentUser().nickname} describe={UserStore.getCurrentUser().nickname}
updateSection={function(){self.updateSection("nickname");}} updateSection={function() {
self.updateSection('nickname');
}}
/> />
); );
} }
var usernameSection; var usernameSection;
if (this.props.activeSection === 'username') { if (this.props.activeSection === 'username') {
var inputs = [];
inputs.push( inputs.push(
<div className="form-group"> <div className='form-group'>
<label className="col-sm-5 control-label">{utils.isMobile() ? "": "Username"}</label> <label className='col-sm-5 control-label'>{utils.isMobile() ? '': 'Username'}</label>
<div className="col-sm-7"> <div className='col-sm-7'>
<input className="form-control" type="text" onChange={this.updateUsername} value={this.state.username}/> <input className='form-control' type='text' onChange={this.updateUsername} value={this.state.username}/>
</div> </div>
</div> </div>
); );
usernameSection = ( usernameSection = (
<SettingItemMax <SettingItemMax
title="Username" title='Username'
inputs={inputs} inputs={inputs}
submit={this.submitUsername} submit={this.submitUsername}
server_error={server_error} server_error={server_error}
client_error={client_error} client_error={client_error}
updateSection={function(e){self.updateSection("");e.preventDefault();}} updateSection={function(e) {
self.updateSection('');
e.preventDefault();
}}
/> />
); );
} else { } else {
usernameSection = ( usernameSection = (
<SettingItemMin <SettingItemMin
title="Username" title='Username'
describe={UserStore.getCurrentUser().username} describe={UserStore.getCurrentUser().username}
updateSection={function(){self.updateSection("username");}} updateSection={function() {
self.updateSection('username');
}}
/> />
); );
} }
var emailSection; var emailSection;
if (this.props.activeSection === 'email') { if (this.props.activeSection === 'email') {
var inputs = [];
inputs.push( inputs.push(
<div className="form-group"> <div className='form-group'>
<label className="col-sm-5 control-label">Primary Email</label> <label className='col-sm-5 control-label'>Primary Email</label>
<div className="col-sm-7"> <div className='col-sm-7'>
<input className="form-control" type="text" onChange={this.updateEmail} value={this.state.email}/> <input className='form-control' type='text' onChange={this.updateEmail} value={this.state.email}/>
</div> </div>
</div> </div>
); );
emailSection = ( emailSection = (
<SettingItemMax <SettingItemMax
title="Email" title='Email'
inputs={inputs} inputs={inputs}
submit={this.submitEmail} submit={this.submitEmail}
server_error={server_error} server_error={server_error}
client_error={email_error} client_error={email_error}
updateSection={function(e){self.updateSection("");e.preventDefault();}} updateSection={function(e) {
self.updateSection('');
e.preventDefault();
}}
/> />
); );
} else { } else {
emailSection = ( emailSection = (
<SettingItemMin <SettingItemMin
title="Email" title='Email'
describe={UserStore.getCurrentUser().email} describe={UserStore.getCurrentUser().email}
updateSection={function(){self.updateSection("email");}} updateSection={function() {
self.updateSection('email');
}}
/> />
); );
} }
@@ -966,57 +984,60 @@ var GeneralTab = React.createClass({
if (this.props.activeSection === 'picture') { if (this.props.activeSection === 'picture') {
pictureSection = ( pictureSection = (
<SettingPicture <SettingPicture
title="Profile Picture" title='Profile Picture'
submit={this.submitPicture} submit={this.submitPicture}
src={"/api/v1/users/" + user.id + "/image?time=" + user.last_picture_update} src={'/api/v1/users/' + user.id + '/image?time=' + user.last_picture_update}
server_error={server_error} server_error={server_error}
client_error={client_error} client_error={client_error}
updateSection={function(e){self.updateSection("");e.preventDefault();}} updateSection={function(e) {
self.updateSection('');
e.preventDefault();
}}
picture={this.state.picture} picture={this.state.picture}
pictureChange={this.updatePicture} pictureChange={this.updatePicture}
submitActive={this.submitActive} submitActive={this.submitActive}
/> />
); );
} else { } else {
var minMessage = "Click Edit to upload an image."; var minMessage = 'Click \'Edit\' to upload an image.';
if (user.last_picture_update) { if (user.last_picture_update) {
minMessage = "Image last updated " + utils.displayDate(user.last_picture_update) minMessage = 'Image last updated ' + utils.displayDate(user.last_picture_update);
} }
pictureSection = ( pictureSection = (
<SettingItemMin <SettingItemMin
title="Profile Picture" title='Profile Picture'
describe={minMessage} describe={minMessage}
updateSection={function(){self.updateSection("picture");}} updateSection={function() {
self.updateSection('picture');
}}
/> />
); );
} }
return ( return (
<div> <div>
<div className="modal-header"> <div className='modal-header'>
<button type="button" className="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button> <button type='button' className='close' data-dismiss='modal' aria-label='Close'><span aria-hidden='true'>&times;</span></button>
<h4 className="modal-title" ref="title"><i className="modal-back"></i>General Settings</h4> <h4 className='modal-title' ref='title'><i className='modal-back'></i>General Settings</h4>
</div> </div>
<div className="user-settings"> <div className='user-settings'>
<h3 className="tab-header">General Settings</h3> <h3 className='tab-header'>General Settings</h3>
<div className="divider-dark first"/> <div className='divider-dark first'/>
{nameSection} {nameSection}
<div className="divider-light"/> <div className='divider-light'/>
{usernameSection} {usernameSection}
<div className="divider-light"/> <div className='divider-light'/>
{nicknameSection} {nicknameSection}
<div className="divider-light"/> <div className='divider-light'/>
{emailSection} {emailSection}
<div className="divider-light"/> <div className='divider-light'/>
{pictureSection} {pictureSection}
<div className="divider-dark"/> <div className='divider-dark'/>
</div> </div>
</div> </div>
); );
} }
}); });
var AppearanceTab = React.createClass({ var AppearanceTab = React.createClass({
submitTheme: function(e) { submitTheme: function(e) {
e.preventDefault(); e.preventDefault();