Calculated Fields Form - Version 1.1.130

Version Description

  • Implements two new operations VALIDFORM and VALIDFIELD to validate the forms and fields from the equations and buttons.
  • Fixes a minor issue displaying the placeholders in fields when validation fails.
  • Displays the fields' values into tags with the attribute data-cff-field and fieldname#.
  • Fixes a minor issue loading resources.
  • Fixes a minor issue generating cached forms (Commercial versions).
Download this release

Release Info

Developer codepeople
Plugin Icon 128x128 Calculated Fields Form
Version 1.1.130
Comparing to
See all releases

Code changes from version 1.1.129 to 1.1.130

README.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://cff.dwbooster.com
4
  Tags: form,quote form,contact form,form builder,calculator,calculated,quote calculator,forms,form editor,advanced forms,payment calculator,payment,recurring payment,quote,fields,calculated field,price calculator,email,form design,paypal,equation editor,formula,equation,quote calculator,post,posts,plugin,widget,admin,sidebar,images,image,page,shortcode,products form,woocommerce,addons,layout,session,post,cookie,get,webhook,Dropbox,pdf,language
5
  Requires at least: 3.0.5
6
  Tested up to: 6.1
7
- Stable tag: 1.1.129
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -965,6 +965,14 @@ A: Please, follow the steps below:
965
 
966
  == Changelog ==
967
 
 
 
 
 
 
 
 
 
968
  = 1.1.129 =
969
 
970
  * Improves the fields' selection in the dependency settings, equations edition, and summary fields configuration.
@@ -1012,11 +1020,4 @@ A: Please, follow the steps below:
1012
 
1013
  = 1.1.121 =
1014
 
1015
- * Improves the plugin security.
1016
-
1017
- = 1.1.120 =
1018
-
1019
- * Optimizes select queries in widgets by reducing execution time and resource usage.
1020
- * Fixes an issue in container fields (DIV and Fieldset) when the choices of contained radio buttons and checkbox fields are generated dynamically.
1021
- * Fixes an issue in the spinner number fields when multiple forms are on the same page.
1022
- * Triggers cff-summary-update event after updating the summary fields.
4
  Tags: form,quote form,contact form,form builder,calculator,calculated,quote calculator,forms,form editor,advanced forms,payment calculator,payment,recurring payment,quote,fields,calculated field,price calculator,email,form design,paypal,equation editor,formula,equation,quote calculator,post,posts,plugin,widget,admin,sidebar,images,image,page,shortcode,products form,woocommerce,addons,layout,session,post,cookie,get,webhook,Dropbox,pdf,language
5
  Requires at least: 3.0.5
6
  Tested up to: 6.1
7
+ Stable tag: 1.1.130
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
965
 
966
  == Changelog ==
967
 
968
+ = 1.1.130 =
969
+
970
+ * Implements two new operations VALIDFORM and VALIDFIELD to validate the forms and fields from the equations and buttons.
971
+ * Fixes a minor issue displaying the placeholders in fields when validation fails.
972
+ * Displays the fields' values into tags with the attribute data-cff-field and fieldname#.
973
+ * Fixes a minor issue loading resources.
974
+ * Fixes a minor issue generating cached forms (Commercial versions).
975
+
976
  = 1.1.129 =
977
 
978
  * Improves the fields' selection in the dependency settings, equations edition, and summary fields configuration.
1020
 
1021
  = 1.1.121 =
1022
 
1023
+ * Improves the plugin security.
 
 
 
 
 
 
 
changelog.txt CHANGED
@@ -1,5 +1,13 @@
1
  == Changelog ==
2
 
 
 
 
 
 
 
 
 
3
  = 1.1.129 =
4
 
5
  * Improves the fields' selection in the dependency settings, equations edition, and summary fields configuration.
1
  == Changelog ==
2
 
3
+ = 1.1.130 =
4
+
5
+ * Implements two new operations VALIDFORM and VALIDFIELD to validate the forms and fields from the equations and buttons.
6
+ * Fixes a minor issue displaying the placeholders in fields when validation fails.
7
+ * Displays the fields' values into tags with the attribute data-cff-field and fieldname#.
8
+ * Fixes a minor issue loading resources.
9
+ * Fixes a minor issue generating cached forms (Commercial versions).
10
+
11
  = 1.1.129 =
12
 
13
  * Improves the fields' selection in the dependency settings, equations edition, and summary fields configuration.
cp_calculatedfieldsf_free.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Calculated Fields Form
4
  Plugin URI: https://cff.dwbooster.com
