blob: 68d3b7e93b1e4a740cd7e3ccfb3ef0c2cdc0a6e7 (
plain)
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
49
50
51
52
53
54
55
56
57
|
var JarrDispatcher = require('../dispatcher/JarrDispatcher');
var ActionTypes = require('../constants/JarrConstants');
var EventEmitter = require('events').EventEmitter;
var CHANGE_EVENT = 'change_middle_panel';
var assign = require('object-assign');
var MenuStore = require('../stores/MenuStore');
var RightPanelStore = assign({}, EventEmitter.prototype, {
_datas: {category: null, feed: null, article: null},
getAll: function() {
return this._datas;
},
emitChange: function() {
this.emit(CHANGE_EVENT);
},
addChangeListener: function(callback) {
this.on(CHANGE_EVENT, callback);
},
removeChangeListener: function(callback) {
this.removeListener(CHANGE_EVENT, callback);
},
});
RightPanelStore.dispatchToken = JarrDispatcher.register(function(action) {
switch(action.type) {
case ActionTypes.PARENT_FILTER:
RightPanelStore._datas.article = null;
if(action.filter_id == null) {
RightPanelStore._datas.category = null;
RightPanelStore._datas.feed = null;
} else if(action.filter_type == 'category_id') {
RightPanelStore._datas.category = MenuStore._datas.categories[action.filter_id];
RightPanelStore._datas.feed = null;
RightPanelStore._datas.current = 'category';
} else {
RightPanelStore._datas.feed = MenuStore._datas.feeds[action.filter_id];
RightPanelStore._datas.category = MenuStore._datas.categories[RightPanelStore._datas.feed.category_id];
RightPanelStore._datas.current = 'feed';
}
RightPanelStore.emitChange();
break;
case ActionTypes.LOAD_ARTICLE:
RightPanelStore._datas.feed = MenuStore._datas.feeds[action.article.feed_id];
RightPanelStore._datas.category = MenuStore._datas.categories[action.article.category_id];
RightPanelStore._datas.article = action.article;
RightPanelStore._datas.current = 'article';
RightPanelStore.emitChange();
break;
default:
// pass
}
});
module.exports = RightPanelStore;
|