cocoon 1.0.5 → 1.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +5 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +53 -56
- data/History.md +29 -0
- data/README.markdown +2 -0
- data/VERSION +1 -1
- data/cocoon.gemspec +82 -86
- data/lib/generators/cocoon/install/templates/cocoon.js +28 -30
- data/spec/cocoon_spec.rb +5 -5
- data/spec/dummy/script/rails +0 -0
- metadata +139 -37
- data/.gitignore +0 -7
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -2,96 +2,93 @@ GEM
|
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
4
|
abstract (1.0.0)
|
5
|
-
actionmailer (3.0.
|
6
|
-
actionpack (= 3.0.
|
7
|
-
mail (~> 2.2.
|
8
|
-
actionpack (3.0.
|
9
|
-
activemodel (= 3.0.
|
10
|
-
activesupport (= 3.0.
|
5
|
+
actionmailer (3.0.8)
|
6
|
+
actionpack (= 3.0.8)
|
7
|
+
mail (~> 2.2.19)
|
8
|
+
actionpack (3.0.8)
|
9
|
+
activemodel (= 3.0.8)
|
10
|
+
activesupport (= 3.0.8)
|
11
11
|
builder (~> 2.1.2)
|
12
12
|
erubis (~> 2.6.6)
|
13
|
-
i18n (~> 0.
|
13
|
+
i18n (~> 0.5.0)
|
14
14
|
rack (~> 1.2.1)
|
15
|
-
rack-mount (~> 0.6.
|
16
|
-
rack-test (~> 0.5.
|
15
|
+
rack-mount (~> 0.6.14)
|
16
|
+
rack-test (~> 0.5.7)
|
17
17
|
tzinfo (~> 0.3.23)
|
18
|
-
activemodel (3.0.
|
19
|
-
activesupport (= 3.0.
|
18
|
+
activemodel (3.0.8)
|
19
|
+
activesupport (= 3.0.8)
|
20
20
|
builder (~> 2.1.2)
|
21
|
-
i18n (~> 0.
|
22
|
-
activerecord (3.0.
|
23
|
-
activemodel (= 3.0.
|
24
|
-
activesupport (= 3.0.
|
25
|
-
arel (~> 2.0.
|
21
|
+
i18n (~> 0.5.0)
|
22
|
+
activerecord (3.0.8)
|
23
|
+
activemodel (= 3.0.8)
|
24
|
+
activesupport (= 3.0.8)
|
25
|
+
arel (~> 2.0.10)
|
26
26
|
tzinfo (~> 0.3.23)
|
27
|
-
activeresource (3.0.
|
28
|
-
activemodel (= 3.0.
|
29
|
-
activesupport (= 3.0.
|
30
|
-
activesupport (3.0.
|
31
|
-
arel (2.0.
|
27
|
+
activeresource (3.0.8)
|
28
|
+
activemodel (= 3.0.8)
|
29
|
+
activesupport (= 3.0.8)
|
30
|
+
activesupport (3.0.8)
|
31
|
+
arel (2.0.10)
|
32
32
|
builder (2.1.2)
|
33
33
|
diff-lcs (1.1.2)
|
34
34
|
erubis (2.6.6)
|
35
35
|
abstract (>= 1.0.0)
|
36
|
-
gemcutter (0.6.1)
|
37
36
|
git (1.2.5)
|
38
37
|
i18n (0.5.0)
|
39
|
-
jeweler (1.
|
40
|
-
|
38
|
+
jeweler (1.6.2)
|
39
|
+
bundler (~> 1.0)
|
41
40
|
git (>= 1.2.5)
|
42
|
-
|
43
|
-
json_pure (1.
|
44
|
-
mail (2.2.
|
41
|
+
rake
|
42
|
+
json_pure (1.5.2)
|
43
|
+
mail (2.2.19)
|
45
44
|
activesupport (>= 2.3.6)
|
46
45
|
i18n (>= 0.4.0)
|
47
46
|
mime-types (~> 1.16)
|
48
47
|
treetop (~> 1.4.8)
|
49
48
|
mime-types (1.16)
|
50
49
|
polyglot (0.3.1)
|
51
|
-
rack (1.2.
|
52
|
-
rack-mount (0.6.
|
50
|
+
rack (1.2.3)
|
51
|
+
rack-mount (0.6.14)
|
53
52
|
rack (>= 1.0.0)
|
54
53
|
rack-test (0.5.7)
|
55
54
|
rack (>= 1.0)
|
56
|
-
rails (3.0.
|
57
|
-
actionmailer (= 3.0.
|
58
|
-
actionpack (= 3.0.
|
59
|
-
activerecord (= 3.0.
|
60
|
-
activeresource (= 3.0.
|
61
|
-
activesupport (= 3.0.
|
55
|
+
rails (3.0.8)
|
56
|
+
actionmailer (= 3.0.8)
|
57
|
+
actionpack (= 3.0.8)
|
58
|
+
activerecord (= 3.0.8)
|
59
|
+
activeresource (= 3.0.8)
|
60
|
+
activesupport (= 3.0.8)
|
62
61
|
bundler (~> 1.0)
|
63
|
-
railties (= 3.0.
|
64
|
-
railties (3.0.
|
65
|
-
actionpack (= 3.0.
|
66
|
-
activesupport (= 3.0.
|
62
|
+
railties (= 3.0.8)
|
63
|
+
railties (3.0.8)
|
64
|
+
actionpack (= 3.0.8)
|
65
|
+
activesupport (= 3.0.8)
|
67
66
|
rake (>= 0.8.7)
|
68
67
|
thor (~> 0.14.4)
|
69
|
-
rake (0.
|
70
|
-
rspec (2.
|
71
|
-
rspec-core (~> 2.
|
72
|
-
rspec-expectations (~> 2.
|
73
|
-
rspec-mocks (~> 2.
|
74
|
-
rspec-core (2.4
|
75
|
-
rspec-expectations (2.
|
68
|
+
rake (0.9.2)
|
69
|
+
rspec (2.6.0)
|
70
|
+
rspec-core (~> 2.6.0)
|
71
|
+
rspec-expectations (~> 2.6.0)
|
72
|
+
rspec-mocks (~> 2.6.0)
|
73
|
+
rspec-core (2.6.4)
|
74
|
+
rspec-expectations (2.6.0)
|
76
75
|
diff-lcs (~> 1.1.2)
|
77
|
-
rspec-mocks (2.
|
78
|
-
rspec-rails (2.
|
76
|
+
rspec-mocks (2.6.0)
|
77
|
+
rspec-rails (2.6.1)
|
79
78
|
actionpack (~> 3.0)
|
80
79
|
activesupport (~> 3.0)
|
81
80
|
railties (~> 3.0)
|
82
|
-
rspec (~> 2.
|
83
|
-
|
84
|
-
|
85
|
-
simplecov (0.
|
86
|
-
simplecov-html (>= 0.3.7)
|
87
|
-
simplecov-html (0.3.9)
|
81
|
+
rspec (~> 2.6.0)
|
82
|
+
simplecov (0.4.2)
|
83
|
+
simplecov-html (~> 0.4.4)
|
84
|
+
simplecov-html (0.4.5)
|
88
85
|
sqlite3 (1.3.3)
|
89
86
|
sqlite3-ruby (1.3.3)
|
90
87
|
sqlite3 (>= 1.3.3)
|
91
88
|
thor (0.14.6)
|
92
89
|
treetop (1.4.9)
|
93
90
|
polyglot (>= 0.3.1)
|
94
|
-
tzinfo (0.3.
|
91
|
+
tzinfo (0.3.28)
|
95
92
|
|
96
93
|
PLATFORMS
|
97
94
|
ruby
|
@@ -100,7 +97,7 @@ DEPENDENCIES
|
|
100
97
|
actionpack (>= 3.0.0)
|
101
98
|
jeweler
|
102
99
|
json_pure
|
103
|
-
rails (= 3.0.
|
100
|
+
rails (= 3.0.8)
|
104
101
|
rspec (>= 2.0.0.rc)
|
105
102
|
rspec-rails (>= 2.0.0.beta)
|
106
103
|
simplecov
|
data/History.md
CHANGED
@@ -1,8 +1,37 @@
|
|
1
1
|
# Change History / Release Notes
|
2
2
|
|
3
|
+
## Version 1.0.7 (20/06/2011)
|
4
|
+
|
5
|
+
Apparently, the gem 1.0.6 which was generated with ruby 1.9.2 gave the following error upon install:
|
6
|
+
|
7
|
+
uninitialized constant Psych::Syck (NameError)
|
8
|
+
|
9
|
+
This is related to this bug: http://rubyforge.org/tracker/?group_id=126&atid=575&func=detail&aid=29163
|
10
|
+
|
11
|
+
This should be fixed in the next release of rubygems, the fix should be to build the gem with ruby 1.8.7.
|
12
|
+
Let's hope this works.
|
13
|
+
|
14
|
+
## Version 1.0.6 (19/06/2011)
|
15
|
+
|
16
|
+
* The javascript has been improved to consistently use `e.preventDefault` instead of returning false.
|
17
|
+
|
18
|
+
Run
|
19
|
+
|
20
|
+
rails g cocoon:install
|
21
|
+
|
22
|
+
to copy the new `cocoon.js` to your `public/javascripts` folder.
|
23
|
+
|
24
|
+
|
3
25
|
## Version 1.0.5 (17/06/2011)
|
4
26
|
|
5
27
|
* This release make sure that the `link_to_add_association` generates a correctly clickable
|
6
28
|
link in the newer rails 3 versions as well. In rails 3.0.8. the html was double escaped.
|
7
29
|
|
30
|
+
If you are upgrading from 1.0.4, you just have to update the gem. No other actions needed. If you are updating
|
31
|
+
from earlier versions, it is safer to do
|
32
|
+
|
33
|
+
rails g cocoon:install
|
34
|
+
|
35
|
+
This will copy the new `cocoon.js` files to your `public/javascripts` folder.
|
36
|
+
|
8
37
|
|
data/README.markdown
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.7
|
data/cocoon.gemspec
CHANGED
@@ -1,118 +1,114 @@
|
|
1
1
|
# Generated by jeweler
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{cocoon}
|
8
|
-
s.version = "1.0.
|
8
|
+
s.version = "1.0.7"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Nathan Van der Auwera"]
|
12
|
-
s.date = %q{2011-
|
12
|
+
s.date = %q{2011-07-21}
|
13
13
|
s.description = %q{Unobtrusive nested forms handling, using jQuery. Use this and discover cocoon-heaven.}
|
14
14
|
s.email = %q{nathan@dixis.com}
|
15
15
|
s.extra_rdoc_files = [
|
16
16
|
"README.markdown"
|
17
17
|
]
|
18
18
|
s.files = [
|
19
|
-
".
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
19
|
+
".travis.yml",
|
20
|
+
"Gemfile",
|
21
|
+
"Gemfile.lock",
|
22
|
+
"History.md",
|
23
|
+
"MIT-LICENSE",
|
24
|
+
"README.markdown",
|
25
|
+
"Rakefile",
|
26
|
+
"VERSION",
|
27
|
+
"cocoon.gemspec",
|
28
|
+
"lib/cocoon.rb",
|
29
|
+
"lib/cocoon/view_helpers.rb",
|
30
|
+
"lib/generators/cocoon/install/install_generator.rb",
|
31
|
+
"lib/generators/cocoon/install/templates/cocoon.js",
|
32
|
+
"spec/cocoon_spec.rb",
|
33
|
+
"spec/dummy/Rakefile",
|
34
|
+
"spec/dummy/app/controllers/application_controller.rb",
|
35
|
+
"spec/dummy/app/helpers/application_helper.rb",
|
36
|
+
"spec/dummy/app/models/comment.rb",
|
37
|
+
"spec/dummy/app/models/person.rb",
|
38
|
+
"spec/dummy/app/models/post.rb",
|
39
|
+
"spec/dummy/app/views/layouts/application.html.erb",
|
40
|
+
"spec/dummy/config.ru",
|
41
|
+
"spec/dummy/config/application.rb",
|
42
|
+
"spec/dummy/config/boot.rb",
|
43
|
+
"spec/dummy/config/database.yml",
|
44
|
+
"spec/dummy/config/environment.rb",
|
45
|
+
"spec/dummy/config/environments/development.rb",
|
46
|
+
"spec/dummy/config/environments/production.rb",
|
47
|
+
"spec/dummy/config/environments/test.rb",
|
48
|
+
"spec/dummy/config/initializers/backtrace_silencers.rb",
|
49
|
+
"spec/dummy/config/initializers/inflections.rb",
|
50
|
+
"spec/dummy/config/initializers/mime_types.rb",
|
51
|
+
"spec/dummy/config/initializers/secret_token.rb",
|
52
|
+
"spec/dummy/config/initializers/session_store.rb",
|
53
|
+
"spec/dummy/config/locales/en.yml",
|
54
|
+
"spec/dummy/config/routes.rb",
|
55
|
+
"spec/dummy/db/migrate/20110306212208_create_posts.rb",
|
56
|
+
"spec/dummy/db/migrate/20110306212250_create_comments.rb",
|
57
|
+
"spec/dummy/db/migrate/20110420222224_create_people.rb",
|
58
|
+
"spec/dummy/db/schema.rb",
|
59
|
+
"spec/dummy/public/404.html",
|
60
|
+
"spec/dummy/public/422.html",
|
61
|
+
"spec/dummy/public/500.html",
|
62
|
+
"spec/dummy/public/favicon.ico",
|
63
|
+
"spec/dummy/public/javascripts/application.js",
|
64
|
+
"spec/dummy/public/javascripts/controls.js",
|
65
|
+
"spec/dummy/public/javascripts/dragdrop.js",
|
66
|
+
"spec/dummy/public/javascripts/effects.js",
|
67
|
+
"spec/dummy/public/javascripts/prototype.js",
|
68
|
+
"spec/dummy/public/javascripts/rails.js",
|
69
|
+
"spec/dummy/public/stylesheets/.gitkeep",
|
70
|
+
"spec/dummy/script/rails",
|
71
|
+
"spec/integration/navigation_spec.rb",
|
72
|
+
"spec/spec_helper.rb"
|
73
73
|
]
|
74
74
|
s.homepage = %q{http://github.com/nathanvda/cocoon}
|
75
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
76
75
|
s.require_paths = ["lib"]
|
77
|
-
s.rubygems_version = %q{1.
|
76
|
+
s.rubygems_version = %q{1.6.2}
|
78
77
|
s.summary = %q{gem that enables easier nested forms with standard forms, formtastic and simple-form}
|
79
|
-
s.test_files = [
|
80
|
-
"spec/spec_helper.rb",
|
81
|
-
"spec/dummy/app/controllers/application_controller.rb",
|
82
|
-
"spec/dummy/app/models/person.rb",
|
83
|
-
"spec/dummy/app/models/comment.rb",
|
84
|
-
"spec/dummy/app/models/post.rb",
|
85
|
-
"spec/dummy/app/helpers/application_helper.rb",
|
86
|
-
"spec/dummy/config/environment.rb",
|
87
|
-
"spec/dummy/config/initializers/session_store.rb",
|
88
|
-
"spec/dummy/config/initializers/mime_types.rb",
|
89
|
-
"spec/dummy/config/initializers/secret_token.rb",
|
90
|
-
"spec/dummy/config/initializers/backtrace_silencers.rb",
|
91
|
-
"spec/dummy/config/initializers/inflections.rb",
|
92
|
-
"spec/dummy/config/environments/production.rb",
|
93
|
-
"spec/dummy/config/environments/development.rb",
|
94
|
-
"spec/dummy/config/environments/test.rb",
|
95
|
-
"spec/dummy/config/application.rb",
|
96
|
-
"spec/dummy/config/routes.rb",
|
97
|
-
"spec/dummy/config/boot.rb",
|
98
|
-
"spec/dummy/db/schema.rb",
|
99
|
-
"spec/dummy/db/migrate/20110306212208_create_posts.rb",
|
100
|
-
"spec/dummy/db/migrate/20110420222224_create_people.rb",
|
101
|
-
"spec/dummy/db/migrate/20110306212250_create_comments.rb",
|
102
|
-
"spec/cocoon_spec.rb",
|
103
|
-
"spec/integration/navigation_spec.rb"
|
104
|
-
]
|
105
78
|
|
106
79
|
if s.respond_to? :specification_version then
|
107
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
108
80
|
s.specification_version = 3
|
109
81
|
|
110
82
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
83
|
+
s.add_runtime_dependency(%q<rails>, ["= 3.0.8"])
|
84
|
+
s.add_runtime_dependency(%q<sqlite3-ruby>, [">= 0"])
|
85
|
+
s.add_runtime_dependency(%q<json_pure>, [">= 0"])
|
86
|
+
s.add_development_dependency(%q<jeweler>, [">= 0"])
|
87
|
+
s.add_development_dependency(%q<rspec-rails>, [">= 2.0.0.beta"])
|
88
|
+
s.add_development_dependency(%q<rspec>, [">= 2.0.0.rc"])
|
89
|
+
s.add_development_dependency(%q<actionpack>, [">= 3.0.0"])
|
90
|
+
s.add_development_dependency(%q<simplecov>, [">= 0"])
|
111
91
|
s.add_development_dependency(%q<rspec>, [">= 2.0.0"])
|
112
92
|
else
|
93
|
+
s.add_dependency(%q<rails>, ["= 3.0.8"])
|
94
|
+
s.add_dependency(%q<sqlite3-ruby>, [">= 0"])
|
95
|
+
s.add_dependency(%q<json_pure>, [">= 0"])
|
96
|
+
s.add_dependency(%q<jeweler>, [">= 0"])
|
97
|
+
s.add_dependency(%q<rspec-rails>, [">= 2.0.0.beta"])
|
98
|
+
s.add_dependency(%q<rspec>, [">= 2.0.0.rc"])
|
99
|
+
s.add_dependency(%q<actionpack>, [">= 3.0.0"])
|
100
|
+
s.add_dependency(%q<simplecov>, [">= 0"])
|
113
101
|
s.add_dependency(%q<rspec>, [">= 2.0.0"])
|
114
102
|
end
|
115
103
|
else
|
104
|
+
s.add_dependency(%q<rails>, ["= 3.0.8"])
|
105
|
+
s.add_dependency(%q<sqlite3-ruby>, [">= 0"])
|
106
|
+
s.add_dependency(%q<json_pure>, [">= 0"])
|
107
|
+
s.add_dependency(%q<jeweler>, [">= 0"])
|
108
|
+
s.add_dependency(%q<rspec-rails>, [">= 2.0.0.beta"])
|
109
|
+
s.add_dependency(%q<rspec>, [">= 2.0.0.rc"])
|
110
|
+
s.add_dependency(%q<actionpack>, [">= 3.0.0"])
|
111
|
+
s.add_dependency(%q<simplecov>, [">= 0"])
|
116
112
|
s.add_dependency(%q<rspec>, [">= 2.0.0"])
|
117
113
|
end
|
118
114
|
end
|
@@ -1,63 +1,61 @@
|
|
1
1
|
$(document).ready(function() {
|
2
2
|
|
3
3
|
function replace_in_content(content, regexp_str, with_str) {
|
4
|
-
|
5
|
-
|
4
|
+
reg_exp = new RegExp(regexp_str);
|
5
|
+
content.replace(reg_exp, with_str);
|
6
6
|
}
|
7
7
|
|
8
|
+
$('.add_fields').live('click', function(e) {
|
9
|
+
e.preventDefault();
|
10
|
+
var assoc = $(this).data('association'),
|
11
|
+
assocs = $(this).data('associations'),
|
12
|
+
content = $(this).data('template'),
|
13
|
+
insertionPosition = $(this).data('association-insertion-position'),
|
14
|
+
insertionNode = $(this).data('association-insertion-node'),
|
15
|
+
insertionCallback = $(this).data('insertion-callback'),
|
16
|
+
regexp_braced = new RegExp('\\[new_' + assoc + '\\]', 'g'),
|
17
|
+
regexp_underscord = new RegExp('_new_' + assoc + '_', 'g'),
|
18
|
+
new_id = new Date().getTime(),
|
19
|
+
newcontent_braced = '[' + new_id + ']',
|
20
|
+
newcontent_underscord = '_' + new_id + '_',
|
21
|
+
new_content = content.replace(regexp_braced, '[' + new_id + ']');
|
8
22
|
|
9
|
-
$('.add_fields').live('click', function() {
|
10
|
-
var assoc = $(this).attr('data-association');
|
11
|
-
var assocs = $(this).attr('data-associations');
|
12
|
-
var content = $(this).attr('data-template');
|
13
|
-
var insertionPosition = $(this).attr('data-association-insertion-position');
|
14
|
-
var insertionNode = $(this).attr('data-association-insertion-node');
|
15
|
-
var insertionCallback = $(this).data('insertion-callback');
|
16
|
-
var regexp_braced = new RegExp('\\[new_' + assoc + '\\]', 'g');
|
17
|
-
var regexp_underscord = new RegExp('_new_' + assoc + '_', 'g');
|
18
|
-
var new_id = new Date().getTime();
|
19
|
-
var newcontent_braced = '[' + new_id + ']';
|
20
|
-
var newcontent_underscord = '_' + new_id + '_';
|
21
|
-
var new_content = content.replace(regexp_braced, '[' + new_id + ']');
|
22
23
|
if (new_content == content) {
|
23
24
|
regexp_braced = new RegExp('\\[new_' + assocs + '\\]', 'g');
|
24
25
|
regexp_underscord = new RegExp('_new_' + assocs + '_', 'g');
|
25
26
|
new_content = content.replace(regexp_braced, '[' + new_id + ']');
|
26
27
|
}
|
28
|
+
|
27
29
|
new_content = new_content.replace(regexp_underscord, newcontent_underscord);
|
28
30
|
|
29
|
-
if (insertionNode)
|
31
|
+
if (insertionNode){
|
30
32
|
insertionNode = $(insertionNode);
|
31
|
-
}
|
32
|
-
else {
|
33
|
+
} else {
|
33
34
|
insertionNode = $(this).parent();
|
34
35
|
}
|
35
36
|
|
36
37
|
var contentNode = $(new_content);
|
37
|
-
|
38
|
+
|
38
39
|
if (insertionPosition == 'after'){
|
39
40
|
insertionNode.after(contentNode);
|
40
41
|
} else {
|
41
|
-
insertionNode.before(contentNode);
|
42
|
+
insertionNode.before(contentNode);
|
42
43
|
}
|
43
|
-
|
44
|
-
if(insertionCallback){
|
44
|
+
|
45
|
+
if (insertionCallback){
|
45
46
|
insertionCallback.call(contentNode);
|
46
47
|
}
|
47
|
-
|
48
|
-
return false;
|
49
48
|
});
|
50
49
|
|
51
|
-
$('.remove_fields.dynamic').live('click', function() {
|
50
|
+
$('.remove_fields.dynamic').live('click', function(e) {
|
51
|
+
e.preventDefault();
|
52
52
|
$(this).closest(".nested-fields").remove();
|
53
|
-
return false;
|
54
53
|
});
|
55
54
|
|
56
|
-
$('.remove_fields.existing').live('click', function() {
|
55
|
+
$('.remove_fields.existing').live('click', function(e) {
|
56
|
+
e.preventDefault();
|
57
57
|
$(this).prev("input[type=hidden]").val("1");
|
58
58
|
$(this).closest(".nested-fields").hide();
|
59
|
-
return false;
|
60
59
|
});
|
61
60
|
|
62
|
-
});
|
63
|
-
|
61
|
+
});
|
data/spec/cocoon_spec.rb
CHANGED
@@ -21,12 +21,12 @@ describe Cocoon do
|
|
21
21
|
context "without a block" do
|
22
22
|
it "should accept a name" do
|
23
23
|
result = @tester.link_to_add_association('add something', @form_obj, :comments)
|
24
|
-
result.to_s.should == '<a href="#" class="add_fields" data-association="comment" data-associations="comments" data-template="form&
|
24
|
+
result.to_s.should == '<a href="#" class="add_fields" data-association="comment" data-associations="comments" data-template="form<tag>">add something</a>'
|
25
25
|
end
|
26
26
|
|
27
27
|
it "should accept html options and pass them to link_to" do
|
28
28
|
result = @tester.link_to_add_association('add something', @form_obj, :comments, {:class => 'something silly'})
|
29
|
-
result.to_s.should == '<a href="#" class="something silly add_fields" data-association="comment" data-associations="comments" data-template="form&
|
29
|
+
result.to_s.should == '<a href="#" class="something silly add_fields" data-association="comment" data-associations="comments" data-template="form<tag>">add something</a>'
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
@@ -35,14 +35,14 @@ describe Cocoon do
|
|
35
35
|
result = @tester.link_to_add_association(@form_obj, :comments) do
|
36
36
|
"some long name"
|
37
37
|
end
|
38
|
-
result.to_s.should == '<a href="#" class="add_fields" data-association="comment" data-associations="comments" data-template="form&
|
38
|
+
result.to_s.should == '<a href="#" class="add_fields" data-association="comment" data-associations="comments" data-template="form<tag>">some long name</a>'
|
39
39
|
end
|
40
40
|
|
41
41
|
it "should accept html options and pass them to link_to" do
|
42
42
|
result = @tester.link_to_add_association(@form_obj, :comments, {:class => 'floppy disk'}) do
|
43
43
|
"some long name"
|
44
44
|
end
|
45
|
-
result.to_s.should == '<a href="#" class="floppy disk add_fields" data-association="comment" data-associations="comments" data-template="form&
|
45
|
+
result.to_s.should == '<a href="#" class="floppy disk add_fields" data-association="comment" data-associations="comments" data-template="form<tag>">some long name</a>'
|
46
46
|
end
|
47
47
|
|
48
48
|
end
|
@@ -50,7 +50,7 @@ describe Cocoon do
|
|
50
50
|
context "with an irregular plural" do
|
51
51
|
it "should use the correct plural" do
|
52
52
|
result = @tester.link_to_add_association('add something', @form_obj, :people)
|
53
|
-
result.to_s.should == '<a href="#" class="add_fields" data-association="person" data-associations="people" data-template="form&
|
53
|
+
result.to_s.should == '<a href="#" class="add_fields" data-association="person" data-associations="people" data-template="form<tag>">add something</a>'
|
54
54
|
end
|
55
55
|
|
56
56
|
end
|
data/spec/dummy/script/rails
CHANGED
File without changes
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cocoon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
hash: 25
|
5
|
+
prerelease:
|
5
6
|
segments:
|
6
7
|
- 1
|
7
8
|
- 0
|
8
|
-
-
|
9
|
-
version: 1.0.
|
9
|
+
- 7
|
10
|
+
version: 1.0.7
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Nathan Van der Auwera
|
@@ -14,24 +15,147 @@ autorequire:
|
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
17
|
|
17
|
-
date: 2011-
|
18
|
+
date: 2011-07-21 00:00:00 +02:00
|
18
19
|
default_executable:
|
19
20
|
dependencies:
|
20
21
|
- !ruby/object:Gem::Dependency
|
21
|
-
|
22
|
+
type: :runtime
|
22
23
|
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - "="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
hash: 23
|
29
|
+
segments:
|
30
|
+
- 3
|
31
|
+
- 0
|
32
|
+
- 8
|
33
|
+
version: 3.0.8
|
34
|
+
name: rails
|
35
|
+
version_requirements: *id001
|
36
|
+
prerelease: false
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
type: :runtime
|
39
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
41
|
+
requirements:
|
42
|
+
- - ">="
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
hash: 3
|
45
|
+
segments:
|
46
|
+
- 0
|
47
|
+
version: "0"
|
48
|
+
name: sqlite3-ruby
|
49
|
+
version_requirements: *id002
|
50
|
+
prerelease: false
|
51
|
+
- !ruby/object:Gem::Dependency
|
52
|
+
type: :runtime
|
53
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
54
|
+
none: false
|
55
|
+
requirements:
|
56
|
+
- - ">="
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
hash: 3
|
59
|
+
segments:
|
60
|
+
- 0
|
61
|
+
version: "0"
|
62
|
+
name: json_pure
|
63
|
+
version_requirements: *id003
|
64
|
+
prerelease: false
|
65
|
+
- !ruby/object:Gem::Dependency
|
66
|
+
type: :development
|
67
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
23
68
|
none: false
|
24
69
|
requirements:
|
25
70
|
- - ">="
|
26
71
|
- !ruby/object:Gem::Version
|
72
|
+
hash: 3
|
73
|
+
segments:
|
74
|
+
- 0
|
75
|
+
version: "0"
|
76
|
+
name: jeweler
|
77
|
+
version_requirements: *id004
|
78
|
+
prerelease: false
|
79
|
+
- !ruby/object:Gem::Dependency
|
80
|
+
type: :development
|
81
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
82
|
+
none: false
|
83
|
+
requirements:
|
84
|
+
- - ">="
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
hash: 31098209
|
27
87
|
segments:
|
28
88
|
- 2
|
29
89
|
- 0
|
30
90
|
- 0
|
31
|
-
|
91
|
+
- beta
|
92
|
+
version: 2.0.0.beta
|
93
|
+
name: rspec-rails
|
94
|
+
version_requirements: *id005
|
95
|
+
prerelease: false
|
96
|
+
- !ruby/object:Gem::Dependency
|
32
97
|
type: :development
|
98
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
99
|
+
none: false
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
hash: 7712058
|
104
|
+
segments:
|
105
|
+
- 2
|
106
|
+
- 0
|
107
|
+
- 0
|
108
|
+
- rc
|
109
|
+
version: 2.0.0.rc
|
110
|
+
name: rspec
|
111
|
+
version_requirements: *id006
|
112
|
+
prerelease: false
|
113
|
+
- !ruby/object:Gem::Dependency
|
114
|
+
type: :development
|
115
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
116
|
+
none: false
|
117
|
+
requirements:
|
118
|
+
- - ">="
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
hash: 7
|
121
|
+
segments:
|
122
|
+
- 3
|
123
|
+
- 0
|
124
|
+
- 0
|
125
|
+
version: 3.0.0
|
126
|
+
name: actionpack
|
127
|
+
version_requirements: *id007
|
128
|
+
prerelease: false
|
129
|
+
- !ruby/object:Gem::Dependency
|
130
|
+
type: :development
|
131
|
+
requirement: &id008 !ruby/object:Gem::Requirement
|
132
|
+
none: false
|
133
|
+
requirements:
|
134
|
+
- - ">="
|
135
|
+
- !ruby/object:Gem::Version
|
136
|
+
hash: 3
|
137
|
+
segments:
|
138
|
+
- 0
|
139
|
+
version: "0"
|
140
|
+
name: simplecov
|
141
|
+
version_requirements: *id008
|
142
|
+
prerelease: false
|
143
|
+
- !ruby/object:Gem::Dependency
|
144
|
+
type: :development
|
145
|
+
requirement: &id009 !ruby/object:Gem::Requirement
|
146
|
+
none: false
|
147
|
+
requirements:
|
148
|
+
- - ">="
|
149
|
+
- !ruby/object:Gem::Version
|
150
|
+
hash: 15
|
151
|
+
segments:
|
152
|
+
- 2
|
153
|
+
- 0
|
154
|
+
- 0
|
155
|
+
version: 2.0.0
|
156
|
+
name: rspec
|
157
|
+
version_requirements: *id009
|
33
158
|
prerelease: false
|
34
|
-
version_requirements: *id001
|
35
159
|
description: Unobtrusive nested forms handling, using jQuery. Use this and discover cocoon-heaven.
|
36
160
|
email: nathan@dixis.com
|
37
161
|
executables: []
|
@@ -41,7 +165,7 @@ extensions: []
|
|
41
165
|
extra_rdoc_files:
|
42
166
|
- README.markdown
|
43
167
|
files:
|
44
|
-
- .
|
168
|
+
- .travis.yml
|
45
169
|
- Gemfile
|
46
170
|
- Gemfile.lock
|
47
171
|
- History.md
|
@@ -100,8 +224,8 @@ homepage: http://github.com/nathanvda/cocoon
|
|
100
224
|
licenses: []
|
101
225
|
|
102
226
|
post_install_message:
|
103
|
-
rdoc_options:
|
104
|
-
|
227
|
+
rdoc_options: []
|
228
|
+
|
105
229
|
require_paths:
|
106
230
|
- lib
|
107
231
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -109,7 +233,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
109
233
|
requirements:
|
110
234
|
- - ">="
|
111
235
|
- !ruby/object:Gem::Version
|
112
|
-
hash:
|
236
|
+
hash: 3
|
113
237
|
segments:
|
114
238
|
- 0
|
115
239
|
version: "0"
|
@@ -118,38 +242,16 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
118
242
|
requirements:
|
119
243
|
- - ">="
|
120
244
|
- !ruby/object:Gem::Version
|
245
|
+
hash: 3
|
121
246
|
segments:
|
122
247
|
- 0
|
123
248
|
version: "0"
|
124
249
|
requirements: []
|
125
250
|
|
126
251
|
rubyforge_project:
|
127
|
-
rubygems_version: 1.
|
252
|
+
rubygems_version: 1.6.2
|
128
253
|
signing_key:
|
129
254
|
specification_version: 3
|
130
255
|
summary: gem that enables easier nested forms with standard forms, formtastic and simple-form
|
131
|
-
test_files:
|
132
|
-
|
133
|
-
- spec/dummy/app/controllers/application_controller.rb
|
134
|
-
- spec/dummy/app/models/person.rb
|
135
|
-
- spec/dummy/app/models/comment.rb
|
136
|
-
- spec/dummy/app/models/post.rb
|
137
|
-
- spec/dummy/app/helpers/application_helper.rb
|
138
|
-
- spec/dummy/config/environment.rb
|
139
|
-
- spec/dummy/config/initializers/session_store.rb
|
140
|
-
- spec/dummy/config/initializers/mime_types.rb
|
141
|
-
- spec/dummy/config/initializers/secret_token.rb
|
142
|
-
- spec/dummy/config/initializers/backtrace_silencers.rb
|
143
|
-
- spec/dummy/config/initializers/inflections.rb
|
144
|
-
- spec/dummy/config/environments/production.rb
|
145
|
-
- spec/dummy/config/environments/development.rb
|
146
|
-
- spec/dummy/config/environments/test.rb
|
147
|
-
- spec/dummy/config/application.rb
|
148
|
-
- spec/dummy/config/routes.rb
|
149
|
-
- spec/dummy/config/boot.rb
|
150
|
-
- spec/dummy/db/schema.rb
|
151
|
-
- spec/dummy/db/migrate/20110306212208_create_posts.rb
|
152
|
-
- spec/dummy/db/migrate/20110420222224_create_people.rb
|
153
|
-
- spec/dummy/db/migrate/20110306212250_create_comments.rb
|
154
|
-
- spec/cocoon_spec.rb
|
155
|
-
- spec/integration/navigation_spec.rb
|
256
|
+
test_files: []
|
257
|
+
|