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

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