dynamic_fields 0.3.2 → 0.3.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0fa88f573fb227a2be4e6aa9e48183f35cb1415b
4
- data.tar.gz: 3f11350e5dc3211bca179c939964ef6e530b4835
3
+ metadata.gz: 7c7782de18661f1d656579c0823345c53778d23b
4
+ data.tar.gz: 4d081f29ec410831343c908a32d85f7fbec43a58
5
5
  SHA512:
6
- metadata.gz: 11cbfa77a10e6c46502c8cff2dd67cb980962065532ad6cf0fe6e964d622049d57e12a813837022cbe15adff8fff3c426dfcf587cb0b57e45fc9d778f7723943
7
- data.tar.gz: fb3eda2cdd80c2eae91e1c0284d0d4356347b2935fc581f38da1d2617473bfdcc01aaa33a0b75fec0e9b2a09523f65430536b1bcbf39161117c1551a34c1cb7b
6
+ metadata.gz: 6926230579224265c1cc18f68ca84f8be7bb4c0185a8fd246cd1094c9a15dc172693ca30f3479dab481c46623e420bc8fe7a1a417f4832a1ea2dcd724b2a22fe
7
+ data.tar.gz: 9fc87a40fd43d91f9cbf27b2e71083878e9c7b2f2eb039df1eb208fca420826b1285867debef93b958456f53097aee7a8d2c1ea656e71046b5e06cbc1254d6b4
data/README.md CHANGED
@@ -78,6 +78,12 @@ If you override the :class option, you will need to apply that to the Javascript
78
78
  itemWrapper: ".nested_field"
79
79
  })
80
80
 
81
+ The `removeFields` method may accept a hash of options as parameter. To change the confirmation message,
82
+ set the `confirmationMessage` value in the options hash. The default confirmation message is "Are you sure?".
83
+
84
+ $("body").delegate ".remove_dynamic_field", 'click', ->
85
+ $(this).removeFields({confirmationMessage: 'Deleting a record may have dire consequences; are you sure?'})
86
+ ...
81
87
 
82
88
  Example
83
89
  --------
@@ -5,13 +5,16 @@
5
5
  var options = $.extend(defaults, opts);
6
6
 
7
7
  return $.dynamicFields.cloneFields(this, options);
8
- }
8
+ };
9
+
10
+ $.fn.removeFields = function(opts){
11
+ var defaults = { confirmationMessage: 'Are you sure?' };
12
+ var options = $.extend(defaults, opts);
9
13
 
10
- $.fn.removeFields = function(){
11
14
  var $items = this.parent();
12
15
  var destroy_field = $items.find("input[name$='[_destroy]']");
13
16
 
14
- if (confirm("Are you sure?")) {
17
+ if (confirm(options.confirmationMessage)) {
15
18
  if (destroy_field[0] != undefined) {
16
19
  destroy_field.val('true');
17
20
  $items.hide();
@@ -25,11 +28,11 @@
25
28
  })
26
29
  }
27
30
  }
28
- return true
31
+ return true;
29
32
  }else{
30
- return false
33
+ return false;
31
34
  }
32
- }
35
+ };
33
36
 
34
37
  $.dynamicFields = {
35
38
 
@@ -66,19 +69,19 @@
66
69
  if ($(this)[0].type == 'textarea' || $(this)[0].type == 'text' || $(this)[0].type.match(/select/)){
67
70
  $(this).val("");
68
71
  }else if ($(this)[0].type == 'radio'){
69
- $(this).attr("checked", false)
72
+ $(this).attr("checked", false);
70
73
  }else if ($(this)[0].type == 'checkbox'){
71
- $(this).attr("checked", false)
74
+ $(this).attr("checked", false);
72
75
  }
73
76
 
74
- })
77
+ });
75
78
 
76
79
  item.find('label').each(function(){
77
80
  if ($(this).attr('for')){
78
81
  new_id = $(this).attr('for').replace(/\d/, ''+item_num);
79
82
  $(this).attr('for', new_id);
80
83
  }
81
- })
84
+ });
82
85
 
83
86
  item.insertAfter(origin);
84
87
  return item;
@@ -1,3 +1,3 @@
1
1
  module DynamicFields
2
- VERSION = "0.3.2"
2
+ VERSION = "0.3.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dynamic_fields
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jiongye Li
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-20 00:00:00.000000000 Z
11
+ date: 2016-06-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -199,7 +199,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
199
199
  version: '0'
200
200
  requirements: []
201
201
  rubyforge_project:
202
- rubygems_version: 2.2.2
202
+ rubygems_version: 2.4.5.1
203
203
  signing_key:
204
204
  specification_version: 4
205
205
  summary: Generate dynamic fields for Rails