@@ -63,109 +63,68 @@ var default_1 = (function (_super) {
63
63
__extends ( default_1 , _super ) ;
64
64
function default_1 ( ) {
65
65
_super . call ( this ) ;
66
- this . state = {
67
- hintPos :- 1 ,
68
- taskPos :0
69
- } ;
70
66
}
71
67
default_1 . prototype . componentDidUpdate = function ( ) {
72
- var taskPosition = this . props . taskPosition ;
68
+ var _a = this . props , taskPosition = _a . taskPosition , hintPosition = _a . hintPosition ;
73
69
if ( taskPosition > 0 && taskPosition < this . props . tasks . length ) {
74
- ReactDOM . findDOMNode ( this . refs [ 'task' + taskPosition ] ) . scrollIntoView ( ) ;
70
+ ReactDOM . findDOMNode ( this . refs . listEnd ) . scrollIntoView ( ) ;
75
71
}
76
- if ( this . state . taskPos !== taskPosition ) {
77
- this . setState ( {
78
- hintPos :- 1 ,
79
- taskPos :taskPosition
80
- } ) ;
81
- }
82
- else if ( this . state . hintPos > - 1 ) {
83
- ReactDOM . findDOMNode ( this . refs [ 'hint' + this . state . hintPos ] ) . scrollIntoView ( ) ;
72
+ if ( hintPosition > - 1 ) {
73
+ ReactDOM . findDOMNode ( this . refs . listEnd ) . scrollIntoView ( ) ;
84
74
}
85
75
else if ( this . props . page . completed && this . props . page . onPageComplete ) {
86
- ReactDOM . findDOMNode ( this . refs . onPageComplete ) . scrollIntoView ( ) ;
76
+ ReactDOM . findDOMNode ( this . refs . listEnd ) . scrollIntoView ( ) ;
87
77
}
88
78
} ;
89
79
default_1 . prototype . displayHint = function ( task ) {
80
+ var hintPosition = this . props . hintPosition ;
90
81
if ( task && task . hints && task . hints . length ) {
91
- if ( this . state . hintPos < task . hints . length - 1 ) {
92
- this . setState ( { hintPos : this . state . hintPos += 1 , taskPos : this . state . taskPos } ) ;
82
+ if ( hintPosition < task . hints . length - 1 ) {
83
+ this . props . showHint ( hintPosition + 1 ) ;
93
84
}
94
85
}
95
86
else {
96
- this . setState ( { hintPos : - 1 , taskPos : this . state . taskPos } ) ;
87
+ this . props . showHint ( - 1 ) ;
97
88
}
98
89
} ;
99
90
default_1 . prototype . render = function ( ) {
100
91
var _this = this ;
101
- var page = this . props . page ;
102
- var taskPosition = this . props . taskPosition ;
92
+ var _a = this . props , page = _a . page , taskPosition = _a . taskPosition , hintPosition = _a . hintPosition ;
103
93
var tasks = visibleTasks ( this . props . tasks , taskPosition ) ;
104
94
var currentTask = taskPosition <= tasks . length ?tasks [ taskPosition ] :null ;
105
95
var allComplete = taskPosition >= tasks . length ;
106
- return ( React . createElement ( material_ui_2 . Paper , { style :style , zDepth :1 , className :'cr-page' } ,
107
- React . createElement ( content_1 . default , { page :page } ) ,
108
- React . createElement ( material_ui_1 . Divider , null ) ,
109
- React . createElement ( material_ui_1 . List , { subheader :'Tasks' , className :'cr-tasks' , ref :'tasks' } ,
110
- tasks . map ( function ( task , index ) {
111
- var isCurrentTask = index === taskPosition ;
112
- var isDisabledTask = index > taskPosition ;
113
- var isCompletedTask = index < taskPosition ;
114
- var isFinalTask = index >= tasks . length - 1 ;
115
- var hints = hintsShown ( task , _this . state . hintPos ) ;
116
- return ( React . createElement ( "div" , null ,
117
- React . createElement ( material_ui_1 . ListItem , { ref :'task' + index , className :classnames ( {
118
- 'cr-task' :true ,
119
- 'isCompletedTask' :isCompletedTask ,
120
- 'isCurrentTask' :isCurrentTask ,
121
- 'isDisabledTask' :isDisabledTask
122
- } ) } ,
123
- React . createElement ( TaskCheckbox , { index :index , taskPosition :taskPosition , runTests :_this . props . runTests } ) ,
124
- React . createElement ( "span" , { className :'cr-task-index' } ,
125
- index + 1 ,
126
- "." ) ,
127
- React . createElement ( "div" , { className :'cr-task-description' } ,
128
- React . createElement ( _components_1 . MarkdownText , { text :task . description } )
129
- ) ) ,
130
- isCurrentTask && hints ?
131
- hints . map ( function ( hint , indexHint ) {
132
- return React . createElement ( material_ui_1 . ListItem , { className :'cr-task-hint' , ref :'hint' + indexHint } ,
133
- React . createElement ( "div" , { class :'cr-task-hint-box' } ,
134
- React . createElement ( "span" , { className :'cr-task-hint-index' } ,
135
- indexHint + 1 ,
136
- "." ) ,
137
- React . createElement ( "div" , { className :'cr-task-hint-description' } ,
138
- React . createElement ( _components_1 . MarkdownText , { text :hint } )
139
- ) )
140
- ) ;
141
- } )
142
- :null ,
143
- isFinalTask ?null :React . createElement ( material_ui_1 . Divider , null ) ) ) ;
144
- } ) ,
145
- page . completed && ! ! page . onPageComplete ?React . createElement ( material_ui_1 . ListItem , { className :'cr-task-onComplete' , ref :'onPageComplete' } ,
146
- React . createElement ( "div" , { className :'cr-task-onComplete-description' } ,
147
- React . createElement ( _components_1 . MarkdownText , { text :page . onPageComplete } )
148
- )
149
- ) :null ) ,
150
- React . createElement ( "section" , { className :'cr-page-toolbar' } ,
151
- React . createElement ( material_ui_2 . LinearProgress , { mode :'determinate' , value :taskProgress ( taskPosition , tasks . length ) , style :{ height :'6px' } } ) ,
152
- React . createElement ( material_ui_2 . Toolbar , null ,
153
- currentTask && currentTask . hints && currentTask . hints . length ?
154
- React . createElement ( material_ui_2 . ToolbarGroup , { float :'left' } , this . state . hintPos <= currentTask . hints . length - 2 ?
155
- React . createElement ( material_ui_2 . FlatButton , { className :'cr-task-showHint' , icon :React . createElement ( InfoOutline , null ) , onClick :this . displayHint . bind ( this , currentTask ) } )
156
- :React . createElement ( material_ui_2 . FlatButton , { className :'cr-task-showHint-disabled' , icon :React . createElement ( Info , null ) , disabled :true } ) )
157
- :null ,
158
- React . createElement ( material_ui_2 . ToolbarGroup , { float :'right' } , allComplete ?
159
- React . createElement ( material_ui_2 . RaisedButton , { label :'Continue' , primary :true , onClick :this . props . callNextPage } )
160
- :
161
- React . createElement ( material_ui_2 . RaisedButton , { label :'Run' , secondary :true , onClick :this . props . callRunTests } ) ) ) ) ) ) ;
96
+ return ( React . createElement ( material_ui_2 . Paper , { style :style , zDepth :1 , className :'cr-page' } , React . createElement ( content_1 . default , { page :page } ) , React . createElement ( material_ui_1 . Divider , null ) , React . createElement ( material_ui_1 . List , { subheader :'Tasks' , className :'cr-tasks' , ref :'tasks' } , tasks . map ( function ( task , index ) {
97
+ var isCurrentTask = index === taskPosition ;
98
+ var isDisabledTask = index > taskPosition ;
99
+ var isCompletedTask = index < taskPosition ;
100
+ var isFinalTask = index >= tasks . length - 1 ;
101
+ var hints = hintsShown ( task , hintPosition ) ;
102
+ return ( React . createElement ( "div" , null , React . createElement ( material_ui_1 . ListItem , { ref :'task' + index , className :classnames ( {
103
+ 'cr-task' :true ,
104
+ 'isCompletedTask' :isCompletedTask ,
105
+ 'isCurrentTask' :isCurrentTask ,
106
+ 'isDisabledTask' :isDisabledTask
107
+ } ) } , React . createElement ( TaskCheckbox , { index :index , taskPosition :taskPosition , runTests :_this . props . runTests } ) , React . createElement ( "span" , { className :'cr-task-index' } , index + 1 , "." ) , React . createElement ( "div" , { className :'cr-task-description' } , React . createElement ( _components_1 . MarkdownText , { text :task . description } ) ) ) , isCurrentTask && hints ?
108
+ hints . map ( function ( hint , indexHint ) {
109
+ return React . createElement ( material_ui_1 . ListItem , { className :'cr-task-hint' , ref :'hint' + indexHint } , React . createElement ( "div" , { class :'cr-task-hint-box' } , React . createElement ( "span" , { className :'cr-task-hint-index' } , indexHint + 1 , "." ) , React . createElement ( "div" , { className :'cr-task-hint-description' } , React . createElement ( _components_1 . MarkdownText , { text :hint } ) ) ) ) ;
110
+ } )
111
+ :null , isFinalTask ?null :React . createElement ( material_ui_1 . Divider , null ) ) ) ;
112
+ } ) , page . completed && ! ! page . onPageComplete ?React . createElement ( material_ui_1 . ListItem , { className :'cr-task-onComplete' , ref :'onPageComplete' } , React . createElement ( "div" , { className :'cr-task-onComplete-description' } , React . createElement ( _components_1 . MarkdownText , { text :page . onPageComplete } ) ) ) :null , React . createElement ( "div" , { ref :'listEnd' } ) ) , React . createElement ( "section" , { className :'cr-page-toolbar' } , React . createElement ( material_ui_2 . LinearProgress , { mode :'determinate' , value :taskProgress ( taskPosition , tasks . length ) , style :{ height :'6px' } } ) , React . createElement ( material_ui_2 . Toolbar , null , currentTask && currentTask . hints && currentTask . hints . length ?
113
+ React . createElement ( material_ui_2 . ToolbarGroup , { float :'left' } , hintPosition <= currentTask . hints . length - 2 ?
114
+ React . createElement ( material_ui_2 . FlatButton , { className :'cr-task-showHint' , icon :React . createElement ( InfoOutline , null ) , onClick :this . displayHint . bind ( this , currentTask ) } )
115
+ :React . createElement ( material_ui_2 . FlatButton , { className :'cr-task-showHint-disabled' , icon :React . createElement ( Info , null ) , disabled :true } ) )
116
+ :null , React . createElement ( material_ui_2 . ToolbarGroup , { float :'right' } , allComplete ?
117
+ React . createElement ( material_ui_2 . RaisedButton , { label :'Continue' , primary :true , onClick :this . props . callNextPage } )
118
+ :
119
+ React . createElement ( material_ui_2 . RaisedButton , { label :'Run' , secondary :true , onClick :this . props . callRunTests } ) ) ) ) ) ) ;
162
120
} ;
163
121
default_1 = __decorate ( [
164
122
react_redux_1 . connect ( null , function ( dispatch , state ) {
165
123
return {
166
124
callNextPage :function ( ) { return dispatch ( Action . nextPage ( ) ) ; } ,
167
125
callRunTests :function ( ) { return dispatch ( Action . runTests ( ) ) ; } ,
168
- toggleLog :function ( ) { return dispatch ( Action . toggleLog ( ) ) ; }
126
+ toggleLog :function ( ) { return dispatch ( Action . toggleLog ( ) ) ; } ,
127
+ showHint :function ( newHintPos ) { return dispatch ( Action . setHintPosition ( newHintPos ) ) ; }
169
128
} ;
170
129
} ) ,
171
130
__metadata ( 'design:paramtypes' , [ ] )