cck_forms 3.4.0 → 3.4.1
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 +4 -4
- data/lib/cck_forms/parameter_type_class/phones.rb +18 -12
- data/lib/cck_forms/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8014d2ff695301e74af0786d64e8c59d9b9028e4
|
4
|
+
data.tar.gz: c7f0347885e943b363c39784abcea19a17669c50
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
77
|
-
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:
|
83
|
-
phone_form << phone_builder.text_field(:code, class:
|
84
|
-
phone_form << phone_builder.text_field(:number, class:
|
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="
|
91
|
+
sprintf '<p class="%s">%s — %s — %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();
|
data/lib/cck_forms/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2018-10-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|