PluginProbe
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder / 2.21.4
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder v2.21.4
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 2.10.2 All 137 releases
bit-form / includes / Admin / Form / ScriptFilePriorityManager.php

ScriptFilePriorityManager.php in Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder 2.21.4, at includes/Admin/Form/ScriptFilePriorityManager.php

682 lines 30.4 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\Admin\Form;
4
5 class ScriptFilePriorityManager
6 {
7 public static function jsFile()
8 {
9 /**
10 * file load priority
11 * first priority status code 100
12 * sub status code link 101,102
13 * second priority status code 200
14 * sub status code link 201,202, 203
15 * continue..........
16 * priority = 100 range for helper file
17 * priority = 200 range for field file
18 * priority = 300 range for script file
19 * priority = 400 range for custom script file
20 * priority = 500 range for js init for custom field file
21 * priority = 600 range for js init for CDN field file
22 * Priority = 700 range for validation js file
23 * priority = 800 range for conditional js file
24 * @array [fieldType] => [
25 * priority => 'choose one of the priority status code',
26 * filename => 'fileName',
27 * scriptTyp => 'script' or 'init' or 'custom' by default script
28 * source => 'filePath' or 'url' or 'cdn' or className or customClassName by scriptTyp && by default it will be 'filePath'=> 'assets/js/fileName.js'',
29 * fk => 'field key'
30 * field => 'field object'
31 * ]
32
33 * final priority
34 helper js
35 common js
36 custom field script js
37 init for custom field js
38 inti for CDN field js
39 validation js
40 confirmation js
41 conditional js
42 submit js
43 custom js
44 */
45 $initSource = '\\BitCode\\BitForm\\Admin\\Form\\InitJs\\';
46 $customSource = '\\BitCode\\BitForm\\Admin\\Form\\ExtraFieldJS\\';
47 return [
48 'helperScript' => [
49 ['priority' => 101, 'filename' => 'bfSelect.min.js'],
50 ['priority' => 101, 'filename' => 'bfReset.min.js'],
51 ['priority' => 101, 'filename' => 'setBFMsg.min.js'],
52 ['priority' => 101, 'filename' => 'bfSplit.min.js'],
53 ['priority' => 101, 'filename' => 'scrollToElm.min.js'],
54 ['priority' => 101, 'filename' => 'getFldKeyAndRowIndx.min.js'],
55 ['priority' => 101, 'filename' => 'moveToFirstErrFld.min.js'],
56 ['priority' => 101, 'filename' => 'bfValidationErrMsg.min.js'],
57 ['priority' => 101, 'filename' => 'setHiddenFld.min.js'],
58 ['priority' => 101, 'filename' => 'submit-form.min.js'],
59 ['priority' => 101, 'filename' => 'setStyleProperty.min.js']
60 ],
61 'range' => [
62 ['priority' => 301, 'filename' => 'SetSliderFieldValue', 'scriptTyp' => 'custom', 'source' => $customSource, 'path' => 'showValue'],
63 ],
64 'country' => [
65 ['priority' => 101, 'filename' => 'observeElm.min.js'],
66 ['priority' => 301, 'filename' => 'bit-country-field.min.js'],
67 ['priority' => 201, 'filename' => 'customFieldsReset.min.js'],
68 ['priority' => 101, 'filename' => 'observeElm.min.js'],
69 ],
70 'currency' => [
71 ['priority' => 101, 'filename' => 'observeElm.min.js'],
72 ['priority' => 301, 'filename' => 'bit-currency-field.min.js'],
73 ['priority' => 201, 'filename' => 'customFieldsReset.min.js'],
74 ['priority' => 101, 'filename' => 'observeElm.min.js'],
75 ],
76 'select' => [
77 ['priority' => 101, 'filename' => 'observeElm.min.js'],
78 ['priority' => 301, 'filename' => 'bit-select-field.min.js'],
79 ['priority' => 201, 'filename' => 'customFieldsReset.min.js'],
80 ['priority' => 101, 'filename' => 'observeElm.min.js'],
81 ],
82 'advanced-file-up' => [
83 ['priority' => 101, 'filename' => 'observeElm.min.js'],
84 ['priority' => 202, 'filename' => 'bit-filepond.min.js'],
85 ['priority' => 301, 'filename' => 'bit-advanced-file-up-field.min.js'],
86 ['priority' => 101, 'filename' => 'advancedFileHandle.min.js'],
87 ['priority' => 201, 'filename' => 'customFieldsReset.min.js'],
88 ],
89 'file-up' => [
90 ['priority' => 301, 'filename' => 'bit-file-up-field.min.js'],
91 ['priority' => 201, 'filename' => 'customFieldsReset.min.js'],
92 ],
93 'phone-number' => [
94 ['priority' => 101, 'filename' => 'observeElm.min.js'],
95 ['priority' => 301, 'filename' => 'bit-phone-number-field.min.js'],
96 ['priority' => 201, 'filename' => 'customFieldsReset.min.js'],
97 ['priority' => 101, 'filename' => 'observeElm.min.js'],
98 ],
99 'paypal' => [
100 ['priority' => 201, 'filename' => 'isFormValidatedWithoutError.min.js'],
101 ['priority' => 202, 'filename' => 'saveFormProgress.min.js'],
102 ['priority' => 201, 'filename' => 'customFieldsReset.min.js'],
103 ['priority' => 301, 'filename' => 'bit-paypal-field.min.js'],
104 ],
105 'stripe' => [
106 ['priority' => 201, 'filename' => 'bitsFetchFront.min.js'],
107 ['priority' => 201, 'filename' => 'isFormValidatedWithoutError.min.js'],
108 ['priority' => 201, 'filename' => 'customFieldsReset.min.js'],
109 ['priority' => 202, 'filename' => 'saveFormProgress.min.js'],
110 ['priority' => 301, 'filename' => 'bit-stripe-field.min.js'],
111 ],
112 'mollie' => [
113 ['priority' => 201, 'filename' => 'bitsFetchFront.min.js'],
114 ['priority' => 201, 'filename' => 'isFormValidatedWithoutError.min.js'],
115 ['priority' => 201, 'filename' => 'customFieldsReset.min.js'],
116 ['priority' => 202, 'filename' => 'saveFormProgress.min.js'],
117 ['priority' => 301, 'filename' => 'bit-mollie-field.min.js'],
118 ],
119 'section' => [
120 ['priority' => 101, 'filename' => 'hideChildFldHandle.min.js'],
121 ],
122 'repeater' => [
123 ['priority' => 101, 'filename' => 'hideChildFldHandle.min.js'],
124 ['priority' => 102, 'filename' => 'bit-repeater-field.min.js'],
125 ['priority' => 701, 'filename' => 'checkRepeatedField.min.js'],
126 ['priority' => 701, 'filename' => 'isRepeaterField.min.js'],
127 ['priority' => 701, 'filename' => 'getRepeatedIndexes.min.js'],
128 ['priority' => 701, 'filename' => 'getIndexesBaseOnConditions.min.js'],
129 ['priority' => 201, 'filename' => 'customFieldsReset.min.js'],
130 ],
131 'razorpay' => [
132 ['priority' => 201, 'filename' => 'replaceFieldAndSmartValues.min.js'],
133 ['priority' => 201, 'filename' => 'isFormValidatedWithoutError.min.js'],
134 ['priority' => 201, 'filename' => 'customFieldsReset.min.js'],
135 ['priority' => 202, 'filename' => 'saveFormProgress.min.js'],
136 ['priority' => 301, 'filename' => 'bit-razorpay-field.min.js'],
137 ],
138 'radio' => [
139 ['priority' => 301, 'filename' => 'OtherOptionJS', 'scriptTyp' => 'custom', 'source' => $customSource, 'path' => 'addOtherOpt'],
140 ],
141 'check' => [
142 ['priority' => 301, 'filename' => 'OtherOptionJS', 'scriptTyp' => 'custom', 'source' => $customSource, 'path' => 'addOtherOpt'],
143 ['priority' => 301, 'filename' => 'CheckDisableOnMax', 'scriptTyp' => 'custom', 'source' => $customSource, 'path' => 'valid->disableOnMax'],
144 ],
145 'image-select' => [
146 ['priority' => 301, 'filename' => 'CheckDisableOnMax', 'scriptTyp' => 'custom', 'source' => $customSource, 'path' => 'valid->disableOnMax'],
147 ],
148 'recaptcha' => [
149 ['priority' => 301, 'filename' => 'bit-recaptcha-field.min.js'],
150 ],
151 'hcaptcha' => [
152 ['priority' => 301, 'filename' => 'bit-hcaptcha-field.min.js'],
153 ],
154 'decision-box' => [
155 ['priority' => 101, 'filename' => 'decisionFldHandle.min.js'],
156 ],
157 'gdpr' => [
158 ['priority' => 101, 'filename' => 'decisionFldHandle.min.js'],
159 ],
160 'signature' => [
161 ['priority' => 201, 'filename' => 'customFieldsReset.min.js'],
162 ['priority' => 301, 'filename' => 'bit-signature-field.min.js'],
163 ],
164 'rating' => [
165 ['priority' => 201, 'filename' => 'customFieldsReset.min.js'],
166 ['priority' => 301, 'filename' => 'bit-rating-field.min.js'],
167 ],
168 'advanced-datetime' => [
169 ['priority' => 101, 'filename' => 'observeElm.min.js'],
170 ['priority' => 201, 'filename' => 'customFieldsReset.min.js'],
171 ['priority' => 301, 'filename' => 'bit-advanced-datetime-field.min.js'],
172 ['priority' => 301, 'filename' => 'bfDatetimeFldValidation.min.js'],
173 ['priority' => 301, 'filename' => 'bfDateFieldsLogicCheck.min.js'],
174 ['priority' => 301, 'filename' => 'bfCalculateDateTimeDifference.min.js'],
175 ['priority' => 301, 'filename' => 'bfAddOrSubtractDateTime.min.js'],
176 ['priority' => 301, 'filename' => 'bfParseDateTime.min.js'],
177 ['priority' => 301, 'filename' => 'bfParseSpecialDateFormat.min.js'],
178 ['priority' => 301, 'filename' => 'bfSetDateTimeConfigOption.min.js'],
179 ['priority' => 301, 'filename' => 'bfFormatDateTime.min.js'],
180 ],
181 'date' => [
182 ['priority' => 301, 'filename' => 'bfDateFieldsLogicCheck.min.js'],
183 ['priority' => 301, 'filename' => 'bfCalculateDateTimeDifference.min.js'],
184 ['priority' => 301, 'filename' => 'bfAddOrSubtractDateTime.min.js'],
185 ['priority' => 301, 'filename' => 'bfParseDateTime.min.js'],
186 ['priority' => 301, 'filename' => 'bfFormatDateTime.min.js'],
187 ],
188 'datetime-local' => [
189 ['priority' => 301, 'filename' => 'bfDateFieldsLogicCheck.min.js'],
190 ['priority' => 301, 'filename' => 'bfCalculateDateTimeDifference.min.js'],
191 ['priority' => 301, 'filename' => 'bfAddOrSubtractDateTime.min.js'],
192 ['priority' => 301, 'filename' => 'bfParseDateTime.min.js'],
193 ['priority' => 301, 'filename' => 'bfFormatDateTime.min.js'],
194 ],
195 'time' => [
196 ['priority' => 301, 'filename' => 'bfDateFieldsLogicCheck.min.js'],
197 ['priority' => 301, 'filename' => 'bfCalculateDateTimeDifference.min.js'],
198 ['priority' => 301, 'filename' => 'bfAddOrSubtractDateTime.min.js'],
199 ['priority' => 301, 'filename' => 'bfParseDateTime.min.js'],
200 ['priority' => 301, 'filename' => 'bfFormatDateTime.min.js'],
201 ],
202 'month' => [
203 ['priority' => 301, 'filename' => 'bfDateFieldsLogicCheck.min.js'],
204 ['priority' => 301, 'filename' => 'bfCalculateDateTimeDifference.min.js'],
205 ['priority' => 301, 'filename' => 'bfAddOrSubtractDateTime.min.js'],
206 ['priority' => 301, 'filename' => 'bfParseDateTime.min.js'],
207 ['priority' => 301, 'filename' => 'bfFormatDateTime.min.js'],
208 ],
209 'week' => [
210 ['priority' => 301, 'filename' => 'bfDateFieldsLogicCheck.min.js'],
211 ['priority' => 301, 'filename' => 'bfCalculateDateTimeDifference.min.js'],
212 ['priority' => 301, 'filename' => 'bfAddOrSubtractDateTime.min.js'],
213 ['priority' => 301, 'filename' => 'bfParseDateTime.min.js'],
214 ['priority' => 301, 'filename' => 'bfFormatDateTime.min.js'],
215 ],
216 ];
217 }
218
219 public static function filePondPlugins($plugin)
220 {
221 $plugins = [
222 'allowFileSizeValidation' => ['priority' => 201, 'filename' => 'bit-filepond-plugin-file-validate-size.min.js'],
223 'allowFileTypeValidation' => ['priority' => 201, 'filename' => 'bit-filepond-plugin-file-validate-type.min.js'],
224 'allowImageCrop' => ['priority' => 201, 'filename' => 'bit-filepond-plugin-image-crop.min.js'],
225 'allowImagePreview' => ['priority' => 201, 'filename' => 'bit-filepond-plugin-image-preview.min.js'],
226 'allowImageResize' => ['priority' => 201, 'filename' => 'bit-filepond-plugin-image-resize.min.js'],
227 'allowImageTransform' => ['priority' => 201, 'filename' => 'bit-filepond-plugin-image-transform.min.js'],
228 'allowImageValidateSize' => ['priority' => 201, 'filename' => 'bit-filepond-plugin-image-validate-size.min.js'],
229 'allowPreview' => ['priority' => 201, 'filename' => 'bit-filepond-plugin-media-preview.min.js'],
230 ];
231 if (array_key_exists($plugin, $plugins)) {
232 return $plugins[$plugin];
233 }
234
235 return false;
236 }
237
238 public static function getAllFldConfs()
239 {
240 // $contentId = $fieldData['contentId'];
241 // $fieldKey = $fieldData['fk'];
242 // $field = $fieldData['field'];
243 // key is config path, value is field path
244 // var is for variable value
245 // path is for field path [ for multiple paths]
246 // val is for static value
247 $configs = [
248 'select' => [
249 'fieldKey' => ['var' => 'fieldKey'],
250 'options' => ['path' => 'optionsList'],
251 'placeholder' => ['path' => 'ph'],
252 'classNames' => ['path' => 'customClasses'],
253 'attributes' => ['path' => 'customAttributes'],
254 'defaultValue' => ['path' => ['val', 'config->defaultValue'], 'val'=> ''],
255 'separator' => ['val' => BITFORMS_BF_SEPARATOR],
256 'mn' => ['path' => 'mn', 'val' => 0],
257 'mx' => ['path' => 'mx', 'val' => 0],
258 'disableOnMax' => ['path' => 'valid->disableOnMax', 'val' => false],
259 ],
260 'country' => [
261 'fieldKey' => ['var' => 'fieldKey'],
262 'options' => ['path' => 'options'],
263 'placeholder' => ['path' => 'ph'],
264 'assetsURL' => ['val' => BITFORMS_ROOT_URI . '/static/countries/'],
265 'classNames' => ['path' => 'customClasses'],
266 'attributes' => ['path' => 'customAttributes'],
267 'defaultValue' => ['path' => ['val', 'config->defaultValue'], 'val'=> ''],
268 ],
269 'currency' => [
270 'fieldKey' => ['var' => 'fieldKey'],
271 'options' => ['path' => 'options'],
272 'assetsURL' => ['val' => BITFORMS_ROOT_URI . '/static/currencies/'],
273 'classNames' => ['path' => 'customClasses'],
274 'attributes' => ['path' => 'customAttributes'],
275 'defaultValue' => ['path' => ['val', 'config->defaultValue'], 'val'=> ''],
276 'inputFormatOptions' => ['path' => 'inputFormatOptions'],
277 'valueFormatOptions' => ['path' => 'valueFormatOptions'],
278 ],
279 'phone-number' => [
280 'fieldKey' => ['var' => 'fieldKey'],
281 'options' => ['path' => 'options'],
282 'assetsURL' => ['val' => BITFORMS_ROOT_URI . '/static/countries/'],
283 'classNames' => ['path' => 'customClasses'],
284 'attributes' => ['path' => 'customAttributes'],
285 'contentId' => ['var' => 'contentId'],
286 ],
287 'file-up' => [
288 'fieldKey' => ['var' => 'fieldKey'],
289 'formID' => ['var' => 'formId'],
290 'maxSizeErrMsg' => ['path' => ['err->maxSize->msg', 'err->maxSize->dflt']],
291 'minFileErrMsg' => ['path' => ['err->minFile->msg', 'err->minFile->dflt']],
292 'maxFileErrMsg' => ['path' => ['err->maxFile->msg', 'err->maxFile->dflt']],
293 'assetsURL' => ['val' => BITFORMS_ROOT_URI . '/static/file-upload/'],
294 'classNames' => ['path' => 'customClasses'],
295 'attributes' => ['path' => 'customAttributes'],
296 'fieldName' => ['path' => 'fieldName'],
297 'contentId' => ['var' => 'contentId'],
298 ],
299 'paypal' => [
300 'payIntegID' => ['path' => 'payIntegID'],
301 'style' => ['path' => 'style'],
302 'currency' => ['path' => 'currency', 'val' => 'USD'],
303 'amount' => ['path' => 'amount', 'val' => 0],
304 'amountFld' => ['path' => 'amountFld', 'val' => ''],
305 'shipping' => ['path' => 'shipping', 'val' => 0],
306 'shippingVal' => ['path' => 'shippingFld', 'val' => ''],
307 'tax' => ['path' => 'tax', 'val' => 0],
308 'taxVal' => ['path' => 'taxFld', 'val' => ''],
309 'description' => ['path' => 'description', 'val' => ''],
310 'descFld' => ['path' => 'descFld', 'val' => ''],
311 'payType' => ['path' => 'payType', 'val' => 'payment'],
312 'planId' => ['path' => 'planId', 'val' => ''],
313 'locale' => ['path' => 'locale', 'val' => 'en_US'],
314 'disableFunding' => ['path' => 'disableFunding', 'val' => ''],
315 'fieldKey' => ['var' => 'fieldKey'],
316 'clientId' => ['path' => 'clientId'],
317 'contentId' => ['var' => 'contentId'],
318 'namespace' => ['val' => 'bit-paypal-__$contentId__'],
319 ],
320 'stripe' => [
321 'payIntegID' => ['path' => 'payIntegID'],
322 'locale' => ['path' => 'config->options->locale', 'val' => 'en'],
323 'amountType' => ['path' => 'config->amountType', 'val'=> 'fixed'],
324 'fieldKey' => ['var' => 'fieldKey'],
325 'contentId' => ['var' => 'contentId'],
326 'publishableKey' => ['path' => 'publishableKey'],
327 ],
328 'mollie' => [
329 'payIntegID' => ['path' => 'payIntegID'],
330 'locale' => ['path' => 'config->locale', 'val' => 'en'],
331 'amountType' => ['path' => 'config->amountType', 'val'=> 'fixed'],
332 'fieldKey' => ['var' => 'fieldKey'],
333 'contentId' => ['var' => 'contentId'],
334 'apiKey' => ['path' => 'apiKey'],
335 'payment_method' => ['path' => 'config->payment_method', 'val' => ['creditcard']],
336 'description' => ['path' => 'config->description', 'val' => ''],
337 'amount' => ['path' => 'config->amount', 'val' => 0],
338 'currency' => ['path' => 'config->currency', 'val' => 'EUR'],
339 ],
340 'advanced-file-up' => [
341 'fieldKey' => ['var' => 'fieldKey'],
342 'formID' => ['var' => 'formId'],
343 'configSetting' => ['path' => 'config'],
344 'ajaxURL' => ['val' => admin_url('admin-ajax.php')],
345 'nonce' => ['val' => wp_create_nonce('bitforms_save')],
346 'uploadFileToServer' => ['val' => 1],
347 'fieldName' => ['path' => 'fieldName'],
348 'contentId' => ['var' => 'contentId'],
349 ],
350 'advanced-datetime' => [
351 'fieldKey' => ['var' => 'fieldKey'],
352 'formID' => ['var' => 'formId'],
353 'configSetting' => ['path' => 'config'],
354 'fieldName' => ['path' => 'fieldName'],
355 'contentId' => ['var' => 'contentId'],
356 ],
357 'razorpay' => [
358 'fieldKey' => ['var' => 'fieldKey'],
359 'options' => ['path' => 'options'],
360 'payIntegID' => ['path' => 'payIntegID'],
361 'payType' => ['path' =>'payType', 'val' => ''],
362 'clientId' => ['path' => 'clientId'],
363 'contentId' => ['var' => 'contentId'],
364 'includeOrderId' => ['path' => 'includeOrderId', 'val' => false],
365 'newOrderId' => ['path' => 'newOrderId', 'val' => false],
366 'orderIdFld' => ['path' => 'orderIdFld', 'val' => ''],
367 'formID' => ['var' => 'formId'],
368 ],
369 'repeater' => [
370 'fieldKey' => ['var' => 'fieldKey'],
371 'fieldName' => ['path' => 'fieldName'],
372 'contentId' => ['var' => 'contentId'],
373 'defaultRow' => ['path' => 'defaultRow', 'val' => 1],
374 'minimumRow' => ['path' => 'minRow', 'val' => 1],
375 'maximumRow' => ['path' => 'maxRow', 'val' => 0],
376 'showAddBtn' => ['path' => 'addBtn->show', 'val' => false],
377 'showAddToEndBtn' => ['path' => 'addToEndBtn->show', 'val' => false],
378 'defaultValue' => ['path' => 'val', 'val' => ''],
379 ],
380 'signature' => [
381 'fieldKey' => ['var' => 'fieldKey'],
382 'contentId' => ['var' => 'contentId'],
383 'maxWidth' => ['path' => 'config->maxWidth', 'val' => '1'],
384 'penColor' => ['path' => 'config->penColor', 'val'=> '#000000'],
385 'backgroundColor' => ['path' => 'config->backgroundColor', 'val' => '#ffffff'],
386 'imgTyp' => ['path' => 'config->imgTyp', 'val' => 'image/png'],
387 'assetsURL' => ['val' => BITFORMS_ROOT_URI . '/static/signature/']
388 ],
389 'rating' => [
390 'fieldKey' => ['var' => 'fieldKey'],
391 'contentId' => ['var' => 'contentId'],
392 'options' => ['path' => 'opt'],
393 'showReviewLblOnHover' => ['path' => 'showReviewLblOnHover'],
394 'showReviewLblOnSelect' => ['path' => 'showReviewLblOnSelect'],
395 'selectedRating' => ['path' => 'selectedRating'],
396 'defaultValue' => ['path' => ['val', 'config->defaultValue'], 'val'=> ''],
397 ]
398 ];
399
400 return $configs;
401 }
402
403 public static function multiStepFiles()
404 {
405 return [
406 ['priority' => 201, 'filename' => 'customFieldsReset.min.js'],
407 ['priority' => 201, 'filename' => 'isFormValidatedWithoutError.min.js'],
408 ['priority' => 202, 'filename' => 'saveFormProgress.min.js'],
409 ['priority' => 700, 'filename' => 'bit-multi-step-form.min.js'],
410 ];
411 }
412
413 public static function conversationalFormFiles()
414 {
415 return [
416 ['priority' => 202, 'filename' => 'saveFormProgress.min.js'],
417 ['priority' => 700, 'filename' => 'bit-conversational-form.min.js'],
418 ['priority' => 700, 'filename' => 'handleConversationalFormMsg.min.js'],
419 ];
420 }
421
422 public static function frontendScriptFile()
423 {
424 return [
425 'observeElm' => ['priority' => 101, 'filename' => 'observeElm.min.js'],
426 'hidden-token-field' => ['priority' => 300, 'filename' => 'hidden-token-field.min.js'],
427 ];
428 }
429
430 public static function validationAndOtherScriptFile()
431 {
432 return [
433 'checkFldValidation' => ['priority' => 701, 'filename' => 'checkFldValidation.min.js'],
434 'checkMinMaxOptions' => ['priority' => 702, 'filename' => 'checkMinMaxOptions.min.js'],
435 'bfDatetimeFldValidation' => ['priority' => 702, 'filename' => 'bfDatetimeFldValidation.min.js'],
436 'bfParseDateTime' => ['priority' => 301, 'filename' => 'bfParseDateTime.min.js'],
437 'checkMinMaxValue' => ['priority' => 702, 'filename' => 'checkMinMaxValue.min.js'],
438 'customOptionValidation' => ['priority' => 702, 'filename' => 'customOptionValidation.min.js'],
439 'dcsnbxFldValidation' => ['priority' => 702, 'filename' => 'dcsnbxFldValidation.min.js'],
440 'emailFldValidation' => ['priority' => 702, 'filename' => 'emailFldValidation.min.js'],
441 'fileupFldValidation' => ['priority' => 702, 'filename' => 'fileupFldValidation.min.js'],
442 'advanceFileupFldValidation' => ['priority' => 702, 'filename' => 'advanceFileUpFldValidation.min.js'],
443 'phoneNumberFldValidation' => ['priority' => 702, 'filename' => 'phoneNumberFldValidation.min.js'],
444 'currencyFldValidation' => ['priority' => 702, 'filename' => 'currencyFldValidation.min.js'],
445 'generateBackslashPattern' => ['priority' => 700, 'filename' => 'generateBackslashPattern.min.js'],
446 'nmbrFldValidation' => ['priority' => 702, 'filename' => 'nmbrFldValidation.min.js'],
447 'regexPatternValidation' => ['priority' => 701, 'filename' => 'regexPatternValidation.min.js'], // load before generateBackslashPattern file, then load regexPatternValidation
448 'inputMaskValidation' => ['priority' => 701, 'filename' => 'inputMaskValidation.min.js'], // load before generateBackslashPattern file, then load inputMaskValidation
449 'bit-input-mask' => ['priority' => 701, 'filename' => 'bit-input-mask.min.js'], // load before generateBackslashPattern file, then load bit-input-mask
450 'setBitInputMaskToInput' => ['priority' => 702, 'filename' => 'setBitInputMaskToInput.min.js'], // load before generateBackslashPattern file, then load setBitInputMaskToInput
451 'requiredFldValidation' => ['priority' => 700, 'filename' => 'requiredFldValidation.min.js'],
452 'urlFldValidation' => ['priority' => 702, 'filename' => 'urlFldValidation.min.js'],
453 'validation' => ['priority' => 705, 'filename' => 'validateForm.min.js'], // last priority for validation script
454 'conditionalLogic' => ['priority' => 705, 'filename' => 'bit-conditionals.min.js'], // last priority for validation script
455 'resetPlaceholders' => ['priority' => 201, 'filename' => 'resetPlaceholders.min.js'],
456 'bfResetDefaultValue' => ['priority' => 201, 'filename' => 'bfResetDefaultValue.min.js'],
457 'validateFocusLost' => ['priority' => 706, 'filename' => 'validate-focus.min.js'], // last priority for validation script
458 ];
459 }
460
461 public static function validationScriptFileMapping($fieldType)
462 {
463 $textTypeField = ['text', 'password', 'username', 'color'];
464 if (in_array($fieldType, $textTypeField)) {
465 $fieldType = 'text';
466 }
467 $fields =
468 [
469 'text' => [
470 'regexPatternValidation' => [
471 'paths' => ['valid->regexr'],
472 'dependencies' => [
473 'generateBackslashPattern'
474 ]
475 ],
476 'bit-input-mask' => [
477 'paths' => ['valid->inputMask'],
478 ],
479 'inputMaskValidation' => [
480 'paths' => ['valid->inputMask'],
481 'dependencies' => [
482 'generateBackslashPattern',
483 'validation',
484 ]
485 ],
486 'setBitInputMaskToInput' => [
487 'paths' => ['valid->inputMask'],
488 'dependencies' => [
489 'bit-input-mask'
490 ]
491 ]
492 ],
493 'textarea' => [
494 'bit-input-mask' => [
495 'paths' => ['valid->inputMask'],
496 ],
497 'inputMaskValidation' => [
498 'paths' => ['valid->inputMask'],
499 'dependencies' => [
500 'generateBackslashPattern',
501 'validation',
502 ]
503 ],
504 'setBitInputMaskToInput' => [
505 'paths' => ['valid->inputMask'],
506 'dependencies' => [
507 'bit-input-mask'
508 ]
509 ]
510 ],
511 'email' => [
512 'emailFldValidation' => [
513 'paths' => ['err->invalid->show'],
514 'dependencies' => [
515 'generateBackslashPattern'
516 ]
517 ],
518 ],
519 'number' => [
520 'nmbrFldValidation' => [
521 'paths' => ['mn', 'mx']
522 ]
523 ],
524 'radio' => [
525 'customOptionValidation' => [
526 'paths' => ['valid->otherOptReq'],
527 ]
528 ],
529 'check' => [
530 'checkMinMaxOptions' => [
531 'paths' => ['mn', 'mx'],
532 'dependencies' => [
533 'checkFldValidation'
534 ]
535 ],
536 'customOptionValidation' => [
537 'paths' => ['valid->otherOptReq'],
538 ]
539 ],
540 'select' => [
541 'checkMinMaxOptions' => [
542 'paths' => ['mn', 'mx'],
543 'dependencies' => [
544 'checkFldValidation'
545 ]
546 ],
547 ],
548 'image-select' => [
549 'checkMinMaxOptions' => [
550 'paths' => ['mn', 'mx'],
551 'dependencies' => [
552 'checkFldValidation'
553 ]
554 ],
555 ],
556 'range' => [
557 'checkMinMaxValue' => [
558 'paths' => ['mn', 'mx']
559 ]
560 ],
561 'url' => [
562 'regexPatternValidation' => [
563 'paths' => ['valid->regexr'],
564 'dependencies' => [
565 'generateBackslashPattern'
566 ]
567 ],
568 'urlFldValidation' => [
569 'paths' => ['err->invalid->show'],
570 'dependencies' => [
571 'generateBackslashPattern'
572 ]
573 ],
574 'bit-input-mask' => [
575 'paths' => ['valid->inputMask'],
576 ],
577 'inputMaskValidation' => [
578 'paths' => ['valid->inputMask'],
579 'dependencies' => [
580 'generateBackslashPattern',
581 'validation',
582 ]
583 ],
584 'setBitInputMaskToInput' => [
585 'paths' => ['valid->inputMask'],
586 'dependencies' => [
587 'bit-input-mask'
588 ]
589 ]
590 ],
591 'decision-box' => [
592 'dcsnbxFldValidation' => [
593 'paths' => ['valid->req']
594 ]
595 ],
596 'gdpr' => [
597 'dcsnbxFldValidation' => [
598 'paths' => ['valid->req']
599 ]
600 ],
601 'file-up' => [
602 'fileupFldValidation' => [
603 'paths' => ['valid->req']
604 ]
605 ],
606 'advanced-file-up' => [
607 'advanceFileupFldValidation' => [
608 'paths' => ['valid->req']
609 ]
610 ],
611 'phone-number' => [
612 'phoneNumberFldValidation' => [
613 'paths' => ['err->invalid->show'],
614 ]
615 ],
616 'currency' => [
617 'currencyFldValidation' => [
618 'paths' => ['err->minValue->show', 'err->maxValue->show'],
619 ]
620 ],
621 'date' => [
622 'bfDatetimeFldValidation' => [
623 'paths' => ['mn', 'mx'],
624 'dependencies' => [
625 'bfParseDateTime'
626 ]
627 ],
628 ],
629 'time' => [
630 'bfDatetimeFldValidation' => [
631 'paths' => ['mn', 'mx'],
632 'dependencies' => [
633 'bfParseDateTime'
634 ]
635 ],
636 ],
637 'week' => [
638 'bfDatetimeFldValidation' => [
639 'paths' => ['mn', 'mx'],
640 'dependencies' => [
641 'bfParseDateTime'
642 ]
643 ],
644 ],
645 'month' => [
646 'bfDatetimeFldValidation' => [
647 'paths' => ['mn', 'mx'],
648 'dependencies' => [
649 'bfParseDateTime'
650 ]
651 ],
652 ],
653 'datetime-local' => [
654 'bfDatetimeFldValidation' => [
655 'paths' => ['mn', 'mx'],
656 'dependencies' => [
657 'bfParseDateTime'
658 ]
659 ],
660 ],
661 ];
662 return isset($fields[$fieldType]) ? $fields[$fieldType] : [];
663 }
664
665 public static function formAbandonmentNeededFiles($abandonType = null)
666 {
667 $files = [
668 'autoSave' => [
669 ['priority' => 201, 'filename' => 'bit-page-lifecycle.min.js'],
670 ['priority' => 402, 'filename' => 'autoSavePartial.min.js'],
671 ]
672 ];
673
674 $required = [
675 ['priority' => 402, 'filename' => 'bit-form-abandonment.min.js'],
676 ['priority' => 401, 'filename' => 'saveFormProgress.min.js'],
677 ['priority' => 701, 'filename' => 'setFieldValues.min.js'],
678 ];
679 return isset($files[$abandonType]) ? array_merge($files[$abandonType], $required) : $required;
680 }
681 }
682