Plan, Source and Solution View (and models), initial stub for HelpControlsView
This commit is contained in:
parent
ba86d2d6d6
commit
998401a631
@ -2,20 +2,34 @@ define(['jquery',
|
|||||||
'underscore',
|
'underscore',
|
||||||
'libs/backbone',
|
'libs/backbone',
|
||||||
'goatApp/model/LessonContentData',
|
'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'
|
'use strict'
|
||||||
|
|
||||||
|
|
||||||
var Controller = function(options) {
|
var Controller = function(options) {
|
||||||
this.lessonView = options.lessonView;
|
|
||||||
this.lessonContent = new LessonContentData();
|
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);
|
_.extend(Controller.prototype,Backbone.Events);
|
||||||
this.start = function() {
|
this.start = function() {
|
||||||
this.listenTo(this.lessonContent,'contentLoaded',this.onContentLoaded);
|
this.listenTo(this.lessonContent,'contentLoaded',this.onContentLoaded);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//load View, which can pull data
|
//load View, which can pull data
|
||||||
@ -35,14 +49,13 @@ define(['jquery',
|
|||||||
|
|
||||||
//load cookies/parameters view
|
//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)
|
//plan view (initially hidden)
|
||||||
|
this.planView = new PlanView();
|
||||||
//solution view (initially hidden)
|
//solution view (initially hidden)
|
||||||
|
this.solutionView = new SolutionView();
|
||||||
//source (initially hidden)
|
//source (initially hidden)
|
||||||
|
this.sourceView = new SourceView();
|
||||||
//load help controls view (contextul to what helps are available)
|
//load help controls view (contextul to what helps are available)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
27
src/main/webapp/js/goatApp/model/HTMLContentModel.js
Normal file
27
src/main/webapp/js/goatApp/model/HTMLContentModel.js
Normal 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();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
@ -1,9 +1,13 @@
|
|||||||
define(['jquery',
|
define(['jquery',
|
||||||
'underscore',
|
'underscore',
|
||||||
'backbone'],
|
'backbone',
|
||||||
function($,_,Backbone){
|
'goatApp/model/HTMLContentModel'],
|
||||||
|
function($,
|
||||||
|
_,
|
||||||
|
Backbone,
|
||||||
|
HTMLContentModel){
|
||||||
|
|
||||||
return Backbone.Model.extend({
|
return HTMLContentModel.extend({
|
||||||
urlRoot:null,
|
urlRoot:null,
|
||||||
defaults: {
|
defaults: {
|
||||||
items:null,
|
items:null,
|
||||||
@ -15,7 +19,7 @@ define(['jquery',
|
|||||||
this.baseUrlRoot = 'attack?Screen=';//
|
this.baseUrlRoot = 'attack?Screen=';//
|
||||||
},
|
},
|
||||||
loadData: function(options) {
|
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('menuParam',options.menu);
|
||||||
this.set('screenParam',options.screen);
|
this.set('screenParam',options.screen);
|
||||||
|
|
||||||
@ -31,13 +35,6 @@ define(['jquery',
|
|||||||
fetch: function (options) {
|
fetch: function (options) {
|
||||||
options = options || {};
|
options = options || {};
|
||||||
return Backbone.Model.prototype.fetch.call(this, _.extend({ dataType: "html"}, 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
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
19
src/main/webapp/js/goatApp/model/LessonPlanModel.js
Normal file
19
src/main/webapp/js/goatApp/model/LessonPlanModel.js
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
});
|
18
src/main/webapp/js/goatApp/model/LessonSolutionModel.js
Normal file
18
src/main/webapp/js/goatApp/model/LessonSolutionModel.js
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
});
|
19
src/main/webapp/js/goatApp/model/LessonSourceModel.js
Normal file
19
src/main/webapp/js/goatApp/model/LessonSourceModel.js
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
});
|
11
src/main/webapp/js/goatApp/view/HelpControlsView.js
Normal file
11
src/main/webapp/js/goatApp/view/HelpControlsView.js
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
define(['jquery',
|
||||||
|
'underscore',
|
||||||
|
'backbone'],
|
||||||
|
function($,_,Backbone) {
|
||||||
|
return Backbone.View.extend({
|
||||||
|
el:'#lessonHelp', //Check this
|
||||||
|
render:function(title) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
@ -11,7 +11,6 @@ function($,_,Backbone,JQueryForm,LessonData) {
|
|||||||
options = options || {};
|
options = options || {};
|
||||||
},
|
},
|
||||||
render: function() {
|
render: function() {
|
||||||
//alert('render');
|
|
||||||
this.$el.html(this.model.get('content'));
|
this.$el.html(this.model.get('content'));
|
||||||
this.makeFormsAjax();
|
this.makeFormsAjax();
|
||||||
},
|
},
|
||||||
|
@ -75,7 +75,6 @@ define(['jquery',
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
triggerTitleRender: function (title) {
|
triggerTitleRender: function (title) {
|
||||||
console.debug('title:'+title);
|
|
||||||
this.trigger('lesson:click',title);
|
this.trigger('lesson:click',title);
|
||||||
},
|
},
|
||||||
expandCategory: function (id) {
|
expandCategory: function (id) {
|
||||||
@ -86,17 +85,12 @@ define(['jquery',
|
|||||||
accordionMenu: function(id) {
|
accordionMenu: function(id) {
|
||||||
if (this.openMenu !== id) {
|
if (this.openMenu !== id) {
|
||||||
this.$el.find('#' + id).slideDown(300);
|
this.$el.find('#' + id).slideDown(300);
|
||||||
|
this.openMenu = id;
|
||||||
} else { //it's open
|
} else { //it's open
|
||||||
this.$el.find('#' + id).slideUp(300).attr('isOpen', 0);
|
this.$el.find('#' + id).slideUp(300).attr('isOpen', 0);
|
||||||
|
this.openMenu = null;
|
||||||
return;
|
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);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
23
src/main/webapp/js/goatApp/view/PlanView.js
Normal file
23
src/main/webapp/js/goatApp/view/PlanView.js
Normal 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() {
|
||||||
|
// ???
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
20
src/main/webapp/js/goatApp/view/SolutionView.js
Normal file
20
src/main/webapp/js/goatApp/view/SolutionView.js
Normal 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() {
|
||||||
|
// ???
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
23
src/main/webapp/js/goatApp/view/SourceView.js
Normal file
23
src/main/webapp/js/goatApp/view/SourceView.js
Normal 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() {
|
||||||
|
// ???
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
Loading…
x
Reference in New Issue
Block a user