abracadabra 1.1.0 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3d6397a100fc0730bd922ccf829cbc8ede263f1b
4
- data.tar.gz: 52da01d686c8c0eaec065fbcab683d8c38d39413
3
+ metadata.gz: 025f02f748f449835b124aa15061c474a691f58e
4
+ data.tar.gz: 30de840217af8e49fbe7880668798fe8090cad62
5
5
  SHA512:
6
- metadata.gz: 782696df1679bb883dba8a4e0d33c4f600f25823b9f2e3a6c94c427a332e05a060a92192b3f9a0df0d4857e7e2a60888a2cec1833ca53f596f831298f7c889cd
7
- data.tar.gz: 7828f591e8beb2b38ca705357f84f927bb917a2af406a51fa11e4bfb4635b41f705bc8c94c2a7eb6deb2bcc6bf33e6dcd38d08bce11874ca1fdbc026a1f4b018
6
+ metadata.gz: c9a2e9dc647d8c1e2ad27cc6b93aa35836408307bd124dc591b46b55e6cc0bcd7f1fda5f96171ecd158bb294d96615acf3fbf7a69a869263330aed1a59c969d4
7
+ data.tar.gz: cd5a2bb60ac2171620725ccd8ef586e621ec57816226ddbf7f07854f9e8079dfce46e76e405d2ff369eef03bbe5e3c3f220e785301db1e8242572b4619180071
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  The gem that swaps out text with a fully-compliant Rails form in one click.
4
4
 
