Merge pull request #202 from misfir3/develop

Develop
This commit is contained in:
mayhew64 2016-02-23 09:07:40 -05:00
commit 3d7eb40787
2 changed files with 20 additions and 20 deletions

View File

@ -102,6 +102,11 @@
<div class="col-md-8"> <div class="col-md-8">
<div class="col-md-12" align="left"> <div class="col-md-12" align="left">
<div class="panel" id="help-controls"> <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>
<div class="lesson-hint" id="lesson-hint-container"> <div class="lesson-hint" id="lesson-hint-container">
<h4>Hints</h4> <h4>Hints</h4>

View File

@ -4,14 +4,7 @@ define(['jquery',
function($,_,Backbone) { function($,_,Backbone) {
return Backbone.View.extend({ return Backbone.View.extend({
el:'#help-controls', //Check this 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'})
},
initialize: function (options) { initialize: function (options) {
if (!options) { if (!options) {
return; return;
@ -21,28 +14,30 @@ function($,_,Backbone) {
this.hasSource = options.hasSource; this.hasSource = options.hasSource;
this.hasHints = options.hasHints; this.hasHints = options.hasHints;
}, },
render:function(title) { 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) { if (this.hasSource) {
this.helpButtons.showSource.unbind().on('click',_.bind(this.showSource,this)); this.$el.find('#show-source-button').unbind().on('click',_.bind(this.showSource,this)).show();
this.$el.append(this.helpButtons.showSource);
} }
if (this.hasSolution) { if (this.hasSolution) {
this.helpButtons.showSolution.unbind().on('click',_.bind(this.showSolution,this)); this.$el.find('#show-solution-button').unbind().on('click',_.bind(this.showSolution,this)).show();
this.$el.append(this.helpButtons.showSolution);
} }
if (this.hasPlan) { if (this.hasPlan) {
this.helpButtons.showPlan.unbind().on('click',_.bind(this.showPlan,this)); this.$el.find('#show-plan-button').unbind().on('click',_.bind(this.showPlan,this)).show();
this.$el.append(this.helpButtons.showPlan);
} }
if (this.hasHints) { if (this.hasHints) {
this.helpButtons.showHints.unbind().on('click',_.bind(this.showHints,this)); this.$el.find('#show-hints-button').unbind().on('click',_.bind(this.showHints,this)).show();
this.$el.append(this.helpButtons.showHints);
} }
this.helpButtons.restartLesson.unbind().on('click',_.bind(this.restartLesson,this)); this.$el.find('#restart-lesson-button').unbind().on('click',_.bind(this.restartLesson,this)).show();
this.$el.append(this.helpButtons.restartLesson); //this.$el.append(this.helpButtons.restartLesson);
}, },
showSource: function() { showSource: function() {