Merge pull request #3205 from FreeCodeCamp/feature/ctrl-enter-submit

add ctrl enter press to submit on modal
This commit is contained in:
Quincy Larson
2015-09-09 20:40:02 -07:00
4 changed files with 24 additions and 4 deletions

View File

@ -418,6 +418,13 @@ var testSuccess = function() {
}
};
function ctrlEnterClickHandler(e) {
// ctrl + enter
if (e.ctrlKey && e.keyCode === 13) {
$('#submit-challenge').click();
}
}
function showCompletion() {
if (isInitRun) {
isInitRun = false;
@ -433,8 +440,11 @@ function showCompletion() {
);
var bonfireSolution = myCodeMirror.getValue();
var didCompleteWith = $('#completed-with').val() || null;
$('#complete-courseware-dialog').modal('show');
$('#complete-courseware-dialog .modal-header').click();
$('#submit-challenge').click(function(e) {
e.preventDefault();
@ -765,6 +775,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

@ -145,8 +145,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

@ -91,7 +91,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

@ -93,7 +93,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