Merge pull request #153 from misfir3/master

#133 hiding hint on change of lesson/loesson load
This commit is contained in:
Nanne 2015-12-02 21:34:32 +01:00
commit 5bd348f975
5 changed files with 19 additions and 19 deletions

View File

@ -52,7 +52,6 @@ define(['jquery',
}; };
this.loadLesson = function(scr,menu,stage,num) { this.loadLesson = function(scr,menu,stage,num) {
console.log("Loading a lesson, scr: " + scr + ", menu: " + menu + ", stage: " + stage + ", num: " + num);
this.titleView = new TitleView(); this.titleView = new TitleView();
this.helpsLoaded = {}; this.helpsLoaded = {};
if (typeof(scr) == "undefined") { if (typeof(scr) == "undefined") {
@ -85,7 +84,6 @@ define(['jquery',
}; };
this.onInfoLoaded = function() { this.onInfoLoaded = function() {
console.log("Lesson info loaded")
this.helpControlsView = new HelpControlsView({ this.helpControlsView = new HelpControlsView({
hasPlan:this.lessonInfoModel.get('hasPlan'), hasPlan:this.lessonInfoModel.get('hasPlan'),
hasSolution:this.lessonInfoModel.get('hasSolution'), hasSolution:this.lessonInfoModel.get('hasSolution'),
@ -105,7 +103,6 @@ define(['jquery',
}; };
this.onContentLoaded = function(loadHelps) { this.onContentLoaded = function(loadHelps) {
console.log("Lesson content loaded")
this.lessonInfoModel = new LessonInfoModel(); this.lessonInfoModel = new LessonInfoModel();
this.listenTo(this.lessonInfoModel,'info:loaded',this.onInfoLoaded); this.listenTo(this.lessonInfoModel,'info:loaded',this.onInfoLoaded);

View File

@ -12,6 +12,7 @@ define(['jquery',
//var id = //var id =
return lessonName.replace(/\s|\(|\)|\!|\:|\;|\@|\#|\$|\%|\^|\&|\*/g, ''); return lessonName.replace(/\s|\(|\)|\!|\:|\;|\@|\#|\$|\%|\^|\&|\*/g, '');
}, },
addMenuClasses: function(arr) { addMenuClasses: function(arr) {
for (var i = 0; i < arr.length; i++) { for (var i = 0; i < arr.length; i++) {
var menuItem = arr[i]; var menuItem = arr[i];
@ -46,7 +47,8 @@ define(['jquery',
if (show) { if (show) {
$('#' + id).show(); $('#' + id).show();
} else { } else {
a }
}
} }
}, },

View File

@ -40,13 +40,12 @@ define(['jquery',
goatRouter.on('route:attackRoute', function(scr,menu,stage,num) { goatRouter.on('route:attackRoute', function(scr,menu,stage,num) {
this.lessonController.loadLesson(scr,menu,stage,num); this.lessonController.loadLesson(scr,menu,stage,num);
this.menuController.updateMenu(scr,menu); this.menuController.updateMenu(scr,menu);
//update menu
}); });
goatRouter.on('route:welcomeRoute', function() { goatRouter.on('route:welcomeRoute', function() {
this.lessonController.loadWelcome(); this.lessonController.loadWelcome();
}); });
goatRouter.on("route", function(route, params) { goatRouter.on("route", function(route, params) {
console.log("Got a route event: " + route + ", params: " + params);
}); });
Backbone.history.start(); Backbone.history.start();

View File

@ -16,7 +16,7 @@ function($,
this.curHint=0; this.curHint=0;
this.collection = new HintCollection(); this.collection = new HintCollection();
this.listenTo(this.collection,'loaded',this.onModelLoaded); this.listenTo(this.collection,'loaded',this.onModelLoaded);
this.hideHints();
}, },
render:function() { render:function() {
@ -37,6 +37,12 @@ function($,
this.trigger('hints:loaded',{'helpElement':'hints','value':true}) this.trigger('hints:loaded',{'helpElement':'hints','value':true})
}, },
hideHints: function() {
if (this.$el.is(':visible')) {
this.$el.hide(350);
}
},
showNextHint: function() { showNextHint: function() {
this.curHint = (this.curHint < this.collection.length -1) ? this.curHint+1 : this.curHint; this.curHint = (this.curHint < this.collection.length -1) ? this.curHint+1 : this.curHint;
this.hideShowPrevNextButtons(); this.hideShowPrevNextButtons();

View File

@ -50,7 +50,6 @@ define(['jquery',
catLink.append(catArrow); catLink.append(catArrow);
catLink.append(catLinkText); catLink.append(catLinkText);
//TODO: refactor this along with sub-views/components
var self = this; var self = this;
catLink.click(_.bind(this.expandCategory,this,catId)); catLink.click(_.bind(this.expandCategory,this,catId));
category.append(catLink); category.append(catLink);
@ -62,12 +61,12 @@ define(['jquery',
for (var j=0; j < lessons.length;j++) { for (var j=0; j < lessons.length;j++) {
var lessonItem = $('<li>',{class:'lesson'}); var lessonItem = $('<li>',{class:'lesson'});
var lessonName = lessons[j].name; var lessonName = lessons[j].name;
var lessonId = GoatUtils.makeId(lessonName); var lessonId = catId + '-' + GoatUtils.makeId(lessonName);
if (this.curLessonLinkId === lessonId) { if (this.curLessonLinkId === lessonId) {
lessonItem.addClass('selected'); lessonItem.addClass('selected');
} }
var lessonLink = $('<a>',{href:lessons[j].link,text:lessonName,id:lessonId}); var lessonLink = $('<a>',{href:lessons[j].link,text:lessonName,id:lessonId});
lessonLink.click(_.bind(this.onLessonClick,this,lessonName)); lessonLink.click(_.bind(this.onLessonClick,this,lessonId));
lessonItem.append(lessonLink); lessonItem.append(lessonLink);
//check for lab/stages //check for lab/stages
categoryLessonList.append(lessonItem); categoryLessonList.append(lessonItem);
@ -78,12 +77,12 @@ define(['jquery',
for (k=0; k < stages.length; k++) { for (k=0; k < stages.length; k++) {
var stageItem = $('<li>',{class:'stage'}); var stageItem = $('<li>',{class:'stage'});
var stageName = stages[k].name; var stageName = stages[k].name;
var stageId = GoatUtils.makeId(stageName); var stageId = lessonId + '-stage' + k;
if (this.curLessonLinkId === stageId) { if (this.curLessonLinkId === stageId) {
stageItem.addClass('selected'); stageItem.addClass('selected');
} }
var stageLink = $('<a>',{href:stages[k].link,text:stageName,id:stageId}); var stageLink = $('<a>',{href:stages[k].link,text:stageName,id:stageId});
stageLink.click(_.bind(this.onLessonClick,this,stageName)); stageLink.click(_.bind(this.onLessonClick,this,stageId));
stageItem.append(stageLink); stageItem.append(stageLink);
categoryLessonList.append(stageItem); categoryLessonList.append(stageItem);
if (stages[k].complete) { if (stages[k].complete) {
@ -108,14 +107,11 @@ define(['jquery',
this.collection.fetch(); this.collection.fetch();
}, },
onLessonClick: function (title) { onLessonClick: function (elementId) {
var oldLinkId = GoatUtils.makeId(this.curLessonLinkId); $('#'+this.curLessonLinkId).removeClass('selected');
$('#'+oldLinkId).removeClass('selected');
//update //update
this.curLessonLinkId = GoatUtils.makeId(title); $('#'+elementId).addClass('selected');
var newLinkId = GoatUtils.makeId(this.curLessonLinkId) this.curLessonLinkId = elementId;
$('#'+newLinkId).addClass('selected');
this.trigger('lesson:click', title); // will cause menu reload
}, },
expandCategory: function (id) { expandCategory: function (id) {