Calculated Fields Form - Version 1.1.108

Version Description

  • Implements the create form from the templates library module.
Download this release

Release Info

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

Code changes from version 1.1.107 to 1.1.108

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.0
7
- Stable tag: 1.1.107
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -965,6 +965,10 @@ A: Please, follow the steps below:
965
 
966
  == Changelog ==
967
 
 
 
 
 
968
  = 1.1.107 =
969
 
970
  * Allows the associate audio tutorials to the form fields.
@@ -1011,10 +1015,4 @@ A: Please, follow the steps below:
1011
 
1012
  = 1.1.99 =
1013
 
1014
- * Fixes an issue with the Select2 integration to display the choices texts instead of their values.
1015
-
1016
- = 1.1.98 =
1017
-
1018
- * Improves the feedback module that alerts to errors in the database.
1019
- * Improves the CSV data source (Developer and Platinum versions).
1020
- * Implements support for Google Analytics 4 (Platinum version).
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.0
7
+ Stable tag: 1.1.108
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.108 =
969
+
970
+ * Implements the create form from the templates library module.
971
+
972
  = 1.1.107 =
973
 
974
  * Allows the associate audio tutorials to the form fields.
1015
 
1016
  = 1.1.99 =
1017
 
1018
+ * Fixes an issue with the Select2 integration to display the choices texts instead of their values.
 
 
 
 
 
 
changelog.txt CHANGED
@@ -1,5 +1,9 @@
1
  == Changelog ==
2
 
 
 
 
 
3
  = 1.1.107 =
4
 
5
  * Allows the associate audio tutorials to the form fields.
1
  == Changelog ==
2
 
3
+ = 1.1.108 =
4
+
5
+ * Implements the create form from the templates library module.
6
+
7
  = 1.1.107 =
8
 