5
  Description: Create forms with field values calculated based in other form field values.
6
- Version: 1.1.129
7
  Text Domain: calculated-fields-form
8
  Author: CodePeople
9
  Author URI: https://cff.dwbooster.com
@@ -15,7 +15,7 @@ if ( ! defined( 'WP_DEBUG' ) || true != WP_DEBUG ) {
15
  }
16
 
17
  // Defining main constants
18
- define( 'CP_CALCULATEDFIELDSF_VERSION', '1.1.129' );
19
  define( 'CP_CALCULATEDFIELDSF_MAIN_FILE_PATH', __FILE__ );
20
  define( 'CP_CALCULATEDFIELDSF_BASE_PATH', dirname( CP_CALCULATEDFIELDSF_MAIN_FILE_PATH ) );
21
  define( 'CP_CALCULATEDFIELDSF_BASE_NAME', plugin_basename( CP_CALCULATEDFIELDSF_MAIN_FILE_PATH ) );
3
  Plugin Name: Calculated Fields Form
4
  Plugin URI: https://cff.dwbooster.com
5
  Description: Create forms with field values calculated based in other form field values.
6
+ Version: 1.1.130
7
  Text Domain: calculated-fields-form
8
  Author: CodePeople
9
  Author URI: https://cff.dwbooster.com
15
  }
16
 
17
  // Defining main constants
18
+ define( 'CP_CALCULATEDFIELDSF_VERSION', '1.1.130' );
19
  define( 'CP_CALCULATEDFIELDSF_MAIN_FILE_PATH', __FILE__ );
20
  define( 'CP_CALCULATEDFIELDSF_BASE_PATH', dirname( CP_CALCULATEDFIELDSF_MAIN_FILE_PATH ) );
21
  define( 'CP_CALCULATEDFIELDSF_BASE_NAME', plugin_basename( CP_CALCULATEDFIELDSF_MAIN_FILE_PATH ) );
css/stylepublic.css CHANGED
@@ -383,7 +383,7 @@
383
  #fbuilder .top_aligned .fields label.cpefb_error,
384
  #fbuilder .left_aligned .fields label.cpefb_error,
385
  #fbuilder .right_aligned .fields label.cpefb_error{display:block;border:0px;color:#dc3545;float:none;}
386
- #fbuilder .cpefb_error::placeholder{color:rgba(255,255,255,.6)}
387
 
388
  #fbuilder div.cpefb_error{background: #dc3545 !important;color:white !important;padding:5px 10px;border-radius:5px;margin-top:15px;z-index:1000;font-size:12px;font-style:normal;text-shadow:none;}
389
  #fbuilder div.cpefb_error:after{width: 0;height: 0;border-left: 10px solid transparent;border-right: 10px solid transparent;border-bottom: 10px solid #dc3545 !important;content:"";position:absolute;top:-8px;left:10px;z-index:1000;}
383
  #fbuilder .top_aligned .fields label.cpefb_error,
384
  #fbuilder .left_aligned .fields label.cpefb_error,
385
  #fbuilder .right_aligned .fields label.cpefb_error{display:block;border:0px;color:#dc3545;float:none;}
386
+ /* #fbuilder .cpefb_error::placeholder{color:rgba(255,255,255,.6)} */
387
 
388
  #fbuilder div.cpefb_error{background: #dc3545 !important;color:white !important;padding:5px 10px;border-radius:5px;margin-top:15px;z-index:1000;font-size:12px;font-style:normal;text-shadow:none;}
389
  #fbuilder div.cpefb_error:after{width: 0;height: 0;border-left: 10px solid transparent;border-right: 10px solid transparent;border-bottom: 10px solid #dc3545 !important;content:"";position:absolute;top:-8px;left:10px;z-index:1000;}
js/fbuilder-loader-admin.php CHANGED
@@ -68,7 +68,7 @@ fbuilderjQuery(window).on('load',function(){
68
  if(!fbuilderjQuery('[href*="jquery-ui"]').length)
69
  {
70
  fbuilderjQuery('body').append(
71
- '<link href="<?php print esc_attr( plugins_url( '/vendors/jquery-ui/jquery-ui.min.css', CP_CALCULATEDFIELDSF_MAIN_FILE_PATH ) ); // phpcs:ignore WordPress.WP.EnqueuedResources ?>" type="text/css" rel="stylesheet" property="stylesheet" />'
72
  );
73
  }
74
  });
