cocoon 1.2.5 → 1.2.6
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 +8 -8
- data/History.md +8 -0
- data/README.markdown +14 -11
- data/Rakefile +0 -1
- data/VERSION +1 -1
- data/app/assets/javascripts/cocoon.js +9 -9
- data/cocoon.gemspec +5 -8
- data/lib/cocoon/view_helpers.rb +6 -4
- metadata +11 -21
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
M2MwYmFkNzAwZjhhYjA2NmEwMjMxMzMwY2Q0ZjNiNzU5YzFkZWE4YQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NmE1YTIwY2YzOTVkOTI1NzkzNGE4ZjIyZmUyZGI4ZTA0OTRkMmVhNg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZGZhNGU1N2FlNGZlOTFjYjVlZmNjZTFkMDIzYzE2OGNjMDJmZDljMTMxYTFh
|
10
|
+
MTIzYzkyNzExOWNlODljYzk0ZTQ2NmM3NzY2MDUyMmJiZjhmMGUzOWQ5Mzdh
|
11
|
+
YWRlNmM4NDZiMjdmZDdmNGEyYjVjOWYxYTc4ZjJkM2JhMWI0Yzg=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YzUxMTgzY2VlOWRiNzgyMDlhMWRmYTU5ZmJjNjI4YjBlYzAwYmRmZTRkMzM4
|
14
|
+
MDNlOGFiNDAyMTM5ZWJlZjkxMDc3ZWEwZGRiNmNkZTI3Njk1NWRkNjQzMjhj
|
15
|
+
MzkxODI0NDkyMmU1NjU0NDkwYTQwNzQzNzE5NzQwODMyM2JlNjY=
|
data/History.md
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
# Change History / Release Notes
|
2
2
|
|
3
|
+
## Version 1.2.6
|
4
|
+
|
5
|
+
* added some explicit documentation we use haml. Fixed the formtastic example.
|
6
|
+
* "unfreeze" frozen objects. Fixes #193.
|
7
|
+
* IE8 jquery fix (thanks @niuage).
|
8
|
+
* merged #191 which fixes an issue with a monkeypatched CGI. For more info, see
|
9
|
+
ticket #191. Thanks gsmendoza.
|
10
|
+
|
3
11
|
## Version 1.2.5
|
4
12
|
|
5
13
|
* fix gem dependencies: we added gems to allow building for rubinius, but those are only
|
data/README.markdown
CHANGED
@@ -101,22 +101,25 @@ E.g. in your `ProjectsController`:
|
|
101
101
|
Cocoon's default configuration requires `link_to_add_association` and associated partials to
|
102
102
|
be properly wrapped with elements. The examples below illustrate simple layouts.
|
103
103
|
|
104
|
+
Please note these examples rely on the `haml` gem (instead of the default `erb` views).
|
105
|
+
|
104
106
|
### Formtastic
|
105
107
|
|
106
108
|
In our `projects/_form` partial we'd write:
|
107
109
|
|
108
110
|
```haml
|
109
|
-
=
|
110
|
-
= f.
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
=
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
= f.
|
111
|
+
= semantic_form_for @project do |f|
|
112
|
+
= f.inputs do
|
113
|
+
= f.input :name
|
114
|
+
= f.input :description
|
115
|
+
%h3 Tasks
|
116
|
+
#tasks
|
117
|
+
= f.semantic_fields_for :tasks do |task|
|
118
|
+
= render 'task_fields', :f => task
|
119
|
+
.links
|
120
|
+
= link_to_add_association 'add task', f, :tasks
|
121
|
+
= f.actions do
|
122
|
+
= f.action :submit
|
120
123
|
```
|
121
124
|
|
122
125
|
And in our `_task_fields` partial we'd write:
|
data/Rakefile
CHANGED
@@ -33,7 +33,6 @@ begin
|
|
33
33
|
gem.email = "nathan@dixis.com"
|
34
34
|
gem.homepage = "http://github.com/nathanvda/cocoon"
|
35
35
|
gem.authors = ["Nathan Van der Auwera"]
|
36
|
-
gem.add_development_dependency "rspec", ">= 2.0.0"
|
37
36
|
gem.licenses = ["MIT"]
|
38
37
|
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
39
38
|
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.2.
|
1
|
+
1.2.6
|
@@ -5,11 +5,11 @@
|
|
5
5
|
var create_new_id = function() {
|
6
6
|
return (new Date().getTime() + cocoon_element_counter++);
|
7
7
|
}
|
8
|
-
|
8
|
+
|
9
9
|
var newcontent_braced = function(id) {
|
10
10
|
return '[' + id + ']$1';
|
11
11
|
}
|
12
|
-
|
12
|
+
|
13
13
|
var newcontent_underscord = function(id) {
|
14
14
|
return '_' + id + '_$1';
|
15
15
|
}
|
@@ -30,7 +30,7 @@
|
|
30
30
|
new_content = content.replace(regexp_braced, newcontent_braced(new_id)),
|
31
31
|
new_contents = [];
|
32
32
|
|
33
|
-
|
33
|
+
|
34
34
|
if (new_content == content) {
|
35
35
|
regexp_braced = new RegExp('\\[new_' + assocs + '\\](.*?\\s)', 'g');
|
36
36
|
regexp_underscord = new RegExp('_new_' + assocs + '_(\\w*)', 'g');
|
@@ -42,16 +42,16 @@
|
|
42
42
|
|
43
43
|
count = (isNaN(count) ? 1 : Math.max(count, 1));
|
44
44
|
count -= 1;
|
45
|
-
|
45
|
+
|
46
46
|
while (count) {
|
47
47
|
new_id = create_new_id();
|
48
48
|
new_content = content.replace(regexp_braced, newcontent_braced(new_id));
|
49
49
|
new_content = new_content.replace(regexp_underscord, newcontent_underscord(new_id));
|
50
50
|
new_contents.push(new_content);
|
51
|
-
|
51
|
+
|
52
52
|
count -= 1;
|
53
53
|
}
|
54
|
-
|
54
|
+
|
55
55
|
if (insertionNode){
|
56
56
|
if (insertionTraversal){
|
57
57
|
insertionNode = $this[insertionTraversal](insertionNode);
|
@@ -62,8 +62,8 @@
|
|
62
62
|
insertionNode = $this.parent();
|
63
63
|
}
|
64
64
|
|
65
|
-
|
66
|
-
var contentNode = $(
|
65
|
+
$.each(new_contents, function(i, node) {
|
66
|
+
var contentNode = $(node);
|
67
67
|
|
68
68
|
insertionNode.trigger('cocoon:before-insert', [contentNode]);
|
69
69
|
|
@@ -73,7 +73,7 @@
|
|
73
73
|
var addedContent = insertionNode[insertionMethod](contentNode);
|
74
74
|
|
75
75
|
insertionNode.trigger('cocoon:after-insert', [contentNode]);
|
76
|
-
}
|
76
|
+
});
|
77
77
|
});
|
78
78
|
|
79
79
|
$(document).on('click', '.remove_fields.dynamic, .remove_fields.existing', function(e) {
|
data/cocoon.gemspec
CHANGED
@@ -2,15 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: cocoon 1.2.
|
5
|
+
# stub: cocoon 1.2.6 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "cocoon"
|
9
|
-
s.version = "1.2.
|
9
|
+
s.version = "1.2.6"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
|
+
s.require_paths = ["lib"]
|
12
13
|
s.authors = ["Nathan Van der Auwera"]
|
13
|
-
s.date = "
|
14
|
+
s.date = "2014-03-18"
|
14
15
|
s.description = "Unobtrusive nested forms handling, using jQuery. Use this and discover cocoon-heaven."
|
15
16
|
s.email = "nathan@dixis.com"
|
16
17
|
s.extra_rdoc_files = [
|
@@ -79,8 +80,7 @@ Gem::Specification.new do |s|
|
|
79
80
|
]
|
80
81
|
s.homepage = "http://github.com/nathanvda/cocoon"
|
81
82
|
s.licenses = ["MIT"]
|
82
|
-
s.
|
83
|
-
s.rubygems_version = "2.1.11"
|
83
|
+
s.rubygems_version = "2.2.1"
|
84
84
|
s.summary = "gem that enables easier nested forms with standard forms, formtastic and simple-form"
|
85
85
|
|
86
86
|
if s.respond_to? :specification_version then
|
@@ -102,7 +102,6 @@ Gem::Specification.new do |s|
|
|
102
102
|
s.add_development_dependency(%q<psych>, [">= 0"])
|
103
103
|
s.add_development_dependency(%q<racc>, [">= 0"])
|
104
104
|
s.add_development_dependency(%q<rubinius-developer_tools>, [">= 0"])
|
105
|
-
s.add_development_dependency(%q<rspec>, [">= 2.0.0"])
|
106
105
|
else
|
107
106
|
s.add_dependency(%q<rails>, [">= 4.0.0"])
|
108
107
|
s.add_dependency(%q<sqlite3>, [">= 0"])
|
@@ -119,7 +118,6 @@ Gem::Specification.new do |s|
|
|
119
118
|
s.add_dependency(%q<psych>, [">= 0"])
|
120
119
|
s.add_dependency(%q<racc>, [">= 0"])
|
121
120
|
s.add_dependency(%q<rubinius-developer_tools>, [">= 0"])
|
122
|
-
s.add_dependency(%q<rspec>, [">= 2.0.0"])
|
123
121
|
end
|
124
122
|
else
|
125
123
|
s.add_dependency(%q<rails>, [">= 4.0.0"])
|
@@ -137,7 +135,6 @@ Gem::Specification.new do |s|
|
|
137
135
|
s.add_dependency(%q<psych>, [">= 0"])
|
138
136
|
s.add_dependency(%q<racc>, [">= 0"])
|
139
137
|
s.add_dependency(%q<rubinius-developer_tools>, [">= 0"])
|
140
|
-
s.add_dependency(%q<rspec>, [">= 2.0.0"])
|
141
138
|
end
|
142
139
|
end
|
143
140
|
|
data/lib/cocoon/view_helpers.rb
CHANGED
@@ -12,7 +12,7 @@ module Cocoon
|
|
12
12
|
# - *f* : the form this link should be placed in
|
13
13
|
# - *html_options*: html options to be passed to link_to (see <tt>link_to</tt>)
|
14
14
|
# - *&block*: the output of the block will be show in the link, see <tt>link_to</tt>
|
15
|
-
|
15
|
+
|
16
16
|
def link_to_remove_association(*args, &block)
|
17
17
|
if block_given?
|
18
18
|
f = args.first
|
@@ -60,7 +60,7 @@ module Cocoon
|
|
60
60
|
# - *:locals* : the locals hash in the :render_options is handed to the partial
|
61
61
|
# - *:partial* : explicitly override the default partial name
|
62
62
|
# - *:wrap_object* : a proc that will allow to wrap your object, especially suited when using
|
63
|
-
# decorators, or if you want special initialisation
|
63
|
+
# decorators, or if you want special initialisation
|
64
64
|
# - *:form_name* : the parameter for the form in the nested form partial. Default `f`.
|
65
65
|
# - *:count* : Count of how many objects will be added on a single click. Default `1`.
|
66
66
|
# - *&block*: see <tt>link_to</tt>
|
@@ -92,8 +92,8 @@ module Cocoon
|
|
92
92
|
new_object = create_object(f, association, force_non_association_create)
|
93
93
|
new_object = wrap_object.call(new_object) if wrap_object.respond_to?(:call)
|
94
94
|
|
95
|
-
html_options[:'data-association-insertion-template'] = CGI.escapeHTML(render_association(association, f, new_object, form_parameter_name, render_options, override_partial)).html_safe
|
96
|
-
|
95
|
+
html_options[:'data-association-insertion-template'] = CGI.escapeHTML(render_association(association, f, new_object, form_parameter_name, render_options, override_partial).to_str).html_safe
|
96
|
+
|
97
97
|
html_options[:'data-count'] = count if count > 0
|
98
98
|
|
99
99
|
link_to(name, '#', html_options)
|
@@ -137,6 +137,8 @@ module Cocoon
|
|
137
137
|
f.object.send(association).delete
|
138
138
|
end
|
139
139
|
|
140
|
+
assoc_obj = assoc_obj.dup if assoc_obj.frozen?
|
141
|
+
|
140
142
|
assoc_obj
|
141
143
|
end
|
142
144
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cocoon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nathan Van der Auwera
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-03-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -72,28 +72,32 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - ! '>='
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
75
|
+
version: !binary |-
|
76
|
+
Mi44LjA=
|
76
77
|
type: :development
|
77
78
|
prerelease: false
|
78
79
|
version_requirements: !ruby/object:Gem::Requirement
|
79
80
|
requirements:
|
80
81
|
- - ! '>='
|
81
82
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
83
|
+
version: !binary |-
|
84
|
+
Mi44LjA=
|
83
85
|
- !ruby/object:Gem::Dependency
|
84
86
|
name: rspec
|
85
87
|
requirement: !ruby/object:Gem::Requirement
|
86
88
|
requirements:
|
87
89
|
- - ! '>='
|
88
90
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
91
|
+
version: !binary |-
|
92
|
+
Mi44LjA=
|
90
93
|
type: :development
|
91
94
|
prerelease: false
|
92
95
|
version_requirements: !ruby/object:Gem::Requirement
|
93
96
|
requirements:
|
94
97
|
- - ! '>='
|
95
98
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
99
|
+
version: !binary |-
|
100
|
+
Mi44LjA=
|
97
101
|
- !ruby/object:Gem::Dependency
|
98
102
|
name: actionpack
|
99
103
|
requirement: !ruby/object:Gem::Requirement
|
@@ -220,20 +224,6 @@ dependencies:
|
|
220
224
|
- - ! '>='
|
221
225
|
- !ruby/object:Gem::Version
|
222
226
|
version: '0'
|
223
|
-
- !ruby/object:Gem::Dependency
|
224
|
-
name: rspec
|
225
|
-
requirement: !ruby/object:Gem::Requirement
|
226
|
-
requirements:
|
227
|
-
- - ! '>='
|
228
|
-
- !ruby/object:Gem::Version
|
229
|
-
version: 2.0.0
|
230
|
-
type: :development
|
231
|
-
prerelease: false
|
232
|
-
version_requirements: !ruby/object:Gem::Requirement
|
233
|
-
requirements:
|
234
|
-
- - ! '>='
|
235
|
-
- !ruby/object:Gem::Version
|
236
|
-
version: 2.0.0
|
237
227
|
description: Unobtrusive nested forms handling, using jQuery. Use this and discover
|
238
228
|
cocoon-heaven.
|
239
229
|
email: nathan@dixis.com
|
@@ -321,7 +311,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
321
311
|
version: '0'
|
322
312
|
requirements: []
|
323
313
|
rubyforge_project:
|
324
|
-
rubygems_version: 2.1
|
314
|
+
rubygems_version: 2.2.1
|
325
315
|
signing_key:
|
326
316
|
specification_version: 4
|
327
317
|
summary: gem that enables easier nested forms with standard forms, formtastic and
|