LessonHint code and more work toward LessonHelpControls

This commit is contained in:
Jason White 2015-07-01 19:19:24 -04:00
parent bcfc1be59c
commit ebfcdba3dd
8 changed files with 84 additions and 8 deletions

View File

@ -97,7 +97,7 @@
<div class="row">
<div class="col-md-8">
<div class="col-md-12" align="left">
<div class="panel">
<div class="panel" id="help-controls">
<div id="help-buttons" class="panel-body">
<!-- <button type="button" id="showSourceBtn" ng-show="showSource" class="btn btn-primary btn-xs" onclick="showLessonSource()">Java [Source]</button>
<button type="button" id="showSolutionBtn" class="btn btn-primary btn-xs" onclick="showLessonSolution()">Solution</button>

View File

@ -6,6 +6,7 @@ define(['jquery',
'goatApp/view/PlanView',
'goatApp/view/SourceView',
'goatApp/view/SolutionView',
'goatApp/view/LessonHintView'
],
function($,
_,
@ -14,7 +15,8 @@ define(['jquery',
LessonContentView,
PlanView,
SourceView,
SolutionView
SolutionView,
LessonHintView
) {
'use strict'
@ -22,6 +24,7 @@ define(['jquery',
var Controller = function(options) {
this.lessonContent = new LessonContentData();
this.lessonView = options.lessonView;
/*this.planView = new PlanView();
this.solutionView = new SolutionView();
this.sourceView = new SourceView();
@ -34,12 +37,17 @@ define(['jquery',
//load View, which can pull data
this.loadLesson = function(scr,menu) {
this.helpsLoaded = {};
this.lessonContent.loadData({
'screen': encodeURIComponent(scr),
'menu': encodeURIComponent(menu),
});
//this.registerListeners();
this.planView = {};
this.solutionView = {};
this.sourceView = {};
this.lessonHintView = {};
//
};
this.onContentLoaded = function() {
@ -57,7 +65,12 @@ define(['jquery',
//source (initially hidden)
this.sourceView = new SourceView();
//load help controls view (contextul to what helps are available)
this.lessonHintView = new LessonHintView();
this.listenTo(this.lessonHintView,'hints:loaded',this.areHelpsReady);
},
this.areHelpsReady = function (curHelp) {
this.helpsLoaded[curHelp.helpElement] = curHelp.value;
// check if all are ready
}
};

View File

@ -5,7 +5,6 @@ define(['jquery','underscore','backbone','goatApp/view/GoatRouter'],
return {
initApp: function() {
//TODO: add query/ability to load from where they left off
console.log('initApp')
var goatRouter = new Router();
goatRouter.init();
}

View File

@ -0,0 +1,24 @@
define(['jquery',
'underscore',
'backbone',
'goatApp/model/LessonHintModel'],
function($,_,Backbone,LessonHintModel) {
return Backbone.Collection.extend({
model: LessonHintModel,
url:'service/hint.mvc',
initialize: function () {
var self = this;
this.fetch().then(function (data) {
this.models = data;
self.onDataLoaded();
});
},
onDataLoaded:function() {
this.trigger('hints:loaded');//copied over as boiler-plate ... use this event trigger?
},
checkNullModel:function() {
//
}
});
});

View File

@ -0,0 +1,10 @@
define(['jquery',
'underscore',
'backbone'],
function($,
_,
Backbone,
HTMLContentModel) {
return Backbone.Model.extend({
});
});

View File

@ -6,7 +6,6 @@ define(['jquery',
_,
Backbone,
HTMLContentModel) {
//TODO: make a base class to extend for items with 'traditional data' (e.g. LessonContentData, this ... others?)
return HTMLContentModel.extend({
url:'service/lessonplan.mvc',
checkNullModel: function() {

View File

@ -3,7 +3,16 @@ define(['jquery',
'backbone'],
function($,_,Backbone) {
return Backbone.View.extend({
el:'#lessonHelp', //Check this
el:'#help-controls', //Check this
initialize: function (options) {
if (!options) {
return;
}
this.hasPlan = options.hasPlan;
this.hasSolution = options.hasSolution;
this.hasSource = options.hasSource;
this.hasHints = options.hasHints;
},
render:function(title) {
}

View File

@ -0,0 +1,22 @@
define(['jquery',
'underscore',
'backbone',
'goatApp/model/LessonHintCollection'],
function($,
_,
Backbone,
LessonHintCollection) {
return Backbone.View.extend({
el:'#lessonHelpWrapper .lessonHelp.lessonHint',
initialize: function() {
this.collection = new LessonHintCollection();
this.listenTo(this.collection,'hints:loaded',this.onModelLoaded);
},
render:function(title) {
},
onModelLoaded: function() {
this.trigger('hints:loaded',{'helpElement':'hints','value':true})
}
});
});