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="row">
<div class="col-md-8"> <div class="col-md-8">
<div class="col-md-12" align="left"> <div class="col-md-12" align="left">
<div class="panel"> <div class="panel" id="help-controls">
<div id="help-buttons" class="panel-body"> <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="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> <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/PlanView',
'goatApp/view/SourceView', 'goatApp/view/SourceView',
'goatApp/view/SolutionView', 'goatApp/view/SolutionView',
'goatApp/view/LessonHintView'
], ],
function($, function($,
_, _,
@ -14,7 +15,8 @@ define(['jquery',
LessonContentView, LessonContentView,
PlanView, PlanView,
SourceView, SourceView,
SolutionView SolutionView,
LessonHintView
) { ) {
'use strict' 'use strict'
@ -22,6 +24,7 @@ define(['jquery',
var Controller = function(options) { var Controller = function(options) {
this.lessonContent = new LessonContentData(); this.lessonContent = new LessonContentData();
this.lessonView = options.lessonView; this.lessonView = options.lessonView;
/*this.planView = new PlanView(); /*this.planView = new PlanView();
this.solutionView = new SolutionView(); this.solutionView = new SolutionView();
this.sourceView = new SourceView(); this.sourceView = new SourceView();
@ -34,12 +37,17 @@ define(['jquery',
//load View, which can pull data //load View, which can pull data
this.loadLesson = function(scr,menu) { this.loadLesson = function(scr,menu) {
this.helpsLoaded = {};
this.lessonContent.loadData({ this.lessonContent.loadData({
'screen': encodeURIComponent(scr), 'screen': encodeURIComponent(scr),
'menu': encodeURIComponent(menu), 'menu': encodeURIComponent(menu),
}); });
this.planView = {};
//this.registerListeners(); this.solutionView = {};
this.sourceView = {};
this.lessonHintView = {};
//
}; };
this.onContentLoaded = function() { this.onContentLoaded = function() {
@ -57,7 +65,12 @@ define(['jquery',
//source (initially hidden) //source (initially hidden)
this.sourceView = new SourceView(); this.sourceView = new SourceView();
//load help controls view (contextul to what helps are available) //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 { return {
initApp: function() { initApp: function() {
//TODO: add query/ability to load from where they left off //TODO: add query/ability to load from where they left off
console.log('initApp')
var goatRouter = new Router(); var goatRouter = new Router();
goatRouter.init(); 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, Backbone,
HTMLContentModel) { HTMLContentModel) {
//TODO: make a base class to extend for items with 'traditional data' (e.g. LessonContentData, this ... others?)
return HTMLContentModel.extend({ return HTMLContentModel.extend({
url:'service/lessonplan.mvc', url:'service/lessonplan.mvc',
checkNullModel: function() { checkNullModel: function() {

View File

@ -3,7 +3,16 @@ define(['jquery',
'backbone'], 'backbone'],
function($,_,Backbone) { function($,_,Backbone) {
return Backbone.View.extend({ 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) { 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})
}
});
});