Calculated Fields Form - Version 1.0.447

Version Description

  • Improves the plugin's performance.
  • Includes two new operations in the Managing Fields operations: EVALEQUATIONS and EVALEQUATION.
  • Fixes an issue in the PRESENTVALUE operation (Developer and Platinum versions of the plugin).
Download this release

Release Info

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

Code changes from version 1.0.443 to 1.0.447

README.txt CHANGED
@@ -949,6 +949,26 @@ This way the special characters should show correctly.
949
 
950
  == Changelog ==
951
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
952
  = 1.0.443 =
953
 
954
  * Includes two new operations: ENABLEEQUATIONS and DISABLEEQUATIONS for enabling/disabling the dynamic evaluation of the equations, respectively.
@@ -976,30 +996,8 @@ This way the special characters should show correctly.
976
  * Fixes an issue duplicating summary controls.
977
  * Modifies the defaultCalc operation for accepting an object.
978
 
979
- = 1.0.437 =
980
-
981
- * Fixes a zoom issue in iPhones.
982
- * Includes a new feature in the Users Permissions add-on for sending a notification email to the users when admin edit their submissions (Developer and Platinum versions).
983
-
984
- = 1.0.436 =
985
-
986
- * Modifies the button control for accepting OnMouseDown button.
987
- * Modifies the media control to allow the width and height attributes to affect the audio tags.
988
- * Modifies the template 13 to allow printing the ticked radio buttons and checkbox fields.
989
- * Fixes a minor conflict between the no-cache attribute and the thank you pages URLs with bookmarks (Professional, Developer, and Platinum versions).
990
-
991
- = 1.0.435 =
992
-
993
- * Implements the REMAINDER operation.
994
-
995
- = 1.0.434 =
996
-
997
- * Fixes a minor issue in the radio buttons controls.
998
- * Modifies the WooCommerce add-on to allow editing the products added to the cart (Developer and Platinum versions).
999
- * Modifies the Users Permissions add-on (Developer and Platinum versions).
1000
-
1001
  == Upgrade Notice ==
1002
 
1003
- = 1.0.443 =
1004
 
1005
  Important note: If you are using the Professional version don't update via the WP dashboard but using your personal update link. Contact us if you need further information: http://cff.dwbooster.com/contact-us
949
 
950
  == Changelog ==
951
 
952
+ = 1.0.447 =
953
+
954
+ * Improves the plugin's performance.
955
+ * Includes two new operations in the Managing Fields operations: EVALEQUATIONS and EVALEQUATION.
956
+ * Fixes an issue in the PRESENTVALUE operation (Developer and Platinum versions of the plugin).
957
+
958
+ = 1.0.446 =
959
+
960
+ * Fixes a conflict with third party plugins that overwrite the POW operation in the plugin.
961
+ * Modifies the WooCommerce add-on to allow its use with WooCommerce Booking and similar plugins (Developer and Platinum versions of the plugin).
962
+
963
+ = 1.0.445 =
964
+
965
+ * Fixes an issue with the Sliders for ranges.
966
+ * Improves the mathematical operations.
967
+
968
+ = 1.0.444 =
969
+
970
+ * Fixes some compatibility issues with PHP8.
971
+
972
  = 1.0.443 =
973
 
974
  * Includes two new operations: ENABLEEQUATIONS and DISABLEEQUATIONS for enabling/disabling the dynamic evaluation of the equations, respectively.
996
  * Fixes an issue duplicating summary controls.
997
  * Modifies the defaultCalc operation for accepting an object.
998
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
999
  == Upgrade Notice ==
1000
 
1001
+ = 1.0.447 =
1002
 
1003
  Important note: If you are using the Professional version don't update via the WP dashboard but using your personal update link. Contact us if you need further information: http://cff.dwbooster.com/contact-us
changelog.txt CHANGED
@@ -1,5 +1,25 @@
1
  == Changelog ==
2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  = 1.0.443 =
4
 
5
  * Includes two new operations: ENABLEEQUATIONS and DISABLEEQUATIONS for enabling/disabling the dynamic evaluation of the equations, respectively.
@@ -505,23 +525,4 @@
505
 
506
  = 1.0.348 =
507
 
