Skip to content

Commit 5372d79

Browse files
author
Jason White
committed
menu decoration updates
1 parent 1a1a8bf commit 5372d79

File tree

4 files changed

+57
-29
lines changed

4 files changed

+57
-29
lines changed

src/main/webapp/WEB-INF/pages/main_new.jsp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
<!-- end of CSS -->
2828

2929
<!-- JS -->
30+
<script src="js/jquery/jquery-1.10.2.min.js"></script>
3031
<script src="js/angular/angular.min.js"></script>
3132
<!-- angular modules -->
3233
<script src="js/angular/angular-animate.min.js"></script>
@@ -40,7 +41,7 @@
4041
<![endif]-->
4142

4243
<!--Global JS-->
43-
<script src="js/jquery/jquery-1.10.2.min.js"></script>
44+
4445
<script src="js/jquery_form/jquery.form.js"></script>
4546
<script src="plugins/bootstrap/js/bootstrap.min.js"></script>
4647

@@ -114,9 +115,9 @@
114115
<a ng-click="accordionMenu(item.id)" href=""><i class="fa {{item.class}}"></i><span>{{item.name}}</span></a><!-- expanded = !expanded-->
115116
<ul class="slideDown lessonsAndStages" id="{{item.id}}" isOpen=0>
116117
<li ng-repeat="lesson in item.children">
117-
<a ng-click="renderLesson(lesson.link)" title="link to {{lesson.name}}" href="">{{lesson.name}}</a>
118+
<a ng-click="renderLesson(lesson.id,lesson.link)" id="{{lesson.id}}" title="link to {{lesson.name}}" href="">{{lesson.name}}</a><span class="{{lesson.completeClass}}"></span>
118119
<span ng-repeat="stage in lesson.children" >
119-
<a ng-click="renderLesson(stage.link)" title="link to {{stage.name}}" href="">{{stage.name}}</a>
120+
<a ng-click="renderLesson(lesson.id,stage.link)" id="{{stage.id}}" title="link to {{stage.name}}" href="">{{stage.name}}</a><span class="{{stage.completeClass}}"></span>
120121
</span>
121122
</li>
122123
</ul>

src/main/webapp/css/main.css

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -801,6 +801,22 @@ fieldset[disabled] .btn-warning.active {
801801
max-width: 200px;
802802
font-size: x-small;
803803
}
804+
/* MENU */
805+
.sidebar ul span.lessonComplete {
806+
float: right;
807+
margin-left: -5px;
808+
/*margin-right: 5px;*/
809+
padding-top: 15px;
810+
}
811+
812+
#leftside-navigation ul li.selected {
813+
background-color: #555;
814+
}
815+
816+
#leftside-navigation ul li.selected a.selected {
817+
color:white;
818+
}
819+
804820

805821
/* HINTS */
806822
#hintsViewTop{

src/main/webapp/js/goatConstants.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
var goatConstants = {
44
CATEGORYCLASS:'fa-angle-right pull-right',
5+
lessonCompleteClass:'glyphicon glyphicon-check lessonComplete',
6+
selectedMenuClass:'selected',
57
menuPrefix : [
68
{
79
name:'LESSONS',

src/main/webapp/js/goatControllers.js

Lines changed: 35 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,31 @@ var goatMenu = function($scope, $http, $modal, $log, $templateCache) {
1111
goat.data.loadMenu($http).then( //$http({method: 'GET', url: goatConstants.lessonService})
1212
function(menuData) {
1313
var menuItems = goat.utils.addMenuClasses(goatConstants.menuPrefix.concat(menuData.data));
14+
//top-tier 'categories'
1415
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+
}
1737
}
1838
}
19-
2039
$scope.menuTopics = menuItems;
2140
},
2241
function(error) {
@@ -26,13 +45,20 @@ var goatMenu = function($scope, $http, $modal, $log, $templateCache) {
2645
);
2746
};
2847

29-
$scope.renderLesson = function(url) {
48+
$scope.renderLesson = function(id,url) {
3049
//console.log(url + ' was passed in');
3150
// use jquery to render lesson content to div
3251
$scope.hintIndex = 0;
3352
var curScope = $scope;
3453
$('.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+
//
3560
curScope.parameters = goat.utils.scrapeParams(url);
61+
// lesson content
3662
goat.data.loadLessonContent($http,url).then(
3763
function(reply) {
3864
goat.data.loadLessonTitle($http).then(
@@ -41,6 +67,8 @@ var goatMenu = function($scope, $http, $modal, $log, $templateCache) {
4167
}
4268
);
4369
$("#lesson_content").html(reply.data);
70+
//hook forms
71+
goat.utils.makeFormsAjax();
4472
$('#leftside-navigation').height($('#main-content').height()+15)
4573
$scope.$emit('lessonUpdate',{params:curScope.parameters});
4674
}
@@ -56,35 +84,16 @@ var goatMenu = function($scope, $http, $modal, $log, $templateCache) {
5684
if ($scope.expandMe) {
5785
$('ul#'+id).slideDown(300).attr('isOpen',1);
5886
}
59-
console.log('accordion for ' + id);
6087
}
6188
$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
6391
var url = 'attack?Screen=32&menu=5';
64-
angular.element($('#leftside-navigation')).scope().renderLesson(url);
92+
angular.element($('#leftside-navigation')).scope().renderLesson(null,url);
6593
}
6694

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-
8595
/* lesson controller */
8696
var goatLesson = function($scope,$http,$log) {
87-
//hook forms
8897

8998
$('#hintsView').hide();
9099
// adjust menu to lessonContent size if necssary

0 commit comments

Comments
 (0)