68
  if(!fbuilderjQuery('[href*="jquery-ui"]').length)
69
  {
70
  fbuilderjQuery('body').append(
71
+ '<link href="<?php print esc_attr( preg_replace( '/[\n\r]/', '', plugins_url( '/vendors/jquery-ui/jquery-ui.min.css', CP_CALCULATEDFIELDSF_MAIN_FILE_PATH ) ) ); // phpcs:ignore WordPress.WP.EnqueuedResources ?>" type="text/css" rel="stylesheet" property="stylesheet" />'
72
  );
73
  }
74
  });
js/fbuilder-pro-public.jquery.js CHANGED
@@ -1,4 +1,4 @@
1
- $.fbuilder['version'] = '1.1.129';
2
  $.fbuilder['controls'] = $.fbuilder['controls'] || {};
3
  $.fbuilder['forms'] = $.fbuilder['forms'] || {};
4
 
@@ -837,4 +837,41 @@
837
  o.setVal(v);
838
  e.valid();
839
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
840
  });
1
+ $.fbuilder['version'] = '1.1.130';
2
  $.fbuilder['controls'] = $.fbuilder['controls'] || {};
3
  $.fbuilder['forms'] = $.fbuilder['forms'] || {};
4
 
837
  o.setVal(v);
838
  e.valid();
839
  }
840
+ });
841
+
842
+ function assign_data_cff_field_content( field ) {
843
+ try{
844
+ field = $(field);
845
+
846
+ var field_name = field.attr('name').match(/fieldname\d+/)[0];
847
+ form_obj = field.closest('form'),
848
+ tags = form_obj.find('[data-cff-field="'+field_name+'"]');
849
+ if( tags.length ){
850
+ var ignore = field.hasClass('ignore'),
851
+ field_obj = getField(field, form_obj),
852
+ value = (ignore || ! field_obj) ? '' : field_obj.val(true, true);
853
+
854
+ value = Array.isArray(value) ? value.join(', ') : value;
855
+ tags.each(function(){$(this).html(value);});
856
+ }
857
+ } catch( err ) {}
858
+ };
859
+
860
+ $(document).on('change keyup', '#fbuilder :input[name*="fieldname"]', function(){ assign_data_cff_field_content(this); });
861
+
862
+ $(document).one('showHideDepEvent', function(){
863
+ try{
864
+ var form_obj = $('#'+arguments[1]);
865
+ form_obj.find( '[data-cff-field]' ).each(function(){
866
+ try {
867
+ var tag_obj = $(this),
868
+ field_name = tag_obj.attr('data-cff-field'),
869
+ field_obj;
870
+ if( field_name.length && /fieldname\d+/.test(field_name) ) {
871
+ field_obj = form_obj.find('[name*="'+field_name+'_"]');
872
+ if( field_obj.length ) assign_data_cff_field_content( field_obj );
873
+ }
874
+ } catch( err ) {}
875
+ } );
876
+ } catch( err ){}
877
  });
js/modules/05_managing_fields/admin/module_admin.js CHANGED
@@ -43,6 +43,16 @@ fbuilderjQuery[ 'fbuilder' ][ 'modules' ][ 'processing' ] = {
43
  "code" : "SHOWFIELD(",
44
  "tip" : "<p>Show a field explicitly. If the field was hidden by a dependency or by the IGNOREFIELD operation, it must be displayed by the ACTIVATEFIELD operation. <strong>SHOWFIELD( # or fieldname#, form or form selector )</strong></p><p>The first parameter is required. It is the numeric part of the field name or the field name. The second parameter would be a form object or a selector with the form reference. If the second parameter is not passed, the plugin will display the field in the first form on the page. For example: SHOWFIELD(1); or SHOWFIELD(&quot;fieldname1&quot;);</p>"
45
  },
 
 
 
 
 
 
 
 
 
 
46
  {
47
  "value" : "DISABLEEQUATIONS",
48
  "code" : "DISABLEEQUATIONS(",
43
  "code" : "SHOWFIELD(",
44
  "tip" : "<p>Show a field explicitly. If the field was hidden by a dependency or by the IGNOREFIELD operation, it must be displayed by the ACTIVATEFIELD operation. <strong>SHOWFIELD( # or fieldname#, form or form selector )</strong></p><p>The first parameter is required. It is the numeric part of the field name or the field name. The second parameter would be a form object or a selector with the form reference. If the second parameter is not passed, the plugin will display the field in the first form on the page. For example: SHOWFIELD(1); or SHOWFIELD(&quot;fieldname1&quot;);</p>"
45
  },
