PluginProbe
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder / 2.9.1
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder v2.9.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 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.9.1, at includes/Admin/Form/ScriptFilePriorityManager.php

461 lines 20.6 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' => 'scrollToElm.min.js'],
53 ['priority' => 101, 'filename' => 'getFldKeyAndRowIndx.min.js'],
54 ['priority' => 101, 'filename' => 'moveToFirstErrFld.min.js'],
55 ['priority' => 101, 'filename' => 'bfValidationErrMsg.min.js'],
56 ['priority' => 101, 'filename' => 'setHiddenFld.min.js'],
57 ['priority' => 101, 'filename' => 'submit-form.min.js'],
58 ['priority' => 101, 'filename' => 'setStyleProperty.min.js']
59 ],
60 'country' => [
61 ['priority' => 101, 'filename' => 'observeElm.min.js'],
62 ['priority' => 301, 'filename' => 'bit-country-field.min.js'],
63 ['priority' => 201, 'filename' => 'customFieldsReset.min.js'],
64 ['priority' => 101, 'filename' => 'observeElm.min.js'],
65 ],
66 'currency' => [
67 ['priority' => 101, 'filename' => 'observeElm.min.js'],
68 ['priority' => 301, 'filename' => 'bit-currency-field.min.js'],
69 ['priority' => 201, 'filename' => 'customFieldsReset.min.js'],
70 ['priority' => 101, 'filename' => 'observeElm.min.js'],
71 ],
72 'select' => [
73 ['priority' => 101, 'filename' => 'observeElm.min.js'],
74 ['priority' => 301, 'filename' => 'bit-select-field.min.js'],
75 ['priority' => 201, 'filename' => 'customFieldsReset.min.js'],
76 ['priority' => 101, 'filename' => 'observeElm.min.js'],
77 ],
78 'advanced-file-up' => [
79 ['priority' => 101, 'filename' => 'observeElm.min.js'],
80 ['priority' => 202, 'filename' => 'bit-filepond.min.js'],
81 ['priority' => 301, 'filename' => 'bit-advanced-file-up-field.min.js'],
82 ['priority' => 101, 'filename' => 'advancedFileHandle.min.js'],
83 ['priority' => 201, 'filename' => 'customFieldsReset.min.js'],
84 ],
85 'file-up' => [
86 ['priority' => 301, 'filename' => 'bit-file-up-field.min.js'],
87 ['priority' => 201, 'filename' => 'customFieldsReset.min.js'],
88 ],
89 'phone-number' => [
90 ['priority' => 101, 'filename' => 'observeElm.min.js'],
91 ['priority' => 301, 'filename' => 'bit-phone-number-field.min.js'],
92 ['priority' => 201, 'filename' => 'customFieldsReset.min.js'],
93 ['priority' => 101, 'filename' => 'observeElm.min.js'],
94 ],
95 'paypal' => [
96 ['priority' => 201, 'filename' => 'isFormValidatedWithoutError.min.js'],
97 ['priority' => 202, 'filename' => 'saveFormProgress.min.js'],
98 ['priority' => 201, 'filename' => 'customFieldsReset.min.js'],
99 ['priority' => 301, 'filename' => 'bit-paypal-field.min.js'],
100 ],
101 'stripe' => [
102 ['priority' => 201, 'filename' => 'bitsFetchFront.min.js'],
103 ['priority' => 201, 'filename' => 'isFormValidatedWithoutError.min.js'],
104 ['priority' => 201, 'filename' => 'customFieldsReset.min.js'],
105 ['priority' => 202, 'filename' => 'saveFormProgress.min.js'],
106 ['priority' => 301, 'filename' => 'bit-stripe-field.min.js'],
107 ],
108 'repeater' => [
109 ['priority' => 301, 'filename' => 'bit-repeater-field.min.js'],
110 ['priority' => 701, 'filename' => 'checkRepeatedField.min.js'],
111 ['priority' => 701, 'filename' => 'getRepeatedIndexes.min.js'],
112 ['priority' => 701, 'filename' => 'getIndexesBaseOnConditions.min.js'],
113 ['priority' => 201, 'filename' => 'customFieldsReset.min.js'],
114 ],
115 'razorpay' => [
116 ['priority' => 201, 'filename' => 'isFormValidatedWithoutError.min.js'],
117 ['priority' => 201, 'filename' => 'customFieldsReset.min.js'],
118 ['priority' => 202, 'filename' => 'saveFormProgress.min.js'],
119 ['priority' => 301, 'filename' => 'bit-razorpay-field.min.js'],
120 ],
121 'radio' => [
122 ['priority' => 301, 'filename' => 'OtherOptionJS', 'scriptTyp' => 'custom', 'source' => $customSource, 'path' => 'addOtherOpt'],
123 ],
124 'check' => [
125 ['priority' => 301, 'filename' => 'OtherOptionJS', 'scriptTyp' => 'custom', 'source' => $customSource, 'path' => 'addOtherOpt'],
126 ['priority' => 301, 'filename' => 'CheckDisableOnMax', 'scriptTyp' => 'custom', 'source' => $customSource, 'path' => 'valid->disableOnMax'],
127 ],
128 'image-select' => [
129 ['priority' => 301, 'filename' => 'CheckDisableOnMax', 'scriptTyp' => 'custom', 'source' => $customSource, 'path' => 'valid->disableOnMax'],
130 ],
131 'recaptcha' => [
132 ['priority' => 301, 'filename' => 'bit-recaptcha-field.min.js'],
133 ],
134 'decision-box' => [
135 ['priority' => 101, 'filename' => 'decisionFldHandle.min.js'],
136 ],
137 'signature' => [
138 ['priority' => 201, 'filename' => 'customFieldsReset.min.js'],
139 ['priority' => 301, 'filename' => 'bit-signature-field.min.js'],
140 ],
141 'rating' => [
142 ['priority' => 201, 'filename' => 'customFieldsReset.min.js'],
143 ['priority' => 301, 'filename' => 'bit-rating-field.min.js'],
144 ],
145 ];
146 }
147
148 public static function filePondPlugins($plugin)
149 {
150 $plugins = [
151 'allowFileSizeValidation' => ['priority' => 201, 'filename' => 'bit-filepond-plugin-file-validate-size.min.js'],
152 'allowFileTypeValidation' => ['priority' => 201, 'filename' => 'bit-filepond-plugin-file-validate-type.min.js'],
153 'allowImageCrop' => ['priority' => 201, 'filename' => 'bit-filepond-plugin-image-crop.min.js'],
154 'allowImagePreview' => ['priority' => 201, 'filename' => 'bit-filepond-plugin-image-preview.min.js'],
155 'allowImageResize' => ['priority' => 201, 'filename' => 'bit-filepond-plugin-image-resize.min.js'],
156 'allowImageTransform' => ['priority' => 201, 'filename' => 'bit-filepond-plugin-image-transform.min.js'],
157 'allowImageValidateSize' => ['priority' => 201, 'filename' => 'bit-filepond-plugin-image-validate-size.min.js'],
158 'allowPreview' => ['priority' => 201, 'filename' => 'bit-filepond-plugin-media-preview.min.js'],
159 ];
160 if (array_key_exists($plugin, $plugins)) {
161 return $plugins[$plugin];
162 }
163
164 return false;
165 }
166
167 public static function getAllFldConfs()
168 {
169 // $contentId = $fieldData['contentId'];
170 // $fieldKey = $fieldData['fk'];
171 // $field = $fieldData['field'];
172 // key is config path, value is field path
173 // var is for variable value
174 // path is for field path [ for multiple paths]
175 // val is for static value
176 $configs = [
177 'select' => [
178 'fieldKey' => ['var' => 'fieldKey'],
179 'options' => ['path' => 'optionsList'],
180 'placeholder' => ['path' => 'ph'],
181 'classNames' => ['path' => 'customClasses'],
182 'attributes' => ['path' => 'customAttributes'],
183 'defaultValue' => ['path' => ['val', 'config->defaultValue'], 'val'=> ''],
184 'separator' => ['val' => BITFORMS_BF_SEPARATOR],
185 'mn' => ['path' => 'mn', 'val' => 0],
186 'mx' => ['path' => 'mx', 'val' => 0],
187 'disableOnMax' => ['path' => 'valid->disableOnMax', 'val' => false],
188 ],
189 'country' => [
190 'fieldKey' => ['var' => 'fieldKey'],
191 'options' => ['path' => 'options'],
192 'placeholder' => ['path' => 'ph'],
193 'assetsURL' => ['val' => BITFORMS_ROOT_URI . '/static/countries/'],
194 'classNames' => ['path' => 'customClasses'],
195 'attributes' => ['path' => 'customAttributes'],
196 'defaultValue' => ['path' => ['val', 'config->defaultValue'], 'val'=> ''],
197 ],
198 'currency' => [
199 'fieldKey' => ['var' => 'fieldKey'],
200 'options' => ['path' => 'options'],
201 'assetsURL' => ['val' => BITFORMS_ROOT_URI . '/static/currencies/'],
202 'classNames' => ['path' => 'customClasses'],
203 'attributes' => ['path' => 'customAttributes'],
204 'defaultValue' => ['path' => ['val', 'config->defaultValue'], 'val'=> ''],
205 ],
206 'phone-number' => [
207 'fieldKey' => ['var' => 'fieldKey'],
208 'options' => ['path' => 'options'],
209 'assetsURL' => ['val' => BITFORMS_ROOT_URI . '/static/countries/'],
210 'classNames' => ['path' => 'customClasses'],
211 'attributes' => ['path' => 'customAttributes']
212 ],
213 'file-up' => [
214 'fieldKey' => ['var' => 'fieldKey'],
215 'formID' => ['var' => 'formId'],
216 'maxSizeErrMsg' => ['path' => ['err->maxSize->msg', 'err->maxSize->dflt']],
217 'minFileErrMsg' => ['path' => ['err->minFile->msg', 'err->minFile->dflt']],
218 'maxFileErrMsg' => ['path' => ['err->maxFile->msg', 'err->maxFile->dflt']],
219 'assetsURL' => ['val' => BITFORMS_ROOT_URI . '/static/file-upload/'],
220 'classNames' => ['path' => 'customClasses'],
221 'attributes' => ['path' => 'customAttributes'],
222 'fieldName' => ['path' => 'fieldName'],
223 ],
224 'paypal' => [
225 'payIntegID' => ['path' => 'payIntegID'],
226 'style' => ['path' => 'style'],
227 'currency' => ['path' => 'currency', 'val' => 'USD'],
228 'amount' => ['path' => 'amount', 'val' => 0],
229 'amountFld' => ['path' => 'amountFld', 'val' => ''],
230 'shipping' => ['path' => 'shipping', 'val' => 0],
231 'shippingVal' => ['path' => 'shippingFld', 'val' => ''],
232 'tax' => ['path' => 'tax', 'val' => 0],
233 'taxVal' => ['path' => 'taxFld', 'val' => ''],
234 'description' => ['path' => 'description', 'val' => ''],
235 'descFld' => ['path' => 'descFld', 'val' => ''],
236 'payType' => ['path' => 'payType', 'val' => 'payment'],
237 'planId' => ['path' => 'planId', 'val' => ''],
238 'locale' => ['path' => 'locale', 'val' => 'en_US'],
239 'disableFunding' => ['path' => 'disableFunding', 'val' => ''],
240 'fieldKey' => ['var' => 'fieldKey'],
241 'clientId' => ['path' => 'clientId'],
242 'contentId' => ['var' => 'contentId'],
243 'namespace' => ['val' => 'bit-paypal-__$contentId__'],
244 ],
245 'stripe' => [
246 'payIntegID' => ['path' => 'payIntegID'],
247 'locale' => ['path' => 'config->options->locale', 'val' => 'en'],
248 'amountType' => ['path' => 'config->amountType', 'val'=> 'fixed'],
249 'fieldKey' => ['var' => 'fieldKey'],
250 'contentId' => ['var' => 'contentId'],
251 'publishableKey' => ['path' => 'publishableKey'],
252 ],
253 'advanced-file-up' => [
254 'fieldKey' => ['var' => 'fieldKey'],
255 'formID' => ['var' => 'formId'],
256 'configSetting' => ['path' => 'config'],
257 'ajaxURL' => ['val' => admin_url('admin-ajax.php')],
258 'nonce' => ['val' => wp_create_nonce('bitforms_save')],
259 'uploadFileToServer' => ['val' => 1],
260 'fieldName' => ['path' => 'fieldName'],
261 ],
262 'razorpay' => [
263 'fieldKey' => ['var' => 'fieldKey'],
264 'options' => ['path' => 'options'],
265 'payIntegID' => ['path' => 'payIntegID'],
266 'payType' => ['path' =>'payType', 'val' => ''],
267 'clientId' => ['path' => 'clientId'],
268 'contentId' => ['var' => 'contentId'],
269 ],
270 'repeater' => [
271 'fieldKey' => ['var' => 'fieldKey'],
272 'fieldName' => ['path' => 'fieldName'],
273 'contentId' => ['var' => 'contentId'],
274 'defaultRow' => ['path' => 'defaultRow', 'val' => 1],
275 'minimumRow' => ['path' => 'minRow', 'val' => 1],
276 'maximumRow' => ['path' => 'maxRow', 'val' => 0],
277 'showAddBtn' => ['path' => 'addBtn->show', 'val' => false],
278 'showAddToEndBtn' => ['path' => 'addToEndBtn->show', 'val' => false],
279 'defaultValue' => ['path' => 'val', 'val' => ''],
280 ],
281 'signature' => [
282 'fieldKey' => ['var' => 'fieldKey'],
283 'contentId' => ['var' => 'contentId'],
284 'maxWidth' => ['path' => 'config->maxWidth', 'val' => '1'],
285 'penColor' => ['path' => 'config->penColor', 'val'=> '#000000'],
286 'backgroundColor' => ['path' => 'config->backgroundColor', 'val' => '#ffffff'],
287 'imgTyp' => ['path' => 'config->imgTyp', 'val' => 'image/png'],
288 'assetsURL' => ['val' => BITFORMS_ROOT_URI . '/static/signature/']
289 ],
290 'rating' => [
291 'fieldKey' => ['var' => 'fieldKey'],
292 'contentId' => ['var' => 'contentId'],
293 'options' => ['path' => 'opt'],
294 'showReviewLblOnHover' => ['path' => 'showReviewLblOnHover'],
295 'showReviewLblOnSelect' => ['path' => 'showReviewLblOnSelect'],
296 'selectedRating' => ['path' => 'selectedRating'],
297 'defaultValue' => ['path' => ['val', 'config->defaultValue'], 'val'=> ''],
298 ]
299 ];
300
301 return $configs;
302 }
303
304 public static function multiStepFiles()
305 {
306 return [
307 ['priority' => 201, 'filename' => 'customFieldsReset.min.js'],
308 ['priority' => 201, 'filename' => 'isFormValidatedWithoutError.min.js'],
309 ['priority' => 202, 'filename' => 'saveFormProgress.min.js'],
310 ['priority' => 700, 'filename' => 'bit-multi-step-form.min.js'],
311 ];
312 }
313
314 public static function frontendScriptFile()
315 {
316 return [
317 'observeElm' => ['priority' => 101, 'filename' => 'observeElm.min.js'],
318 'hidden-token-field' => ['priority' => 300, 'filename' => 'hidden-token-field.min.js'],
319 ];
320 }
321
322 public static function validationAndOtherScriptFile()
323 {
324 return [
325 'checkFldValidation' => ['priority' => 701, 'filename' => 'checkFldValidation.min.js'],
326 'checkMinMaxOptions' => ['priority' => 702, 'filename' => 'checkMinMaxOptions.min.js'],
327 'customOptionValidation' => ['priority' => 702, 'filename' => 'customOptionValidation.min.js'],
328 'dcsnbxFldValidation' => ['priority' => 702, 'filename' => 'dcsnbxFldValidation.min.js'],
329 'emailFldValidation' => ['priority' => 702, 'filename' => 'emailFldValidation.min.js'],
330 'fileupFldValidation' => ['priority' => 702, 'filename' => 'fileupFldValidation.min.js'],
331 'advanceFileupFldValidation' => ['priority' => 702, 'filename' => 'advanceFileUpFldValidation.min.js'],
332 'phoneNumberFldValidation' => ['priority' => 702, 'filename' => 'phoneNumberFldValidation.min.js'],
333 'generateBackslashPattern' => ['priority' => 700, 'filename' => 'generateBackslashPattern.min.js'],
334 'nmbrFldValidation' => ['priority' => 702, 'filename' => 'nmbrFldValidation.min.js'],
335 'regexPatternValidation' => ['priority' => 701, 'filename' => 'regexPatternValidation.min.js'], // load before generateBackslashPattern file, then load regexPatternValidation
336 'requiredFldValidation' => ['priority' => 700, 'filename' => 'requiredFldValidation.min.js'],
337 'urlFldValidation' => ['priority' => 702, 'filename' => 'urlFldValidation.min.js'],
338 'validation' => ['priority' => 705, 'filename' => 'validateForm.min.js'], // last priority for validation script
339 'conditionalLogic' => ['priority' => 705, 'filename' => 'bit-conditionals.min.js'], // last priority for validation script
340 'resetPlaceholders' => ['priority' => 201, 'filename' => 'resetPlaceholders.min.js'],
341 'validateFocusLost' => ['priority' => 706, 'filename' => 'validate-focus.min.js'], // last priority for validation script
342 ];
343 }
344
345 public static function validationScriptFileMapping($fieldType)
346 {
347 $textTypeField = ['text', 'password', 'username', 'date', 'datetime-local', 'time', 'month', 'week', 'color'];
348 if (in_array($fieldType, $textTypeField)) {
349 $fieldType = 'text';
350 }
351 $fields =
352 [
353 'text' => [
354 'regexPatternValidation' => [
355 'paths' => ['valid->regexr'],
356 'dependencies' => [
357 'generateBackslashPattern'
358 ]
359 ]
360 ],
361 'email' => [
362 'emailFldValidation' => [
363 'paths' => ['err->invalid->show'],
364 'dependencies' => [
365 'generateBackslashPattern'
366 ]
367 ],
368 ],
369 'number' => [
370 'nmbrFldValidation' => [
371 'paths' => ['mn', 'mx']
372 ]
373 ],
374 'radio' => [
375 'customOptionValidation' => [
376 'paths' => ['valid->otherOptReq'],
377 ]
378 ],
379 'check' => [
380 'checkMinMaxOptions' => [
381 'paths' => ['mn', 'mx'],
382 'dependencies' => [
383 'checkFldValidation'
384 ]
385 ],
386 'customOptionValidation' => [
387 'paths' => ['valid->otherOptReq'],
388 ]
389 ],
390 'select' => [
391 'checkMinMaxOptions' => [
392 'paths' => ['mn', 'mx'],
393 'dependencies' => [
394 'checkFldValidation'
395 ]
396 ],
397 ],
398 'image-select' => [
399 'checkMinMaxOptions' => [
400 'paths' => ['mn', 'mx'],
401 'dependencies' => [
402 'checkFldValidation'
403 ]
404 ],
405 ],
406 'url' => [
407 'regexPatternValidation' => [
408 'paths' => ['valid->regexr'],
409 'dependencies' => [
410 'generateBackslashPattern'
411 ]
412 ],
413 'urlFldValidation' => [
414 'paths' => ['err->invalid->show'],
415 'dependencies' => [
416 'generateBackslashPattern'
417 ]
418 ]
419 ],
420 'decision-box' => [
421 'dcsnbxFldValidation' => [
422 'paths' => ['valid->req']
423 ]
424 ],
425 'file-up' => [
426 'fileupFldValidation' => [
427 'paths' => ['valid->req']
428 ]
429 ],
430 'advanced-file-up' => [
431 'advanceFileupFldValidation' => [
432 'paths' => ['valid->req']
433 ]
434 ],
435 'phone-number' => [
436 'phoneNumberFldValidation' => [
437 'paths' => ['err->invalid->show'],
438 ]
439 ],
440 ];
441 return isset($fields[$fieldType]) ? $fields[$fieldType] : [];
442 }
443
444 public static function formAbandonmentNeededFiles($abandonType = null)
445 {
446 $files = [
447 'autoSave' => [
448 ['priority' => 201, 'filename' => 'bit-page-lifecycle.min.js'],
449 ['priority' => 402, 'filename' => 'autoSavePartial.min.js'],
450 ]
451 ];
452
453 $required = [
454 ['priority' => 402, 'filename' => 'bit-form-abandonment.min.js'],
455 ['priority' => 401, 'filename' => 'saveFormProgress.min.js'],
456 ['priority' => 701, 'filename' => 'setFieldValues.min.js'],
457 ];
458 return isset($files[$abandonType]) ? array_merge($files[$abandonType], $required) : $required;
459 }
460 }
461