3
3
4
4
/* ### GOAT CONTROLLERS ### */
5
5
6
- /** Lesson Controller (includes menu stuff)
7
- * prepares and updates menu topic items for the view
8
- */
9
- //<<<<<<< Updated upstream
10
- //goat.controller('goatLesson', function($scope, $http, $modal, $log, $sce) { //$templateCache
11
- //=======
6
+ /* menu controller */
12
7
var goatMenu = function ( $scope , $http , $modal , $log , $templateCache ) {
13
8
$scope . cookies = [ ] ;
14
9
$scope . params = [ ] ;
@@ -36,7 +31,7 @@ var goatMenu = function($scope, $http, $modal, $log, $templateCache) {
36
31
// use jquery to render lesson content to div
37
32
$scope . hintIndex = 0 ;
38
33
var curScope = $scope ;
39
-
34
+ $ ( '.lessonHelp' ) . hide ( ) ;
40
35
curScope . parameters = goat . utils . scrapeParams ( url ) ;
41
36
goat . data . loadLessonContent ( $http , url ) . then (
42
37
function ( reply ) {
@@ -47,6 +42,7 @@ var goatMenu = function($scope, $http, $modal, $log, $templateCache) {
47
42
) ;
48
43
$ ( "#lesson_content" ) . html ( reply . data ) ;
49
44
$ ( '#leftside-navigation' ) . height ( $ ( '#main-content' ) . height ( ) + 15 )
45
+ $scope . $emit ( 'lessonUpdate' , { params :curScope . parameters } ) ;
50
46
}
51
47
) } ;
52
48
$scope . accordionMenu = function ( id ) {
@@ -86,53 +82,55 @@ var goatMenu = function($scope, $http, $modal, $log, $templateCache) {
86
82
87
83
});*/
88
84
85
+ /* lesson controller */
89
86
var goatLesson = function ( $scope , $http , $log ) {
90
87
//hook forms
91
88
92
89
$ ( '#hintsView' ) . hide ( ) ;
93
90
// adjust menu to lessonContent size if necssary
94
- //@TODO : this is still clunky ... needs some TLC
95
- if ( $ ( 'div.panel-body' ) . height ( ) > 400 ) {
96
- $ ( '#leftside-navigation' ) . height ( $ ( window ) . height ( ) ) ;
91
+ //cookies
92
+
93
+ $scope . $on ( 'lessonUpdate' , function ( params ) {
94
+ $scope . parameters = arguments [ 1 ] ;
95
+ curScope = $scope ; //TODO .. update below, this curScope is probably not needed
96
+ goat . data . loadCookies ( $http ) . then (
97
+ function ( resp ) {
98
+ curScope . cookies = resp . data ;
97
99
}
98
- //cookies
99
- goat . data . loadCookies ( $http ) . then (
100
- function ( resp ) {
101
- curScope . cookies = resp . data ;
102
- }
103
- ) ;
104
- //hints
105
- curScope = $scope ; //TODO .. update below, this curScope is probably not needed
106
- curScope . hintIndex = 0 ;
107
- goat . data . loadHints ( $http ) . then (
108
- function ( resp ) {
109
- curScope . hints = resp . data ;
110
- if ( curScope . hints . length > 0 && curScope . hints [ 0 ] . hint . indexOf ( goatConstants . noHints ) === - 1 ) {
111
- goat . utils . displayButton ( 'showHintsBtn' , true ) ;
112
- } else {
113
- goat . utils . displayButton ( 'showHintsBtn' , false ) ;
114
- }
115
- }
116
- ) ;
117
- //source
118
- goat . data . loadSource ( $http ) . then (
119
- function ( resp ) {
120
- curScope . source = resp . data ;
121
- }
122
- ) ;
123
- //plan
124
- goat . data . loadPlan ( $http ) . then (
125
- function ( resp ) {
126
- curScope . plan = resp . data ;
127
- }
128
- ) ;
129
- //solution
130
- goat . data . loadSolution ( $http ) . then (
131
- function ( resp ) {
132
- curScope . solution = resp . data ;
133
- }
134
- ) ;
135
- goat . utils . scrollToTop ( ) ;
100
+ ) ;
101
+ //hints
102
+ curScope . hintIndex = 0 ;
103
+ goat . data . loadHints ( $http ) . then (
104
+ function ( resp ) {
105
+ curScope . hints = resp . data ;
106
+ if ( curScope . hints . length > 0 && curScope . hints [ 0 ] . hint . indexOf ( goatConstants . noHints ) === - 1 ) {
107
+ goat . utils . displayButton ( 'showHintsBtn' , true ) ;
108
+ } else {
109
+ goat . utils . displayButton ( 'showHintsBtn' , false ) ;
110
+ }
111
+ }
112
+ ) ;
113
+ //source
114
+ goat . data . loadSource ( $http ) . then (
115
+ function ( resp ) {
116
+ curScope . source = resp . data ;
117
+ }
118
+ ) ;
119
+ //plan
120
+ goat . data . loadPlan ( $http ) . then (
121
+ function ( resp ) {
122
+ curScope . plan = resp . data ;
123
+ }
124
+ ) ;
125
+ //solution
126
+ goat . data . loadSolution ( $http ) . then (
127
+ function ( resp ) {
128
+ curScope . solution = resp . data ;
129
+ }
130
+ ) ;
131
+ } ) ;
132
+
133
+ //goat.utils.scrollToTop();
136
134
137
135
138
136
$scope . showLessonSource = function ( ) {
0 commit comments