TitleView implemented. Need to add way to handle on route, not just click.
This commit is contained in:
parent
e6411f76a3
commit
226c9b9960
@ -54,8 +54,8 @@
|
|||||||
<i class="fa fa-bars"></i>
|
<i class="fa fa-bars"></i>
|
||||||
</button>
|
</button>
|
||||||
</div><!--toggle navigation end-->
|
</div><!--toggle navigation end-->
|
||||||
<div class="lessonTitle" >
|
<div id="lessonTitleWrapper" >
|
||||||
<h1 id="lessonTitle"></h1>
|
<h1 class="lessonTitle"></h1>
|
||||||
</div><!--lesson title end-->
|
</div><!--lesson title end-->
|
||||||
<div class="user-nav pull-right" style="margin-right: 75px;">
|
<div class="user-nav pull-right" style="margin-right: 75px;">
|
||||||
<div class="dropdown" style="display:inline">
|
<div class="dropdown" style="display:inline">
|
||||||
|
@ -32,6 +32,7 @@ define(['jquery',
|
|||||||
//this.lessonView = new LessonContentView({content:LessonContent.content});
|
//this.lessonView = new LessonContentView({content:LessonContent.content});
|
||||||
this.lessonView.model = this.lessonContent;
|
this.lessonView.model = this.lessonContent;
|
||||||
this.lessonView.render();
|
this.lessonView.render();
|
||||||
|
|
||||||
//load cookies/parameters view
|
//load cookies/parameters view
|
||||||
|
|
||||||
//load title view (initially hidden)
|
//load title view (initially hidden)
|
||||||
@ -43,6 +44,7 @@ define(['jquery',
|
|||||||
//source (initially hidden)
|
//source (initially hidden)
|
||||||
|
|
||||||
//load help controls view (contextul to what helps are available)
|
//load help controls view (contextul to what helps are available)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -1,14 +1,22 @@
|
|||||||
define(['jquery','underscore','backbone','goatApp/view/MenuView'],
|
define(['jquery','underscore','backbone','goatApp/view/MenuView'],
|
||||||
function($,_,Backbone,MenuView) {
|
function($,_,Backbone,MenuView) {
|
||||||
Controller = function(options){
|
Controller = function(options){
|
||||||
|
_.extend(Controller.prototype,Backbone.Events);
|
||||||
options = options || {};
|
options = options || {};
|
||||||
this.menuView = options.menuView;
|
this.menuView = options.menuView;
|
||||||
|
this.titleView = options.titleView;
|
||||||
|
|
||||||
this.initMenu = function() {
|
this.initMenu = function() {
|
||||||
console.debug('initing menu');
|
this.listenTo(this.menuView,'lesson:click',this.renderTitle);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.updateMenu = function() {
|
this.updateMenu = function() {
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
//TODO: move title rendering into lessonContent/View pipeline once data can support it
|
||||||
|
this.renderTitle = function(title) {
|
||||||
|
this.titleView.render(title);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -4,11 +4,14 @@ define(['jquery',
|
|||||||
'goatApp/controller/LessonController',
|
'goatApp/controller/LessonController',
|
||||||
'goatApp/controller/MenuController',
|
'goatApp/controller/MenuController',
|
||||||
'goatApp/view/LessonContentView',
|
'goatApp/view/LessonContentView',
|
||||||
'goatApp/view/MenuView'
|
'goatApp/view/MenuView',
|
||||||
], function ($,_,Backbone,LessonController,MenuController,LessonContentView,MenuView) {
|
'goatApp/view/TitleView'
|
||||||
|
], function ($,_,Backbone,LessonController,MenuController,LessonContentView,MenuView,TitleView) {
|
||||||
|
|
||||||
var lessonView = new LessonContentView();
|
var lessonView = new LessonContentView();
|
||||||
var menuView = new MenuView();
|
var menuView = new MenuView();
|
||||||
|
var titleView = new TitleView();
|
||||||
|
|
||||||
var GoatAppRouter = Backbone.Router.extend({
|
var GoatAppRouter = Backbone.Router.extend({
|
||||||
routes: {
|
routes: {
|
||||||
//#....
|
//#....
|
||||||
@ -19,7 +22,8 @@ define(['jquery',
|
|||||||
lessonView:lessonView
|
lessonView:lessonView
|
||||||
}),
|
}),
|
||||||
menuController: new MenuController({
|
menuController: new MenuController({
|
||||||
menuView:menuView
|
menuView:menuView,
|
||||||
|
titleView:titleView
|
||||||
}),
|
}),
|
||||||
|
|
||||||
init:function() {
|
init:function() {
|
||||||
|
@ -28,7 +28,7 @@ define(['jquery',
|
|||||||
var menuMarkup = '';
|
var menuMarkup = '';
|
||||||
var menuUl = $('<ul>',{class:'nano-content'});
|
var menuUl = $('<ul>',{class:'nano-content'});
|
||||||
for(var i=0;i<items.length;i++) { //CATEGORY LEVEL
|
for(var i=0;i<items.length;i++) { //CATEGORY LEVEL
|
||||||
var catId, category, catLink, catArrow, catLinkText;
|
var catId, category, catLink, catArrow, catLinkText, lessonName, stageName;
|
||||||
catId = GoatUtils.makeId(items[i].get('name'));
|
catId = GoatUtils.makeId(items[i].get('name'));
|
||||||
category = $('<li>',{class:'sub-menu ng-scope'});
|
category = $('<li>',{class:'sub-menu ng-scope'});
|
||||||
catLink = $('<a>',{'category':catId});
|
catLink = $('<a>',{'category':catId});
|
||||||
@ -40,7 +40,6 @@ define(['jquery',
|
|||||||
//TODO: refactor this along with sub-views/components
|
//TODO: refactor this along with sub-views/components
|
||||||
var self = this;
|
var self = this;
|
||||||
catLink.click(_.bind(this.expandCategory,this,catId));
|
catLink.click(_.bind(this.expandCategory,this,catId));
|
||||||
//TODO: bind catLink to accordion and selection method
|
|
||||||
category.append(catLink);
|
category.append(catLink);
|
||||||
// lesson level (first children level)
|
// lesson level (first children level)
|
||||||
//var lessons = new MenuItemView({items:items[i].get('children')}).render();
|
//var lessons = new MenuItemView({items:items[i].get('children')}).render();
|
||||||
@ -49,14 +48,17 @@ define(['jquery',
|
|||||||
var categoryLessonList = $('<ul>',{class:'slideDown lessonsAndStages',id:catId}); //keepOpen
|
var categoryLessonList = $('<ul>',{class:'slideDown lessonsAndStages',id:catId}); //keepOpen
|
||||||
for (var j=0; j < lessons.length;j++) {
|
for (var j=0; j < lessons.length;j++) {
|
||||||
var lessonItem = $('<li>');
|
var lessonItem = $('<li>');
|
||||||
var lessonLink = $('<a>',{href:lessons[j].link,text:lessons[j].name,id:GoatUtils.makeId(lessons[j].name)});
|
lessonName = lessons[j].name;
|
||||||
|
var lessonLink = $('<a>',{href:lessons[j].link,text:lessonName,id:lessonName});
|
||||||
|
lessonLink.click(_.bind(this.triggerTitleRender,this,lessonName));
|
||||||
lessonItem.append(lessonLink);
|
lessonItem.append(lessonLink);
|
||||||
//check for lab/stages
|
//check for lab/stages
|
||||||
categoryLessonList.append(lessonItem);
|
categoryLessonList.append(lessonItem);
|
||||||
var stages = lessons[j].children;
|
var stages = lessons[j].children;
|
||||||
for (k=0; k < stages.length; k++) {
|
for (k=0; k < stages.length; k++) {
|
||||||
|
var stageName = stages[k].name;
|
||||||
var stageSpan = $('<span>');
|
var stageSpan = $('<span>');
|
||||||
var stageLink = $('<a>',{href:stages[k].link,text:stages[k].name,id:GoatUtils.makeId(stages[k].name)});
|
var stageLink = $('<a>',{href:stages[k].link,text:stageName,id:GoatUtils.makeId(stageName)});
|
||||||
stageSpan.append(stageLink);
|
stageSpan.append(stageLink);
|
||||||
categoryLessonList.append(stageSpan);
|
categoryLessonList.append(stageSpan);
|
||||||
}
|
}
|
||||||
@ -64,7 +66,6 @@ define(['jquery',
|
|||||||
category.append(categoryLessonList);
|
category.append(categoryLessonList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
menuUl.append(category);
|
menuUl.append(category);
|
||||||
}
|
}
|
||||||
this.$el.append(menuUl);
|
this.$el.append(menuUl);
|
||||||
@ -73,6 +74,10 @@ define(['jquery',
|
|||||||
this.accordionMenu(this.openMenu);
|
this.accordionMenu(this.openMenu);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
triggerTitleRender: function (title) {
|
||||||
|
console.debug('title:'+title);
|
||||||
|
this.trigger('lesson:click',title);
|
||||||
|
},
|
||||||
expandCategory: function (id) {
|
expandCategory: function (id) {
|
||||||
if (id) {
|
if (id) {
|
||||||
this.accordionMenu(id);
|
this.accordionMenu(id);
|
||||||
|
11
src/main/webapp/js/goatApp/view/TitleView.js
Normal file
11
src/main/webapp/js/goatApp/view/TitleView.js
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
define(['jquery',
|
||||||
|
'underscore',
|
||||||
|
'backbone'],
|
||||||
|
function($,_,Backbone) {
|
||||||
|
return Backbone.View.extend({
|
||||||
|
el:'#lessonTitleWrapper',
|
||||||
|
render:function(title) {
|
||||||
|
this.$el.find('.lessonTitle').html(title);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
Loading…
x
Reference in New Issue
Block a user