508
- * Improves the appearance of the forms list in the medium-size screens.
509
-
510
- = 1.0.347 =
511
-
512
- * Modifies the validation on Currency and Number fields.
513
-
514
- = 1.0.346 =
515
-
516
- * Fixes some warnings.
517
-
518
- = 1.0.345 =
519
-
520
- * Fixes an issue in the number fields when the percent option is selected as their formats.
521
- * Modifies the forms list to be ordered by their IDs in ascending way.
522
- * Fixes an issue in the new forms, selecting the calculated field through the Request Cost attribute by default.
523
- * Includes new class names into the Dashboard widget and the messages section (Professional, Developer and Platinum versions of the plugin)
524
-
525
- = 1.0.344 =
526
-
527
- * Improves the goToPage operation to allow jumping to a sepecific page in multi-pages forms, from button fields. Ex: for jumping to the third page in the form (the pages indexes start in 0), insert a button in the form and enter as its onclick event the piece of code: fbuilderjQuery.fbuilder.goToPage({form:this.form, to:2});
1
  == Changelog ==
2
 
3
+ = 1.0.447 =
4
+
5
+ * Improves the plugin's performance.
6
+ * Includes two new operations in the Managing Fields operations: EVALEQUATIONS and EVALEQUATION.
7
+ * Fixes an issue in the PRESENTVALUE operation (Developer and Platinum versions of the plugin).
8
+
9
+ = 1.0.446 =
10
+
11
+ * Fixes a conflict with third party plugins that overwrite the POW operation in the plugin.
12
+ * Modifies the WooCommerce add-on to allow its use with WooCommerce Booking and similar plugins (Developer and Platinum versions of the plugin).
13
+
14
+ = 1.0.445 =
15
+
16
+ * Fixes an issue with the Sliders for ranges.
17
+ * Improves the mathematical operations.
18
+
19
+ = 1.0.444 =
20
+
21
+ * Fixes some compatibility issues with PHP8.
22
+
23
  = 1.0.443 =
24
 
25
  * Includes two new operations: ENABLEEQUATIONS and DISABLEEQUATIONS for enabling/disabling the dynamic evaluation of the equations, respectively.
525
 
526
  = 1.0.348 =
527
 
528
+ * Improves the appearance of the forms list in the medium-size screens.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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.0.443
7
  Text Domain: calculated-fields-form
8
  Author: CodePeople
9
  Author URI: https://cff.dwbooster.com
@@ -16,7 +16,7 @@ if(!defined('WP_DEBUG') || true != WP_DEBUG)
16
  }
17
 
18
  // Defining main constants
19
- define('CP_CALCULATEDFIELDSF_VERSION', '1.0.443' );
20
  define('CP_CALCULATEDFIELDSF_MAIN_FILE_PATH', __FILE__ );
21
  define('CP_CALCULATEDFIELDSF_BASE_PATH', dirname( CP_CALCULATEDFIELDSF_MAIN_FILE_PATH ) );
22
  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.0.447
7
  Text Domain: calculated-fields-form
8
  Author: CodePeople
9
  Author URI: https://cff.dwbooster.com
16
  }
17
 
18
  // Defining main constants
19
+ define('CP_CALCULATEDFIELDSF_VERSION', '1.0.447' );
20
  define('CP_CALCULATEDFIELDSF_MAIN_FILE_PATH', __FILE__ );
21
  define('CP_CALCULATEDFIELDSF_BASE_PATH', dirname( CP_CALCULATEDFIELDSF_MAIN_FILE_PATH ) );
22
  define('CP_CALCULATEDFIELDSF_BASE_NAME', plugin_basename( CP_CALCULATEDFIELDSF_MAIN_FILE_PATH ) );
inc/cpcff_admin_int_list.inc.php CHANGED
@@ -25,18 +25,18 @@ if (isset($_GET['a']) && $_GET['a'] == '1')
25
  $cpcff_main->create_form((isset($_GET["name"])) ? sanitize_text_field(stripcslashes($_GET["name"])) : '');
26
  $message = __( "Item added", 'calculated-fields-form' );
27
  }
28
- else if (isset($_GET['u']) && $_GET['u'] != '')
29
  {
30
  check_admin_referer( 'cff-update-form', '_cpcff_nonce' );
31
  $cpcff_main->get_form($_GET['u'])->update_name((isset($_GET["name"])) ? sanitize_text_field(stripcslashes($_GET["name"])) : '');
32
  $message = __( "Item updated", 'calculated-fields-form' );
33
  }
