Skip to content

Commit

Permalink
#597 Handlebars compilation script and template sources added. Adding…
Browse files Browse the repository at this point in the history
… id to modal dialog buttons in the game.
  • Loading branch information
Paweł Krupiński committed Aug 25, 2015
1 parent 7d89a46 commit da5a09c
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 43 deletions.
1 change: 1 addition & 0 deletions compile_handlebars.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
handlebars handlebars --min -f game/static/game/js/templates.js
6 changes: 3 additions & 3 deletions game/static/game/js/button.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ var ocargo = ocargo || {};
ocargo.button = {};

// Returns the html code for a button which closes the popup using handlebars precompiled templates
ocargo.button.getDismissButtonHtml = function(label){
return Handlebars.templates['button-dismiss']({label: label});
ocargo.button.getDismissButtonHtml = function(id, label){
return Handlebars.templates['button-dismiss']({label: label, id: id});
}

// Returns the html code for a button which redirects to location using handlebars precompiled templates
Expand All @@ -53,5 +53,5 @@ ocargo.button.getRedirectButtonHtml = function(location, label){

// Returns the html code for a button which shows the try again message and closes the popup
ocargo.button.getTryAgainButtonHtml = function(){
return ocargo.button.getDismissButtonHtml(ocargo.messages.tryagainLabel)
return ocargo.button.getDismissButtonHtml('try_again_button', ocargo.messages.tryagainLabel)
}
2 changes: 1 addition & 1 deletion game/static/game/js/drawing.js
Original file line number Diff line number Diff line change
Expand Up @@ -938,7 +938,7 @@ ocargo.Drawing.startPopup = function(title, subtitle, message, mascot, buttons,
if(buttons){
$('#modal-buttons').html(buttons);
} else {
$('#modal-buttons').html(ocargo.button.getDismissButtonHtml("Close"));
$('#modal-buttons').html(ocargo.button.getDismissButtonHtml('close_button', 'Close'));
}

setTimeout( function() { $('#myModal').foundation('reveal', 'open'); }, delay);
Expand Down
2 changes: 1 addition & 1 deletion game/static/game/js/game.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ ocargo.Game.prototype.setup = function() {
}
}
ocargo.Drawing.startPopup(title, LESSON,
loggedOutWarning, true, ocargo.button.getDismissButtonHtml('Play'));
loggedOutWarning, true, ocargo.button.getDismissButtonHtml('play_button', 'Play'));
};

ocargo.Game.prototype.reset = function() {
Expand Down
39 changes: 1 addition & 38 deletions game/static/game/js/templates.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions handlebars/button-dismiss.handlebars
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<button id="{{id}}" class="navigation_button long_button" onclick="document.getElementById('close-modal').click()">
<span>{{label}}</span>
</button>
3 changes: 3 additions & 0 deletions handlebars/button-redirect.handlebars
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<button class="navigation_button long_button" onclick="window.location.href={{location}}">
<span>{{label}}</span>
</button>

0 comments on commit da5a09c

Please sign in to comment.