aboutsummaryrefslogtreecommitdiff
path: root/src/settings
diff options
context:
space:
mode:
Diffstat (limited to 'src/settings')
-rw-r--r--src/settings/actions/setting.js2
-rw-r--r--src/settings/components/form/BlacklistForm.jsx13
-rw-r--r--src/settings/components/form/KeymapsForm.jsx1
-rw-r--r--src/settings/components/form/PropertiesForm.jsx1
-rw-r--r--src/settings/components/form/SearchForm.jsx11
-rw-r--r--src/settings/components/index.jsx11
6 files changed, 32 insertions, 7 deletions
diff --git a/src/settings/actions/setting.js b/src/settings/actions/setting.js
index 8844252..db63a45 100644
--- a/src/settings/actions/setting.js
+++ b/src/settings/actions/setting.js
@@ -60,4 +60,4 @@ const set = (settings) => {
};
};
-export { load, save, switchToForm, switchToJson };
+export { load, save, set, switchToForm, switchToJson };
diff --git a/src/settings/components/form/BlacklistForm.jsx b/src/settings/components/form/BlacklistForm.jsx
index cf7cffe..c470758 100644
--- a/src/settings/components/form/BlacklistForm.jsx
+++ b/src/settings/components/form/BlacklistForm.jsx
@@ -13,9 +13,13 @@ class BlacklistForm extends React.Component {
return <div key={index} className='form-blacklist-form-row'>
<input data-index={index} type='text' name='url'
className='column-url' value={url}
- onChange={this.bindValue.bind(this)} />
+ onChange={this.bindValue.bind(this)}
+ onBlur={this.props.onBlur}
+ />
<DeleteButton data-index={index} name='delete'
- onClick={this.bindValue.bind(this)} />
+ onClick={this.bindValue.bind(this)}
+ onBlur={this.props.onBlur}
+ />
</div>;
})
}
@@ -38,17 +42,22 @@ class BlacklistForm extends React.Component {
}
this.props.onChange(next);
+ if (name === 'delete') {
+ this.props.onBlur();
+ }
}
}
BlacklistForm.propTypes = {
value: PropTypes.arrayOf(PropTypes.string),
onChange: PropTypes.func,
+ onBlur: PropTypes.func,
};
BlacklistForm.defaultProps = {
value: [],
onChange: () => {},
+ onBlur: () => {},
};
export default BlacklistForm;
diff --git a/src/settings/components/form/KeymapsForm.jsx b/src/settings/components/form/KeymapsForm.jsx
index 5bb65cb..01acf61 100644
--- a/src/settings/components/form/KeymapsForm.jsx
+++ b/src/settings/components/form/KeymapsForm.jsx
@@ -20,6 +20,7 @@ class KeymapsForm extends React.Component {
type='text' id={name} name={name} key={name}
label={label} value={value}
onChange={this.bindValue.bind(this)}
+ onBlur={this.props.onBlur}
/>;
})
}
diff --git a/src/settings/components/form/PropertiesForm.jsx b/src/settings/components/form/PropertiesForm.jsx
index 0014899..979fdd8 100644
--- a/src/settings/components/form/PropertiesForm.jsx
+++ b/src/settings/components/form/PropertiesForm.jsx
@@ -27,6 +27,7 @@ class PropertiesForm extends React.Component {
className='column-input'
value={value[name] ? value[name] : ''}
onChange={this.bindValue.bind(this)}
+ onBlur={this.props.onBlur}
checked={value[name]}
/>
</label>
diff --git a/src/settings/components/form/SearchForm.jsx b/src/settings/components/form/SearchForm.jsx
index d2f2d48..6b0bd01 100644
--- a/src/settings/components/form/SearchForm.jsx
+++ b/src/settings/components/form/SearchForm.jsx
@@ -23,11 +23,15 @@ class SearchForm extends React.Component {
return <div key={index} className='form-search-form-row'>
<input data-index={index} type='text' name='name'
className='column-name' value={engine[0]}
- onChange={this.bindValue.bind(this)} />
+ onChange={this.bindValue.bind(this)}
+ onBlur={this.props.onBlur}
+ />
<input data-index={index} type='text' name='url'
placeholder='http://example.com/?q={}'
className='column-url' value={engine[1]}
- onChange={this.bindValue.bind(this)} />
+ onChange={this.bindValue.bind(this)}
+ onBlur={this.props.onBlur}
+ />
<div className='column-option'>
<input data-index={index} type='radio' name='default'
checked={value.default === engine[0]}
@@ -66,6 +70,9 @@ class SearchForm extends React.Component {
}
this.props.onChange(next);
+ if (name === 'delete' || name === 'default') {
+ this.props.onBlur();
+ }
}
}
diff --git a/src/settings/components/index.jsx b/src/settings/components/index.jsx
index affa2e9..4ef59d7 100644
--- a/src/settings/components/index.jsx
+++ b/src/settings/components/index.jsx
@@ -25,6 +25,7 @@ class SettingsComponent extends React.Component {
<KeymapsForm
value={form.keymaps}
onChange={value => this.bindForm('keymaps', value)}
+ onBlur={this.save.bind(this)}
/>
</fieldset>
<fieldset>
@@ -32,6 +33,7 @@ class SettingsComponent extends React.Component {
<SearchForm
value={form.search}
onChange={value => this.bindForm('search', value)}
+ onBlur={this.save.bind(this)}
/>
</fieldset>
<fieldset>
@@ -39,6 +41,7 @@ class SettingsComponent extends React.Component {
<BlacklistForm
value={form.blacklist}
onChange={value => this.bindForm('blacklist', value)}
+ onBlur={this.save.bind(this)}
/>
</fieldset>
<fieldset>
@@ -47,6 +50,7 @@ class SettingsComponent extends React.Component {
types={properties.types}
value={form.properties}
onChange={value => this.bindForm('properties', value)}
+ onBlur={this.save.bind(this)}
/>
</fieldset>
</div>;
@@ -61,6 +65,7 @@ class SettingsComponent extends React.Component {
spellCheck='false'
error={error}
onChange={this.bindJson.bind(this)}
+ onBlur={this.save.bind(this)}
value={json}
/>
</div>;
@@ -109,7 +114,7 @@ class SettingsComponent extends React.Component {
form: { ...this.props.form },
};
settings.form[name] = value;
- this.props.dispatch(settingActions.save(settings));
+ this.props.dispatch(settingActions.set(settings));
}
bindJson(e) {
@@ -118,7 +123,7 @@ class SettingsComponent extends React.Component {
json: e.target.value,
form: this.props.form,
};
- this.props.dispatch(settingActions.save(settings));
+ this.props.dispatch(settingActions.set(settings));
}
bindSource(e) {
@@ -135,7 +140,9 @@ class SettingsComponent extends React.Component {
}
this.props.dispatch(settingActions.switchToForm(this.props.json));
}
+ }
+ save() {
let settings = this.props.store.getState();
this.props.dispatch(settingActions.save(settings));
}