abracadabra 1.0.8 → 1.0.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2e278480715ec17aca8e37299701755c70cbc868
4
- data.tar.gz: c0924415b005bc88e6f6599e526ff9b3754c0f9c
3
+ metadata.gz: edd223049678c26610b8c2fadec6d8f8ad595061
4
+ data.tar.gz: 41c3481424371382ec2a0301a5842e6a129b423d
5
5
  SHA512:
6
- metadata.gz: 7e8d0e0377c5b2d984639fcab19c040b586f53fdb037f1e895d2c647df5f4c3774fe3a6b004dc4fc6e4faaca7acaa5bb8b16af005e2e3f44ba7c335d7d72f83e
7
- data.tar.gz: e3b8ab44882e0fb8f3809422abcfca1d03dda31bc9414a329b9154185b709433aef075174af787e46f05c37cf469698e24fafdcd2579c8e21ed248056f0746ce
6
+ metadata.gz: 340c4fecc67742521dfefbc59e52e1291f956072c707cf6104f6e36417e09e851d90af20be0d4db60773a4a6606e67392514ea49816f705469298685268cefe2
7
+ data.tar.gz: 0720c36847639c2e10e3961a8f7cb627a32a159a551c8d174c3f747190b69591d3a20c07f02af5c12c9c721f3158b8bb0be4011c9dfa18e3c393c0f870932d34
@@ -1,8 +1,9 @@
1
1
  $(function() {
2
2
  abracadabraSubmissionInProgress = false;
3
3
  abracadabraDeleteMousedown = false;
4
+ abracadabraEscapeKeydown = true;
4
5
 
5
- function closeAbracadabra(element, destroy) {
6
+ function closeAbracadabra(element, destroy, valueChanged) {
6
7
  $element = $(element);
7
8
  if($element.hasClass("abracadabra-container")) {
8
9
  container = $element;
@@ -13,7 +14,11 @@ $(function() {
13
14
  if(destroy) {
14
15
  container.siblings(".abracadabra").remove();
15
16
  } else {
16
- value = container.find(".abracadabra-input").val();
17
+ if(valueChanged == true) {
18
+ value = container.find(".abracadabra-input").val();
19
+ } else {
20
+ value = container.find(".abracadabra-input").data("original-value");
21
+ }
17
22
  container.siblings(".abracadabra").text(value).show();
18
23
  }
19
24
 
@@ -38,16 +43,17 @@ $(function() {
38
43
  }
39
44
  /* /If selector isn't an ID, find the element with the class AFTER the current element */
40
45
 
41
- closeAbracadabra(element, false);
46
+ closeAbracadabra(element, false, true);
42
47
  nextAbracadabra.click();
43
48
  } else {
44
- closeAbracadabra(element, false);
49
+ closeAbracadabra(element, false, true);
45
50
  }
46
51
  }
47
52
 
48
53
  $("body").on("submit", ".abracadabra-form", function(e) {
49
- if(abracadabraSubmissionInProgress == true) {
54
+ if(abracadabraSubmissionInProgress == true || abracadabraEscapeKeydown == true) {
50
55
  e.preventDefault();
56
+ abracadabraEscapeKeydown = false;
51
57
  return false;
52
58
  }
53
59
  abracadabraSubmissionInProgress = true;
@@ -70,7 +76,7 @@ $(function() {
70
76
 
71
77
  /* If form is a DELETE, remove abracadabra instance, if not, call tabToNextSelector */
72
78
  if(target.hasClass("abracadabra-delete")) {
73
- closeAbracadabra(target, true);
79
+ closeAbracadabra(target, true, true);
74
80
  abracadabraDeleteMousedown = false;
75
81
  } else {
76
82
  input = $(target).find(".abracadabra-input");
@@ -84,7 +90,7 @@ $(function() {
84
90
 
85
91
  $("body").on("click", ".abracadabra-cancel", function() {
86
92
  if(abracadabraSubmissionInProgress == false) {
87
- closeAbracadabra(this, false);
93
+ closeAbracadabra(this, false, false);
88
94
  }
89
95
  });
90
96
 
@@ -93,7 +99,7 @@ $(function() {
93
99
  if($(this).data("submit-on-blur") == true) {
94
100
  $(this.form).submit();
95
101
  } else {
96
- closeAbracadabra(this, false);
102
+ closeAbracadabra(this, false, false);
97
103
  }
98
104
  }
99
105
  });
@@ -112,9 +118,10 @@ $(function() {
112
118
  /* Press Escape to cancel */
113
119
  if (e.keyCode == 27)
114
120
  {
121
+ abracadabraEscapeKeydown = true;
115
122
  e.preventDefault();
116
123
  if(abracadabraSubmissionInProgress == false) {
117
- closeAbracadabra(this, false);
124
+ closeAbracadabra(this, false, false);
118
125
  }
119
126
  }
120
127
  /* /Press Escape to cancel */
@@ -132,6 +139,10 @@ $(function() {
132
139
  });
133
140
 
134
141
  $(".abracadabra").on("click", function() {
142
+ if($(".abracadabra-container:visible").length) {
143
+ return false;
144
+ }
145
+
135
146
  link = $(this);
136
147
  link.hide();
137
148
  path = link.data("path");
@@ -214,7 +225,7 @@ $(function() {
214
225
 
215
226
  openFormTag = "<form accept-charset=\"UTF-8\" action=\"" + path + "\"" + remote + type + " class=\"form-inline abracadabra-form\" method=\"post\">";
216
227
  hiddenMethodTags = "<div style=\"display:none;\"><input name=\"utf8\" type=\"hidden\" value=\"&#10003;\"><input name=\"_method\" type=\"hidden\" value=\"" + formMethod + "\">" + authToken + "</div>";
217
- input = "<input type=\"text\" class=\"form-control abracadabra-input\" id=\"" + inputId + "\" name=\"" + inputName + "\" value=\"" + inputValue + "\"" + tabToNextSelector + submitOnBlur + ">";
228
+ input = "<input type=\"text\" class=\"form-control abracadabra-input\" id=\"" + inputId + "\" name=\"" + inputName + "\" value=\"" + inputValue + "\" data-original-value=\"" + inputValue + "\"" + tabToNextSelector + submitOnBlur + ">";
218
229
 
219
230
  html = "<span class=\"abracadabra-container\">" + openFormTag + hiddenMethodTags;
220
231
  html += "<div class=\"control-group\"><div class=\"abracadabra-input-and-button-wrapper\"><div class=\"abracadabra-input-container\">" + input + deletable + "</div>";
@@ -1,5 +1,5 @@
1
1
  module Abracadabra
2
2
  module Rails
3
- VERSION = "1.0.8"
3
+ VERSION = "1.0.9"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: abracadabra
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.8
4
+ version: 1.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Trevor Hinesley