34
- else if (isset($_GET['d']) && $_GET['d'] != '')
35
  {
36
  check_admin_referer( 'cff-delete-form', '_cpcff_nonce' );
37
  $cpcff_main->delete_form($_GET['d']);
38
  $message = __( "Item deleted", 'calculated-fields-form' );
39
- } else if (isset($_GET['c']) && $_GET['c'] != '')
40
  {
41
  check_admin_referer( 'cff-clone-form', '_cpcff_nonce' );
42
  if($cpcff_main->clone_form(@intval($_GET['c'])) !== false) $message = __( "Item duplicated/cloned", 'calculated-fields-form' );
@@ -69,7 +69,7 @@ else if (isset($_GET['d']) && $_GET['d'] != '')
69
  }
70
  }catch( Exception $err ){}
71
 
72
- if ($_GET["chs"] != '')
73
  {
74
  $target_charset = $_GET["chs"];
75
  if( !in_array($target_charset, array('utf8_general_ci', 'utf8mb4_general_ci', 'latin1_swedish_ci')) ) $target_charset = 'utf8_general_ci';
25
  $cpcff_main->create_form((isset($_GET["name"])) ? sanitize_text_field(stripcslashes($_GET["name"])) : '');
26
  $message = __( "Item added", 'calculated-fields-form' );
27
  }
28
+ else if (!empty($_GET['u']))
29
  {
30
  check_admin_referer( 'cff-update-form', '_cpcff_nonce' );
31
  $cpcff_main->get_form($_GET['u'])->update_name((isset($_GET["name"])) ? sanitize_text_field(stripcslashes($_GET["name"])) : '');
32
  $message = __( "Item updated", 'calculated-fields-form' );
33
  }
34
+ else if (!empty($_GET['d']))
35
  {
36
  check_admin_referer( 'cff-delete-form', '_cpcff_nonce' );
37
  $cpcff_main->delete_form($_GET['d']);
38
  $message = __( "Item deleted", 'calculated-fields-form' );
39
+ } else if (!empty($_GET['c']))
40
  {
41
  check_admin_referer( 'cff-clone-form', '_cpcff_nonce' );
42
  if($cpcff_main->clone_form(@intval($_GET['c'])) !== false) $message = __( "Item duplicated/cloned", 'calculated-fields-form' );
69
  }
70
  }catch( Exception $err ){}
71
 
72
+ if (!empty($_GET["chs"]))
73
  {
74
  $target_charset = $_GET["chs"];
75
  if( !in_array($target_charset, array('utf8_general_ci', 'utf8mb4_general_ci', 'latin1_swedish_ci')) ) $target_charset = 'utf8_general_ci';
js/fbuilder-loader-admin.php CHANGED
@@ -65,6 +65,8 @@ fbuilderjQuery.fbuilderjQueryGenerator = function(){
65
  {
66
  require $file;
67
  }
 
 
68
  }
69
  catch (Exception $e)
70
  {
65
  {
66
  require $file;
67
  }
68
+
69
+ do_action('cpcff_load_controls_admin');
70
  }
71
  catch (Exception $e)
72
  {
js/fbuilder-loader-public.php CHANGED
@@ -63,6 +63,8 @@ fbuilderjQuery.fbuilderjQueryGenerator = function(){
63
  {
64
  require $file;
65
  }
 
 
66
  } catch (Exception $e) {
67
  // ignore the error
68
  }
63
  {
64
  require $file;
65
  }
66
+
67
+ do_action('cpcff_load_controls_public');
68
  } catch (Exception $e) {
69
  // ignore the error
70
  }
js/fbuilder-pro-public.jquery.js CHANGED
@@ -216,7 +216,7 @@
216
  for( var fieldId in data )
217
  {
218
  item = formObj.getItem(fieldId+id);
219
- try{ if('setVal' in item) item.setVal(data[fieldId]); }
220
  catch(err){}
221
  }
222
 
@@ -275,6 +275,7 @@
275
  }).messages = opt.messages;
276
 
277
  var items = [],
 
278
  reloadItemsPublic = function()
