| 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115 | 2×
2×
2×
2×
2×
2×
2×
2×
2×
2×
2×
2×
2×
2×
2×
11×
11×
11×
11×
11×
5×
27×
27×
27×
27×
18×
27×
16×
38×
38×
38×
38×
38×
16×
16×
16×
2×
| var BS, CourseActions, CourseDataMixin, CourseStore, LoadableItem, React, ReferenceBook, ReferenceBookActions, ReferenceBookPageShell, ReferenceBookShell, ReferenceBookStore, Router, TeacherContentToggle, _, classnames, moment, ref, ref1;
React = require('react');
Router = require('react-router');
BS = require('react-bootstrap');
_ = require('underscore');
classnames = require('classnames');
ref = require('../../flux/reference-book'), ReferenceBookActions = ref.ReferenceBookActions, ReferenceBookStore = ref.ReferenceBookStore;
ref1 = require('../../flux/course'), CourseActions = ref1.CourseActions, CourseStore = ref1.CourseStore;
ReferenceBookPageShell = require('./page-shell');
LoadableItem = require('../loadable-item');
moment = require('moment');
ReferenceBook = require('./reference-book');
CourseDataMixin = require('../course-data-mixin');
TeacherContentToggle = require('./teacher-content-toggle');
ReferenceBookShell = React.createClass({
displayName: 'ReferenceBookShell',
mixins: [CourseDataMixin],
contextTypes: {
router: React.PropTypes.func
},
getInitialState: function() {
return this.getIds();
},
componentWillMount: function() {
var courseId;
courseId = this.context.router.getCurrentParams().courseId;
this.setIds();
Iif (!CourseStore.isLoaded(courseId)) {
CourseActions.load(courseId);
return CourseStore.once('course.loaded', this.setIds);
}
},
componentWillReceiveProps: function() {
return this.setIds();
},
getIds: function() {
var courseId, ecosystemId, ref2, ref3, section;
ref2 = this.context.router.getCurrentParams(), courseId = ref2.courseId, section = ref2.section;
ecosystemId = this.context.router.getCurrentQuery().ecosystemId;
if (ecosystemId == null) {
ecosystemId = (ref3 = CourseStore.get(courseId)) != null ? ref3.ecosystem_id : void 0;
}
return {
courseId: courseId,
section: section,
ecosystemId: ecosystemId
};
},
setIds: function() {
return this.setState(this.getIds());
},
setTeacherContent: function(isShowing) {
return this.setState({
isShowingTeacherContent: isShowing
});
},
renderNavbarControls: function() {
Eif (!CourseStore.isTeacher(this.state.courseId)) {
return null;
}
return React.createElement(BS.Nav, {
"navbar": true,
"right": true
}, React.createElement(TeacherContentToggle, {
"isShowing": this.state.isShowingTeacherContent,
"onChange": this.setTeacherContent
}));
},
renderBook: function() {
var courseId, ecosystemId, ref2;
ref2 = this.state, courseId = ref2.courseId, ecosystemId = ref2.ecosystemId;
return React.createElement(ReferenceBook, {
"navbarControls": this.renderNavbarControls(),
"section": this.state.section,
"pageNavRouterLinkTarget": 'viewReferenceBookSection',
"menuRouterLinkTarget": 'viewReferenceBookSection',
"className": classnames({
'is-teacher': this.state.isShowingTeacherContent
}),
"dataProps": (courseId ? this.getCourseDataProps(courseId) : void 0),
"ecosystemId": ecosystemId
});
},
render: function() {
var courseId, ecosystemId, ref2;
ref2 = this.state, courseId = ref2.courseId, ecosystemId = ref2.ecosystemId;
return React.createElement(LoadableItem, {
"id": ecosystemId || CourseStore.get(courseId).ecosystem_id,
"store": ReferenceBookStore,
"actions": ReferenceBookActions,
"renderItem": this.renderBook
});
}
});
module.exports = {
ReferenceBookShell: ReferenceBookShell,
ReferenceBookPageShell: ReferenceBookPageShell
};
|