abracadabra 1.0.0 → 1.0.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 +4 -4
- data/README.md +2 -2
- data/app/assets/javascripts/abracadabra.js +12 -2
- data/app/helpers/abracadabra/rails/view_helper.rb +10 -1
- data/lib/abracadabra/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7e03037f4fc3e7394b71c09177465f31067ae2c8
|
4
|
+
data.tar.gz: 865be37e5de9c41bba0fd4cdae75a4b9b9b82c7c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9bb8bc8c5b41505f6dea32169c0b0838e4c260c425b1ab557eb4a2196069be4d23120c0f1893ba1cfd30467e8849134784e926c0704ffb815f020cc9c21a22ee
|
7
|
+
data.tar.gz: f31ec09f9dbe929185b1f5e7d5d4d6c68a03779ea9c0adb00783aa62e0afc2dfae1e55a89f57d145fb4e4c0f90743003bdc3e6b381e59dc9f0d5f91dad5ebb31
|
data/README.md
CHANGED
@@ -61,9 +61,9 @@ method: "patch"
|
|
61
61
|
|
62
62
|
## Future & Contributing
|
63
63
|
|
64
|
-
I would love anyone to add date pickers and other alternate field types to this.
|
64
|
+
I would love anyone to add date pickers and other alternate field types to this. Any other ideas, feel free to contribute!
|
65
65
|
|
66
|
-
1. Fork it ( http://github.com
|
66
|
+
1. Fork it ( http://github.com/TrevorHinesley/abracadabra/fork )
|
67
67
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
68
68
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
69
69
|
4. Push to the branch (`git push origin my-new-feature`)
|
@@ -24,14 +24,24 @@ $(function() {
|
|
24
24
|
path = link.data("path");
|
25
25
|
attribute = link.data("attribute");
|
26
26
|
form_method = link.data("method");
|
27
|
+
remote = ((link.data("remote") == true) ? " data-remote='true'" : "");
|
28
|
+
|
29
|
+
if(remote == "") {
|
30
|
+
auth_token = "<input name='authenticity_token' type='hidden' value='" + $('meta[name="csrf-token"]').attr('content') + "'>";
|
31
|
+
type = "";
|
32
|
+
} else {
|
33
|
+
auth_token = "";
|
34
|
+
type = " data-type='" + link.data("type") + "'";
|
35
|
+
}
|
36
|
+
|
27
37
|
instance_class = link.data("class");
|
28
38
|
input_value = link.text();
|
29
39
|
input_id = instance_class + "_" + attribute;
|
30
40
|
input_name = instance_class + "[" + attribute + "]";
|
31
41
|
|
32
42
|
buttons = "<button type='submit' class='btn btn-primary abracadabra-submit'><i class='fa fa-check'></i></button><button type='button' class='btn abracadabra-cancel'><i class='fa fa-times'></i></button>";
|
33
|
-
open_form_tag = "<form accept-charset='UTF-8' action='" + path + "'
|
34
|
-
hidden_method_tags = "<div style='display:none;'><input name='utf8' type='hidden' value='✓'><input name='_method' type='hidden' value='" + form_method + "'
|
43
|
+
open_form_tag = "<form accept-charset='UTF-8' action='" + path + "'" + remote + type + " class='form-inline abracadabra-form' method='post'>";
|
44
|
+
hidden_method_tags = "<div style='display:none;'><input name='utf8' type='hidden' value='✓'><input name='_method' type='hidden' value='" + form_method + "'>" + auth_token + "</div>";
|
35
45
|
input = "<input type='text' class='form-control' id='" + input_id + "' name='" + input_name + "' value='" + input_value + "'>";
|
36
46
|
|
37
47
|
html = "<span class='abracadabra-container abracadabra-inline'>" + open_form_tag + hidden_method_tags;
|
@@ -6,7 +6,16 @@ module Abracadabra
|
|
6
6
|
link_class = "#{options[:class]} abracadabra".strip
|
7
7
|
value = options[:value] || instance.send(options[:attribute])
|
8
8
|
method = options[:method] || "patch"
|
9
|
-
|
9
|
+
|
10
|
+
if (options[:remote].nil? && options[:type].nil?) || options[:remote] == true
|
11
|
+
remote = true
|
12
|
+
else
|
13
|
+
remote = false
|
14
|
+
end
|
15
|
+
|
16
|
+
data_type = options[:type].to_s.gsub(/^j+s+$/, "script") || "script"
|
17
|
+
|
18
|
+
link_to value, "javascript:void(0)", class: link_class, method: method.to_sym, data: { path: options[:path], attribute: options[:attribute], class: instance_class, type: data_type.to_sym }, remote: remote
|
10
19
|
end
|
11
20
|
end
|
12
21
|
end
|
data/lib/abracadabra/version.rb
CHANGED