aboutsummaryrefslogtreecommitdiff
path: root/src/components/setting.js
diff options
context:
space:
mode:
authorShin'ya Ueoka <ueokande@i-beam.org>2017-10-01 10:59:47 +0900
committerShin'ya Ueoka <ueokande@i-beam.org>2017-10-01 11:09:29 +0900
commit61806a4e7ff01e8b5fdfdcef0308a2c41fc98778 (patch)
tree0aa0588c7380d88cfa7d394856cd07a153e61dcf /src/components/setting.js
parent709fa95aa383b75e88fb12512f772ea55d757b06 (diff)
setting as redux
Diffstat (limited to 'src/components/setting.js')
-rw-r--r--src/components/setting.js31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/components/setting.js b/src/components/setting.js
new file mode 100644
index 0000000..afbd56c
--- /dev/null
+++ b/src/components/setting.js
@@ -0,0 +1,31 @@
+import * as settingActions from '../actions/setting';
+
+export default class SettingComponent {
+ constructor(wrapper, store) {
+ this.wrapper = wrapper;
+ this.store = store;
+
+ let doc = wrapper.ownerDocument;
+ let form = doc.getElementById('vimvixen-settings-form');
+ form.addEventListener('submit', this.onSubmit.bind(this));
+
+ store.dispatch(settingActions.load());
+ }
+
+ onSubmit(e) {
+ let settings = {
+ json: e.target.elements['plain-json'].value,
+ };
+ this.store.dispatch(settingActions.save(settings));
+ e.preventDefault();
+ }
+
+ update() {
+ let { settings } = this.store.getState();
+
+ let doc = this.wrapper.ownerDocument;
+ let form = doc.getElementById('vimvixen-settings-form');
+ let plainJsonInput = form.elements['plain-json'];
+ plainJsonInput.value = settings.json;
+ }
+}