mirror of
https://github.com/ascribe/onion.git
synced 2025-02-14 21:10:27 +01:00
refactor input checkbox
This commit is contained in:
parent
b530018dda
commit
09ce4de29d
@ -123,7 +123,8 @@ let SignupForm = React.createClass({
|
|||||||
name="terms"
|
name="terms"
|
||||||
className="ascribe-settings-property-collapsible-toggle"
|
className="ascribe-settings-property-collapsible-toggle"
|
||||||
style={{paddingBottom: 0}}>
|
style={{paddingBottom: 0}}>
|
||||||
<InputCheckbox>
|
<InputCheckbox
|
||||||
|
defaultChecked={true}>
|
||||||
<span>
|
<span>
|
||||||
{' ' + getLangText('I agree to the Terms of Service') + ' '}
|
{' ' + getLangText('I agree to the Terms of Service') + ' '}
|
||||||
(<a href="https://www.ascribe.io/terms" target="_blank" style={{fontSize: '0.9em', color: 'rgba(0,0,0,0.7)'}}>
|
(<a href="https://www.ascribe.io/terms" target="_blank" style={{fontSize: '0.9em', color: 'rgba(0,0,0,0.7)'}}>
|
||||||
|
@ -4,35 +4,40 @@ import React from 'react';
|
|||||||
|
|
||||||
let InputCheckbox = React.createClass({
|
let InputCheckbox = React.createClass({
|
||||||
propTypes: {
|
propTypes: {
|
||||||
required: React.PropTypes.string.isRequired,
|
required: React.PropTypes.bool,
|
||||||
defaultValue: React.PropTypes.bool,
|
defaultChecked: React.PropTypes.bool,
|
||||||
children: React.PropTypes.oneOfType([
|
children: React.PropTypes.oneOfType([
|
||||||
React.PropTypes.arrayOf(React.PropTypes.element),
|
React.PropTypes.arrayOf(React.PropTypes.element),
|
||||||
React.PropTypes.element
|
React.PropTypes.element
|
||||||
]).isRequired
|
]).isRequired
|
||||||
},
|
},
|
||||||
getDefaultProps() {
|
|
||||||
return {
|
|
||||||
required: 'required'
|
|
||||||
};
|
|
||||||
},
|
|
||||||
|
|
||||||
getInitialState() {
|
getInitialState() {
|
||||||
return {
|
return {
|
||||||
//show: false
|
value: this.props.defaultChecked
|
||||||
value: this.props.defaultValue
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
onChange: function(event) {
|
componentDidMount() {
|
||||||
let newValue = !this.state.value;
|
this.props.onChange({
|
||||||
event.target.value = newValue;
|
target: {
|
||||||
this.props.onChange(event);
|
value: this.state.value
|
||||||
event.stopPropagation();
|
}
|
||||||
this.setState({value: newValue});
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
onChange() {
|
||||||
|
let value = !this.refs.checkbox.getDOMNode().checked;
|
||||||
|
this.setState({value: value});
|
||||||
|
this.props.onChange({
|
||||||
|
target: {
|
||||||
|
value: value
|
||||||
|
}
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
console.log(this.state.value);
|
||||||
return (
|
return (
|
||||||
<span
|
<span
|
||||||
onClick={this.onChange}>
|
onClick={this.onChange}>
|
||||||
@ -40,7 +45,8 @@ let InputCheckbox = React.createClass({
|
|||||||
type="checkbox"
|
type="checkbox"
|
||||||
ref="checkbox"
|
ref="checkbox"
|
||||||
onChange={this.onChange}
|
onChange={this.onChange}
|
||||||
checked={this.state.value}/>
|
checked={this.state.value}
|
||||||
|
defaultChecked={this.props.defaultChecked}/>
|
||||||
<span className="checkbox">
|
<span className="checkbox">
|
||||||
{this.props.children}
|
{this.props.children}
|
||||||
</span>
|
</span>
|
||||||
|
@ -39,6 +39,9 @@ let Property = React.createClass({
|
|||||||
|
|
||||||
getInitialState() {
|
getInitialState() {
|
||||||
return {
|
return {
|
||||||
|
// Please don't confuse initialValue with react's defaultValue.
|
||||||
|
// initialValue is set by us to ensure that a user can reset a specific
|
||||||
|
// property (after editing) to its initial value
|
||||||
initialValue: null,
|
initialValue: null,
|
||||||
value: null,
|
value: null,
|
||||||
isFocused: false,
|
isFocused: false,
|
||||||
|
@ -115,7 +115,7 @@ let AccountSettings = React.createClass({
|
|||||||
className="ascribe-settings-property-collapsible-toggle"
|
className="ascribe-settings-property-collapsible-toggle"
|
||||||
style={{paddingBottom: 0}}>
|
style={{paddingBottom: 0}}>
|
||||||
<InputCheckbox
|
<InputCheckbox
|
||||||
defaultValue={this.state.currentUser.profile.hash_locally}>
|
defaultChecked={this.state.currentUser.profile.hash_locally}>
|
||||||
<span>
|
<span>
|
||||||
{' ' + getLangText('Enable hash option for slow connections. ' +
|
{' ' + getLangText('Enable hash option for slow connections. ' +
|
||||||
'Computes and uploads a hash of the work instead.')}
|
'Computes and uploads a hash of the work instead.')}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user