Plan, Source and Solution View (and models), initial stub for HelpControlsView

This commit is contained in:
Jason White 2015-06-26 18:05:21 -04:00
parent ba86d2d6d6
commit 998401a631
12 changed files with 192 additions and 29 deletions

View File

@ -2,20 +2,34 @@ define(['jquery',
'underscore',
'libs/backbone',
'goatApp/model/LessonContentData',
'goatApp/view/LessonContentView'
'goatApp/view/LessonContentView',
'goatApp/view/PlanView',
'goatApp/view/SourceView',
'goatApp/view/SolutionView',
],
function($,_,Backbone,LessonContentData,LessonContentView) {
function($,
_,
Backbone,
LessonContentData,
LessonContentView,
PlanView,
SourceView,
SolutionView
) {
'use strict'
var Controller = function(options) {
this.lessonView = options.lessonView;
this.lessonContent = new LessonContentData();
this.lessonView = options.lessonView;
/*this.planView = new PlanView();
this.solutionView = new SolutionView();
this.sourceView = new SourceView();
*/
_.extend(Controller.prototype,Backbone.Events);
this.start = function() {
this.listenTo(this.lessonContent,'contentLoaded',this.onContentLoaded);
}
//load View, which can pull data
@ -35,14 +49,13 @@ define(['jquery',
//load cookies/parameters view
//load title view (initially hidden)
//load title view (initially hidden) << currently handled via menu click but need to be able to handle via routed request
//plan view (initially hidden)
this.planView = new PlanView();
//solution view (initially hidden)
this.solutionView = new SolutionView();
//source (initially hidden)
this.sourceView = new SourceView();
//load help controls view (contextul to what helps are available)
}

View File

@ -0,0 +1,27 @@
define(['jquery',
'underscore',
'backbone'],
function($,_,Backbone) {
//TODO: make a base class to extend for items with 'traditional data' (e.g. LessonContentData, this ... others?)
return Backbone.Model.extend({
//url:'service/lessonplan.mvc',
fetch: function (options) {
options = options || {};
return Backbone.Model.prototype.fetch.call(this, _.extend({ dataType: "html"}, options));
},
loadData: function() {
var self=this;
this.fetch().then(function(data) {
self.setContent(data);
self.onModelLoaded();
});
},
setContent: function(content) {
this.set('content',content);
this.trigger('loaded');
},
onModelLoaded: function() {
this.checkNullModel();
}
});
});

View File

@ -1,9 +1,13 @@
define(['jquery',
'underscore',
'backbone'],
function($,_,Backbone){
'backbone',
'goatApp/model/HTMLContentModel'],
function($,
_,
Backbone,
HTMLContentModel){
return Backbone.Model.extend({
return HTMLContentModel.extend({
urlRoot:null,
defaults: {
items:null,
@ -15,7 +19,7 @@ define(['jquery',
this.baseUrlRoot = 'attack?Screen=';//
},
loadData: function(options) {
this.urlRoot = this.baseUrlRoot + +options.screen + '&menu=' + options.menu;
this.urlRoot = this.baseUrlRoot +options.screen + '&menu=' + options.menu;
this.set('menuParam',options.menu);
this.set('screenParam',options.screen);
@ -31,13 +35,6 @@ define(['jquery',
fetch: function (options) {
options = options || {};
return Backbone.Model.prototype.fetch.call(this, _.extend({ dataType: "html"}, options));
// var self=this;
// Backbone.Model.prototype.fetch.apply(this, arguments).then(
// function(content){
// self.setContent(content);
// });
// //override with prototype
}
});
});

View File

@ -0,0 +1,19 @@
define(['jquery',
'underscore',
'backbone',
'goatApp/model/HTMLContentModel'],
function($,
_,
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() {
if (this.get('content').indexOf('Plan is not available for this lesson.') > -1) {
this.set('content',null);
}
}
});
});

View File

@ -0,0 +1,18 @@
define(['jquery',
'underscore',
'backbone',
'goatApp/model/HTMLContentModel'],
function($,
_,
Backbone,
HTMLContentModel) {
return HTMLContentModel.extend({
url:'service/solution.mvc',
checkNullModel: function() {
if (this.get('content').indexOf('Solution is not available. Contact') === 0) {
this.set('content',null);
}
}
});
});

View File

@ -0,0 +1,19 @@
define(['jquery',
'underscore',
'backbone',
'goatApp/model/HTMLContentModel'],
function($,
_,
Backbone,
HTMLContentModel) {
return HTMLContentModel.extend({
url:'service/source.mvc',
checkNullModel: function () {
//TODO: move this function into HTMLContentModel and make the string a property of this 'child' model
if (this.get('content').indexOf("No source listing found") > -1) {
this.set('content',null);
}
}
});
});

View File

@ -0,0 +1,11 @@
define(['jquery',
'underscore',
'backbone'],
function($,_,Backbone) {
return Backbone.View.extend({
el:'#lessonHelp', //Check this
render:function(title) {
}
});
});

View File

@ -11,7 +11,6 @@ function($,_,Backbone,JQueryForm,LessonData) {
options = options || {};
},
render: function() {
//alert('render');
this.$el.html(this.model.get('content'));
this.makeFormsAjax();
},

View File

@ -75,7 +75,6 @@ define(['jquery',
}
},
triggerTitleRender: function (title) {
console.debug('title:'+title);
this.trigger('lesson:click',title);
},
expandCategory: function (id) {
@ -86,17 +85,12 @@ define(['jquery',
accordionMenu: function(id) {
if (this.openMenu !== id) {
this.$el.find('#' + id).slideDown(300);
this.openMenu = id;
} else { //it's open
this.$el.find('#' + id).slideUp(300).attr('isOpen', 0);
this.openMenu = null;
return;
}
this.openMenu = id;
this.$el.find('.lessonsAndStages').not('ul#' + id).slideUp(300);
/* //legacy angular code that may be usefl
if ($scope.expandMe) {
$('ul#' + id).slideDown(300).attr('isOpen', 1);
}
*/
}
});
});

View File

@ -0,0 +1,23 @@
define(['jquery',
'underscore',
'backbone',
'goatApp/model/LessonPlanModel'],
function($,
_,
Backbone,
LessonPlanModel) {
return Backbone.View.extend({
el:'#lessonHelpWrapper .lessonHelp.lessonPlan', //Check this
initialize: function() {
this.model = new LessonPlanModel();
this.listenTo(this.model,'loaded',this.onModelLoaded);
this.model.loadData();
},
render:function(title) {
},
onModelLoaded: function() {
// ???
}
});
});

View File

@ -0,0 +1,20 @@
define(['jquery',
'underscore',
'backbone',
'goatApp/model/LessonSolutionModel'],
function($,_,Backbone,LessonSolutionModel) {
return Backbone.View.extend({
el:'#lessonHelpWrapper .lessonHelp.lessonSolution', //Check this
initialize: function() {
this.model = new LessonSolutionModel();
this.listenTo(this.model,'loaded',this.onModelLoaded);
this.model.loadData();
},
render:function(title) {
},
onModelLoaded: function() {
// ???
}
});
});

View File

@ -0,0 +1,23 @@
define(['jquery',
'underscore',
'backbone',
'goatApp/model/LessonSourceModel'],
function($,
_,
Backbone,
LessonSourceModel) {
return Backbone.View.extend({
el:'#lessonHelpWrapper .lessonHelp.lessonPlan', //Check this
initialize: function() {
this.model = new LessonSourceModel();
this.listenTo(this.model,'loaded',this.onModelLoaded);
this.model.loadData();
},
render:function(title) {
},
onModelLoaded: function() {
// ???
}
});
});