5
- Much of the concepts and html mark-up were taken from the awesome [x-editable](http://vitalets.github.io/x-editable/) plugin and the Rails version of this, [x-editable-rails](https://github.com/werein/x-editable-rails). However, this was written from the ground up and uses fully Rails-compliant forms without hacking into x-editable's core files, or overriding them.
5
+ Much of the concepts and html mark-up were taken from the awesome [x-editable](http://vitalets.github.io/x-editable/) plugin and the Rails version of this, [x-editable-rails](https://github.com/werein/x-editable-rails). However, this was written from the ground up and uses fully Rails-compliant forms without hacking into x-editable's core files or overriding them.
6
6
 
7
7
  ## Installation
8
8
 
@@ -20,9 +20,10 @@ Or install it yourself as:
20
20
 
21
21
  ## Usage
22
22
 
23
- * Requires JQuery, JQuery-UJS (rails.js), Bootstrap and Font-Awesome (unless you override the framework specific classes with CSS)
23
+ * Requires JQuery and JQuery-UJS (rails.js)
24
+ * Bootstrap and Font-Awesome are the default, but you can override the CSS and/or customize the icon classes (see [Configuration](#configuration))
24
25
 
25
- In your `application.css`, AFTER Bootstrap (currently only supports Bootstrap), include the css file:
26
+ In your `application.css`, AFTER Bootstrap, include the css file:
26
27
 
27
28
  ```css
28
29
  *= require abracadabra
@@ -86,19 +87,19 @@ remote: true
86
87
  # Description: Same as link_to's `remote: true`, form submits via AJAX.
87
88
  # Default: true
88
89
 
90
+ type: :js
89
91
  # IMPORTANT: `type` will be ignored if `remote = false` is used. HTML is the default
90
92
  # in Rails for standard form submissions.
91
- type: :js
92
93
  # Description: Content type -- responds to any content type (:js and :script can both be
93
94
  # used to respond with Javascript).
94
95
  # Default: :script (:js)
95
96
 
96
- # IMPORTANT: On ajax:success, this will remove the specific abracadabra instance from
97
- # the DOM entirely. ALSO, this will be remote if the main form is remote.
98
97
  deletable: true
99
- # Boolean: DELETE will be submitted without a confirmation dialog
100
98
  # OR
101
99
  deletable: "Are you sure?"
100
+ # IMPORTANT: On ajax:success, this will remove the specific abracadabra instance from
101
+ # the DOM entirely. ALSO, this will be remote if the main form is remote.
102
+ # Boolean: DELETE will be submitted without a confirmation dialog
102
103
  # String: Confirmation dialog, with the string as the message, will be displayed after
103
104
  # clicking the DELETE link
104
105
  # Description: Puts a link to DELETE the object (obviously, it always uses DELETE as
@@ -114,13 +115,13 @@ deletable_type: :js
114
115
  # can both be used to respond with Javascript).
115
116
  # Default: :script (:js)
116
117
 
117
- # Boolean: Open the next abracadabra instance after successful form submission (main
118
- # form, not the DELETE link's submission) by using `.abracadabra` as the selector.
119
118
  tab_to_next: true
120
119
  # OR
121
120
  tab_to_next: ".my-class"
122
- # IMPORTANT: If this is a class, this abracadabra instance MUST have the same class
123
- # as well.
121
+ # IMPORTANT: If use a string, and it's a class, this abracadabra instance MUST have the same
122
+ # class as well.
123
+ # Boolean: Open the next abracadabra instance after successful form submission (main
124
+ # form, not the DELETE link's submission) by using `.abracadabra` as the selector.
124
125
  # String: The class or ID of the next abracadabra instance to open on successful form
125
126
  # submission. Use `.` before a class selector or `#` before a an ID selector just as you
126
127
  # would when finding an element in Javascript.
@@ -132,6 +133,26 @@ submit_on_blur: true
132
133
  # Description: Submit form when focus leaves the input, rather than simply closing it
133
134
  # out.
134
135
  # Default: false
136
+
137
+ ### EXAMPLE ###
138
+ # Simple
139
+ click_to_edit @friend, path: friend_path(@friend), attribute: :name, deletable: true
140
+
141
+ # Using a bunch of options
142
+ click_to_edit @friend,
143
+ path: friend_path(@friend),
144
+ attribute: :name,
145
+ class: "my-abracadabra",
146
+ id: "my-abracadabra-#{index}",
147
+ value: @friend.name.titleize,
148
+ method: :put,
149
+ buttonless: true,
150
+ type: :json,
151
+ deletable: "Are you sure?",
152
+ deletable_path: user_friends_path(@friend),
153
+ deletable_type: :json,
154
+ tab_to_next: "#my-abracadabra-#{index+1}",
155
+ submit_on_blur: true
135
156
  ```
136
157
 
137
158
  ## Configuration
@@ -154,10 +175,6 @@ abracadabraDeleteIcon = "fa fa-times-circle-o"; // default
154
175
 
155
176
  2. I would love the different Bootstrap classes to be overridable with an initializer (config/abracadabra.rb), rather than Javascript (not sure if this is even possible), so that any framework could be used. Same with the Font-Awesome button classes.
156
177
 
157
- 3. I would love for a `buttons: false` option to be offered that would allow only `Tab`, `Enter` and `Escape` to submit or cancel the form submission.
158
-
159
- 4. I would love for a `tabbable: true` option to be offered that would tab to the next text input with the `abracadabra` class.
160
-
161
178
  Any other ideas, feel free to contribute!
162
179
 
163
180
  1. Fork it ( http://github.com/TrevorHinesley/abracadabra/fork )
@@ -1,6 +1,6 @@
1
1
  $(function() {
2
2
  abracadabraSubmissionInProgress = false;
3
- abracadabraDeleteMousedown = false;
3
+ abracadabraButtonMousedown = false;
4
4
  abracadabraEscapeKeydown = false;
5
5
 
6
6
  function closeAbracadabra(element, destroy, valueChanged) {
@@ -68,17 +68,17 @@ $(function() {
68
68
  abracadabraSubmissionInProgress = true;
69
69
  });
70
70
 
71
- $("body").on("mousedown", ".abracadabra-delete", function() {
72
- abracadabraDeleteMousedown = true;
71
+ $("body").on("mousedown", ".abracadabra-delete, .abracadabra-submit, .abracadabra-cancel", function() {
72
+ abracadabraButtonMousedown = true;
73
73
  });
74
74
 
75
75
  $("body").on("ajax:success", ".abracadabra-form", function(e) {
76
76
  target = $(e.target);
77
+ abracadabraButtonMousedown = false;
77
78
 
78
79
  /* If form is a DELETE, remove abracadabra instance, if not, call tabToNextSelector */
79
80
  if(target.hasClass("abracadabra-delete")) {
80
81
  closeAbracadabra(target, true, true);
81
- abracadabraDeleteMousedown = false;
82
82
  } else {
83
83
  input = $(target).find(".abracadabra-input");
84
84
  tabToNextSelector = input.data("tab-to-next-selector");
@@ -96,7 +96,7 @@ $(function() {
96
96
  });
97
97
 
98
98
  $("body").on("blur", ".abracadabra-input", function() {
99
- if(abracadabraSubmissionInProgress == false && abracadabraDeleteMousedown == false) {
99
+ if(abracadabraSubmissionInProgress == false && abracadabraButtonMousedown == false) {
100
100
  if($(this).data("submit-on-blur") == true) {
101
101
  $(this.form).submit();
102
102
  } else {
@@ -1,5 +1,5 @@
1
1
  module Abracadabra
2
2
  module Rails
3
- VERSION = "1.1.0"
3
+ VERSION = "1.1.1"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: abracadabra
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Trevor Hinesley
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-10 00:00:00.000000000 Z
11
+ date: 2014-04-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails