Skip to content
This repository has been archived by the owner on Mar 7, 2020. It is now read-only.

Commit

Permalink
Fixing issue where if escape key was pressed, it would prevent any ot…
Browse files Browse the repository at this point in the history
…her forms from being submitted
  • Loading branch information
TrevorHinesley committed Apr 10, 2014
1 parent 0a099a1 commit ad4b57f
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion app/assets/javascripts/abracadabra.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
$(function() {
abracadabraSubmissionInProgress = false;
abracadabraDeleteMousedown = false;
abracadabraEscapeKeydown = true;

function closeAbracadabra(element, destroy, valueChanged) {
$element = $(element);
Expand Down Expand Up @@ -50,8 +51,9 @@ $(function() {
}

$("body").on("submit", ".abracadabra-form", function(e) {
if(abracadabraSubmissionInProgress == true) {
if(abracadabraSubmissionInProgress == true || abracadabraEscapeKeydown == true) {
e.preventDefault();
abracadabraEscapeKeydown = false;
return false;
}
abracadabraSubmissionInProgress = true;
Expand Down Expand Up @@ -116,6 +118,7 @@ $(function() {
/* Press Escape to cancel */
if (e.keyCode == 27)
{
abracadabraEscapeKeydown = true;
e.preventDefault();
if(abracadabraSubmissionInProgress == false) {
closeAbracadabra(this, false, false);
Expand All @@ -136,6 +139,10 @@ $(function() {
});

$(".abracadabra").on("click", function() {
if($(".abracadabra-container:visible").length) {
return false;
}

link = $(this);
link.hide();
path = link.data("path");
Expand Down

0 comments on commit ad4b57f

Please sign in to comment.