cck_forms 3.4.0 → 3.4.1

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: 47a8cd38b248b42275dbcad881170f8d04da4dc9
4
- data.tar.gz: 8a0e0fd4447f3330f6709b271094438922a4ec39
3
+ metadata.gz: 8014d2ff695301e74af0786d64e8c59d9b9028e4
4
+ data.tar.gz: c7f0347885e943b363c39784abcea19a17669c50
5
5
  SHA512:
6
- metadata.gz: d3bd36c81ce696ee7090d0f7cfba39f9b8fa621a44acbbffa81210f4a87fac291ee8f5cd4e9bbda1fd4234c2d3fac70af702b6147a1a87db62277a37bf98d311
7
- data.tar.gz: 3000a75fb172986b3400c538634191e543986d912743472bab1a8d03607cb5917cb66e93ae47d453e325be9bab4b98fee941240aa86d884e708aec35498d0800
6
+ metadata.gz: 341cc155d587f187fb5c8dea78ca2f1316d04e7d8b5df9763f3b27e093cb8bc43cca209a99330549f5662d2f47603dedefc2aa70bc365ff16aca27c9bcddb5f2
7
+ data.tar.gz: 00058860396b4f8230ae17df449fbb1f47dad879ee5901d3d753444cefd4f06498bed9fce7aa952b08fa6b10811bb299638b0d0bfe7f6d11e3b70cd1797d01ea
@@ -63,28 +63,32 @@ class CckForms::ParameterTypeClass::Phones
63
63
  value = options[:value].presence
64
64
  value = [] unless !value.blank? and value.is_a? Array
65
65
 
66
- result = value.map { |phone| build_single_form(form_builder, phone) }
66
+ result = value.map { |phone| build_single_form(form_builder, phone, options) }
67
67
 
68
- [1, CckForms::ParameterTypeClass::Phones::MIN_PHONES_IN_FORM - result.length].max.times { result << build_single_form(form_builder, {}) }
68
+ [1, CckForms::ParameterTypeClass::Phones::MIN_PHONES_IN_FORM - result.length].max.times { result << build_single_form(form_builder, {}, options) }
69
69
 
70
70
  id = form_builder_name_to_id form_builder
71
- sprintf '<div id="%s">%s</div>%s', id, result.join, script(id)
71
+ sprintf '<div id="%s">%s</div>%s', id, result.join, script(id, options)
72
72
  end
73
73
 
74
74
  # HTML for sinle phone number
75
- def build_single_form(form_builder, phone)
76
- phone = {} unless phone.is_a? Hash
77
- phone = blank_phone.merge phone
75
+ def build_single_form(form_builder, phone, options = {})
76
+ phone = {} unless phone.is_a? Hash
77
+ phone = blank_phone.merge phone
78
+ prefix_class = options[:prefix_class].presence || 'input-tiny form-control'
79
+ code_class = options[:code_class].presence || 'input-mini form-control'
80
+ number_class = options[:number_class].presence || 'input-small form-control'
81
+ group_class = options[:group_class].presence || 'form-inline'
78
82
 
79
83
  phone_form = []
80
84
 
81
85
  form_builder.fields_for(:value, index: '') do |phone_builder|
82
- phone_form << phone_builder.text_field(:prefix, class: 'input-tiny form-control', value: phone['prefix'])
83
- phone_form << phone_builder.text_field(:code, class: 'input-mini form-control', value: phone['code'])
84
- phone_form << phone_builder.text_field(:number, class: 'input-small form-control', value: phone['number'])
86
+ phone_form << phone_builder.text_field(:prefix, class: prefix_class, value: phone['prefix'])
87
+ phone_form << phone_builder.text_field(:code, class: code_class, value: phone['code'])
88
+ phone_form << phone_builder.text_field(:number, class: number_class, value: phone['number'])
85
89
  end
86
90
 
87
- sprintf '<p class="form-inline">%s &mdash; %s &mdash; %s</p>', phone_form[0], phone_form[1], phone_form[2]
91
+ sprintf '<p class="%s">%s &mdash; %s &mdash; %s</p>', group_class, phone_form[0], phone_form[1], phone_form[2]
88
92
  end
89
93
 
90
94
  # 1 empty phone Hash: {prefix: '+7', code: '', number: ''}
@@ -96,7 +100,9 @@ class CckForms::ParameterTypeClass::Phones
96
100
  }
97
101
  end
98
102
 
99
- def script(id)
103
+ def script(id, options = {})
104
+ button_class = options[:button_class]
105
+
100
106
  <<HTML
101
107
  <script type="text/javascript">
102
108
  $(function() {
@@ -120,7 +126,7 @@ class CckForms::ParameterTypeClass::Phones
120
126
  $phones.children("p:last").after($newPhone);
121
127
  }
122
128
 
123
- $phones.append('<a href="#" class="add_more">#{I18n.t 'cck_forms.phones.add_more'}</a>');
129
+ $phones.append('<a href="#" class="add_more #{button_class}">#{I18n.t 'cck_forms.phones.add_more'}</a>');
124
130
  $phones.children(".add_more").click(function() {
125
131
  for(var i = 0; i < doTimes; ++ i) {
126
132
  createPhone();
@@ -1,3 +1,3 @@
1
1
  module CckForms
2
- VERSION = '3.4.0'
2
+ VERSION = '3.4.1'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cck_forms
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.4.0
4
+ version: 3.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ilya Konanykhin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-10-09 00:00:00.000000000 Z
11
+ date: 2018-10-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails