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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0313990291cc523dfc6808622a86e8c7eccd38e2
4
- data.tar.gz: 20e68d186cbddebed1443543d45603c2dae9b924
3
+ metadata.gz: 7e03037f4fc3e7394b71c09177465f31067ae2c8
4
+ data.tar.gz: 865be37e5de9c41bba0fd4cdae75a4b9b9b82c7c
5
5
  SHA512:
6
- metadata.gz: 9e388c41997ce8dc45c4398b694b829db9249c51e4536e7c8973e3fe2a73ec75bae4163f54a26b7992df15ede1bc09638bdb28b2ede43e99e04a76f3b94a970b
7
- data.tar.gz: fbdf1360e53ed87c8c028b3814996d5b2a9e5b0abc15a0e2d36a8ea05b96b2080ec3255f5f0d5de793dcdabb2c9c0d986160b855a9cc06086d47304183ae6362
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. It would be nice to respond to more than just javascript as well (very simple to implement). Any other ideas, feel free to contribute!
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/<my-github-username>/abracadabra/fork )
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 + "' data-remote='true' class='form-inline abracadabra-form' method='post'>";
34
- hidden_method_tags = "<div style='display:none;'><input name='utf8' type='hidden' value='&#10003;'><input name='_method' type='hidden' value='" + form_method + "'></div>";
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='&#10003;'><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
- "<a href='javascript:void(0)' class='#{link_class}' data-path='#{options[:path]}' data-method='#{method}' data-attribute='#{options[:attribute]}' data-class='#{instance_class}'>#{value}</a>".html_safe
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
@@ -1,5 +1,5 @@
1
1
  module Abracadabra
2
2
  module Rails
3
- VERSION = "1.0.0"
3
+ VERSION = "1.0.1"
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.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Trevor Hinesley