@@ -11,12 +11,31 @@ var goatMenu = function($scope, $http, $modal, $log, $templateCache) {
11
11
goat . data . loadMenu ( $http ) . then ( //$http({method: 'GET', url: goatConstants.lessonService})
12
12
function ( menuData ) {
13
13
var menuItems = goat . utils . addMenuClasses ( goatConstants . menuPrefix . concat ( menuData . data ) ) ;
14
+ //top-tier 'categories'
14
15
for ( var i = 0 ; i < menuItems . length ; i ++ ) {
15
- if ( menuItems [ i ] . name ) {
16
- menuItems [ i ] . id = menuItems [ i ] . name . replace ( / \s | \( | \) / g, '' ) ;
16
+ menuItems [ i ] . id = menuItems [ i ] . name . replace ( / \s | \( | \) / g, '' ) ;
17
+ if ( menuItems [ i ] . children ) {
18
+ for ( var j = 0 ; j < menuItems [ i ] . children . length ; j ++ ) {
19
+ menuItems [ i ] . children [ j ] . id = menuItems [ i ] . children [ j ] . name . replace ( / \s | \( | \) / g, '' ) ;
20
+ if ( menuItems [ i ] . children [ j ] . complete ) {
21
+ menuItems [ i ] . children [ j ] . completeClass = goatConstants . lessonCompleteClass ;
22
+ } else {
23
+ menuItems [ i ] . children [ j ] . completeClass = '' ;
24
+ }
25
+ if ( menuItems [ i ] . children [ j ] . children ) {
26
+ for ( var k = 0 ; k < menuItems [ i ] . children [ j ] . children . length ; k ++ ) {
27
+ //TODO make utility function for name >> id
28
+ menuItems [ i ] . children [ j ] . children [ k ] . id = menuItems [ i ] . children [ j ] . children [ k ] . name . replace ( / \s | \( | \) / g, '' ) ;
29
+ if ( menuItems [ i ] . children [ j ] . children [ k ] . complete ) {
30
+ menuItems [ i ] . children [ j ] . children [ k ] . completeClass = goatConstants . lessonCompleteClass ;
31
+ } else {
32
+ menuItems [ i ] . children [ j ] . children [ k ] . completeClass = ''
33
+ }
34
+ }
35
+ }
36
+ }
17
37
}
18
38
}
19
-
20
39
$scope . menuTopics = menuItems ;
21
40
} ,
22
41
function ( error ) {
@@ -26,13 +45,20 @@ var goatMenu = function($scope, $http, $modal, $log, $templateCache) {
26
45
) ;
27
46
} ;
28
47
29
- $scope . renderLesson = function ( url ) {
48
+ $scope . renderLesson = function ( id , url ) {
30
49
//console.log(url + ' was passed in');
31
50
// use jquery to render lesson content to div
32
51
$scope . hintIndex = 0 ;
33
52
var curScope = $scope ;
34
53
$ ( '.lessonHelp' ) . hide ( ) ;
54
+ // clean up menus, mark selected
55
+ $ ( 'ul li.selected' ) . removeClass ( goatConstants . selectedMenuClass )
56
+ $ ( 'ul li.selected a.selected' ) . removeClass ( goatConstants . selectedMenuClass )
57
+ $ ( '#' + id ) . addClass ( goatConstants . selectedMenuClass ) ;
58
+ $ ( '#' + id ) . parent ( ) . addClass ( goatConstants . selectedMenuClass ) ;
59
+ //
35
60
curScope . parameters = goat . utils . scrapeParams ( url ) ;
61
+ // lesson content
36
62
goat . data . loadLessonContent ( $http , url ) . then (
37
63
function ( reply ) {
38
64
goat . data . loadLessonTitle ( $http ) . then (
@@ -41,6 +67,8 @@ var goatMenu = function($scope, $http, $modal, $log, $templateCache) {
41
67
}
42
68
) ;
43
69
$ ( "#lesson_content" ) . html ( reply . data ) ;
70
+ //hook forms
71
+ goat . utils . makeFormsAjax ( ) ;
44
72
$ ( '#leftside-navigation' ) . height ( $ ( '#main-content' ) . height ( ) + 15 )
45
73
$scope . $emit ( 'lessonUpdate' , { params :curScope . parameters } ) ;
46
74
}
@@ -56,35 +84,16 @@ var goatMenu = function($scope, $http, $modal, $log, $templateCache) {
56
84
if ( $scope . expandMe ) {
57
85
$ ( 'ul#' + id ) . slideDown ( 300 ) . attr ( 'isOpen' , 1 ) ;
58
86
}
59
- console . log ( 'accordion for ' + id ) ;
60
87
}
61
88
$scope . renderMenu ( ) ;
62
- //can be augmented later to 'resume' for a given user ... currently kluged to start at fixed lesson
89
+ // runs on first loadcan be augmented later to '
90
+ // resume' for a given user ... currently kluged to start at fixed lesson
63
91
var url = 'attack?Screen=32&menu=5' ;
64
- angular . element ( $ ( '#leftside-navigation' ) ) . scope ( ) . renderLesson ( url ) ;
92
+ angular . element ( $ ( '#leftside-navigation' ) ) . scope ( ) . renderLesson ( null , url ) ;
65
93
}
66
94
67
- /*goatMenu.animation('.slideDown', function() {
68
- var NgHideClassName = 'ng-hide';
69
- return {
70
- beforeAddClass: function(element, className, done) {
71
- if (className === NgHideClassName) {
72
- $(element).slideUp(done);
73
- }
74
- },
75
- removeClass: function(element, className, done) {
76
- if (className === NgHideClassName) {
77
- $(element).hide().slideDown(done);
78
- }
79
- }
80
- };
81
-
82
-
83
- });*/
84
-
85
95
/* lesson controller */
86
96
var goatLesson = function ( $scope , $http , $log ) {
87
- //hook forms
88
97
89
98
$ ( '#hintsView' ) . hide ( ) ;
90
99
// adjust menu to lessonContent size if necssary
0 commit comments