cocoon 1.2.12 → 1.2.13

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3c5f601d2d0e1375b2cf13ff4190ee64a5812a24
4
- data.tar.gz: 939b06465155cb439e825e08acffd858ca1d1e25
3
+ metadata.gz: 6a2d2155c0cc69ace190a63161bc915ce3b3e03c
4
+ data.tar.gz: 0cee433496544f666fc2cdf2713cec2cb10f4eff
5
5
  SHA512:
6
- metadata.gz: d043879722f20274185e96888cbf805a67b94a9f63ac144ed3c31d0d12c52766b173a8e2c5024b04005f6080273c29417702c1ac7b26260ebc964088b6a49d1d
7
- data.tar.gz: 9e9507b5f0f3980233c99c8f438101f5349cbcb2f30ba7f4a480bc0a4f48b1d061d27bb953923d9edb597a4d511b024a190678fa613e4bc481a90d5629d5dba3
6
+ metadata.gz: eda5fba126f97618b349fd7d9ade84807110b1f9b5d5a431eabc9a1d61cec9b7506f9e515ec52532380ea66e45b57d72735404aec104f53e931c073c69a8f15d
7
+ data.tar.gz: '08cac28a03ba86fed70f1e7e6e89143eaed330dffbe014f03dd810b67ebd3520006c76b8202df3baa264ed7bdc645dbf5ae52b9efce5f03ad15985d49c792825'
@@ -368,13 +368,14 @@ On insertion or removal the following events are triggered:
368
368
  To listen to the events in your JavaScript:
369
369
 
370
370
  ```javascript
371
- $('#container').on('cocoon:before-insert', function(e, insertedItem) {
371
+ $('#container').on('cocoon:before-insert', function(e, insertedItem, originalEvent) {
372
372
  // ... do something
373
373
  });
374
374
  ```
375
375
 
376
376
  ...where `e` is the event and the second parameter is the inserted or removed item. This allows you to change markup, or
377
377
  add effects/animations (see example below).
378
+ `originalEvent` is also passed and references the event that triggered an insertion or removal (e.g. the `click` event on the link to add an association)
378
379
 
379
380
 
380
381
  If in your view you have the following snippet to select an `owner`:
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.2.12
1
+ 1.2.13
@@ -51,7 +51,8 @@
51
51
  regexp_underscord = new RegExp('_new_' + assoc + '_(\\w*)', 'g'),
52
52
  new_id = create_new_id(),
53
53
  new_content = content.replace(regexp_braced, newcontent_braced(new_id)),
54
- new_contents = [];
54
+ new_contents = [],
55
+ originalEvent = e;
55
56
 
56
57
 
57
58
  if (new_content == content) {
@@ -85,7 +86,7 @@
85
86
  var contentNode = $(node);
86
87
 
87
88
  var before_insert = jQuery.Event('cocoon:before-insert');
88
- insertionNodeElem.trigger(before_insert, [contentNode]);
89
+ insertionNodeElem.trigger(before_insert, [contentNode, originalEvent]);
89
90
 
90
91
  if (!before_insert.isDefaultPrevented()) {
91
92
  // allow any of the jquery dom manipulation methods (after, before, append, prepend, etc)
@@ -93,7 +94,8 @@
93
94
  // code and doesn't force it to be a sibling like after/before does. default: 'before'
94
95
  var addedContent = insertionNodeElem[insertionMethod](contentNode);
95
96
 
96
- insertionNodeElem.trigger('cocoon:after-insert', [contentNode]);
97
+ insertionNodeElem.trigger('cocoon:after-insert', [contentNode,
98
+ originalEvent]);
97
99
  }
98
100
  });
99
101
  });
@@ -102,12 +104,14 @@
102
104
  var $this = $(this),
103
105
  wrapper_class = $this.data('wrapper-class') || 'nested-fields',
104
106
  node_to_delete = $this.closest('.' + wrapper_class),
105
- trigger_node = node_to_delete.parent();
107
+ trigger_node = node_to_delete.parent(),
108
+ originalEvent = e;
106
109
 
107
110
  e.preventDefault();
111
+ e.stopPropagation();
108
112
 
109
113
  var before_remove = jQuery.Event('cocoon:before-remove');
110
- trigger_node.trigger(before_remove, [node_to_delete]);
114
+ trigger_node.trigger(before_remove, [node_to_delete, originalEvent]);
111
115
 
112
116
  if (!before_remove.isDefaultPrevented()) {
113
117
  var timeout = trigger_node.data('remove-timeout') || 0;
@@ -119,7 +123,8 @@
119
123
  $this.prev("input[type=hidden]").val("1");
120
124
  node_to_delete.hide();
121
125
  }
122
- trigger_node.trigger('cocoon:after-remove', [node_to_delete]);
126
+ trigger_node.trigger('cocoon:after-remove', [node_to_delete,
127
+ originalEvent]);
123
128
  }, timeout);
124
129
  }
125
130
  });
@@ -2,16 +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.12 ruby lib
5
+ # stub: cocoon 1.2.13 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "cocoon".freeze
9
- s.version = "1.2.12"
9
+ s.version = "1.2.13"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib".freeze]
13
13
  s.authors = ["Nathan Van der Auwera".freeze]
14
- s.date = "2018-10-18"
14
+ s.date = "2019-06-18"
15
15
  s.description = "Unobtrusive nested forms handling, using jQuery. Use this and discover cocoon-heaven.".freeze
16
16
  s.email = "nathan@dixis.com".freeze
17
17
  s.extra_rdoc_files = [
@@ -83,7 +83,7 @@ Gem::Specification.new do |s|
83
83
  ]
84
84
  s.homepage = "http://github.com/nathanvda/cocoon".freeze
85
85
  s.licenses = ["MIT".freeze]
86
- s.rubygems_version = "2.6.14".freeze
86
+ s.rubygems_version = "2.6.11".freeze
87
87
  s.summary = "gem that enables easier nested forms with standard forms, formtastic and simple-form".freeze
88
88
 
89
89
  if s.respond_to? :specification_version then
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.12
4
+ version: 1.2.13
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: 2018-10-18 00:00:00.000000000 Z
11
+ date: 2019-06-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -324,7 +324,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
324
324
  version: '0'
325
325
  requirements: []
326
326
  rubyforge_project:
327
- rubygems_version: 2.6.14
327
+ rubygems_version: 2.6.11
328
328
  signing_key:
329
329
  specification_version: 4
330
330
  summary: gem that enables easier nested forms with standard forms, formtastic and