46
+ {
47
+ "value" : "VALIDFORM",
48
+ "code" : "VALIDFORM(",
49
+ "tip" : "<p>Checks if the values of the form fields are valid or not. <b>VALIDFORM( form object or selector, silent )</b></p><p>The first parameter would be a form object or a selector with the reference to the form. If this is null, or not passed to the operation, the plugin validates the first form on the page. The second parameter is a boolean (true or false), and allows us to validate the form without displaying error messages:</p><p><b>VALIDFORM();</b> or<br> <b>VALIDFORM(&quot;cp_calculatedfieldsf_pform_1&quot;, true);</b></p>"
50
+ },
51
+ {
52
+ "value" : "VALIDFIELD",
53
+ "code" : "VALIDFIELD(",
54
+ "tip" : "<p>Checks if the field value is valid or not. <b>VALIDFIELD( field name or number, form object or selector, silent )</b></p><p>The first parameter is required. It is the name of the field to validate (Ex. fieldname123|n) or its numeric components (Ex. 123). The second parameter would be a form object or a selector with the reference to the form. If this is null, or not passed to the operation, the plugin validates the field in the first form on the page. The third parameter is a boolean (true or false), and allows us to validate the field without displaying error messages:</p><p><b>VALIDFIELD(fieldname1|n);</b> or<br> <b>VALIDFIELD(fieldname1|n, &quot;cp_calculatedfieldsf_pform_1&quot;, true);</b></p>"
55
+ },
56
  {
57
  "value" : "DISABLEEQUATIONS",
58
  "code" : "DISABLEEQUATIONS(",
js/modules/05_managing_fields/public/05_managing_fields.js CHANGED
@@ -14,7 +14,7 @@
14
 
15
  function _getForm(_form)
16
  {
17
- if(typeof _form == 'undefined'){
18
  if('currentFormId' in fbuilderjQuery.fbuilder) _form = fbuilderjQuery.fbuilder.currentFormId;
19
  else return '_1';
20
  }
@@ -39,8 +39,12 @@
39
 
40
  if('getAttribute' in _field)
41
  {
42
- _form = $(_field).closest('form');
43
- _field = _field.getAttribute('class').match(/fieldname\d+/)[0];
 
 
 
 
44
  }
45
  else return false;
46
  }
@@ -54,6 +58,27 @@
54
  return _getField(_field, _form);
55
  };
56
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
57
  lib.activatefield = lib.ACTIVATEFIELD = function( _field, _form )
58
  {
59
  var o = _getForm(_form), f = _getField(_field, _form), j;
14
 
15
  function _getForm(_form)
16
  {
17
+ if(typeof _form == 'undefined' || _form == null){
18
  if('currentFormId' in fbuilderjQuery.fbuilder) _form = fbuilderjQuery.fbuilder.currentFormId;
19
  else return '_1';
20
  }
39
 
40
  if('getAttribute' in _field)
41
  {
42
+ _form = $(_field).closest('form');
43
+ var to_check = _field.getAttribute('class').match(/fieldname\d+/);
44
+ if(to_check) _field = to_check[0];
45
+ else {
46
+ _field = _field.getAttribute('name').match(/fieldname\d+/)[0];
47
+ }
48
  }
49
  else return false;
50
  }
58
  return _getField(_field, _form);
59
  };
60
 
61
+ lib.validform = lib.VALIDFORM = lib.ValidForm = function( _form, _silent ){
62
+ _silent = _silent || false;
63
+ var o = _getForm(_form), f;
64
+ if(o){
65
+ f = $('[id="'+$.fbuilder.forms[o]['formId']+'"]');
66
+ if(f.length) return _silent ? f.validate().checkForm() : f.valid();
67
+ }
68
+ return false;
69
+ };
70
+
71
+ lib.validfield = lib.VALIDFIELD = lib.ValidField = function( _field, _form, _silent ){
72
+ _silent = _silent || false;
73
+ var o = _getForm(_form), f = _getField(_field, _form), j;
74
+ if(f){
75
+ j = f.jQueryRef().find(':input');
76
+ if(j.length)
77
+ return _silent ? j.closest('form').validate().check( j ) : j.valid();
78
+ }
79
+ return false;
80
+ };
81
+
82
  lib.activatefield = lib.ACTIVATEFIELD = function( _field, _form )
83
  {
84
  var o = _getForm(_form), f = _getField(_field, _form), j;