cocooned 1.3.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 3d9d9a27c6eb59ebc51ae3ab92101a7cf66f6fc13e8e23b011a19ee8722dd083
4
+ data.tar.gz: c258c388dc29c44d3b0dc9024d5423a7c118ef45f5549c168b61f536c55e9b8a
5
+ SHA512:
6
+ metadata.gz: a5f36777a4f62e29498b58491db235b55df6df2084e9a1cebdbbf0842501751e740ee4e996084d7092fe39da85609fb4575f23e64032a3a4207a5ddb5d7bf605
7
+ data.tar.gz: a80571f97c5ffaf66aea6856b3ea0cc3ee1d403633e48b18cb6e1a464c93cf353cd6d10a4a1681c60bba9aa98f647922de74aac62e9a23172fbdf637fd3b77de
data/.gitignore ADDED
@@ -0,0 +1,15 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ /node_modules/
11
+ /vendor/bundle/
12
+
13
+ spec/dummy/db/*.sqlite3
14
+ spec/dummy/log/*.log
15
+ spec/dummy/tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,14 @@
1
+ sudo: false
2
+ cache: bundler
3
+ language: ruby
4
+ rvm:
5
+ - 2.2.10
6
+ - 2.3.7
7
+ - 2.4.4
8
+ - 2.5.1
9
+ gemfile:
10
+ - gemfiles/Gemfile.rails-4
11
+ - gemfiles/Gemfile.rails-5
12
+
13
+ matrix:
14
+ fast_finish: true
data/Gemfile ADDED
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'http://rubygems.org'
4
+
5
+ # Specify your gem's dependencies in cocooned.gemspec
6
+ gemspec
7
+
8
+ group :development, :test do
9
+ # Dummy app dependencies
10
+ gem 'jquery-rails'
11
+ gem 'rails', '~> 5.0'
12
+ gem 'sqlite3'
13
+
14
+ gem 'nokogiri'
15
+ gem 'simplecov', require: false
16
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,194 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ cocooned (1.3.0)
5
+ rails (>= 4.0, <= 6.0)
6
+
7
+ GEM
8
+ remote: http://rubygems.org/
9
+ specs:
10
+ actioncable (5.2.1)
11
+ actionpack (= 5.2.1)
12
+ nio4r (~> 2.0)
13
+ websocket-driver (>= 0.6.1)
14
+ actionmailer (5.2.1)
15
+ actionpack (= 5.2.1)
16
+ actionview (= 5.2.1)
17
+ activejob (= 5.2.1)
18
+ mail (~> 2.5, >= 2.5.4)
19
+ rails-dom-testing (~> 2.0)
20
+ actionpack (5.2.1)
21
+ actionview (= 5.2.1)
22
+ activesupport (= 5.2.1)
23
+ rack (~> 2.0)
24
+ rack-test (>= 0.6.3)
25
+ rails-dom-testing (~> 2.0)
26
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
27
+ actionview (5.2.1)
28
+ activesupport (= 5.2.1)
29
+ builder (~> 3.1)
30
+ erubi (~> 1.4)
31
+ rails-dom-testing (~> 2.0)
32
+ rails-html-sanitizer (~> 1.0, >= 1.0.3)
33
+ activejob (5.2.1)
34
+ activesupport (= 5.2.1)
35
+ globalid (>= 0.3.6)
36
+ activemodel (5.2.1)
37
+ activesupport (= 5.2.1)
38
+ activerecord (5.2.1)
39
+ activemodel (= 5.2.1)
40
+ activesupport (= 5.2.1)
41
+ arel (>= 9.0)
42
+ activestorage (5.2.1)
43
+ actionpack (= 5.2.1)
44
+ activerecord (= 5.2.1)
45
+ marcel (~> 0.3.1)
46
+ activesupport (5.2.1)
47
+ concurrent-ruby (~> 1.0, >= 1.0.2)
48
+ i18n (>= 0.7, < 2)
49
+ minitest (~> 5.1)
50
+ tzinfo (~> 1.1)
51
+ arel (9.0.0)
52
+ ast (2.4.0)
53
+ builder (3.2.3)
54
+ concurrent-ruby (1.0.5)
55
+ crass (1.0.4)
56
+ diff-lcs (1.3)
57
+ docile (1.3.1)
58
+ erubi (1.7.1)
59
+ globalid (0.4.1)
60
+ activesupport (>= 4.2.0)
61
+ i18n (1.1.0)
62
+ concurrent-ruby (~> 1.0)
63
+ jaro_winkler (1.5.1)
64
+ jasmine (3.2.0)
65
+ jasmine-core (= 3.2.0)
66
+ phantomjs
67
+ rack (>= 1.2.1)
68
+ rake
69
+ jasmine-core (3.2.0)
70
+ jquery-rails (4.3.3)
71
+ rails-dom-testing (>= 1, < 3)
72
+ railties (>= 4.2.0)
73
+ thor (>= 0.14, < 2.0)
74
+ json (2.1.0)
75
+ loofah (2.2.2)
76
+ crass (~> 1.0.2)
77
+ nokogiri (>= 1.5.9)
78
+ mail (2.7.0)
79
+ mini_mime (>= 0.1.1)
80
+ marcel (0.3.2)
81
+ mimemagic (~> 0.3.2)
82
+ method_source (0.9.0)
83
+ mimemagic (0.3.2)
84
+ mini_mime (1.0.1)
85
+ mini_portile2 (2.3.0)
86
+ minitest (5.11.3)
87
+ nio4r (2.3.1)
88
+ nokogiri (1.8.4)
89
+ mini_portile2 (~> 2.3.0)
90
+ parallel (1.12.1)
91
+ parser (2.5.1.2)
92
+ ast (~> 2.4.0)
93
+ phantomjs (2.1.1.0)
94
+ powerpack (0.1.2)
95
+ rack (2.0.5)
96
+ rack-test (1.1.0)
97
+ rack (>= 1.0, < 3)
98
+ rails (5.2.1)
99
+ actioncable (= 5.2.1)
100
+ actionmailer (= 5.2.1)
101
+ actionpack (= 5.2.1)
102
+ actionview (= 5.2.1)
103
+ activejob (= 5.2.1)
104
+ activemodel (= 5.2.1)
105
+ activerecord (= 5.2.1)
106
+ activestorage (= 5.2.1)
107
+ activesupport (= 5.2.1)
108
+ bundler (>= 1.3.0)
109
+ railties (= 5.2.1)
110
+ sprockets-rails (>= 2.0.0)
111
+ rails-dom-testing (2.0.3)
112
+ activesupport (>= 4.2.0)
113
+ nokogiri (>= 1.6)
114
+ rails-html-sanitizer (1.0.4)
115
+ loofah (~> 2.2, >= 2.2.2)
116
+ railties (5.2.1)
117
+ actionpack (= 5.2.1)
118
+ activesupport (= 5.2.1)
119
+ method_source
120
+ rake (>= 0.8.7)
121
+ thor (>= 0.19.0, < 2.0)
122
+ rainbow (3.0.0)
123
+ rake (12.3.1)
124
+ rspec (3.8.0)
125
+ rspec-core (~> 3.8.0)
126
+ rspec-expectations (~> 3.8.0)
127
+ rspec-mocks (~> 3.8.0)
128
+ rspec-core (3.8.0)
129
+ rspec-support (~> 3.8.0)
130
+ rspec-expectations (3.8.1)
131
+ diff-lcs (>= 1.2.0, < 2.0)
132
+ rspec-support (~> 3.8.0)
133
+ rspec-mocks (3.8.0)
134
+ diff-lcs (>= 1.2.0, < 2.0)
135
+ rspec-support (~> 3.8.0)
136
+ rspec-rails (3.8.0)
137
+ actionpack (>= 3.0)
138
+ activesupport (>= 3.0)
139
+ railties (>= 3.0)
140
+ rspec-core (~> 3.8.0)
141
+ rspec-expectations (~> 3.8.0)
142
+ rspec-mocks (~> 3.8.0)
143
+ rspec-support (~> 3.8.0)
144
+ rspec-support (3.8.0)
145
+ rubocop (0.58.2)
146
+ jaro_winkler (~> 1.5.1)
147
+ parallel (~> 1.10)
148
+ parser (>= 2.5, != 2.5.1.1)
149
+ powerpack (~> 0.1)
150
+ rainbow (>= 2.2.2, < 4.0)
151
+ ruby-progressbar (~> 1.7)
152
+ unicode-display_width (~> 1.0, >= 1.0.1)
153
+ ruby-progressbar (1.10.0)
154
+ simplecov (0.16.1)
155
+ docile (~> 1.1)
156
+ json (>= 1.8, < 3)
157
+ simplecov-html (~> 0.10.0)
158
+ simplecov-html (0.10.2)
159
+ sprockets (3.7.2)
160
+ concurrent-ruby (~> 1.0)
161
+ rack (> 1, < 3)
162
+ sprockets-rails (3.2.1)
163
+ actionpack (>= 4.0)
164
+ activesupport (>= 4.0)
165
+ sprockets (>= 3.0.0)
166
+ sqlite3 (1.3.13)
167
+ thor (0.20.0)
168
+ thread_safe (0.3.6)
169
+ tzinfo (1.2.5)
170
+ thread_safe (~> 0.1)
171
+ unicode-display_width (1.4.0)
172
+ websocket-driver (0.7.0)
173
+ websocket-extensions (>= 0.1.0)
174
+ websocket-extensions (0.1.3)
175
+
176
+ PLATFORMS
177
+ ruby
178
+
179
+ DEPENDENCIES
180
+ bundler (~> 1.16)
181
+ cocooned!
182
+ jasmine (~> 3.2)
183
+ jquery-rails
184
+ nokogiri
185
+ rails (~> 5.0)
186
+ rake
187
+ rspec (~> 3.8.0)
188
+ rspec-rails (~> 3.8.0)
189
+ rubocop
190
+ simplecov
191
+ sqlite3
192
+
193
+ BUNDLED WITH
194
+ 1.16.2
data/History.md ADDED
@@ -0,0 +1,253 @@
1
+ # Change History / Release Notes
2
+
3
+ ## Version 1.3.0
4
+
5
+ ### Breaking changes
6
+
7
+ * Drop support for Rubinius, Ruby < 2.2 and Rails < 4.0
8
+ * Drop support for custom wrapper class on item containers (originaly supported _via_ an option on `link_to_remove_association`).
9
+
10
+ ### Deprecated
11
+
12
+ The gem has been renamed to `cocooned`:
13
+
14
+ * `link_to_add_association` has been renamed `cocooned_add_item_link`
15
+ * Generated add links class `add_fields` has been renamed `cocooned-add`
16
+ * `link_to_remove_association` has been renamed `cocooned_remove_item_link`
17
+ * Generated remove links class `remove_fields` has been renamed `cocooned-remove`
18
+ * `cocoon:*` and `*.cocoon` Javascript events have been renamed to `cocooned:*` and `*.cocooned`
19
+ (ex: `cocooned:before-insert`, `click.cocooned`)
20
+ * The `cocoon` i18n scope have been renamed to `cocooned`
21
+ * The `.nested-fields` default item wrapper class have been renamed to `cocooned-item`
22
+
23
+ Other deprecations:
24
+
25
+ * `link_to_add_association`/`cocooned_add_item_link` no longer require a `:render_options` hash to pass locals to the nested partial
26
+
27
+ ### Non-breaking changes
28
+
29
+ * Refactor cocoon javascript as a self-contained object with same functionalities
30
+ * Automatically remove `required` attributes on destroyed elements (thanks @markkhair)
31
+ * Add extra properties on events (thanks @ayaman)
32
+ * Add a basic package.json to be used with Webpack (thanks @dmfrancisco)
33
+ * Compatibility with jQuery 3 (thanks @mstmfm)
34
+ * Namespace click handlers (thanks @chrise86)
35
+ * Drop support for Ruby 1.9 (thanks @simi)
36
+ * Remove Jeweller (thanks @brixen, @tlynam)
37
+
38
+ ## Version 1.2.11
39
+
40
+ * Allow events to be cancelled in the 'before' callbacks (thanks @wgordon17)
41
+
42
+ ## Version 1.2.10
43
+
44
+ * Use lazy-loading in initializer
45
+
46
+ ## Version 1.2.9
47
+
48
+ * Allow function pass to association-insertion-node (thanks @Liooo)
49
+
50
+ ## Version 1.2.8
51
+
52
+ * Compatibility with Turbolinks
53
+
54
+ ## Version 1.2.7
55
+
56
+ * Fix SimpleForm/Formtastic detections (thanks @mfrederickson)
57
+ * Add default captions for add and remove links through I18n (thanks @ViliusLuneckas)
58
+
59
+ ## Version 1.2.6
60
+
61
+ * added some explicit documentation we use haml. Fixed the formtastic example.
62
+ * "unfreeze" frozen objects. Fixes #193.
63
+ * IE8 jquery fix (thanks @niuage).
64
+ * merged #191 which fixes an issue with a monkeypatched CGI. For more info, see
65
+ ticket #191. Thanks gsmendoza.
66
+
67
+ ## Version 1.2.5
68
+
69
+ * fix gem dependencies: we added gems to allow building for rubinius, but those are only
70
+ needed when developing
71
+
72
+ ## Version 1.2.4
73
+
74
+ * the wrapper class is now configurable. Before it was assumed to be `nested-fields`.
75
+ Now it is configurable by handing. See #180. Thanks Yoav Matchulsky.
76
+ * fix build on travis-ci for rubinius (thanks brixen).
77
+
78
+ ## Version 1.2.3
79
+
80
+ * add license info
81
+
82
+ ## Version 1.2.2
83
+
84
+ * added option to add multiple items on one click. See #175.
85
+ * cleaned up javascript code. See #171.
86
+
87
+
88
+ ## Version 1.2.1
89
+
90
+ * added a `:form_name` parameter (fixes #153) which allows to use a self-chosen
91
+ parameter in the nested views. Up until now `f` was assumed (and enforced).
92
+ * improvement of creation of the objects on the association (thanks to Dirk von Grünigen). This
93
+ alleviates the need for the `:force_non_association_create` option in most cases.
94
+ That option is for now still kept.
95
+ * after validation errors, already deleted (but not saved) nested elements, will remain deleted
96
+ (e.g. the state is remembered, and they remain hidden, and will be correctly deleted on next
97
+ succesfull save) (fixes #136).
98
+
99
+ ## Version 1.2.0
100
+
101
+ * support for rails 4.0
102
+
103
+ ## Version 1.1.2
104
+
105
+ * pull #118 (thanks @ahmozkya): remove the deprecated `.live` function, and use `.on` instead.
106
+ Note: at least jquery 1.7 is required now!
107
+
108
+ ## Version 1.1.1
109
+
110
+ * added the to be added/deleted element to the event, this allows to add animations/actions onto them
111
+ * added extra option :wrap_object, allowing to use Decorators instead of the association object
112
+ * added an option :force_non_association_create, that will allow to use `link_to_add_association` inside the fields-partial
113
+
114
+ ## Version 1.1.0
115
+
116
+ * BREAKING: the triggered javascript events `removal-callback`, `after-removal-callback`, and `insertion-callback` are renamed to the more correct and symmetric
117
+ `cocoon:after-insert, cocoon:before-insert, cocoon:after-remove, cocoon:before-remove`. Also the events are namespaced to prevent collisions with other libraries.
118
+ * allow created objects to be decorated with a callable. This is especially useful if you are using Draper or some decorator instead of the plain model in your views.
119
+ * it is now possible to specify a relative node, and use standard jquery traversal methods on insertion
120
+ * trigger insertion event on correct `insertionNode`
121
+ * thanks to #90 cocoon now supports non-AR associations and array-fields, you just have to supply your own `build_<association>` methods
122
+
123
+ I would really really like to thank all contributors, check them out https://github.com/nathanvda/cocoon/graphs/contributors
124
+ They made cocoon way more awesome than I could have done in my lonesome.
125
+
126
+ ## Version 1.0.22
127
+
128
+ * Fix that it still works for mongoid
129
+
130
+ ## Version 1.0.21
131
+
132
+ * Use association build methods instead of assoc.klass.new. This avoids mass-assignment errors and other misbehaviors around attribute accessibility.
133
+
134
+
135
+ ## Version 1.0.20
136
+
137
+ * improved handing of the `:partial`: remove the extra options-hash, and just make it use the single hash, so now we can just write
138
+
139
+ = link_to_add_association 'add something', f, :tasks, :partial => 'shared/task_fields'
140
+ = link_to_add_association 'add something', f, :tasks, :class => 'your-special-class', :partial => 'shared/task_fields'
141
+
142
+
143
+ ## Version 1.0.19
144
+
145
+ * pull #53 (@CuriousCurmudgeon): fixed some bugs introduced in previous version (ooooops! Thanks!!!)
146
+
147
+ ## Version 1.0.18
148
+
149
+ * pull in #51 (@erwin): adding an `after-removal-callback` in javascript, very useful if you want to recalculate e.g. total-items or indexes
150
+ * pull in #42 (@zacstewart): allow to hand extra `:locals` to the partial
151
+ * updated documentation
152
+
153
+ ## Version 1.0.17
154
+
155
+ * fix: make sure that cocoon still works for rails 3.0, where the `conditions` is not available yet
156
+
157
+ ## Version 1.0.16
158
+
159
+ * merged pull request #33 (@fl00r): added the a custom partial option! genius :)
160
+ Also the creation of the nested objects takes any available conditions into account.
161
+ Now you can write
162
+
163
+ = link_to_add_association 'add something', f, :tasks, {}, :partial => 'shared/task_fields'
164
+
165
+ ## Version 1.0.15
166
+
167
+ * added `data-association-insertion-method` that gives more control over where to insert the new nested fields.
168
+ It takes a jquery method as parameter that inserts the new data. `before`, `after`, `append`, `prepend`, etc. Default: `before`.
169
+ * `data-association-insertion-position` is still available and acts as an alias. Probably this will be deprecated in the future.
170
+
171
+
172
+ ## Version 1.0.14
173
+
174
+ * When playing with `simple_form` and `twitter-bootstrap`, I noticed it is crucial that I call the correct nested-fields function.
175
+ That is: `fields_for` for standard forms, `semantic_fields_for` in formtastic and `simple_fields_for` for simple_form.
176
+ Secondly, this was not enough, I needed to be able to hand down options to that method. So in the `link_to_add_association` method you
177
+ can now an extra option `:render_options` and that hash will be handed to the association-builder.
178
+
179
+ This allows the nested fields to be built correctly with `simple_form` for `twitter-bootstrap`.
180
+
181
+ ## Version 1.0.13
182
+
183
+ * A while ago we added the option to add a javascript callback on inserting a new associated object, I now made sure we can add a callback on insertion
184
+ and on removal of a new item. One example where this was useful for me is visible in the demo project `cocoon_simple_form_demo` where I implemented a
185
+ `belongs_to` relation, and either select from a list, or add a new element.
186
+ So: the callback-mechanism has changed, and now the callback is bound to the parent container, instead of the link itself. This is because we can also
187
+ bind the removal callback there (as the removal link is inserted in the html dynamically).
188
+
189
+ For more info, see the `README`.
190
+
191
+ ## Version 1.0.12
192
+
193
+ * using "this" in `association-insertion-node` is now possible
194
+
195
+ If you are using rails < 3.1, you should run
196
+
197
+ rails g cocoon:install
198
+
199
+ to install the new `cocoon.js` to your `public/javascripts` folder.
200
+
201
+
202
+ ## Version 1.0.11
203
+
204
+
205
+ ## Version 1.0.10
206
+
207
+ * Fuck! Built the gem with 1.9.2 again. Built the gem again with 1.8.7.
208
+
209
+ ## Version 1.0.9
210
+
211
+ * is now rails 3.1 compatible. If you are not using Rails 3.1 yet, this should have no effect.
212
+ For rails 3.1 the cocoon.js no longer needs to be installed using the `rails g cocoon:install`. It is
213
+ automatically used from the gem.
214
+
215
+ ## Version 1.0.8
216
+
217
+ * Loosened the gem dependencies.
218
+
219
+ ## Version 1.0.7 (20/06/2011)
220
+
221
+ Apparently, the gem 1.0.6 which was generated with ruby 1.9.2 gave the following error upon install:
222
+
223
+ uninitialized constant Psych::Syck (NameError)
224
+
225
+ This is related to this bug: http://rubyforge.org/tracker/?group_id=126&atid=575&func=detail&aid=29163
226
+
227
+ This should be fixed in the next release of rubygems, the fix should be to build the gem with ruby 1.8.7.
228
+ Let's hope this works.
229
+
230
+ ## Version 1.0.6 (19/06/2011)
231
+
232
+ * The javascript has been improved to consistently use `e.preventDefault` instead of returning false.
233
+
234
+ Run
235
+
236
+ rails g cocoon:install
237
+
238
+ to copy the new `cocoon.js` to your `public/javascripts` folder.
239
+
240
+
241
+ ## Version 1.0.5 (17/06/2011)
242
+
243
+ * This release make sure that the `link_to_add_association` generates a correctly clickable
244
+ link in the newer rails 3 versions as well. In rails 3.0.8. the html was double escaped.
245
+
246
+ If you are upgrading from 1.0.4, you just have to update the gem. No other actions needed. If you are updating
247
+ from earlier versions, it is safer to do
248
+
249
+ rails g cocoon:install
250
+
251
+ This will copy the new `cocoon.js` files to your `public/javascripts` folder.
252
+
253
+
data/LICENSE ADDED
@@ -0,0 +1,13 @@
1
+ Copyright 2018 notus.sh
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.