aboutsummaryrefslogtreecommitdiff
path: root/src/reducers/content.js
blob: bcf1160a486d3f9c221879dcb9e8aa55eeeee6f4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
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;
  }
}