abracadabra 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +34 -6
- data/app/helpers/abracadabra/rails/view_helper.rb +3 -3
- data/lib/abracadabra/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a547e178b8cfdab8f627f326c25a717262c259c8
|
4
|
+
data.tar.gz: b9f09ee3fa7e063623b8f90e0ebbff941296bdf8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 42b5af88fa0c4b382d48779cc039f4f360ca0f99a307d40f93abe1aa439075114a43c22097d5191ccf248a78e434f147e9208f6e08d1efb1c83d774897ae1a08
|
7
|
+
data.tar.gz: 799eed594cf39ee6f922fccddf8768d95bf94131f94b828cf1d0faa0dd45d6a141f6bed55765fdcf6ac3b3dc51804fa340a7cb17e7e266525c3827f8a371c765
|
data/README.md
CHANGED
@@ -20,6 +20,8 @@ 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)
|
24
|
+
|
23
25
|
In your `application.css`, AFTER Bootstrap (currently only supports Bootstrap), include the css file:
|
24
26
|
|
25
27
|
```css
|
@@ -40,28 +42,54 @@ The bread and butter of abracadabra is its helper, `click_to_edit`. Its pretty m
|
|
40
42
|
<%= click_to_edit @user, path: user_path(@user), attribute: :name %>
|
41
43
|
```
|
42
44
|
|
43
|
-
When a user clicks the link generated by this helper, a form with a text field input will replace the link. It's fully Rails compliant, and looks identical to a `form_for` with `remote: true`.
|
45
|
+
When a user clicks the link generated by this helper, a form with a text field input will replace the link. It's fully Rails compliant, and looks identical to a `form_for` with `remote: true`. Here's what it looks like:
|
44
46
|
|
45
|
-
[
|
47
|
+
![Abracadabra Demo](http://recordit.co/CbgPTahYix.gif "Abracadabra Demo")
|
46
48
|
|
47
|
-
The first parameter is the object to be edited, and the only other required parameters are `path` and `attribute`. `path` specifies where the form will be submitted, and `attribute` specifies the column being updated.
|
49
|
+
The first parameter of `click_to_edit` is the object to be edited, and the only other required parameters are `path` and `attribute`. `path` specifies where the form will be submitted, and `attribute` specifies the column being updated.
|
48
50
|
|
49
|
-
It accepts the following
|
51
|
+
It accepts the following parameters:
|
50
52
|
|
51
53
|
```ruby
|
54
|
+
### REQUIRED ###
|
55
|
+
path: user_path(@user)
|
56
|
+
# Specifies where the form will be submitted.
|
57
|
+
|
58
|
+
attribute: :name
|
59
|
+
# Specifies what attribute your text field will be updating.
|
60
|
+
|
61
|
+
|
62
|
+
### OPTIONAL ###
|
52
63
|
class: "my-class"
|
53
|
-
#
|
64
|
+
# Class(es) to be added to the text input of the form. The class "abracadabra" is added either way.
|
65
|
+
# Default: only "abracadabra"
|
54
66
|
|
55
67
|
value: "blah"
|
56
68
|
# An alternate value, other than what object.attribute would return.
|
69
|
+
# Default: object.attribute
|
57
70
|
|
58
71
|
method: "patch"
|
59
72
|
# HTTP REST method to use. Use anything but "get".
|
73
|
+
# Default: "patch"
|
74
|
+
|
75
|
+
remote: true
|
76
|
+
# Same as link_to's remote: true, form submits via AJAX.
|
77
|
+
# Default: true
|
78
|
+
|
79
|
+
# IMPORTANT: `type` will be ignored if `remote = false` is used. HTML is the default
|
80
|
+
# in Rails for standard form submissions.
|
81
|
+
type: :js
|
82
|
+
# Content type -- responds to any content types (:js and :script can both be used to respond with Javascript).
|
83
|
+
# Default: :script (:js)
|
60
84
|
```
|
61
85
|
|
62
86
|
## Future & Contributing
|
63
87
|
|
64
|
-
I would love anyone to add date pickers and other alternate field types to this.
|
88
|
+
1. I would love anyone to add date pickers and other alternate field types to this.
|
89
|
+
|
90
|
+
2. I would love the different Bootstrap classes to be overridable with an initializer (config/abracadabra.rb) so that any framework could be used. Same with the Font-Awesome button classes.
|
91
|
+
|
92
|
+
Any other ideas, feel free to contribute!
|
65
93
|
|
66
94
|
1. Fork it ( http://github.com/TrevorHinesley/abracadabra/fork )
|
67
95
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
@@ -7,10 +7,10 @@ module Abracadabra
|
|
7
7
|
value = options[:value] || instance.send(options[:attribute])
|
8
8
|
method = options[:method] || "patch"
|
9
9
|
|
10
|
-
if
|
11
|
-
remote = true
|
12
|
-
else
|
10
|
+
if !options[:remote].nil? && options[:remote] == false
|
13
11
|
remote = false
|
12
|
+
else
|
13
|
+
remote = true
|
14
14
|
end
|
15
15
|
|
16
16
|
data_type = options[:type].to_s.gsub(/^j+s+$/, "script") || "script"
|
data/lib/abracadabra/version.rb
CHANGED
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.0.
|
4
|
+
version: 1.0.3
|
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-03-
|
11
|
+
date: 2014-03-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|