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

471 lines 20.9 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 'contentId' => ['var' => 'contentId'],
262 ],
263 'razorpay' => [
264 'fieldKey' => ['var' => 'fieldKey'],
265 'options' => ['path' => 'options'],
266 'payIntegID' => ['path' => 'payIntegID'],
267 'payType' => ['path' =>'payType', 'val' => ''],
268 'clientId' => ['path' => 'clientId'],
269 'contentId' => ['var' => 'contentId'],
270 ],
271 'repeater' => [
272 'fieldKey' => ['var' => 'fieldKey'],
273 'fieldName' => ['path' => 'fieldName'],
274 'contentId' => ['var' => 'contentId'],
275 'defaultRow' => ['path' => 'defaultRow', 'val' => 1],
276 'minimumRow' => ['path' => 'minRow', 'val' => 1],
277 'maximumRow' => ['path' => 'maxRow', 'val' => 0],
278 'showAddBtn' => ['path' => 'addBtn->show', 'val' => false],
279 'showAddToEndBtn' => ['path' => 'addToEndBtn->show', 'val' => false],
280 'defaultValue' => ['path' => 'val', 'val' => ''],
281 ],
282 'signature' => [
283 'fieldKey' => ['var' => 'fieldKey'],
284 'contentId' => ['var' => 'contentId'],
285 'maxWidth' => ['path' => 'config->maxWidth', 'val' => '1'],
286 'penColor' => ['path' => 'config->penColor', 'val'=> '#000000'],
287 'backgroundColor' => ['path' => 'config->backgroundColor', 'val' => '#ffffff'],
288 'imgTyp' => ['path' => 'config->imgTyp', 'val' => 'image/png'],
289 'assetsURL' => ['val' => BITFORMS_ROOT_URI . '/static/signature/']
290 ],
291 'rating' => [
292 'fieldKey' => ['var' => 'fieldKey'],
293 'contentId' => ['var' => 'contentId'],
294 'options' => ['path' => 'opt'],
295 'showReviewLblOnHover' => ['path' => 'showReviewLblOnHover'],
296 'showReviewLblOnSelect' => ['path' => 'showReviewLblOnSelect'],
297 'selectedRating' => ['path' => 'selectedRating'],
298 'defaultValue' => ['path' => ['val', 'config->defaultValue'], 'val'=> ''],
299 ]
300 ];
301
302 return $configs;
303 }
304
305 public static function multiStepFiles()
306 {
307 return [
308 ['priority' => 201, 'filename' => 'customFieldsReset.min.js'],
309 ['priority' => 201, 'filename' => 'isFormValidatedWithoutError.min.js'],
310 ['priority' => 202, 'filename' => 'saveFormProgress.min.js'],
311 ['priority' => 700, 'filename' => 'bit-multi-step-form.min.js'],
312 ];
313 }
314
315 public static function conversationalFormFiles()
316 {
317 return [
318 ['priority' => 202, 'filename' => 'saveFormProgress.min.js'],
319 ['priority' => 700, 'filename' => 'bit-conversational-form.min.js'],
320 ['priority' => 700, 'filename' => 'handleConversationalFormMsg.min.js'],
321 ];
322 }
323
324 public static function frontendScriptFile()
325 {
326 return [
327 'observeElm' => ['priority' => 101, 'filename' => 'observeElm.min.js'],
328 'hidden-token-field' => ['priority' => 300, 'filename' => 'hidden-token-field.min.js'],
329 ];
330 }
331
332 public static function validationAndOtherScriptFile()
333 {
334 return [
335 'checkFldValidation' => ['priority' => 701, 'filename' => 'checkFldValidation.min.js'],
336 'checkMinMaxOptions' => ['priority' => 702, 'filename' => 'checkMinMaxOptions.min.js'],
337 'customOptionValidation' => ['priority' => 702, 'filename' => 'customOptionValidation.min.js'],
338 'dcsnbxFldValidation' => ['priority' => 702, 'filename' => 'dcsnbxFldValidation.min.js'],
339 'emailFldValidation' => ['priority' => 702, 'filename' => 'emailFldValidation.min.js'],
340 'fileupFldValidation' => ['priority' => 702, 'filename' => 'fileupFldValidation.min.js'],
341 'advanceFileupFldValidation' => ['priority' => 702, 'filename' => 'advanceFileUpFldValidation.min.js'],
342 'phoneNumberFldValidation' => ['priority' => 702, 'filename' => 'phoneNumberFldValidation.min.js'],
343 'generateBackslashPattern' => ['priority' => 700, 'filename' => 'generateBackslashPattern.min.js'],
344 'nmbrFldValidation' => ['priority' => 702, 'filename' => 'nmbrFldValidation.min.js'],
345 'regexPatternValidation' => ['priority' => 701, 'filename' => 'regexPatternValidation.min.js'], // load before generateBackslashPattern file, then load regexPatternValidation
346 'requiredFldValidation' => ['priority' => 700, 'filename' => 'requiredFldValidation.min.js'],
347 'urlFldValidation' => ['priority' => 702, 'filename' => 'urlFldValidation.min.js'],
348 'validation' => ['priority' => 705, 'filename' => 'validateForm.min.js'], // last priority for validation script
349 'conditionalLogic' => ['priority' => 705, 'filename' => 'bit-conditionals.min.js'], // last priority for validation script
350 'resetPlaceholders' => ['priority' => 201, 'filename' => 'resetPlaceholders.min.js'],
351 'validateFocusLost' => ['priority' => 706, 'filename' => 'validate-focus.min.js'], // last priority for validation script
352 ];
353 }
354
355 public static function validationScriptFileMapping($fieldType)
356 {
357 $textTypeField = ['text', 'password', 'username', 'date', 'datetime-local', 'time', 'month', 'week', 'color'];
358 if (in_array($fieldType, $textTypeField)) {
359 $fieldType = 'text';
360 }
361 $fields =
362 [
363 'text' => [
364 'regexPatternValidation' => [
365 'paths' => ['valid->regexr'],
366 'dependencies' => [
367 'generateBackslashPattern'
368 ]
369 ]
370 ],
371 'email' => [
372 'emailFldValidation' => [
373 'paths' => ['err->invalid->show'],
374 'dependencies' => [
375 'generateBackslashPattern'
376 ]
377 ],
378 ],
379 'number' => [
380 'nmbrFldValidation' => [
381 'paths' => ['mn', 'mx']
382 ]
383 ],
384 'radio' => [
385 'customOptionValidation' => [
386 'paths' => ['valid->otherOptReq'],
387 ]
388 ],
389 'check' => [
390 'checkMinMaxOptions' => [
391 'paths' => ['mn', 'mx'],
392 'dependencies' => [
393 'checkFldValidation'
394 ]
395 ],
396 'customOptionValidation' => [
397 'paths' => ['valid->otherOptReq'],
398 ]
399 ],
400 'select' => [
401 'checkMinMaxOptions' => [
402 'paths' => ['mn', 'mx'],
403 'dependencies' => [
404 'checkFldValidation'
405 ]
406 ],
407 ],
408 'image-select' => [
409 'checkMinMaxOptions' => [
410 'paths' => ['mn', 'mx'],
411 'dependencies' => [
412 'checkFldValidation'
413 ]
414 ],
415 ],
416 'url' => [
417 'regexPatternValidation' => [
418 'paths' => ['valid->regexr'],
419 'dependencies' => [
420 'generateBackslashPattern'
421 ]
422 ],
423 'urlFldValidation' => [
424 'paths' => ['err->invalid->show'],
425 'dependencies' => [
426 'generateBackslashPattern'
427 ]
428 ]
429 ],
430 'decision-box' => [
431 'dcsnbxFldValidation' => [
432 'paths' => ['valid->req']
433 ]
434 ],
435 'file-up' => [
436 'fileupFldValidation' => [
437 'paths' => ['valid->req']
438 ]
439 ],
440 'advanced-file-up' => [
441 'advanceFileupFldValidation' => [
442 'paths' => ['valid->req']
443 ]
444 ],
445 'phone-number' => [
446 'phoneNumberFldValidation' => [
447 'paths' => ['err->invalid->show'],
448 ]
449 ],
450 ];
451 return isset($fields[$fieldType]) ? $fields[$fieldType] : [];
452 }
453
454 public static function formAbandonmentNeededFiles($abandonType = null)
455 {
456 $files = [
457 'autoSave' => [
458 ['priority' => 201, 'filename' => 'bit-page-lifecycle.min.js'],
459 ['priority' => 402, 'filename' => 'autoSavePartial.min.js'],
460 ]
461 ];
462
463 $required = [
464 ['priority' => 402, 'filename' => 'bit-form-abandonment.min.js'],
465 ['priority' => 401, 'filename' => 'saveFormProgress.min.js'],
466 ['priority' => 701, 'filename' => 'setFieldValues.min.js'],
467 ];
468 return isset($files[$abandonType]) ? array_merge($files[$abandonType], $required) : $required;
469 }
470 }
471