279
  {
280
  var form_tag = $("#cp_calculatedfieldsf_pform"+opt.identifier),
@@ -503,6 +504,7 @@
503
  getItem: function( name )
504
  {
505
  var regExp = new RegExp((parseInt(name,10) == name) ? 'fieldname'+name+'_' : name+'_', i);
 
506
  for( var i in items )
507
  {
508
  if( items[ i ].name == name || regExp.test(items[ i ].name))
@@ -535,7 +537,9 @@
535
  obj.name = obj.name+opt.identifier;
536
  obj.form_identifier = opt.identifier;
537
  obj.init();
538
- items[items.length] = obj;
 
 
539
  }
540
  theForm = new fform();
541
  theForm = $.extend(theForm,d[1][0]);
@@ -546,7 +550,7 @@
546
 
547
  reloadItemsPublic();
548
  }
549
- $.fbuilder.cpcffLoadDefaults( opt );
550
  }
551
  }
552
  };
@@ -619,9 +623,11 @@
619
  }
620
  return 0;
621
  },
622
- setVal:function( v )
623
  {
624
- $( "[id='" + this.name + "']" ).val( v ).change();
 
 
625
  }
626
  });
627
 
216
  for( var fieldId in data )
217
  {
218
  item = formObj.getItem(fieldId+id);
219
+ try{ if('setVal' in item) item.setVal(data[fieldId], true); }
220
  catch(err){}
221
  }
222
 
275
  }).messages = opt.messages;
276
 
277
  var items = [],
278
+ fieldsIndex = {},
279
  reloadItemsPublic = function()
280
  {
281
  var form_tag = $("#cp_calculatedfieldsf_pform"+opt.identifier),
504
  getItem: function( name )
505
  {
506
  var regExp = new RegExp((parseInt(name,10) == name) ? 'fieldname'+name+'_' : name+'_', i);
507
+ if(name in fieldsIndex) return items[fieldsIndex[name]];
508
  for( var i in items )
509
  {
510
  if( items[ i ].name == name || regExp.test(items[ i ].name))
537
  obj.name = obj.name+opt.identifier;
538
  obj.form_identifier = opt.identifier;
539
  obj.init();
540
+ /* items[items.length] = obj; */
541
+ items[i] = obj;
542
+ fieldsIndex[obj.name] = i;
543
  }
544
  theForm = new fform();
545
  theForm = $.extend(theForm,d[1][0]);
550
 
551
  reloadItemsPublic();
552
  }
553
+ $.fbuilder.cpcffLoadDefaults( opt );
554
  }
555
  }
556
  };
623
  }
624
  return 0;
625
  },
626
+ setVal:function( v, nochange )
627
  {
628
+ var e = $( "[id='" + this.name + "']" );
629
+ e.val( v );
630
+ if(!nochange) e.change();
631
  }
632
  });
633
 
js/fields-public/02_fbuilder.fslider.js CHANGED
@@ -51,7 +51,7 @@
51
  return v;
52
  }
53
  },
54
- _setFieldValue:function()
55
  {
56
  var me = this;
57
  if( me.range )
@@ -59,7 +59,7 @@
59
  var values = $('#'+me.name+'_slider').slider('values'),
60
  vl = values[0], vr = values[1],
61
  vlf = me._setThousandsSeparator(vl),
62
- vrf = me._setThousandsSeparator(vf);
63
 
64
  $('#'+me.name+'_component_left').val(vl);
65
  $('#'+me.name+'_component_right').val(vr);
@@ -80,7 +80,7 @@
80
  me.caption.replace(/\{\s*0\s*\}/, vf)
81
  );
82
  }
83
- $('#'+me.name).change();
84
  },
85
  _toNumber:function(n){return (new String(n)).replace(/[^\d\.]/g,'')*1;},
86
  init:function()
@@ -243,13 +243,13 @@
243
  }
244
  catch(err){return 0;}
245
  },
246
- setVal:function( v )
247
  {
248
  try{ v = JSON.parse(v); }catch(err){}
249
  try{
250
  $( '[name="'+this.name+'"]' ).val( v );
251
  $('#'+this.name+'_slider').slider((($.isArray(v)) ? 'values' : 'value'), v);
252
- this._setFieldValue();
253
  }catch( err ){}
254
  }
255
  });
51
  return v;
52
  }
53
  },
