aboutsummaryrefslogtreecommitdiff
path: root/src/reducers
diff options
context:
space:
mode:
authorShin'ya Ueoka <ueokande@i-beam.org>2017-09-10 17:51:25 +0900
committerShin'ya Ueoka <ueokande@i-beam.org>2017-09-10 17:51:25 +0900
commitadc6a5175c0d8b83e45b9e8d99109c1605ad29ac (patch)
tree6481cd07b3c3a7e22bf9fa606a0a816ba55ba92d /src/reducers
parent2c40d239f0962f1442f357c0697e4c8aa2eafd31 (diff)
content commands as action/reducer
Diffstat (limited to 'src/reducers')
-rw-r--r--src/reducers/content.js48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/reducers/content.js b/src/reducers/content.js
new file mode 100644
index 0000000..bcf1160
--- /dev/null
+++ b/src/reducers/content.js
@@ -0,0 +1,48 @@
+import * as consoleFrames from '../console/frames';
+import * as histories from '../content/histories';
+import * as scrolls from '../content/scrolls';
+import Follow from '../content/follow';
+import actions from '../actions';
+
+export default function reducer(state, action = {}) {
+ switch (action.type) {
+ case actions.CMD_OPEN:
+ return consoleFrames.showCommand('');
+ case actions.CMD_TABS_OPEN:
+ if (action.alter) {
+ // alter url
+ return consoleFrames.showCommand('open ' + window.location.href);
+ } else {
+ return consoleFrames.showCommand('open ');
+ }
+ case actions.CMD_BUFFER:
+ return consoleFrames.showCommand('buffer ');
+ case actions.SCROLL_LINES:
+ scrolls.scrollLines(window, action.count);
+ break;
+ case actions.SCROLL_PAGES:
+ scrolls.scrollPages(window, action.count);
+ break;
+ case actions.SCROLL_TOP:
+ scrolls.scrollTop(window);
+ break;
+ case actions.SCROLL_BOTTOM:
+ scrolls.scrollBottom(window);
+ break;
+ case actions.SCROLL_LEFT:
+ scrolls.scrollLeft(window);
+ break;
+ case actions.SCROLL_RIGHT:
+ scrolls.scrollRight(window);
+ break;
+ case actions.FOLLOW_START:
+ new Follow(window.document, action.newTab);
+ break;
+ case actions.HISTORY_PREV:
+ histories.prev(window);
+ break;
+ case actions.HISTORY_NEXT:
+ histories.next(window);
+ break;
+ }
+}