work-arounds, fixes for page initialization and some clean-up
This commit is contained in:
parent
20e45da8ae
commit
6cfefba0ee
@ -73,6 +73,7 @@ define(['jquery',
|
||||
}
|
||||
|
||||
this.loadLesson = function(name,pageNum) {
|
||||
|
||||
if (this.name === name) {
|
||||
this.listenToOnce(this.lessonHintView, 'hints:showButton', this.onShowHintsButton);
|
||||
this.listenTo(this.lessonHintView, 'hints:hideButton', this.onHideHintsButton);
|
||||
@ -83,15 +84,15 @@ define(['jquery',
|
||||
return;
|
||||
}
|
||||
|
||||
if (pageNum && !this.name) {
|
||||
//placeholder
|
||||
}
|
||||
|
||||
this.helpsLoaded = {};
|
||||
if (typeof(name) === 'undefined' || name === null) {
|
||||
//TODO: implement lesson not found or return to welcome page?
|
||||
}
|
||||
this.lessonContent.loadData({'name':name});
|
||||
// this.planView = {};
|
||||
// this.solutionView = {};
|
||||
// this.sourceView = {};
|
||||
// this.lessonHintView = {};
|
||||
this.name = name;
|
||||
};
|
||||
|
||||
@ -124,10 +125,7 @@ define(['jquery',
|
||||
this.helpControlsView = null;
|
||||
this.lessonContentView.model = this.lessonContent;
|
||||
this.lessonContentView.render();
|
||||
|
||||
//this.planView = new PlanView();
|
||||
//this.solutionView = new SolutionView();
|
||||
//this.sourceView = new SourceView();
|
||||
//TODO: consider moving hintView as child of lessonContentView ...
|
||||
if (this.lessonHintView) {
|
||||
this.lessonHintView.stopListening();
|
||||
this.lessonHintView = null;
|
||||
@ -152,35 +150,6 @@ define(['jquery',
|
||||
this.helpsLoaded[curHelp.helpElement] = curHelp.value;
|
||||
};
|
||||
|
||||
// this.hideShowHelps = function(showHelp) {
|
||||
// var showId = '#lesson-' + showHelp + '-row';
|
||||
// var contentId = '#lesson-' + showHelp + '-content';
|
||||
// $('.lesson-help').not(showId).hide();
|
||||
// if (!showId) {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// if ($(showId).is(':visible')) {
|
||||
// $(showId).hide();
|
||||
// return;
|
||||
// } else {
|
||||
// //TODO: move individual .html operations into individual help views
|
||||
// switch(showHelp) {
|
||||
// case 'plan':
|
||||
// $(contentId).html(this.planView.model.get('content'));
|
||||
// break;
|
||||
// case 'solution':
|
||||
// $(showId).html(this.solutionView.model.get('content'));
|
||||
// break;
|
||||
// case 'source':
|
||||
// $(contentId).html('<pre>' + this.sourceView.model.get('content') + '</pre>');
|
||||
// break;
|
||||
// }
|
||||
// $(showId).show();
|
||||
// GoatUtils.scrollToHelp()
|
||||
// }
|
||||
// };
|
||||
|
||||
this.showHintsView = function() {
|
||||
this.lessonHintView.render();
|
||||
if (this.lessonHintView.getHintsCount > 0) {
|
||||
|
@ -59,7 +59,7 @@ define(['jquery',
|
||||
var currentPage = (!isNaN(startPageNum) && startPageNum && startPageNum < this.$contentPages) ? startPageNum : 0;
|
||||
//init views & pagination
|
||||
this.showCurContentPage(currentPage);
|
||||
this.paginationControlView = new PaginationControlView(this.$contentPages,this.model.get('lessonUrl'));
|
||||
this.paginationControlView = new PaginationControlView(this.$contentPages,this.model.get('lessonUrl'),startPageNum);
|
||||
},
|
||||
|
||||
updatePagination: function() {
|
||||
@ -187,13 +187,19 @@ define(['jquery',
|
||||
return endpoints;
|
||||
},
|
||||
|
||||
onNavToPage: function(pageNum) {
|
||||
var assignmentPaths = this.findAssigmentEndpointsOnPage(pageNum);
|
||||
this.trigger('endpoints:filtered',assignmentPaths);
|
||||
},
|
||||
|
||||
navToPage: function (pageNum) {
|
||||
this.paginationControlView.setCurrentPage(pageNum);//provides validation
|
||||
this.showCurContentPage(this.paginationControlView.currentPage);
|
||||
this.paginationControlView.render();
|
||||
this.paginationControlView.hideShowNavButtons();
|
||||
var assignmentPaths = this.findAssigmentEndpointsOnPage(pageNum);
|
||||
this.trigger('endpoints:filtered',assignmentPaths);
|
||||
this.onNavToPage(pageNum);
|
||||
//var assignmentPaths = this.findAssigmentEndpointsOnPage(pageNum);
|
||||
//this.trigger('endpoints:filtered',assignmentPaths);
|
||||
},
|
||||
|
||||
/* for testing */
|
||||
|
@ -12,14 +12,14 @@ define(['jquery',
|
||||
template: PaginationTemplate,
|
||||
el: '#lesson-page-controls',
|
||||
|
||||
initialize: function ($contentPages,baseLessonUrl) {
|
||||
initialize: function ($contentPages,baseLessonUrl,initPageNum) {
|
||||
this.$contentPages = $contentPages;
|
||||
this.collection = new LessonOverviewCollection();
|
||||
this.listenTo(this.collection, 'reset', this.render);
|
||||
this.numPages = this.$contentPages.length;
|
||||
this.baseUrl = baseLessonUrl;
|
||||
this.collection.fetch({reset:true});
|
||||
this.initPagination();
|
||||
this.initPagination(initPageNum);
|
||||
//this.render();
|
||||
},
|
||||
|
||||
@ -117,9 +117,9 @@ define(['jquery',
|
||||
$('span.glyphicon-class.glyphicon.glyphicon-circle-arrow-right.show-next-page').hide();
|
||||
},
|
||||
|
||||
initPagination: function() {
|
||||
//track pagination state in this view ... start at 0
|
||||
this.currentPage = 0;
|
||||
initPagination: function(initPageNum) {
|
||||
//track pagination state in this view ... start at 0 .. unless a pageNum was provided
|
||||
this.currentPage = !initPageNum ? 0 : initPageNum;
|
||||
},
|
||||
|
||||
setCurrentPage: function (pageNum) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user