54
+ _setFieldValue:function(nochange)
55
  {
56
  var me = this;
57
  if( me.range )
59
  var values = $('#'+me.name+'_slider').slider('values'),
60
  vl = values[0], vr = values[1],
61
  vlf = me._setThousandsSeparator(vl),
62
+ vrf = me._setThousandsSeparator(vr);
63
 
64
  $('#'+me.name+'_component_left').val(vl);
65
  $('#'+me.name+'_component_right').val(vr);
80
  me.caption.replace(/\{\s*0\s*\}/, vf)
81
  );
82
  }
83
+ if(!nochange) $('#'+me.name).change();
84
  },
85
  _toNumber:function(n){return (new String(n)).replace(/[^\d\.]/g,'')*1;},
86
  init:function()
243
  }
244
  catch(err){return 0;}
245
  },
246
+ setVal:function( v, nochange )
247
  {
248
  try{ v = JSON.parse(v); }catch(err){}
249
  try{
250
  $( '[name="'+this.name+'"]' ).val( v );
251
  $('#'+this.name+'_slider').slider((($.isArray(v)) ? 'values' : 'value'), v);
252
+ this._setFieldValue(nochange);
253
  }catch( err ){}
254
  }
255
  });
js/fields-public/04_fbuilder.fdate.js CHANGED
@@ -222,7 +222,7 @@
222
  }
223
  return str;
224
  },
225
- set_dateTime:function()
226
  {
227
  var me = this,
228
  str = $( '#'+me.name+'_date' ).val();
@@ -232,7 +232,7 @@
232
  str += ':'+$( '#'+me.name+'_minutes' ).val();
233
  if( $( '#'+me.name+'_ampm' ).length ) str += $( '#'+me.name+'_ampm' ).val();
234
  }
235
- $( '#'+me.name ).val( str ).change();
236
  },
237
  set_minDate:function(v, ignore)
238
  {
@@ -406,7 +406,7 @@
406
  }
407
  return 0;
408
  },
409
- setVal:function( v )
410
  {
411
  try
412
  {
@@ -427,7 +427,7 @@
427
  this.set_DefaultTime();
428
  }
429
  }
430
- this.set_dateTime();
431
  }
432
  catch( err )
433
  {}
222
  }
223
  return str;
224
  },
225
+ set_dateTime:function(nochange)
226
  {
227
  var me = this,
228
  str = $( '#'+me.name+'_date' ).val();
232
  str += ':'+$( '#'+me.name+'_minutes' ).val();
233
  if( $( '#'+me.name+'_ampm' ).length ) str += $( '#'+me.name+'_ampm' ).val();
234
  }
235
+ if(!nochange) $( '#'+me.name ).val( str ).change();
236
  },
237
  set_minDate:function(v, ignore)
238
  {
406
  }
407
  return 0;
408
  },
409
+ setVal:function( v, nochange )
410
  {
411
  try
412
  {
427
  this.set_DefaultTime();
428
  }
429
  }
430
+ this.set_dateTime(nochange);
431
  }
432
  catch( err )
433
  {}
js/fields-public/06_fbuilder.fcheck.js CHANGED
@@ -121,7 +121,7 @@
121
  }
122
  return (typeof v == 'object' && typeof v['length'] !== 'undefined') ? v : ((v) ? (($.isNumeric(v)) ? v : '"'+v+'"') : 0);
123
  },