9
  * Allows the associate audio tutorials to the form fields.
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.107
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.1.107' );
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.1.108
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.1.108' );
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 ) );
css/style.css CHANGED
@@ -269,6 +269,15 @@ textarea {resize: none}
269
  .cff-metabox.cff-metabox-closed{background-color:#F6F6F6;}
270
  .cff-metabox.cff-metabox-closed .inside{display:none;}
271
 
 
 
 
 
 
 
 
 
 
272
  /* TABS */
273
  .form-builder #tabs{height:650px;width:100%;overflow:hidden;position:relative;}
274
  .form-builder #tabs-1,
269
  .cff-metabox.cff-metabox-closed{background-color:#F6F6F6;}
270
  .cff-metabox.cff-metabox-closed .inside{display:none;}
271
 
272
+ #metabox_new_form_area form>div{display:flex;flex-direction:column;}
273
+ @media screen AND (min-width:710px) {
274
+ #metabox_new_form_area form>div{flex-direction:row;}
275
+ #metabox_new_form_area form>div>input:nth-of-type(1){flex:3 0 auto;}
276
+ #metabox_new_form_area form>div>input:nth-of-type(2){flex:2 0 auto;margin-left:5px;}
277
+ #metabox_new_form_area form>div>input:nth-of-type(3),
278
+ #metabox_new_form_area form>div>input:nth-of-type(4){flex:1 0 auto;margin-left:5px;}
279
+ }
280
+
281
  /* TABS */
282
  .form-builder #tabs{height:650px;width:100%;overflow:hidden;position:relative;}
283
  .form-builder #tabs-1,
css/stylelibrary.css ADDED
@@ -0,0 +1,121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .cff-form-library-cover{
2
+ z-index:99999;
3
+ position:fixed;
4
+ left:0;
5
+ top:0;
6
+ right:0;
7
+ bottom:0;
8
+ background:rgba(0,0,0,.7)
9
+ }
10
+
11
+ .cff-form-library-container{
12
+ background:white;
13
+ width:700px;
14
+ height:700px;
15
+ max-width:90%;
16
+ max-height:90%;
17
+ position:absolute;
18
+ left:50%;
19
+ top:50%;
20
+ transform: translate( -50%, -50% );
21
+ display: flex;
22
+ }
23
+
24
+ .cff-form-library-column-left{
25
+ /* flex:1 0 auto; */
26
+ border-right:1px solid #dddddd;
27
+ position: relative;
28
+ }
29
+
30
+ .cff-form-library-search-box{
31
+ border-bottom: 1px solid #ddd;
32
+ padding:10px;
33
+ height:50px;
34
+ box-sizing:border-box;
35
+ }
36
+
37
+ .cff-form-library-search-box input{
38
+ width:100%;
39
+ margin-bottom:5px;
40
+ height:30px;
41
+ }
42
+
43
+ .cff-form-library-categories{
44
+ padding:10px;
45
+ position:absolute;
46
+ top:50px;
47
+ bottom:0;
48
+ right:0;
49
+ left:0;
50
+ overflow:auto;
51
+ }
52
+
53
+ .cff-form-library-categories ul>li:not(:first-child){margin-left:20px}
54
+
55
+ .cff-form-library-categories a{text-decoration:none;}
56
+ .cff-form-library-categories a:hover,
57
+ .cff-form-library-categories a:active,
58
+ .cff-form-library-active-category{color:#c52359 !important;}
59
+
60
+ .cff-form-library-column-right{
61
+ flex:3 0 auto;
62
+ position:relative;
63
+ }
64
+
65
+ .cff-form-library-close{
66
+ float:right;
67
+ padding:5px;
68
+ width:18px;
69
+ height:18px;
70
+ top:0;
71
+ z-index:999;
72
+ }
73
+
74
+ .cff-form-library-close::before{
75
+ content: "✖";
76
+ cursor:pointer;
77
+ font-size:18px;
78
+ line-height:18px;
79
+ }
80
+
81
+ .cff-form-library-close:hover::before{color:#c52359;}
82
+
83
+ .cff-form-library-main{
84
+ top:30px;
85
+ position:absolute;
86
+ padding:10px;
87
+ left:0;
88
+ right:0;
89
+ bottom:0;
90
+ overflow:auto;
91
+ display:flex;
92
+ flex-wrap:wrap;
93
+ align-items:flex-start;
94
+ }
95
+
96
+ .cff-form-library-no-form{text-align:center;}
97
+
98
+ .cff-form-library-form{width:46%;margin:1%;float:left;box-sizing:border-box;border:1px solid #ddd;}
99
+
100
+ .cff-form-library-form-title{font-size:1.2em;font-weight:bold;padding:10px;}
101
+
102
+ .cff-form-library-form-description{padding:0 10px 10px 10px;}
103
+
104
+ .cff-form-library-form-category{border-top:1px solid #ddd;padding:10px;font-style:italic;}
105
+
106
+ .cff-form-library-form [type="button"]{margin:0 10px 10px 10px;}
107
+
108
+
109
+ /* Desktop */
110
+ @media screen and (min-width:710px) {
111
+
112
+ }
113
+
114
+ /* Mobiles devices */
115
+ @media screen and (max-width:710px) {
116
+ .cff-form-library-container{flex-direction:column;}
117
+ .cff-form-library-column-left,
118
+ .cff-form-library-search-box{border:0;}
119
+ .cff-form-library-categories{display:none;}
120
+ .cff-form-library-form{width:98%;}
121
+ }
inc/cpcff_admin_int_list.inc.php CHANGED
@@ -58,7 +58,8 @@ if (isset($_GET['a']) && $_GET['a'] == '1')
58
  check_admin_referer( 'cff-add-form', '_cpcff_nonce' );
59
  $new_form = $cpcff_main->create_form(
60
  isset($_GET["name"]) ? sanitize_text_field(stripcslashes($_GET["name"])) : '',
61
- isset($_GET["category"]) ? sanitize_text_field(stripcslashes($_GET["category"])) : ''
 
62
  );
63
  // Update the default category
64
  $cff_current_form_category = get_option('calculated-fields-form-category', '');
@@ -322,16 +323,17 @@ endif;
322
  <div class="inside">
323
  <form name="additem">
324
  <?php _e( 'Item Name', 'calculated-fields-form' ); ?>:<br />
325
- <input type="text" name="cp_itemname" id="cp_itemname" value="" onkeyup="cp_addItem_keyup( event );" class="width50" style="margin-top:5px;" />&nbsp;
326
- <input type="text" name="calculated-fields-form-category" id="calculated-fields-form-category" value="<?php print esc_attr($cff_current_form_category); ?>" class="width30" style="margin-top:5px;" placeholder="<?php esc_attr_e('Category', 'calculated-fields-form'); ?>" list="calculated-fields-form-categories" />
327
- <datalist id="calculated-fields-form-categories">
328
- <?php
329
- print $cpcff_main->get_categories('DATALIST');
330
- ?>
331
- </datalist>
332
- &nbsp;
333
- <input type="button" onclick="cp_addItem();" name="gobtn" value="<?php esc_attr_e( 'Create Form', 'calculated-fields-form' ); ?>" class="button-secondary" style="margin-top:5px;" />
334
- <br /><br />
 
335
  </form>
336
  </div>
337
  </div>
@@ -436,4 +438,5 @@ endif;
436
  [<a href="https://cff.dwbooster.com/customization" target="_blank"><?php _e( 'Request Custom Modifications', 'calculated-fields-form' ); ?></a>] | [<a href="https://cff.dwbooster.com/download" target="_blank"><?php _e( 'Upgrade', 'calculated-fields-form' ); ?></a>] | [<a href="https://wordpress.org/support/plugin/calculated-fields-form#new-post" target="_blank"><?php _e( 'Help', 'calculated-fields-form' ); ?></a>]
437
  </div>
438
  <script>cff_current_version='free';</script>
439
- <script src="https://cff-bundles.dwbooster.com/plugins/plugins.js?v=<?php print CP_CALCULATEDFIELDSF_VERSION.'_'.date('Y-m-d'); ?>"></script>
 
58
  check_admin_referer( 'cff-add-form', '_cpcff_nonce' );
59
  $new_form = $cpcff_main->create_form(
60
  isset($_GET["name"]) ? sanitize_text_field(stripcslashes($_GET["name"])) : '',
61
+ isset($_GET["category"]) ? sanitize_text_field(stripcslashes($_GET["category"])) : '',
62
+ isset($_GET['ftpl']) ? sanitize_text_field(wp_unslash($_GET['ftpl'])) : 0
63
  );
64
  // Update the default category
65
  $cff_current_form_category = get_option('calculated-fields-form-category', '');
323
  <div class="inside">
324
  <form name="additem">
325
  <?php _e( 'Item Name', 'calculated-fields-form' ); ?>:<br />
326
+ <div>
327
+ <input type="text" name="cp_itemname" id="cp_itemname" value="" onkeyup="cp_addItem_keyup( event );" style="margin-top:5px;" />
328
+ <input type="text" name="calculated-fields-form-category" id="calculated-fields-form-category" value="<?php print esc_attr($cff_current_form_category); ?>" style="margin-top:5px;" placeholder="<?php esc_attr_e('Category', 'calculated-fields-form'); ?>" list="calculated-fields-form-categories" />
329
+ <datalist id="calculated-fields-form-categories">
330
+ <?php
331
+ print $cpcff_main->get_categories('DATALIST');
332
+ ?>
333
+ </datalist>
334
+ <input type="button" onclick="cp_addItem();" name="gobtn" value="<?php esc_attr_e( 'Create Form', 'calculated-fields-form' ); ?>" class="button-secondary" style="margin-top:5px;" />
335
+ <input type="button" onclick="cff_openLibraryDialog();" name="gobtn" value="<?php esc_attr_e( 'From Template', 'calculated-fields-form' ); ?>" class="button-secondary" style="margin-top:5px;" />
336
+ </div>
337
  </form>
338
  </div>
339
  </div>
438
  [<a href="https://cff.dwbooster.com/customization" target="_blank"><?php _e( 'Request Custom Modifications', 'calculated-fields-form' ); ?></a>] | [<a href="https://cff.dwbooster.com/download" target="_blank"><?php _e( 'Upgrade', 'calculated-fields-form' ); ?></a>] | [<a href="https://wordpress.org/support/plugin/calculated-fields-form#new-post" target="_blank"><?php _e( 'Help', 'calculated-fields-form' ); ?></a>]
439
  </div>
440
  <script>cff_current_version='free';</script>
441
+ <script src="https://cff-bundles.dwbooster.com/plugins/plugins.js?v=<?php print CP_CALCULATEDFIELDSF_VERSION.'_'.date('Y-m-d'); ?>"></script>
442
+ <script src="<?php print esc_attr( plugins_url('/vendors/forms.js', CP_CALCULATEDFIELDSF_MAIN_FILE_PATH).'?v='.CP_CALCULATEDFIELDSF_VERSION.'_'.date('Y-m-d') ); ?>"></script>
inc/cpcff_form.inc.php CHANGED
@@ -67,10 +67,28 @@ if(!class_exists('CPCFF_FORM'))
67
  *
68
  * @return object.
69
  */
70
- static public function create_default( $form_name, $category_name = '' )
71
  {
72
  global $wpdb, $cpcff_default_texts_array;
73
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
74
  if(
75
  $wpdb->insert(
76
  $wpdb->prefix.CP_CALCULATEDFIELDSF_FORMS_TABLE,
@@ -79,7 +97,7 @@ if(!class_exists('CPCFF_FORM'))
79
  'form_name' => stripcslashes($form_name),
80
 
81
  // Form structure
82
- 'form_structure' => CP_CALCULATEDFIELDSF_DEFAULT_form_structure,
83
 
84
  // Notification email
85
  'fp_from_email' => CP_CALCULATEDFIELDSF_DEFAULT_fp_from_email,
67
  *
68
  * @return object.
69
  */
70
+ static public function create_default( $form_name, $category_name = '', $form_template = 0 )
71
  {
72
  global $wpdb, $cpcff_default_texts_array;
73
 
74
+ $_form_structure = CP_CALCULATEDFIELDSF_DEFAULT_form_structure;
75
+ // Get form structure from server !!!
76
+ if ( ! empty( $form_template ) ) {
77
+ $response = wp_remote_get(
78
+ 'https://cff.dwbooster.com/forms/forms/'.$form_template.'.cpfm',
79
+ array(
80
+ 'sslverify' => false
81
+ )
82
+ );
83
+
84
+ if ( ! is_wp_error( $response ) ) {
85
+ $_form_structure_tmp = wp_remote_retrieve_body( $response );
86
+ if ( !empty( $_form_structure_tmp ) ) {
87
+ $_form_structure = $_form_structure_tmp;
88
+ }
89
+ }
90
+ }
91
+
92
  if(
93
  $wpdb->insert(
94
  $wpdb->prefix.CP_CALCULATEDFIELDSF_FORMS_TABLE,
97
  'form_name' => stripcslashes($form_name),
98
 
99
  // Form structure
100
+ 'form_structure' => $_form_structure,
101
 
102
  // Notification email
103
  'fp_from_email' => CP_CALCULATEDFIELDSF_DEFAULT_fp_from_email,
inc/cpcff_main.inc.php CHANGED
@@ -333,10 +333,19 @@ if(!class_exists('CPCFF_MAIN'))
333
 
334
  //ULR to the admin resources
335
  $admin_resources = admin_url( "admin.php?page=cp_calculated_fields_form&cp_cff_resources=admin" );
336
- wp_enqueue_script( 'cp_calculatedfieldsf_builder_script', $admin_resources, array("jquery","jquery-ui-core","jquery-ui-sortable","jquery-ui-tabs","jquery-ui-droppable","jquery-ui-button", "jquery-ui-accordion","jquery-ui-datepicker","query-stringify") );
337
- wp_enqueue_script( 'cp_calculatedfieldsf_builder_script_caret', plugins_url('/vendors/jquery.caret.js', CP_CALCULATEDFIELDSF_MAIN_FILE_PATH),array("jquery"));
 
 
 
 
 
 
 
 
338
  wp_enqueue_style('cp_calculatedfieldsf_builder_style', plugins_url('/css/style.css', CP_CALCULATEDFIELDSF_MAIN_FILE_PATH), array(), CP_CALCULATEDFIELDSF_VERSION);
339
- wp_enqueue_style('jquery-style', '//ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/themes/smoothness/jquery-ui.css');
 
340
  }
341
  // Checks if it is to an external page
342
  elseif(
@@ -669,9 +678,9 @@ if(!class_exists('CPCFF_MAIN'))
669
  * @param string $form_name, the name of form.
670
  * @return mixed, an instance of the created form or false.
671
  */
672
- public function create_form($form_name, $category_name = '')
673
  {
674
- $form = CPCFF_FORM::create_default($form_name, $category_name);
675
  if($form) $this->_forms[$form->get_id()] = $form;
676
  return $form;
677
  } // End create_form
333
 
334
  //ULR to the admin resources
335
  $admin_resources = admin_url( "admin.php?page=cp_calculated_fields_form&cp_cff_resources=admin" );
336
+ wp_enqueue_script( 'cp_calculatedfieldsf_builder_script', $admin_resources, array("jquery","jquery-ui-core","jquery-ui-sortable","jquery-ui-tabs","jquery-ui-droppable","jquery-ui-button", "jquery-ui-accordion","jquery-ui-datepicker","query-stringify"), CP_CALCULATEDFIELDSF_VERSION );
337
+
338
+ wp_enqueue_script( 'cp_calculatedfieldsf_builder_library_script', plugins_url('/js/library.js', CP_CALCULATEDFIELDSF_MAIN_FILE_PATH), array("cp_calculatedfieldsf_builder_script"), CP_CALCULATEDFIELDSF_VERSION );
339
+
340
+ wp_localize_script('cp_calculatedfieldsf_builder_library_script', 'cpcff_forms_library_config', array(
341
+ 'version' => 'free',
342
+ 'website_url' => 'admin.php?page=cp_calculated_fields_form&a=1&_cpcff_nonce=' . wp_create_nonce( 'cff-add-form' )
343
+ ));
344
+
345
+ wp_enqueue_script( 'cp_calculatedfieldsf_builder_script_caret', plugins_url('/vendors/jquery.caret.js', CP_CALCULATEDFIELDSF_MAIN_FILE_PATH),array("jquery"), CP_CALCULATEDFIELDSF_VERSION );
346
  wp_enqueue_style('cp_calculatedfieldsf_builder_style', plugins_url('/css/style.css', CP_CALCULATEDFIELDSF_MAIN_FILE_PATH), array(), CP_CALCULATEDFIELDSF_VERSION);
347
+ wp_enqueue_style('cp_calculatedfieldsf_builder_library_style', plugins_url('/css/stylelibrary.css', CP_CALCULATEDFIELDSF_MAIN_FILE_PATH), array('cp_calculatedfieldsf_builder_style'), CP_CALCULATEDFIELDSF_VERSION);
348
+ wp_enqueue_style('jquery-style', '//ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/themes/smoothness/jquery-ui.css', array(), CP_CALCULATEDFIELDSF_VERSION);
349
  }
350
  // Checks if it is to an external page
351
  elseif(
678
  * @param string $form_name, the name of form.
679
  * @return mixed, an instance of the created form or false.
680
  */
681
+ public function create_form($form_name, $category_name = '', $form_template = 0)
682
  {
683
+ $form = CPCFF_FORM::create_default($form_name, $category_name, $form_template);
684
  if($form) $this->_forms[$form->get_id()] = $form;
685
  return $form;
686
  } // End create_form
js/fbuilder-pro-public.jquery.js CHANGED
@@ -1,4 +1,4 @@
1
- $.fbuilder['version'] = '1.1.107';
2
  $.fbuilder['controls'] = $.fbuilder['controls'] || {};
3
  $.fbuilder['forms'] = $.fbuilder['forms'] || {};
4
 
1
+ $.fbuilder['version'] = '1.1.108';
2
  $.fbuilder['controls'] = $.fbuilder['controls'] || {};
3
  $.fbuilder['forms'] = $.fbuilder['forms'] || {};
4
 
js/library.js ADDED
@@ -0,0 +1,179 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ jQuery(function () {
2
+ var $ = jQuery,
3
+
4
+ categories = {},
5
+
6
+ /* Templates */
7
+ dialog_tpl = `
8
+ <div class="cff-form-library-cover">
9
+ <div class="cff-form-library-container">
10
+ <div class="cff-form-library-column-left">
11
+ <div class="cff-form-library-search-box">
12
+ <input type="search" placeholder="Search..." onkeyup="cff_filteringFormsByText(this)">
13
+ </div>
14
+ <div class="cff-form-library-categories">
15
+ <ul>
16
+ <li><a href="javascript:void(0);" onclick="cff_templatesInCategory(this);" class="cff-form-library-active-category">All Categories</a></li>
17
+ </ul>
18
+ </div>
19
+ </div>
20
+ <div class="cff-form-library-column-right">
21
+ <div class="cff-form-library-close" onclick="cff_closeLibraryDialog();"></div>
22
+ <div class="cff-form-library-main">
23
+ <div class="cff-form-library-no-form">No form meets the search criteria</div>
24
+ </div>
25
+ </div>
26
+ </div>
27
+ </div>
28
+ `,
29
+
30
+ form_tpl = `
31
+ <div class="cff-form-library-form">
32
+ <div class="cff-form-library-form-title"></div>
33
+ <div class="cff-form-library-form-description"></div>
34
+ <div class="cff-form-library-form-category"></div>
35
+ <div>
36
+ <input type="button" class="button-secondary" value="Use It" />
37
+ </div>
38
+ </div>
39
+ `;
40
+
41
+ $.expr[":"].contains = $.expr.createPseudo(function (arg) {
42
+ return function (elem) {
43
+ return $(elem).text().toUpperCase().indexOf(arg.toUpperCase()) >= 0;
44
+ };
45
+ });
46
+
47
+ function openDialog() {
48
+ var version = 'free',
49
+ data = [];
50
+ if (!$('.cff-form-library-container').length) {
51
+ $('body').append(dialog_tpl);
52
+
53
+ if (typeof cpcff_forms_library_config != 'undefined' && 'version' in cpcff_forms_library_config) {
54
+ version = cpcff_forms_library_config['version'];
55
+ }
56
+
57
+ if (typeof cff_forms_templates != 'undefined') {
58
+ switch (version) {
59
+ case 'free':
60
+ data = data.concat(cff_forms_templates['free']);
61
+ break;
62
+ case 'pro':
63
+ data = data.concat(cff_forms_templates['free'], cff_forms_templates['pro']);
64
+ break;
65
+ case 'dev':
66
+ data = data.concat(cff_forms_templates['free'], cff_forms_templates['pro'], cff_forms_templates['dev']);
67
+ break;
68
+ case 'plat':
69
+ data = data.concat(cff_forms_templates['free'], cff_forms_templates['pro'], cff_forms_templates['dev'], cff_forms_templates['plat']);
70
+ break;
71
+ }
72
+
73
+ if (data.length) {
74
+ for (var i in data) {
75
+
76
+ categories[data[i]['category']] = '<li><a href="javascript:void(0);" onclick="cff_templatesInCategory(this,\'' + data[i]['category'] + '\')">' + data[i]['category'] + '</a></li>';
77
+
78
+ tmp = $(form_tpl);
79
+ tmp.attr('data-category', data[i]['category']);
80
+ tmp.find('.cff-form-library-form-title').text(data[i]['title']);
81
+ tmp.find('.cff-form-library-form-description').text(data[i]['description']);
82
+ tmp.find('.cff-form-library-form-category').text(data[i]['category']);
83
+ tmp.find('[type="button"]').on(
84
+ 'click',
85
+ (function (id) {
86
+ return function () {
87
+ cff_getTemplate(id);
88
+ };
89
+ })(data[i]['id']));
90
+ tmp.appendTo('.cff-form-library-main');
91
+ }
92
+
93
+ for (var i in categories) {
94
+ $(categories[i]).appendTo('.cff-form-library-categories ul');
95
+ }
96
+ }
97
+ }
98
+ };
99
+
100
+ // Initialize
101
+ showNoFormMessage();
102
+ $('.cff-form-library-search-box input').val('');
103
+ $('.cff-form-library-categories ul>li:first-child a').click();
104
+ $('.cff-form-library-cover').show();
105
+ };
106
+
107
+ function closeDialog() {
108
+ $('.cff-form-library-cover').hide();
109
+ };
110
+
111
+ function showNoFormMessage() {
112
+ $('.cff-form-library-no-form').show();
113
+ };
114
+
115
+ function hideNoFormMessage() {
116
+ $('.cff-form-library-no-form').hide();
117
+ };
118
+
119
+ function displayTemplates(me, category) {
120
+ hideNoFormMessage();
121
+ $('.cff-form-library-search-box input').val('');
122
+ $('.cff-form-library-active-category').removeClass('cff-form-library-active-category');
123
+ $(me).addClass('cff-form-library-active-category');
124
+
125
+ if (typeof category == 'undefined') {
126
+ $('.cff-form-library-form').show();
127
+ } else {
128
+ $('.cff-form-library-form').hide();
129
+ $('.cff-form-library-form[data-category="' + category + '"]').show();
130
+ }
131
+ };
132
+
133
+ function formsByText(me) {
134
+
135
+ var v = $.trim(me.value);
136
+
137
+ $('.cff-form-library-active-category').removeClass('cff-form-library-active-category');
138
+
139
+ $('.cff-form-library-form').hide();
140
+
141
+ $('.cff-form-library-form:contains("' + v + '")').each(function () {
142
+ $(this).show();
143
+ });
144
+
145
+ if ($('.cff-form-library-form:visible').length) {
146
+ hideNoFormMessage();
147
+ } else {
148
+ showNoFormMessage();
149
+ }
150
+ };
151
+
152
+ function getTemplate(id) {
153
+ var form_name = encodeURIComponent($('[id="cp_itemname"]').val() || ''),
154
+ category_name = encodeURIComponent($('[id="calculated-fields-form-category"]').val() || ''),
155
+ url;
156
+
157
+ if (typeof cpcff_forms_library_config != 'undefined' && 'website_url' in cpcff_forms_library_config) {
158
+ url = cpcff_forms_library_config['website_url'] + '&name=' + form_name + '&category=' + category_name;
159
+ if (id) {
160
+ url += '&ftpl=' + encodeURIComponent(id);
161
+ }
162
+ document.location.href = url;
163
+ closeDialog();
164
+ return;
165
+ }
166
+
167
+ if ('cp_addItem' in window)
168
+ cp_addItem();
169
+ };
170
+
171
+ $(document).on('keyup', function(evt){ if ( evt.keyCode == 27 ) { cff_closeLibraryDialog(); } });
172
+
173
+ // Export
174
+ window['cff_openLibraryDialog'] = openDialog;
175
+ window['cff_closeLibraryDialog'] = closeDialog;
176
+ window['cff_getTemplate'] = getTemplate;
177
+ window['cff_templatesInCategory'] = displayTemplates;
178
+ window['cff_filteringFormsByText'] = formsByText;
179
+ });
vendors/forms.js ADDED
@@ -0,0 +1,110 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ cff_forms_templates = {
2
+ "free": [{
3
+ "title": "Simple Operations",
4
+ "category": "Basic Operations",
5
+ "description": "Sum of numbers fields and the sum of ticked choices in a multi-choices field.",
6
+ "id": 1
7
+ }, {
8
+ "title": "Contact Form",
9
+ "category": "Basic Operations",
10
+ "description": "Basic contact form.",
11
+ "id": 19
12
+ }, {
13
+ "title": "Form With Optional Fields",
14
+ "category": "Basic Operations",
15
+ "description": "An order form that allows you to add new products or delete existing ones.",
16
+ "id": 20
17
+ }, {
18
+ "title": "Simple Accommodation Booking",
19
+ "category": "Dates Operations",
20
+ "description": "Gives a quote for a stay in a hotel based in the check-in date, check-out date and some optional services.",
21
+ "id": 2
22
+ }, {
23
+ "title": "Working Days",
24
+ "category": "Dates Operations",
25
+ "description": "Calculates the working days between two dates, excluding specific days of the week.",
26
+ "id": 8
27
+ }, {
28
+ "title": "Increasing Dates",
29
+ "category": "Dates Operations",
30
+ "description": "Adds X days to a date by excluding specific days of the week.",
31
+ "id": 17
32
+ }, {
33
+ "title": "Ideal Weight Calculator",
34
+ "category": "Health",
35
+ "description": "Uses a simple formula but with a conditional rule (if male or female).",
36
+ "id": 3
37
+ }, {
38
+ "title": "Pregnancy Calculator",
39
+ "category": "Health",
40
+ "description": "Calculates the conception date and due date based in the first day of last menstrual period.",
41
+ "id": 4
42
+ }, {
43
+ "title": "BMI",
44
+ "category": "Health",
45
+ "description": "Body Mass Index is a calculation that is used to determine if a person is overweight that applies to both adult men and women.",
46
+ "id": 6
47
+ }, {
48
+ "title": "Calories Calculator",
49
+ "category": "Health",
50
+ "description": "Calculate the number of calories a person needs to consume each day to maintain his or her weight.",
51
+ "id": 7
52
+ }, {
53
+ "title": "Lease Calculator",
54
+ "category": "Financial",
55
+ "description": "Lease calculator based on loan amount, residual value, interest rate, and time interval.",
56
+ "id": 5
57
+ }, {
58
+ "title": "Simple Interest Calculator",
59
+ "category": "Financial",
60
+ "description": "Calculate the earning or interest payment only from what was borrowed, the original amount invested or the face value of a bond.",
61
+ "id": 10
62
+ }, {
63
+ "title": "Compound Interest Calculator (For savings and loans)",
64
+ "category": "Financial",
65
+ "description": "Compound Interest refers to earning or paying interest on interest.",
66
+ "id": 11
67
+ }, {
68
+ "title": "Exchange Rate Form",
69
+ "category": "Financial",
70
+ "description": "Uses the cffProxy operation to call an exchange rate API.",
71
+ "id": 13
72
+ }, {
73
+ "title": "European VAT",
74
+ "category": "Financial",
75
+ "description": "Get the European countries VAT.",
76
+ "id": 14
77
+ }
78
+ ],
79
+ "pro": [
80
+ ],
81
+ "dev": [{
82
+ "title": "Mortgage Calculator",
83
+ "category": "Financial",
84
+ "description": "The mortgage calculator uses the financial operations module to calculate the monthly payment and generate the amortization schedule.",
85
+ "id": 9
86
+ }, {
87
+ "title": "Compound Interest Calculator (With line chart)",
88
+ "category": "Financial",
89
+ "description": "Calculates the compound interest and draws a line chart with the evolution.",
90
+ "id": 12
91
+ }, {
92
+ "title": "Cab Service (DISTANCE operation)",
93
+ "category": "Distance",
94
+ "description": "Determines the distance in miles between two addresses and multiplies it by the cost per mile.",
95
+ "id": 15
96
+ }, {
97
+ "title": "Filtering Posts",
98
+ "category": "Data Sources",
99
+ "description": "Use DS fields for filtering website posts and pages.",
100
+ "id": 16
101
+ }, {
102
+ "title": "Registered User Information",
103
+ "category": "Data Sources",
104
+ "description": "Gets the registered user information from the database using DS fields.",
105
+ "id": 18
106
+ }
107
+ ],
108
+ "plat": [
109
+ ]
110
+ };