#180, better management of show* buttons

This commit is contained in:
Jason White 2016-02-18 19:44:12 -05:00
parent daa05dd192
commit 7c65441c8e
2 changed files with 26 additions and 20 deletions

View File

@ -102,6 +102,11 @@
<div class="col-md-8">
<div class="col-md-12" align="left">
<div class="panel" id="help-controls">
<button class="btn btn-primary btn-xs help-button" id="show-source-button">Show Source</button>
<button class="btn btn-primary btn-xs help-button" id="show-solution-button">Show Solution</button>
<button class="btn btn-primary btn-xs help-button" id="show-plan-button">Show Plan</button>
<button class="btn btn-primary btn-xs help-button" id="show-hints-button">Show Hints</button>
<button class="btn btn-xs help-button" id="show-hints-button">Restart Lesson</button>
</div>
<div class="lesson-hint" id="lesson-hint-container">
<h4>Hints</h4>

View File

@ -4,14 +4,14 @@ define(['jquery',
function($,_,Backbone) {
return Backbone.View.extend({
el:'#help-controls', //Check this
helpButtons: {
//TODO: move this into a template
showSource:$('<button>',{id:'show-source-button','class':'btn btn-primary btn-xs help-button',type:'button',text:'Java Source'}),
showSolution:$('<button>',{id:'show-solution-button','class':'btn btn-primary btn-xs help-button',type:'button',text:'Solution'}),
showPlan:$('<button>',{id:'show-plan-button','class':'btn btn-primary btn-xs help-button',type:'button',text:'Lesson Plan'}),
showHints:$('<button>',{id:'show-hints-button','class':'btn btn-primary btn-xs help-button',type:'button',text:'Hints'}),
restartLesson:$('<button>',{id:'restart-lesson-button','class':'btn btn-xs help-button',type:'button',text:'Restart Lesson'})
},
// helpButtons: {
// //TODO: move this into a template
// showSource:,
// showSolution:,
// showPlan:,
// showHints:,
// restartLesson:
// },
initialize: function (options) {
if (!options) {
return;
@ -22,27 +22,28 @@ function($,_,Backbone) {
this.hasHints = options.hasHints;
},
render:function(title) {
this.$el.html();
//this.$el.html();
// if still showing, hide
$('#show-source-button').hide();
$('#show-solution-button').hide();
$('#show-plan-button').hide();
$('#show-hints-button').hide();
if (this.hasSource) {
this.helpButtons.showSource.unbind().on('click',_.bind(this.showSource,this));
this.$el.append(this.helpButtons.showSource);
this.$el.find('#show-source-button').unbind().on('click',_.bind(this.showSource,this)).show();
}
if (this.hasSolution) {
this.helpButtons.showSolution.unbind().on('click',_.bind(this.showSolution,this));
this.$el.append(this.helpButtons.showSolution);
this.$el.find('#show-solution-button').unbind().on('click',_.bind(this.showSolution,this)).show();
}
if (this.hasPlan) {
this.helpButtons.showPlan.unbind().on('click',_.bind(this.showPlan,this));
this.$el.append(this.helpButtons.showPlan);
this.$el.find('#show-plan-button').unbind().on('click',_.bind(this.showPlan,this)).show();
}
if (this.hasHints) {
this.helpButtons.showHints.unbind().on('click',_.bind(this.showHints,this));
this.$el.append(this.helpButtons.showHints);
this.$el.find('#show-hints-button').unbind().on('click',_.bind(this.showHints,this)).show();
}
this.helpButtons.restartLesson.unbind().on('click',_.bind(this.restartLesson,this));
this.$el.append(this.helpButtons.restartLesson);
this.$el.find('#restart-lesson-button').unbind().on('click',_.bind(this.restartLesson,this)).show();
//this.$el.append(this.helpButtons.restartLesson);
},
showSource: function() {