124
- setVal:function( v )
125
  {
126
  var t, n = this.name;
127
  if( !$.isArray( v ) ) v = [v];
@@ -131,7 +131,7 @@
131
  t = (new String(v[i])).replace(/(['"])/g, "\\$1");
132
  $( '[id*="'+n+'"][vt="'+t+'"],[id*="'+n+'"][value="'+t+'"]' ).prop( 'checked', true );
133
  }
134
- $( '[id*="'+n+'"]' ).change();
135
  },
136
  setChoices:function(choices)
137
  {
@@ -143,10 +143,12 @@
143
  if('dependencies' in choices && $.isArray(choices.dependencies)) this.choicesDep = choices.dependencies;
144
  var html = this.show(),
145
  e = $('.'+this.name),
 
146
  i = e.find('.ignore').length,
147
  ipb = e.find('.ignorepb').length;
148
  e.replaceWith(html);
149
  e = $('.'+this.name);
 
150
  if(i) e.find('input').addClass('ignore');
151
  if(ipb) e.find('input').addClass('ignorepb');
152
  this.setVal(bk);
121
  }
122
  return (typeof v == 'object' && typeof v['length'] !== 'undefined') ? v : ((v) ? (($.isNumeric(v)) ? v : '"'+v+'"') : 0);
123
  },
124
+ setVal:function( v, nochange )
125
  {
126
  var t, n = this.name;
127
  if( !$.isArray( v ) ) v = [v];
131
  t = (new String(v[i])).replace(/(['"])/g, "\\$1");
132
  $( '[id*="'+n+'"][vt="'+t+'"],[id*="'+n+'"][value="'+t+'"]' ).prop( 'checked', true );
133
  }
134
+ if(!nochange) $( '[id*="'+n+'"]' ).change();
135
  },
136
  setChoices:function(choices)
137
  {
143
  if('dependencies' in choices && $.isArray(choices.dependencies)) this.choicesDep = choices.dependencies;
144
  var html = this.show(),
145
  e = $('.'+this.name),
146
+ c = e.attr('class'),
147
  i = e.find('.ignore').length,
148
  ipb = e.find('.ignorepb').length;
149
  e.replaceWith(html);
150
  e = $('.'+this.name);
151
+ e.attr('class', c);
152
  if(i) e.find('input').addClass('ignore');
153
  if(ipb) e.find('input').addClass('ignorepb');
154
  this.setVal(bk);
js/fields-public/07_fbuilder.fradio.js CHANGED
@@ -117,12 +117,12 @@
117
  if( e.length ) return $.fbuilder.parseValStr( (raw == 'vt') ? e.attr('vt') : e.val(), raw );
118
  return 0;
119
  },
120
- setVal:function( v )
121
  {
122
  var t = (new String(v)).replace(/(['"])/g, "\\$1"), n = this.name;
123
  $( '[id*="'+n+'"]' ).prop( 'checked', false );
124
  $( '[id*="'+n+'"][vt="'+t+'"],[id*="'+n+'"][value="'+t+'"]' ).prop( 'checked', true );
125
- $( '[id*="'+n+'"]' ).change();
126
  },
127
  setChoices:function(choices)
128
  {
@@ -134,10 +134,12 @@
134
  if('dependencies' in choices && $.isArray(choices.dependencies)) this.choicesDep = choices.dependencies;
135
  var html = this.show(),
136
  e = $('.'+this.name),
 
137
  i = e.find('.ignore').length,
138
  ipb = e.find('.ignorepb').length;
139
  e.replaceWith(html);
140
  e = $('.'+this.name);
 
141
  if(i) e.find('input').addClass('ignore');
142
  if(ipb) e.find('input').addClass('ignorepb');
143
  this.setVal(bk);
117
  if( e.length ) return $.fbuilder.parseValStr( (raw == 'vt') ? e.attr('vt') : e.val(), raw );
118
  return 0;
119
  },
120
+ setVal:function( v, nochange )
121
  {
122
  var t = (new String(v)).replace(/(['"])/g, "\\$1"), n = this.name;
123
  $( '[id*="'+n+'"]' ).prop( 'checked', false );
124
  $( '[id*="'+n+'"][vt="'+t+'"],[id*="'+n+'"][value="'+t+'"]' ).prop( 'checked', true );
125
+ if(!nochange) $( '[id*="'+n+'"]' ).change();
126
  },
127
  setChoices:function(choices)
128
  {
134
  if('dependencies' in choices && $.isArray(choices.dependencies)) this.choicesDep = choices.dependencies;
135
  var html = this.show(),
136
  e = $('.'+this.name),
137
+ c = e.attr('class'),
138
  i = e.find('.ignore').length,
139
  ipb = e.find('.ignorepb').length;
140
  e.replaceWith(html);
141
  e = $('.'+this.name);
142
+ e.attr('class', c);
143
  if(i) e.find('input').addClass('ignore');
144
  if(ipb) e.find('input').addClass('ignorepb');
145
  this.setVal(bk);
js/fields-public/08_fbuilder.fdropdown.js CHANGED
@@ -136,7 +136,7 @@
136
  }
137
  return (typeof v == 'object' && typeof v['length'] !== 'undefined') ? v : ((v) ? (($.isNumeric(v)) ? v : '"'+v+'"') : 0);
138
  },
139
- setVal:function( v )
140
  {
141
  if( !$.isArray( v ) ) v = [v];
142
  var t, n = this.name;
@@ -146,7 +146,8 @@
146
  $( '[id="'+n+'"] OPTION[vt="'+t+'"],[id="'+n+'"] OPTION[value="'+t+'"]' ).prop( 'selected', true );
147
 
148
  }
149
- $( '[id="'+n+'"]' ).change();
 
150
  },
151
  setChoices:function(choices)
152
  {
@@ -159,10 +160,12 @@
159
  if('optgroup' in choices && $.isArray(choices.optgroup)) this.optgroup = choices.optgroup;
160
  var html = this.show(),
161
  e = $('.'+this.name),
 
162
  i = e.find('.ignore').length,
163
  ipb = e.find('.ignorepb').length;
164
  e.replaceWith(html);
165
  e = $('.'+this.name);
 
166
  if(i) e.find('select').addClass('ignore');
167
  if(ipb) e.find('select').addClass('ignorepb');
168
  this.setVal(bk);
136
  }
137
  return (typeof v == 'object' && typeof v['length'] !== 'undefined') ? v : ((v) ? (($.isNumeric(v)) ? v : '"'+v+'"') : 0);
138
  },
139
+ setVal:function( v, nochange )
140
  {
141
  if( !$.isArray( v ) ) v = [v];
142
  var t, n = this.name;
146
  $( '[id="'+n+'"] OPTION[vt="'+t+'"],[id="'+n+'"] OPTION[value="'+t+'"]' ).prop( 'selected', true );
147
 
148
  }
149
+
150
+ if(!nochange) $( '[id="'+n+'"]' ).change();
151
  },
152
  setChoices:function(choices)
153
  {
160
  if('optgroup' in choices && $.isArray(choices.optgroup)) this.optgroup = choices.optgroup;
161
  var html = this.show(),
162
  e = $('.'+this.name),
163
+ c = e.attr('class'),
164
  i = e.find('.ignore').length,
165
  ipb = e.find('.ignorepb').length;
166
  e.replaceWith(html);
167
  e = $('.'+this.name);
168
+ e.attr('class', c);
169
  if(i) e.find('select').addClass('ignore');
170
  if(ipb) e.find('select').addClass('ignorepb');
171
  this.setVal(bk);
js/modules/01_mathematical_logical/public/module_public.js CHANGED
@@ -6,6 +6,16 @@ fbuilderjQuery[ 'fbuilder' ][ 'modules' ][ 'default' ] = {
6
  'prefix' : '',
7
  'callback' : function()
8
  {
 
 
 
 
 
 
 
 
 
 
9
  if(Number.prototype.LENGTH == undefined)
10
  {
11
  // Only LENGTH in uppercase to prevent a conflict with Lottie
@@ -65,8 +75,8 @@ fbuilderjQuery[ 'fbuilder' ][ 'modules' ][ 'default' ] = {
65
  if('undefined' == typeof pr) pr = 0;
66
  if(/^\d+$/.test(pr) && $.isNumeric(num))
67
  {
68
- var f = POW(10,pr);
69
- num = ROUND(num*f)/f;
70
  return num.toFixed(pr);
71
  }
72
  return num;
@@ -180,16 +190,6 @@ fbuilderjQuery[ 'fbuilder' ][ 'modules' ][ 'default' ] = {
180
  };
181
  } // End if window.LOGAB
182
 
183
- var math_prop = ["LN10", "PI", "E", "LOG10E", "SQRT2", "LOG2E", "SQRT1_2", "LN2", "cos", "pow", "log", "tan", "sqrt", "asin", "abs", "exp", "atan2", "atanh", "random", "acos", "atan", "sin"];
184
-
185
- for(var i = 0, h = math_prop.length; i < h; i++)
186
- {
187
- if( !window[ math_prop[ i ] ] )
188
- {
189
- window[ math_prop[ i ] ] = window[ math_prop[ i ].toUpperCase() ] = Math[ math_prop[ i ] ];
190
- }
191
- }
192
-
193
  if(window.MIN == undefined)
194
  {
195
  window.MIN = window.min = function ()
6
  'prefix' : '',
7
  'callback' : function()
8
  {
9
+ var math_prop = ["LN10", "PI", "E", "LOG10E", "SQRT2", "LOG2E", "SQRT1_2", "LN2", "cos", "pow", "log", "tan", "sqrt", "asin", "abs", "exp", "atan2", "atanh", "random", "acos", "atan", "sin"];
10
+
11
+ for(var i = 0, h = math_prop.length; i < h; i++)
12
+ {
13
+ if( !window[ math_prop[ i ] ] )
14
+ {
15
+ window[ math_prop[ i ] ] = window[ math_prop[ i ].toUpperCase() ] = Math[ math_prop[ i ] ];
16
+ }
17
+ }
18
+
19
  if(Number.prototype.LENGTH == undefined)
20
  {
21
  // Only LENGTH in uppercase to prevent a conflict with Lottie
75
  if('undefined' == typeof pr) pr = 0;
76
  if(/^\d+$/.test(pr) && $.isNumeric(num))
77
  {
78
+ var f = Math.pow(10,pr);
79
+ num = Math.round(num*f)/f;
80
  return num.toFixed(pr);
81
  }
82
  return num;
190
  };
191
  } // End if window.LOGAB
192
 
 
 
 
 
 
 
 
 
 
 
193
  if(window.MIN == undefined)
194
  {
195
  window.MIN = window.min = function ()
js/modules/05_managing_fields/admin/module_admin.js CHANGED
@@ -32,6 +32,16 @@ fbuilderjQuery[ 'fbuilder' ][ 'modules' ][ 'processing' ] = {
32
  "value" : "ENABLEEQUATIONS",
33
  "code" : "ENABLEEQUATIONS(",
34
  "tip" : "<p>Allows to enable dynamic evaluation of equations. Accepts an optional parameter: form object, jQuery object or selector. If the parameter is omitted, enables evaluation of equations on all forms on the page. Ex: ENABLEEQUATIONS();</p>"
 
 
 
 
 
 
 
 
 
 
35
  }
36
  ]
37
  }
32
  "value" : "ENABLEEQUATIONS",
33
  "code" : "ENABLEEQUATIONS(",
34
  "tip" : "<p>Allows to enable dynamic evaluation of equations. Accepts an optional parameter: form object, jQuery object or selector. If the parameter is omitted, enables evaluation of equations on all forms on the page. Ex: ENABLEEQUATIONS();</p>"
35
+ },
36
+ {
37
+ "value" : "EVALEQUATIONS",
38
+ "code" : "EVALEQUATIONS(",
39
+ "tip" : "<p>Evaluates the form equations. Requires as parameter the form object. Ex: EVALEQUATIONS(form);</p>"
40
+ },
41
+ {
42
+ "value" : "EVALEQUATION",
43
+ "code" : "EVALEQUATION(",
44
+ "tip" : "<p>Evaluate specific equation. Requires two parameters, the form object and the field name, or the numeric part of the field name. Ex: EVALEQUATION(form, &quot;fieldname1&quot;); or EVALEQUATION(form, 1);</p>"
45
  }
46
  ]
47
  }
js/modules/05_managing_fields/public/05_managing_fields.js CHANGED
@@ -69,6 +69,34 @@
69
  jQuery(f || '[id*="cp_calculatedfieldsf_pform_"]').attr('data-evalequations',1);
70
  };
71
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
72
  root.CF_FIELDS_MANAGEMENT = lib;
73
 
74
  })(this);
69
  jQuery(f || '[id*="cp_calculatedfieldsf_pform_"]').attr('data-evalequations',1);
70
  };
71
 
72
+ lib.EVALEQUATIONS = lib.evalequations = function(f)
73
+ {
74
+ fbuilderjQuery.fbuilder.calculator.defaultCalc(f);
75
+ };
76
+
77
+ lib.EVALEQUATION = lib.evalequation = function(f,e)
78
+ {
79
+ var c = fbuilderjQuery.fbuilder.calculator, eq, fi, i;
80
+ if(typeof e == 'undefined') c.defaultCalc(f);
81
+ else
82
+ {
83
+ if(Number.isInteger(e)) e = 'fieldname'+e;
84
+ if('equations' in f)
85
+ {
86
+ for(i in f.equations)
87
+ {
88
+ eq = f.equations[i];
89
+ fi = eq.identifier;
90
+ if(eq.result == e+fi){
91
+ c.enqueueEquation(fi, [eq]);
92
+ c.processQueue(fi);
93
+ return;
94
+ }
95
+ }
96
+ }
97
+ }
98
+ };
99
+
100
  root.CF_FIELDS_MANAGEMENT = lib;
101
 
102
  })(this);