PluginProbe
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder / 2.0
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder v2.0
3.3.1 V-3.3.0 3.2.2 3.2.1 3.2.0 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 V3.0.3 V3.0.2 -3.0.1 V_3.0.0 1.1.1 1.1.8 1.2 1.3 1.4 1.4.18 1.5.2 1.9 2.0 2.10.0 2.10.1 All 138 releases
bit-form / includes / Frontend / Form / View / Theme / Fields / CurrencyField.php

CurrencyField.php in Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder 2.0, at includes/Frontend/Form/View/Theme/Fields/CurrencyField.php

211 lines 7.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace BitCode\BitForm\Frontend\Form\View\Theme\Fields;
4
5 class CurrencyField {
6 public static function init($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error = null, $value = null) {
7 $inputWrapper = new InputWrapper($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error, $value);
8 $input = self::field($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error, $value);
9 return $inputWrapper->wrapper($input);
10 }
11
12 private static function field($field, $rowID, $field_name, $form_atomic_Cls_map, $formID, $error = null, $value = null) {
13 $fh = new FieldHelpers($field, $rowID, $form_atomic_Cls_map);
14 $img_url = BITFORMS_ASSET_URI . '/../static/currencies/';
15
16 $req = $fh->required();
17 $disabled = $fh->disabled();
18 $readonly = $fh->readonly();
19 $name = $fh->name();
20 $ph = $fh->placeholder();
21 $selectedFlagImage = '';
22 $tabIndx = isset($field->disabled) ? -1 : 0;
23 $selectedCurrencyClearable = '';
24 $searchPlaceholder = '';
25 $searchClearable = '';
26 $options = '';
27 $readonlyCls = isset($field->readonly) ? 'readonly' : '';
28 $disabledCls = isset($field->disabled) ? 'disabled' : '';
29 $numValue = preg_replace('/[^0-9.-]/', '', $value);
30
31 $img = htmlentities("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg'/>");
32
33 if ($fh->property_exists_nested($field, 'config->selectedFlagImage', true)) {
34 $selectedFlagImage = <<<FLAGIMAGE
35 <div class="{$fh->getAtomicCls('selected-currency-wrp')}">
36 <img
37 class="{$fh->getAtomicCls('selected-currency-img')} {$fh->getCustomClasses('selected-currency-img')}"
38 aria-hidden="true"
39 alt="selected country flag"
40 src="{$img}"
41 {$fh->getCustomAttributes('selected-currency-img')}
42 />
43 </div>
44 FLAGIMAGE;
45 }
46
47 if ($fh->property_exists_nested($field, 'config->selectedCurrencyClearable', true)) {
48 $selectedCurrencyClearable = <<<CLEARABLE
49 <button
50 type="button"
51 title="Clear selected currency value"
52 class="{$fh->getAtomicCls('input-clear-btn')} {$fh->getCustomClasses('input-clear-btn')}"
53 {$fh->getCustomAttributes('input-clear-btn')}
54 >
55 <svg
56 width="12"
57 height="12"
58 role="img"
59 title="Cross icon"
60 viewBox="0 0 24 24"
61 fill="none"
62 stroke="currentColor"
63 stroke-width="2"
64 stroke-linecap="round"
65 stroke-linejoin="round"
66 >
67 <line x1="18" y1="6" x2="6" y2="18" />
68 <line x1="6" y1="6" x2="18" y2="18" />
69 </svg>
70 </button>
71 CLEARABLE;
72 }
73
74 if ($fh->property_exists_nested($field, 'config->searchPlaceholder', '', 1)) {
75 $searchPlaceholder = "placeholder='{$field->config->searchPlaceholder}'";
76 }
77
78 if ($fh->property_exists_nested($field, 'config->searchClearable', true)) {
79 $searchClearable = <<<CLEARABLE
80 <button
81 type="button"
82 title="Clear search"
83 class="{$fh->getAtomicCls('search-clear-btn')} {$fh->getCustomClasses('search-clear-btn')}"
84 {$fh->getCustomAttributes('search-clear-btn')}
85 tabIndex="-1"
86 >
87 <svg
88 width="12"
89 height="12"
90 role="img"
91 title="Cross icon"
92 viewBox="0 0 24 24"
93 fill="none"
94 stroke="currentColor"
95 stroke-width="2"
96 stroke-linecap="round"
97 stroke-linejoin="round"
98 >
99 <line x1="18" y1="6" x2="6" y2="18" />
100 <line x1="6" y1="6" x2="18" y2="18" />
101 </svg>
102 </button>
103 CLEARABLE;
104 }
105
106 return <<<CURRENCYFIELD
107 <div class="{$fh->getAtomicCls('currency-fld-container')}">
108 <div
109 class="{$fh->getAtomicCls('currency-fld-wrp')} {$fh->getCustomClasses('currency-fld-wrp')} {$disabled} {$readonly}"
110 {$fh->getCustomAttributes('currency-fld-wrp')}
111 >
112 <input
113 {$name}
114 {$req}
115 type="hidden"
116 class="{$fh->getAtomicCls('currency-hidden-input')} {$fh->getCustomClasses('currency-hidden-input')}"
117 {$fh->getCustomAttributes('currency-hidden-input')}
118 {$disabled}
119 {$readonly}
120 value="{$value}"
121 />
122 <div class="{$fh->getAtomicCls('currency-inner-wrp')}">
123 <div
124 class="{$fh->getAtomicCls('dpd-wrp')} {$fh->getCustomClasses('dpd-wrp')}"
125 {$fh->getCustomAttributes('dpd-wrp')}
126 role="combobox"
127 aria-controls="currency-dropdown"
128 aria-live="assertive"
129 aria-labelledby="currency-label-2"
130 aria-expanded="false"
131 tabIndex="{$tabIndx}"
132 >
133 {$selectedFlagImage}
134 <div class="{$fh->getAtomicCls('dpd-down-btn')}">
135 <svg
136 width="15"
137 height="15"
138 role="img"
139 title="Downarrow icon"
140 viewBox="0 0 24 24"
141 fill="none"
142 stroke="currentColor"
143 stroke-width="2"
144 stroke-linecap="round"
145 stroke-linejoin="round"
146 >
147 <polyline points="6 9 12 15 18 9" />
148 </svg>
149 </div>
150 </div>
151 <input
152 aria-label="Currency Input"
153 type="text"
154 class="{$fh->getAtomicCls('currency-amount-input')}"
155 {$ph}
156 tabIndex="{$tabIndx}"
157 data-num-value="{$numValue}"
158 />
159 {$selectedCurrencyClearable}
160 </div>
161 <div class="{$fh->getAtomicCls('option-wrp')} {$fh->getCustomClasses('option-wrp')}"
162 {$fh->getCustomAttributes('option-wrp')}
163 >
164 <div class="{$fh->getAtomicCls('option-inner-wrp')}">
165 <div
166 class="{$fh->getAtomicCls('option-search-wrp')} {$fh->getCustomClasses('option-search-wrp')}"
167 {$fh->getCustomAttributes('option-search-wrp')}
168 >
169 <input
170 type="search"
171 class="{$fh->getAtomicCls('opt-search-input')} {$fh->getCustomClasses('opt-search-input')}"
172 {$fh->getCustomAttributes('opt-search-input')}
173 {$searchPlaceholder}
174 autoComplete="off"
175 tabIndex="-1"
176 />
177 <svg
178 class="{$fh->getAtomicCls('opt-search-icn')} {$fh->getCustomClasses('opt-search-icn')}"
179 {$fh->getCustomAttributes('opt-search-icn')}
180 aria-hidden="true"
181 width="22"
182 height="22"
183 viewBox="0 0 24 24"
184 fill="none"
185 stroke="currentColor"
186 stroke-width="2"
187 stroke-linecap="round"
188 stroke-linejoin="round"
189 >
190 <circle cx="11" cy="11" r="8" />
191 <line x1="21" y1="21" x2="16.65" y2="16.65" />
192 </svg>
193 {$searchClearable}
194 </div>
195 <ul
196 class="{$fh->getAtomicCls('option-list')} {$fh->getCustomClasses('option-list')}"
197 {$fh->getCustomAttributes('option-list')}
198 tabIndex="-1"
199 role="listbox"
200 aria-label="currency list"
201 >
202 {$options}
203 </ul>
204 </div>
205 </div>
206 </div>
207 </div>
208 CURRENCYFIELD;
209 }
210 }
211