Merge branch 'feature/ctrl-enter-submit' into staging

This commit is contained in:
Quincy Larson
2015-09-09 20:41:02 -07:00
4 changed files with 31 additions and 4 deletions

View File

@ -420,6 +420,13 @@ var testSuccess = function() {
isInitRun = false;
};
function ctrlEnterClickHandler(e) {
// ctrl + enter
if (e.ctrlKey && e.keyCode === 13) {
$('#submit-challenge').click();
}
}
function showCompletion() {
if (isInitRun) {
isInitRun = false;
@ -435,8 +442,18 @@ function showCompletion() {
);
var bonfireSolution = myCodeMirror.getValue();
var didCompleteWith = $('#completed-with').val() || null;
$('#complete-courseware-dialog').modal('show');
$('#complete-courseware-dialog .modal-header').click();
$('#complete-courseware-dialog').keyup(function(e) {
// ctrl + enter
if (e.ctrlKey && e.keyCode === 13) {
$('#submit-challenge').click();
}
});
$('#submit-challenge').click(function(e) {
e.preventDefault();
@ -766,6 +783,17 @@ $('#submitButton').on('click', function() {
});
$(document).ready(function() {
// init modal keybindings on open
$('#complete-courseware-dialog').on('shown.bs.modal', function() {
$('#complete-courseware-dialog').keyup(ctrlEnterClickHandler);
});
// remove modal keybinds on close
$('#complete-courseware-dialog').on('hidden.bs.modal', function() {
$('#complete-courseware-dialog').unbind('keyup', ctrlEnterClickHandler);
});
var $preview = $('#preview');
isInitRun = true;

View File

@ -141,8 +141,7 @@ block content
.spacer
.row
if (user)
#submit-challenge.btn.btn-lg.btn-primary.btn-block Submit and go to my next challenge
#submit-challenge.animated.fadeIn.btn.btn-lg.btn-primary.btn-block Submit and go to my next challenge (ctrl + enter)
if (user.progressTimestamps.length > 2)
a.btn.btn-lg.btn-block.btn-twitter(target="_blank", href="https://twitter.com/intent/tweet?text=I%20just%20#{verb}%20%40FreeCodeCamp%20#{name}&url=http%3A%2F%2Ffreecodecamp.com/challenges/#{dashedName}&hashtags=LearnToCode, JavaScript")
i.fa.fa-twitter  

View File

@ -92,7 +92,7 @@ block content
span.completion-icon.ion-checkmark-circled.text-primary
.spacer
if(user)
#submit-challenge.btn.btn-lg.btn-primary.btn-block Submit and go to my next challenge
#submit-challenge.animated.fadeIn.btn.btn-lg.btn-primary.btn-block Submit and go to my next challenge (ctrl + enter)
else
a.btn.btn-lg.btn-primary.btn-block(href='/challenges/next-challenge?id=' + challengeId) Go to my next challenge
include ../partials/challenge-modals

View File

@ -88,7 +88,7 @@ block content
.spacer
.row
if (user)
#submit-challenge.btn.btn-lg.btn-primary.btn-block Submit and go to next challenge
#submit-challenge.animated.fadeIn.btn.btn-lg.btn-primary.btn-block Submit and go to my next challenge (ctrl + enter)
if (user.progressTimestamps.length > 2)
a.btn.btn-lg.btn-block.btn-twitter(target="_blank", href="https://twitter.com/intent/tweet?text=I%20just%20#{verb}%20%40FreeCodeCamp%20#{name}&url=http%3A%2F%2Ffreecodecamp.com/challenges/#{dashedName}&hashtags=LearnToCode, JavaScript")
i.fa.fa-twitter