incremental progress on new UI code, mod to AbstractLesson for menu

This commit is contained in:
Jason White
2015-05-12 22:32:56 -04:00
parent 53c4ffc1cf
commit 8aa4b8109f
17 changed files with 5061 additions and 41 deletions

View File

@ -0,0 +1,46 @@
define(['jquery',
'underscore',
'backbone',
'goatApp/controller/LessonController',
'goatApp/controller/MenuController',
'goatApp/view/LessonContentView',
'goatApp/view/MenuView'
], function ($,_,Backbone,LessonController,MenuController,LessonContentView,MenuView) {
var lessonView = new LessonContentView();
var menuView = new MenuView();
var GoatAppRouter = Backbone.Router.extend({
routes: {
//#....
'welcome':'welcomeRoute',
'attack/:scr/:menu':'attackRoute' //
},
lessonController: new LessonController({
lessonView:lessonView
}),
menuController: new MenuController({
menuView:menuView
}),
init:function() {
goatRouter = new GoatAppRouter();
this.lessonController.start();
this.menuController.initMenu();
goatRouter.on('route:attackRoute', function(scr,menu) {
console.log('attack route');
this.lessonController.loadLesson(scr,menu);
this.menuController.updateMenu(scr,menu);
//update menu
});
goatRouter.on('route:welcomeRoute', function() {
alert('welcome route');
});
Backbone.history.start();
}
});
return GoatAppRouter;
});

View File

@ -4,22 +4,16 @@ define(['jquery',
'backbone',
'goatApp/model/LessonContentData'],
function($,_,Backbone,LessonData) {
var contentView = Backbone.View.extend({
el:'#lessonContent',
return Backbone.View.extend({
el:'#lessonContentWrapper', //TODO << get this fixed up in DOM
initialize: function(options) {
//this.content = options.content;
this.lessonData = {};
this.listenTo(this.lessonData,'sync',this.render);
},
loadLesson: function(options) {
this.lessonData = new LessonData(options.screen,options.menu);
options = options || {};
},
render: function() {
alert('render');
this.$el.html(this.content);
//alert('render');
this.$el.html(this.model.get('content'));
}
});
return contentView;
});

View File

@ -0,0 +1,14 @@
define(['jquery',
'underscore',
'backbone'], function($,_,Backbone) {
return Backbone.View.extend({
initialize: function(options) {
options = options || {};
}
});
});

View File

@ -1,12 +1,19 @@
define(['jquery','underscore','backbone','goatApp/model/MenuData'], function($,_,Backbone,MenuData) {
define(['jquery',
'underscore',
'backbone',
'goatApp/model/MenuItemCollection'],
function($,_,Backbone,MenuItemCollection) {
return Backbone.View.extend({
el:'#menuContainer',
//TODO: set template
initialize: function() {
this.collection = new MenuItemCollection();
this.listenTo(this.collection,'menuData:loaded',this.render);
},
render: function (model){
//TODO: implement own HTML Encoder
this.$el.html(buildMenu(items));
this.$el.html('render ' + this.collection.length + ' items');//buildMenu(items)
},
buildMenu: function(items) {
@ -44,6 +51,7 @@ define(['jquery','underscore','backbone','goatApp/model/MenuData'], function($,_
$(goatConstants.getDOMContainers().lessonMenu).html('').append($wholeMenu);
};
}
},
});
});