Version Description
- Modifies the code of the plugin for allowing the compatibility with outdated versions of PHP.
Download this release
Release Info
Developer | codepeople |
Plugin | Calculated Fields Form |
Version | 1.0.336 |
Comparing to | |
See all releases |
Code changes from version 1.0.318 to 1.0.336
- README.txt +33 -37
- changelog.txt +78 -0
- config/cpcff_config.cfg.php +2 -3
- cp_calculatedfieldsf_free.php +2 -2
- inc/cpcff_admin_int.inc.php +1 -0
- inc/cpcff_main.inc.php +3 -2
- inc/cpcff_page_builders.inc.php +14 -1
- inc/cpcff_public_int.inc.php +1 -1
- inc/cpcff_session.inc.php +16 -0
- js/fbuilder-loader-public.php +1 -18
- js/fbuilder-pro-admin.jquery.js +18 -0
- js/fbuilder-pro-public.jquery.js +47 -29
- js/fields-admin/01_fbuilder.ftext.js +4 -1
- js/fields-admin/02_fbuilder.fnumber.js +1 -1
- js/fields-admin/03_fbuilder.femail.js +7 -4
- js/fields-admin/06_fbuilder.fcheck.js +19 -9
- js/fields-admin/07_fbuilder.fradio.js +208 -198
- js/fields-admin/08_fbuilder.fdropdown.js +16 -6
- js/fields-admin/10_fbuilder.fpassword.js +7 -4
- js/fields-public/02_fbuilder.fnumber.js +8 -8
- js/fields-public/06_fbuilder.fcheck.js +14 -1
- js/fields-public/07_fbuilder.fradio.js +14 -1
- js/fields-public/08_fbuilder.fdropdown.js +14 -0
- js/fields-public/32_fbuilder.fbutton.js +1 -1
- js/fields-public/fbuilder.fcalculated.js +33 -14
- js/jquery.validate.js +5 -1
- js/modules/01_mathematical_logical/admin/module_admin.js +6 -0
- pagebuilders/divi/cff.pb.php +78 -0
- pagebuilders/visualcomposer/CFFForm/public/dist/element.bundle.js +1 -1
README.txt
CHANGED
@@ -56,6 +56,7 @@ The "Calculated Fields Form" plugin allows the specific integration with the fol
|
|
56 |
* Page Builder by SiteOrigin.
|
57 |
* Beaver Builder.
|
58 |
* Visual Composer.
|
|
|
59 |
* For other editors, the shortcodes should be inserted using other controls of general purpose, like the controls for inserting HTML or shortcodes.
|
60 |
|
61 |
= Latest Features Added =
|
@@ -94,6 +95,7 @@ The plugin has two additional (commercial) versions: **Premium** and **Developer
|
|
94 |
* Submits the form data, and stores the data on database, for future review
|
95 |
* Allows send notification emails with the data submitted, to the form editor and users
|
96 |
* Allows charge the calculated field directly through PayPal
|
|
|
97 |
* Allows export and import your forms between different WordPress
|
98 |
* Allows to display the submitted data in the thanks page
|
99 |
* Includes a dashboard widget to display the submissions of the last week
|
@@ -132,6 +134,7 @@ The plugin has two additional (commercial) versions: **Premium** and **Developer
|
|
132 |
* Includes the "WebMerge" add-on to integrate the forms with the WebMerge Service, and generate PDF and Office documents at runtime with the information collected by the forms.
|
133 |
* Includes the "PrintFriendly" add-on to integrate the forms with the PrintFriendly API for generating PDF files after forms submissions, and attach the resulting files to the notification emails.
|
134 |
* Includes the "MailChimp" add-on to add new members to the MailChimp Service using the data collected by the form.
|
|
|
135 |
* Includes the "Emma" add-on to add new members to the Emma Service using the data collected by the form.
|
136 |
* Includes the "Twilio" add-on for sending notification messages (SMS) when the forms are submitted.
|
137 |
* Includes the "MailPoet" add-on to add new subscribers to the MailPoet's Mailing Lists.
|
@@ -424,6 +427,12 @@ Includes the "MailChimp" add-on to integrate the forms with the MailChimp Servic
|
|
424 |
|
425 |
[CLICK HERE for additional information ](http://cff.dwbooster.com/documentation#mailchimp-addon "MailChimp add-on")
|
426 |
|
|
|
|
|
|
|
|
|
|
|
|
|
427 |
= Emma add-on - Only available in the Platinum version of the plugin =
|
428 |
|
429 |
Includes the "Emma" add-on to integrate the forms with the Emma Service to add new members to the Emma groups.
|
@@ -919,64 +928,51 @@ This way the special characters should show correctly.
|
|
919 |
|
920 |
== Changelog ==
|
921 |
|
922 |
-
= 1.0.
|
923 |
|
924 |
-
* Modifies the
|
925 |
-
* Improves the performance of DS fields (Developer and Platinum versions of the plugin).
|
926 |
-
* Modifies the WooCommerce add-on to include the form in the products' pages, even if the products' prices were left in blank in the WooCommerce settings (Developer and Platinum versions of the plugin).
|
927 |
-
* Modifies the RedSys add-on to prevent the payments fail if the "Product name" attribute was left in blank in the form's settings (Platinum version of the plugin).
|
928 |
|
929 |
-
= 1.0.
|
930 |
|
931 |
-
*
|
932 |
-
* Modifies the Users Permissions add-on to prevent the files uploaded previously being lost when the uses edit their submissions.
|
933 |
|
934 |
-
= 1.0.
|
935 |
|
936 |
-
*
|
937 |
-
* Fixes an issue between the module that pre-fills the form's fields and the dependencies.
|
938 |
-
* Includes the "callback" attribute in the fields tags, allowing to apply escape functions before the tags' replacement (Professional, Developer and Platinum versions of the plugin).
|
939 |
-
* Implements the "STRAIGHT" mode in the "DISTANCE" operation to determine the straight line distance between addresses (Developer and Platinum versions of the plugin).
|
940 |
-
* Implements the attribute: events_per_page into the [CP_CALCULATED_FIELDS_RESULT_LIST] shortcode to allow paginate the submissions lists (Professional, Developer and Platinum versions of the plugin).
|
941 |
-
* Implements the attribute: events_per_page into the [CP_CALCULATED_FIELDS_USER_SUBMISSIONS_LIST] shortcode of the Users Permissions add-on for controlling the number of items per page (Developer and Platinum versions of the plugin).
|
942 |
-
* Allows to insert the [CP_CALCULATED_FIELDS_USER_SUBMISSIONS_LIST] shortcode with the format: [CP_CALCULATED_FIELDS_USER_SUBMISSIONS_LIST] content [/CP_CALCULATED_FIELDS_USER_SUBMISSIONS_LIST]. In this way the content takes precedence over the "Summary" attribute in the form's settings (Developer and Platinum versions of the plugin).
|
943 |
|
944 |
-
= 1.0.
|
945 |
|
946 |
-
*
|
947 |
-
* Implements a specific element to insert the forms using Visual Composer.
|
948 |
|
949 |
-
= 1.0.
|
950 |
|
951 |
-
*
|
952 |
-
* Fixes an issue assigning the default values in the Date/Time fields, specifically populating the time component.
|
953 |
|
954 |
-
= 1.0.
|
955 |
|
956 |
-
*
|
957 |
-
* Includes a new module in the Beaver Page Builder for generating the javascript variables.
|
958 |
-
* Fixes an issue in the PrintFriendly add-on when there are multiple notification emails (Platinum version of the plugin).
|
959 |
|
960 |
-
= 1.0.
|
961 |
|
962 |
-
* Modifies the
|
963 |
|
964 |
-
= 1.0.
|
965 |
|
966 |
-
*
|
967 |
-
*
|
968 |
-
*
|
969 |
|
970 |
-
= 1.0.
|
971 |
|
972 |
-
*
|
973 |
|
974 |
-
= 1.0.
|
975 |
|
976 |
-
*
|
|
|
977 |
|
978 |
== Upgrade Notice ==
|
979 |
|
980 |
-
= 1.0.
|
981 |
|
982 |
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
|
56 |
* Page Builder by SiteOrigin.
|
57 |
* Beaver Builder.
|
58 |
* Visual Composer.
|
59 |
+
* DIVI Builder.
|
60 |
* For other editors, the shortcodes should be inserted using other controls of general purpose, like the controls for inserting HTML or shortcodes.
|
61 |
|
62 |
= Latest Features Added =
|
95 |
* Submits the form data, and stores the data on database, for future review
|
96 |
* Allows send notification emails with the data submitted, to the form editor and users
|
97 |
* Allows charge the calculated field directly through PayPal
|
98 |
+
* Payments are SCA ready (Strong Customer Authentication), compatible with the new Payment services (PSD 2) - Directive (EU)
|
99 |
* Allows export and import your forms between different WordPress
|
100 |
* Allows to display the submitted data in the thanks page
|
101 |
* Includes a dashboard widget to display the submissions of the last week
|
134 |
* Includes the "WebMerge" add-on to integrate the forms with the WebMerge Service, and generate PDF and Office documents at runtime with the information collected by the forms.
|
135 |
* Includes the "PrintFriendly" add-on to integrate the forms with the PrintFriendly API for generating PDF files after forms submissions, and attach the resulting files to the notification emails.
|
136 |
* Includes the "MailChimp" add-on to add new members to the MailChimp Service using the data collected by the form.
|
137 |
+
* Includes the "Mautic" add-on to add new contacts (or update the existent ones) into the Mautic Service, using the information collected by the form.
|
138 |
* Includes the "Emma" add-on to add new members to the Emma Service using the data collected by the form.
|
139 |
* Includes the "Twilio" add-on for sending notification messages (SMS) when the forms are submitted.
|
140 |
* Includes the "MailPoet" add-on to add new subscribers to the MailPoet's Mailing Lists.
|
427 |
|
428 |
[CLICK HERE for additional information ](http://cff.dwbooster.com/documentation#mailchimp-addon "MailChimp add-on")
|
429 |
|
430 |
+
= Mautic add-on - Only available in the Platinum version of the plugin =
|
431 |
+
|
432 |
+
Includes the "Mautic" add-on to integrate the forms with the Mautic Service. This add-on creates new contacts, or update the existent ones, in the Mautic service.
|
433 |
+
|
434 |
+
[CLICK HERE for additional information ](http://cff.dwbooster.com/documentation#mautic-addon "Mautic add-on")
|
435 |
+
|
436 |
= Emma add-on - Only available in the Platinum version of the plugin =
|
437 |
|
438 |
Includes the "Emma" add-on to integrate the forms with the Emma Service to add new members to the Emma groups.
|
928 |
|
929 |
== Changelog ==
|
930 |
|
931 |
+
= 1.0.336 =
|
932 |
|
933 |
+
* Modifies the code of the plugin for allowing the compatibility with outdated versions of PHP.
|
|
|
|
|
|
|
934 |
|
935 |
+
= 1.0.335 =
|
936 |
|
937 |
+
* Fixes an issue in forms when the calculated fields are evaluated the first time.
|
|
|
938 |
|
939 |
+
= 1.0.334 =
|
940 |
|
941 |
+
* Modifies the dependencies in the calculated fields to allow the use of value and value|r (for raw values) in the manual definition of dependency rules.
|
|
|
|
|
|
|
|
|
|
|
|
|
942 |
|
943 |
+
= 1.0.333 =
|
944 |
|
945 |
+
* Includes specific buttons in the Logical Operations module to for the operators: equal, not equal, less than, less than or equal to, greater than, greater than or equal.
|
|
|
946 |
|
947 |
+
= 1.0.332 =
|
948 |
|
949 |
+
* Includes a specific DIVI module to allow the insertion of the form's shortcode from the DIVI Builder.
|
|
|
950 |
|
951 |
+
= 1.0.331 =
|
952 |
|
953 |
+
* Modifies the module that evaluate all equations, and the dependencies, improving the forms performance.
|
|
|
|
|
954 |
|
955 |
+
= 1.0.330 =
|
956 |
|
957 |
+
* Modifies the 'Equal To' attribute in the controls: Single Line Text, Email and Password for all versions of the plugin, and the controls: Line Text DS, Email DS in the Developer and Platinum versions.
|
958 |
|
959 |
+
= 1.0.329 =
|
960 |
|
961 |
+
* Modifies the CSS editor.
|
962 |
+
* Includes the new filter: cpcff_price that allows modify the calculated price. This filter receives two parameters: the calcualted price, and an array with the list of fields and their values (Professional, Developer and Platinum versions of the plugin).
|
963 |
+
* Modifies the SERVER-SIDE EQUATIONS add-on. The new version includes a new section in the forms' settings to allow calculate the final price through a server side equation after the form be submitted (Developer and Platinum versions of the plugin).
|
964 |
|
965 |
+
= 1.0.328 =
|
966 |
|
967 |
+
* Replaces the 'Customize Form Design' attribute in the 'Form Settings' tab by a real CSS editor, with auto-completing, syntax highlighting, and error checking.
|
968 |
|
969 |
+
= 1.0.327 =
|
970 |
|
971 |
+
* Improves the definition of the dependencies in the Radio Buttons, Checkbox and DropDown fields.
|
972 |
+
* Modifies the script blocks to prevent that some optimization plugins affect the forms.
|
973 |
|
974 |
== Upgrade Notice ==
|
975 |
|
976 |
+
= 1.0.336 =
|
977 |
|
978 |
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,83 @@
|
|
1 |
== Changelog ==
|
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
= 1.0.318 =
|
4 |
|
5 |
* Modifies the Advanced Equations module.
|
1 |
== Changelog ==
|
2 |
|
3 |
+
= 1.0.336 =
|
4 |
+
|
5 |
+
* Modifies the code of the plugin for allowing the compatibility with outdated versions of PHP.
|
6 |
+
|
7 |
+
= 1.0.335 =
|
8 |
+
|
9 |
+
* Fixes an issue in forms when the calculated fields are evaluated the first time.
|
10 |
+
|
11 |
+
= 1.0.334 =
|
12 |
+
|
13 |
+
* Modifies the dependencies in the calculated fields to allow the use of value and value|r (for raw values) in the manual definition of dependency rules.
|
14 |
+
|
15 |
+
= 1.0.333 =
|
16 |
+
|
17 |
+
* Includes specific buttons in the Logical Operations module to for the operators: equal, not equal, less than, less than or equal to, greater than, greater than or equal.
|
18 |
+
|
19 |
+
= 1.0.332 =
|
20 |
+
|
21 |
+
* Includes a specific DIVI module to allow the insertion of the form's shortcode from the DIVI Builder.
|
22 |
+
|
23 |
+
= 1.0.331 =
|
24 |
+
|
25 |
+
* Modifies the module that evaluate all equations, and the dependencies, improving the forms performance.
|
26 |
+
|
27 |
+
= 1.0.330 =
|
28 |
+
|
29 |
+
* Modifies the 'Equal To' attribute in the controls: Single Line Text, Email and Password for all versions of the plugin, and the controls: Line Text DS, Email DS in the Developer and Platinum versions.
|
30 |
+
|
31 |
+
= 1.0.329 =
|
32 |
+
|
33 |
+
* Modifies the CSS editor.
|
34 |
+
* Includes the new filter: cpcff_price that allows modify the calculated price. This filter receives two parameters: the calcualted price, and an array with the list of fields and their values (Professional, Developer and Platinum versions of the plugin).
|
35 |
+
* Modifies the SERVER-SIDE EQUATIONS add-on. The new version includes a new section in the forms' settings to allow calculate the final price through a server side equation after the form be submitted (Developer and Platinum versions of the plugin).
|
36 |
+
|
37 |
+
= 1.0.328 =
|
38 |
+
|
39 |
+
* Replaces the 'Customize Form Design' attribute in the 'Form Settings' tab by a real CSS editor, with auto-completing, syntax highlighting, and error checking.
|
40 |
+
|
41 |
+
= 1.0.327 =
|
42 |
+
|
43 |
+
* Improves the definition of the dependencies in the Radio Buttons, Checkbox and DropDown fields.
|
44 |
+
* Modifies the script blocks to prevent that some optimization plugins affect the forms.
|
45 |
+
|
46 |
+
= 1.0.326 =
|
47 |
+
|
48 |
+
* Modifies the forms' validations module to restrict the error messages to the form's scope, and not to the page's scope. At the page's scope the error messages defined by the last form in the page, affect to the other forms in the same page.
|
49 |
+
|
50 |
+
= 1.0.325 =
|
51 |
+
|
52 |
+
* Modifies the way the plugin manages the session variables.
|
53 |
+
* Allows to includes results shortcodes for multiple forms in the thank you page. Furthermore, includes the if_latest attribute in the results shortcode (Professional, Developer and Platinum versions of the plugin).
|
54 |
+
|
55 |
+
= 1.0.324 =
|
56 |
+
|
57 |
+
* Modifies the number control. Includes the percent option as the field's formats. The numbers configured as percent should not be divide by 100 in the equations.
|
58 |
+
|
59 |
+
= 1.0.323 =
|
60 |
+
|
61 |
+
* Modifies the controls: checkbox and radio buttons to prevent a conflict with those themes that manipulate the DOM of pages at runtime to customize the appearance of these fields.
|
62 |
+
|
63 |
+
= 1.0.322 =
|
64 |
+
|
65 |
+
* Modifies the module that manage the browser's history. Now if there is a multi-pages form, and the browser's persistence is enabled on it, if the user refreshes the browser when he/she is populating the fields of page X, the plugin will pre-fill the form's fields, and will jump to the page X automatically.
|
66 |
+
|
67 |
+
= 1.0.321 =
|
68 |
+
|
69 |
+
* Fixes some notices related with the servers' settings.
|
70 |
+
|
71 |
+
= 1.0.320 =
|
72 |
+
|
73 |
+
* Modifies the Radio Buttons, Checkbox and DropDown controls. Implements in them the setChoices method to replace their choices programmatically.
|
74 |
+
* Modifies the Calculated fields to improve the process that evaluates the equations.
|
75 |
+
* Modifies the module that check the dependencies.
|
76 |
+
|
77 |
+
= 1.0.319 =
|
78 |
+
|
79 |
+
* Fixes an issue in the integration with Visual Composer.
|
80 |
+
|
81 |
= 1.0.318 =
|
82 |
|
83 |
* Modifies the Advanced Equations module.
|
config/cpcff_config.cfg.php
CHANGED
@@ -133,9 +133,8 @@ if(!function_exists('cpcff_init_constants'))
|
|
133 |
if(!defined('CP_CALCULATEDFIELDSF_DEFAULT_fp_from_email'))
|
134 |
{
|
135 |
$user_email = get_the_author_meta('user_email', get_current_user_id());
|
136 |
-
$host = $_SERVER['HTTP_HOST'];
|
137 |
-
preg_match("/[^\.\/]+(\.[^\.\/]+)?$/", $host, $matches);
|
138 |
-
$domain = $matches[0];
|
139 |
$pos = strpos($user_email, $domain);
|
140 |
if ($pos === false) define('CP_CALCULATEDFIELDSF_DEFAULT_fp_from_email', 'admin@'.$domain );
|
141 |
else define('CP_CALCULATEDFIELDSF_DEFAULT_fp_from_email', $user_email );
|
133 |
if(!defined('CP_CALCULATEDFIELDSF_DEFAULT_fp_from_email'))
|
134 |
{
|
135 |
$user_email = get_the_author_meta('user_email', get_current_user_id());
|
136 |
+
$host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : '';
|
137 |
+
$domain = preg_match("/[^\.\/]+(\.[^\.\/]+)?$/", $host, $matches) ? $matches[0] : $user_email;
|
|
|
138 |
$pos = strpos($user_email, $domain);
|
139 |
if ($pos === false) define('CP_CALCULATEDFIELDSF_DEFAULT_fp_from_email', 'admin@'.$domain );
|
140 |
else define('CP_CALCULATEDFIELDSF_DEFAULT_fp_from_email', $user_email );
|
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.
|
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.
|
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.336
|
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.336' );
|
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.inc.php
CHANGED
@@ -11,6 +11,7 @@ require_once CP_CALCULATEDFIELDSF_BASE_PATH.'/inc/cpcff_templates.inc.php';
|
|
11 |
|
12 |
check_admin_referer( 'cff-form-settings', '_cpcff_nonce' );
|
13 |
wp_enqueue_media();
|
|
|
14 |
|
15 |
if (!defined('CP_CALCULATEDFIELDSF_ID'))
|
16 |
define ('CP_CALCULATEDFIELDSF_ID',intval($_GET["cal"]));
|
11 |
|
12 |
check_admin_referer( 'cff-form-settings', '_cpcff_nonce' );
|
13 |
wp_enqueue_media();
|
14 |
+
if(function_exists('wp_enqueue_code_editor')) wp_enqueue_code_editor( array( 'type' => 'text/html' ) );
|
15 |
|
16 |
if (!defined('CP_CALCULATEDFIELDSF_ID'))
|
17 |
define ('CP_CALCULATEDFIELDSF_ID',intval($_GET["cal"]));
|
inc/cpcff_main.inc.php
CHANGED
@@ -379,6 +379,7 @@ if(!class_exists('CPCFF_MAIN'))
|
|
379 |
{
|
380 |
if(isset($atts['shortcode_atts']))
|
381 |
{
|
|
|
382 |
global $wp_styles, $wp_scripts;
|
383 |
if(!empty($wp_scripts)) $wp_scripts->reset();
|
384 |
$message = $this->public_form($atts['shortcode_atts']);
|
@@ -819,13 +820,13 @@ if(!class_exists('CPCFF_MAIN'))
|
|
819 |
<?php
|
820 |
}
|
821 |
?>
|
822 |
-
<script type='text/javascript'>
|
823 |
/* <![CDATA[ */
|
824 |
<?php
|
825 |
print 'var cp_calculatedfieldsf_fbuilder_config_'.self::$form_counter.'={"obj":'.$config_json.'};';
|
826 |
?>
|
827 |
/* ]]> */
|
828 |
-
</script>
|
829 |
<?php
|
830 |
}
|
831 |
} // End _public_resources
|
379 |
{
|
380 |
if(isset($atts['shortcode_atts']))
|
381 |
{
|
382 |
+
error_reporting(E_ERROR|E_PARSE);
|
383 |
global $wp_styles, $wp_scripts;
|
384 |
if(!empty($wp_scripts)) $wp_scripts->reset();
|
385 |
$message = $this->public_form($atts['shortcode_atts']);
|
820 |
<?php
|
821 |
}
|
822 |
?>
|
823 |
+
<pre style="display:none !important;"><script type='text/javascript'>
|
824 |
/* <![CDATA[ */
|
825 |
<?php
|
826 |
print 'var cp_calculatedfieldsf_fbuilder_config_'.self::$form_counter.'={"obj":'.$config_json.'};';
|
827 |
?>
|
828 |
/* ]]> */
|
829 |
+
</script></pre>
|
830 |
<?php
|
831 |
}
|
832 |
} // End _public_resources
|
inc/cpcff_page_builders.inc.php
CHANGED
@@ -43,6 +43,9 @@ if(!class_exists('CPCFF_PAGE_BUILDERS'))
|
|
43 |
include_once CP_CALCULATEDFIELDSF_BASE_PATH.'/pagebuilders/beaverbuilder/cffvar/cffvar.inc.php';
|
44 |
}
|
45 |
|
|
|
|
|
|
|
46 |
} // End init
|
47 |
|
48 |
public function after_setup_theme()
|
@@ -57,6 +60,16 @@ if(!class_exists('CPCFF_PAGE_BUILDERS'))
|
|
57 |
add_action('vcv:api', array($instance, 'visualcomposer_editor'));
|
58 |
} // End after_setup_theme
|
59 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
60 |
/**************************** GUTENBERG ****************************/
|
61 |
|
62 |
/**
|
@@ -148,7 +161,7 @@ if(!class_exists('CPCFF_PAGE_BUILDERS'))
|
|
148 |
|
149 |
public function visualcomposer_editor($api)
|
150 |
{
|
151 |
-
$elementsToRegister =
|
152 |
$pluginBaseUrl = rtrim(plugins_url('/pagebuilders/visualcomposer/', CP_CALCULATEDFIELDSF_MAIN_FILE_PATH), '\\/');
|
153 |
$elementsApi = $api->elements;
|
154 |
foreach ($elementsToRegister as $tag)
|
43 |
include_once CP_CALCULATEDFIELDSF_BASE_PATH.'/pagebuilders/beaverbuilder/cffvar/cffvar.inc.php';
|
44 |
}
|
45 |
|
46 |
+
// DIVI
|
47 |
+
add_action( 'et_builder_ready', array($instance, 'divi_editor') );
|
48 |
+
|
49 |
} // End init
|
50 |
|
51 |
public function after_setup_theme()
|
60 |
add_action('vcv:api', array($instance, 'visualcomposer_editor'));
|
61 |
} // End after_setup_theme
|
62 |
|
63 |
+
/**************************** DIVI ****************************/
|
64 |
+
|
65 |
+
public function divi_editor()
|
66 |
+
{
|
67 |
+
if(class_exists('ET_Builder_Module'))
|
68 |
+
{
|
69 |
+
require_once CP_CALCULATEDFIELDSF_BASE_PATH.'/pagebuilders/divi/cff.pb.php';
|
70 |
+
}
|
71 |
+
} // End divi_editor
|
72 |
+
|
73 |
/**************************** GUTENBERG ****************************/
|
74 |
|
75 |
/**
|
161 |
|
162 |
public function visualcomposer_editor($api)
|
163 |
{
|
164 |
+
$elementsToRegister = array('CFFForm');
|
165 |
$pluginBaseUrl = rtrim(plugins_url('/pagebuilders/visualcomposer/', CP_CALCULATEDFIELDSF_MAIN_FILE_PATH), '\\/');
|
166 |
$elementsApi = $api->elements;
|
167 |
foreach ($elementsToRegister as $tag)
|
inc/cpcff_public_int.inc.php
CHANGED
@@ -50,7 +50,7 @@ if( !empty( $form_data ) )
|
|
50 |
<form name="<?php echo $form_data[ 1 ][ 'formid' ]; ?>" id="<?php echo $form_data[ 1 ][ 'formid' ]; ?>" action="?" method="post" enctype="multipart/form-data" class="<?php
|
51 |
if(!empty($form_data[1][0]) && !empty($form_data[1][0]->persistence)) echo ' persist-form';
|
52 |
if(!empty($atts) && !empty($atts['class'])) echo ' '.esc_attr($atts['class']);
|
53 |
-
?>"><input type="hidden" name="cp_calculatedfieldsf_id" value="<?php echo $id; ?>" /><pre style="display:none;"><!--noptimize--><script>form_structure_<?php echo CPCFF_MAIN::$form_counter; ?>=<?php print str_replace( array( "\n", "\r" ), " ", ((version_compare(CP_CFF_PHPVERSION,"5.3.0")>=0)?json_encode($form_data, JSON_HEX_QUOT|JSON_HEX_TAG):json_encode($form_data)) ); ?>;</script><!--/noptimize--></pre>
|
54 |
<div id="fbuilder">
|
55 |
<div id="fbuilder_<?php echo CPCFF_MAIN::$form_counter; ?>">
|
56 |
<div id="formheader_<?php echo CPCFF_MAIN::$form_counter; ?>"></div>
|
50 |
<form name="<?php echo $form_data[ 1 ][ 'formid' ]; ?>" id="<?php echo $form_data[ 1 ][ 'formid' ]; ?>" action="?" method="post" enctype="multipart/form-data" class="<?php
|
51 |
if(!empty($form_data[1][0]) && !empty($form_data[1][0]->persistence)) echo ' persist-form';
|
52 |
if(!empty($atts) && !empty($atts['class'])) echo ' '.esc_attr($atts['class']);
|
53 |
+
?>"><input type="hidden" name="cp_calculatedfieldsf_id" value="<?php echo $id; ?>" /><pre style="display:none !important;"><!--noptimize--><script>form_structure_<?php echo CPCFF_MAIN::$form_counter; ?>=<?php print str_replace( array( "\n", "\r" ), " ", ((version_compare(CP_CFF_PHPVERSION,"5.3.0")>=0)?json_encode($form_data, JSON_HEX_QUOT|JSON_HEX_TAG):json_encode($form_data)) ); ?>;</script><!--/noptimize--></pre>
|
54 |
<div id="fbuilder">
|
55 |
<div id="fbuilder_<?php echo CPCFF_MAIN::$form_counter; ?>">
|
56 |
<div id="formheader_<?php echo CPCFF_MAIN::$form_counter; ?>"></div>
|
inc/cpcff_session.inc.php
CHANGED
@@ -174,6 +174,22 @@ if( !class_exists( 'CP_SESSION' ) )
|
|
174 |
$instance->_unset_var( $name );
|
175 |
}
|
176 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
177 |
} // End clss
|
178 |
}
|
179 |
?>
|
174 |
$instance->_unset_var( $name );
|
175 |
}
|
176 |
|
177 |
+
// Special methods for registering and recovering the forms submissions
|
178 |
+
public static function register_event($eventid, $formid)
|
179 |
+
{
|
180 |
+
$cp_cff_form_data = self::get_var('cp_cff_form_data');
|
181 |
+
if(empty($cp_cff_form_data)) $cp_cff_form_data = array();
|
182 |
+
|
183 |
+
$cp_cff_form_data[$formid] = $eventid;
|
184 |
+
$cp_cff_form_data['latest'] = $formid;
|
185 |
+
|
186 |
+
self::set_var('cp_cff_form_data', $cp_cff_form_data);
|
187 |
+
}
|
188 |
+
|
189 |
+
public static function registered_events()
|
190 |
+
{
|
191 |
+
return self::get_var('cp_cff_form_data');
|
192 |
+
}
|
193 |
} // End clss
|
194 |
}
|
195 |
?>
|
js/fbuilder-loader-public.php
CHANGED
@@ -74,24 +74,7 @@ fbuilderjQuery.fbuilderjQueryGenerator = function(){
|
|
74 |
try {
|
75 |
var cp_calculatedfieldsf_fbuilder_config = window["cp_calculatedfieldsf_fbuilder_config"+fnum];
|
76 |
var f = $("#fbuilder"+fnum).fbuilder(( typeof cp_calculatedfieldsf_fbuilder_config.obj == 'string' ) ? $.parseJSON(cp_calculatedfieldsf_fbuilder_config.obj) : cp_calculatedfieldsf_fbuilder_config.obj );
|
77 |
-
|
78 |
-
ignore:".ignore,.ignorepb",
|
79 |
-
errorElement: "div",
|
80 |
-
errorPlacement: function(e, element)
|
81 |
-
{
|
82 |
-
var _parent = element.closest( '.dfield' ),
|
83 |
-
_uh = _parent.find( 'span.uh:visible' );
|
84 |
-
|
85 |
-
if( _uh.length )
|
86 |
-
e.appendTo( _uh );
|
87 |
-
else
|
88 |
-
e.insertAfter( _parent );
|
89 |
-
|
90 |
-
e.addClass( 'message' )
|
91 |
-
.css( 'position', 'absolute' );
|
92 |
-
}
|
93 |
-
});
|
94 |
-
f.fBuild.loadData("form_structure"+fnum);
|
95 |
} catch (e) {}
|
96 |
fcount++;
|
97 |
fnum = "_"+fcount;
|
74 |
try {
|
75 |
var cp_calculatedfieldsf_fbuilder_config = window["cp_calculatedfieldsf_fbuilder_config"+fnum];
|
76 |
var f = $("#fbuilder"+fnum).fbuilder(( typeof cp_calculatedfieldsf_fbuilder_config.obj == 'string' ) ? $.parseJSON(cp_calculatedfieldsf_fbuilder_config.obj) : cp_calculatedfieldsf_fbuilder_config.obj );
|
77 |
+
f.fBuild.loadData("form_structure"+fnum);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
78 |
} catch (e) {}
|
79 |
fcount++;
|
80 |
fnum = "_"+fcount;
|
js/fbuilder-pro-admin.jquery.js
CHANGED
@@ -268,6 +268,24 @@
|
|
268 |
theForm.customstyles = $(this).val();
|
269 |
$.fbuilder.reloadItems({'form':1});
|
270 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
271 |
};
|
272 |
|
273 |
$.fbuilder[ 'defineGeneralEvents' ] = function()
|
268 |
theForm.customstyles = $(this).val();
|
269 |
$.fbuilder.reloadItems({'form':1});
|
270 |
});
|
271 |
+
|
272 |
+
// CSS Editor
|
273 |
+
if( 'codeEditor' in wp)
|
274 |
+
{
|
275 |
+
var cssEditorSettings = wp.codeEditor.defaultSettings ? _.clone( wp.codeEditor.defaultSettings ) : {},
|
276 |
+
editor;
|
277 |
+
cssEditorSettings.codemirror = _.extend(
|
278 |
+
{},
|
279 |
+
cssEditorSettings.codemirror,
|
280 |
+
{
|
281 |
+
indentUnit: 2,
|
282 |
+
tabSize: 2,
|
283 |
+
mode: 'css'
|
284 |
+
}
|
285 |
+
);
|
286 |
+
editor = wp.codeEditor.initialize( $('#fCustomStyles'), cssEditorSettings );
|
287 |
+
editor.codemirror.on('change', function(cm){ $('#fCustomStyles').val(cm.getValue()).change();});
|
288 |
+
}
|
289 |
};
|
290 |
|
291 |
$.fbuilder[ 'defineGeneralEvents' ] = function()
|
js/fbuilder-pro-public.jquery.js
CHANGED
@@ -76,19 +76,39 @@
|
|
76 |
dateddmmyyyy: "Please enter a valid date with this format(dd/mm/yyyy)",
|
77 |
number: "Please enter a valid number.",
|
78 |
digits: "Please enter only digits.",
|
79 |
-
maxlength:
|
80 |
-
minlength:
|
81 |
equalTo: "Please enter the same value again.",
|
82 |
-
max:
|
83 |
-
min:
|
84 |
currency: "Please enter a valid currency value."
|
85 |
},opt.messages);
|
86 |
|
87 |
opt.messages.max = $.validator.format(opt.messages.max);
|
88 |
opt.messages.min = $.validator.format(opt.messages.min);
|
|
|
|
|
89 |
|
90 |
$.extend($.validator.messages, opt.messages);
|
91 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
92 |
var items = [],
|
93 |
reloadItemsPublic = function()
|
94 |
{
|
@@ -229,23 +249,27 @@
|
|
229 |
items[i].after_show();
|
230 |
}
|
231 |
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
);
|
238 |
-
|
239 |
-
$( '#fieldlist'+opt.identifier).find(".depItemSel,.depItem").bind("change", { 'identifier' : opt.identifier }, function( evt )
|
240 |
{
|
241 |
$.fbuilder.showHideDep(
|
242 |
{
|
243 |
'formIdentifier' : evt.data.identifier,
|
244 |
-
'fieldItentifier': evt.target.id
|
245 |
-
'throwEvent' : true
|
246 |
}
|
247 |
);
|
248 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
249 |
try
|
250 |
{
|
251 |
$.widget.bridge('uitooltip', $.ui.tooltip);
|
@@ -439,10 +463,7 @@
|
|
439 |
$.fbuilder[ 'manageHistory' ] = function(state)
|
440 |
{
|
441 |
var bookmark = (document.URL.split('#').length > 1) ? document.URL.split('#')[1] : null,
|
442 |
-
_match, _form, _to, setHistoryEntry = false
|
443 |
-
_goToPage = function(config){
|
444 |
-
|
445 |
-
};
|
446 |
|
447 |
if(bookmark)
|
448 |
{
|
@@ -450,9 +471,12 @@
|
|
450 |
{
|
451 |
_form = '_'+_match[1];
|
452 |
_to = _match[2]*1;
|
|
|
|
|
|
|
|
|
453 |
if(
|
454 |
-
|
455 |
-
!('currentPage' in $.fbuilder.forms[_form]) || // Next/Prev buttons has been pressed previously
|
456 |
_to != $.fbuilder['goToPage'](
|
457 |
{
|
458 |
'formIdentifier' : _form,
|
@@ -461,7 +485,6 @@
|
|
461 |
}
|
462 |
)
|
463 |
) setHistoryEntry = true;
|
464 |
-
bookmark = bookmark.replace(_match[0],'');
|
465 |
}
|
466 |
}
|
467 |
else
|
@@ -578,11 +601,7 @@
|
|
578 |
items = (typeof configObj[ 'fieldItentifier' ] != 'undefined' ) ? [ $.fbuilder[ 'forms' ][ identifier ].getItem(configObj[ 'fieldItentifier' ].replace(/_[cr]b\d+$/i, '')) ] : $.fbuilder[ 'forms' ][ identifier ].getItems();
|
579 |
|
580 |
process_items( items );
|
581 |
-
|
582 |
-
if( typeof configObj[ 'throwEvent' ] == 'undefined' || configObj[ 'throwEvent' ] )
|
583 |
-
{
|
584 |
-
$( document ).trigger( 'showHideDepEvent', $.fbuilder[ 'forms' ][ identifier ][ 'formId' ] );
|
585 |
-
}
|
586 |
}
|
587 |
}
|
588 |
}; // End showHideDep
|
@@ -614,8 +633,7 @@
|
|
614 |
|
615 |
$.fbuilder.showHideDep(
|
616 |
{
|
617 |
-
'formIdentifier' : o.identifier
|
618 |
-
'throwEvent' : true
|
619 |
}
|
620 |
);
|
621 |
}
|
76 |
dateddmmyyyy: "Please enter a valid date with this format(dd/mm/yyyy)",
|
77 |
number: "Please enter a valid number.",
|
78 |
digits: "Please enter only digits.",
|
79 |
+
maxlength: "Please enter no more than {0} characters.",
|
80 |
+
minlength: "Please enter at least {0} characters.",
|
81 |
equalTo: "Please enter the same value again.",
|
82 |
+
max: "Please enter a value less than or equal to {0}.",
|
83 |
+
min: "Please enter a value greater than or equal to {0}.",
|
84 |
currency: "Please enter a valid currency value."
|
85 |
},opt.messages);
|
86 |
|
87 |
opt.messages.max = $.validator.format(opt.messages.max);
|
88 |
opt.messages.min = $.validator.format(opt.messages.min);
|
89 |
+
opt.messages.maxlength = $.validator.format(opt.messages.maxlength);
|
90 |
+
opt.messages.minlength = $.validator.format(opt.messages.minlength);
|
91 |
|
92 |
$.extend($.validator.messages, opt.messages);
|
93 |
|
94 |
+
$("#cp_calculatedfieldsf_pform"+fnum).validate({
|
95 |
+
ignore:".ignore,.ignorepb",
|
96 |
+
errorElement: "div",
|
97 |
+
errorPlacement: function(e, element)
|
98 |
+
{
|
99 |
+
var _parent = element.closest( '.dfield' ),
|
100 |
+
_uh = _parent.find( 'span.uh:visible' );
|
101 |
+
|
102 |
+
if( _uh.length )
|
103 |
+
e.appendTo( _uh );
|
104 |
+
else
|
105 |
+
e.insertAfter( _parent );
|
106 |
+
|
107 |
+
e.addClass( 'message' )
|
108 |
+
.css( 'position', 'absolute' );
|
109 |
+
}
|
110 |
+
}).messages = opt.messages;
|
111 |
+
|
112 |
var items = [],
|
113 |
reloadItemsPublic = function()
|
114 |
{
|
249 |
items[i].after_show();
|
250 |
}
|
251 |
|
252 |
+
$(document).on(
|
253 |
+
'change',
|
254 |
+
'#fieldlist'+opt.identifier+' .depItemSel,'+'#fieldlist'+opt.identifier+' .depItem',
|
255 |
+
{ 'identifier' : opt.identifier },
|
256 |
+
function( evt )
|
|
|
|
|
|
|
257 |
{
|
258 |
$.fbuilder.showHideDep(
|
259 |
{
|
260 |
'formIdentifier' : evt.data.identifier,
|
261 |
+
'fieldItentifier': evt.target.id
|
|
|
262 |
}
|
263 |
);
|
264 |
+
}
|
265 |
+
);
|
266 |
+
|
267 |
+
$.fbuilder.showHideDep(
|
268 |
+
{
|
269 |
+
'formIdentifier' : opt.identifier
|
270 |
+
}
|
271 |
+
);
|
272 |
+
|
273 |
try
|
274 |
{
|
275 |
$.widget.bridge('uitooltip', $.ui.tooltip);
|
463 |
$.fbuilder[ 'manageHistory' ] = function(state)
|
464 |
{
|
465 |
var bookmark = (document.URL.split('#').length > 1) ? document.URL.split('#')[1] : null,
|
466 |
+
_match, _form, _to, setHistoryEntry = false;
|
|
|
|
|
|
|
467 |
|
468 |
if(bookmark)
|
469 |
{
|
471 |
{
|
472 |
_form = '_'+_match[1];
|
473 |
_to = _match[2]*1;
|
474 |
+
bookmark = bookmark.replace(_match[0],'');
|
475 |
+
|
476 |
+
if(!(_form in $.fbuilder.forms)){setHistoryEntry = true; continue;}
|
477 |
+
if('currentPage' in $.fbuilder.forms[_form]) continue;
|
478 |
if(
|
479 |
+
!$('#'+$.fbuilder.forms[_form].formId).hasClass('persist-form') ||
|
|
|
480 |
_to != $.fbuilder['goToPage'](
|
481 |
{
|
482 |
'formIdentifier' : _form,
|
485 |
}
|
486 |
)
|
487 |
) setHistoryEntry = true;
|
|
|
488 |
}
|
489 |
}
|
490 |
else
|
601 |
items = (typeof configObj[ 'fieldItentifier' ] != 'undefined' ) ? [ $.fbuilder[ 'forms' ][ identifier ].getItem(configObj[ 'fieldItentifier' ].replace(/_[cr]b\d+$/i, '')) ] : $.fbuilder[ 'forms' ][ identifier ].getItems();
|
602 |
|
603 |
process_items( items );
|
604 |
+
$( document ).trigger( 'showHideDepEvent', $.fbuilder[ 'forms' ][ identifier ][ 'formId' ] );
|
|
|
|
|
|
|
|
|
605 |
}
|
606 |
}
|
607 |
}; // End showHideDep
|
633 |
|
634 |
$.fbuilder.showHideDep(
|
635 |
{
|
636 |
+
'formIdentifier' : o.identifier
|
|
|
637 |
}
|
638 |
);
|
639 |
}
|
js/fields-admin/01_fbuilder.ftext.js
CHANGED
@@ -41,7 +41,10 @@
|
|
41 |
var str = '<option value="" '+(("" == $(this).attr("dvalue"))?"selected":"")+'></option>';
|
42 |
for (var i=0;i<items.length;i++)
|
43 |
{
|
44 |
-
if (
|
|
|
|
|
|
|
45 |
{
|
46 |
str += '<option value="'+$.fbuilder.htmlEncode(items[i].name)+'" '+((items[i].name == $(this).attr("dvalue"))?"selected":"")+'>'+(items[i].title)+'</option>';
|
47 |
}
|
41 |
var str = '<option value="" '+(("" == $(this).attr("dvalue"))?"selected":"")+'></option>';
|
42 |
for (var i=0;i<items.length;i++)
|
43 |
{
|
44 |
+
if (
|
45 |
+
$.inArray(items[i].ftype, ['ftext', 'femail', 'fpassword', 'ftextds', 'femailds']) != -1 &&
|
46 |
+
items[i].name != $(this).attr("dname")
|
47 |
+
)
|
48 |
{
|
49 |
str += '<option value="'+$.fbuilder.htmlEncode(items[i].name)+'" '+((items[i].name == $(this).attr("dvalue"))?"selected":"")+'>'+(items[i].title)+'</option>';
|
50 |
}
|
js/fields-admin/02_fbuilder.fnumber.js
CHANGED
@@ -23,7 +23,7 @@
|
|
23 |
max:"",
|
24 |
formatDynamically:false,
|
25 |
dformat:"digits",
|
26 |
-
formats:new Array("digits","number"),
|
27 |
display:function()
|
28 |
{
|
29 |
return '<div class="fields '+this.name+'" id="field'+this.form_identifier+'-'+this.index+'" title="'+this.name+'"><div class="arrow ui-icon ui-icon-play "></div><div title="Delete" class="remove ui-icon ui-icon-trash "></div><div title="Duplicate" class="copy ui-icon ui-icon-copy "></div><label>'+this.title+''+((this.required)?"*":"")+'</label><div class="dfield"><input class="field disabled '+this.size+'" type="text" value="'+$.fbuilder.htmlEncode(this.predefined)+'"/><span class="uh">'+this.userhelp+'</span></div><div class="clearer"></div></div>';
|
23 |
max:"",
|
24 |
formatDynamically:false,
|
25 |
dformat:"digits",
|
26 |
+
formats:new Array("digits","number", "percent"),
|
27 |
display:function()
|
28 |
{
|
29 |
return '<div class="fields '+this.name+'" id="field'+this.form_identifier+'-'+this.index+'" title="'+this.name+'"><div class="arrow ui-icon ui-icon-play "></div><div title="Delete" class="remove ui-icon ui-icon-trash "></div><div title="Duplicate" class="copy ui-icon ui-icon-copy "></div><label>'+this.title+''+((this.required)?"*":"")+'</label><div class="dfield"><input class="field disabled '+this.size+'" type="text" value="'+$.fbuilder.htmlEncode(this.predefined)+'"/><span class="uh">'+this.userhelp+'</span></div><div class="clearer"></div></div>';
|
js/fields-admin/03_fbuilder.femail.js
CHANGED
@@ -34,16 +34,19 @@
|
|
34 |
var str = '<option value="" '+(("" == $(this).attr("dvalue"))?"selected":"")+'></option>';
|
35 |
for (var i=0;i<items.length;i++)
|
36 |
{
|
37 |
-
if (
|
|
|
|
|
|
|
38 |
{
|
39 |
str += '<option value="'+items[i].name+'" '+((items[i].name == $(this).attr("dvalue"))?"selected":"")+'>'+(items[i].title)+'</option>';
|
40 |
-
}
|
41 |
-
}
|
42 |
$(this).html(str);
|
43 |
});
|
44 |
$.fbuilder.controls[ 'ffields' ].prototype.editItemEvents.call(this, evt);
|
45 |
},
|
46 |
-
showSpecialDataInstance: function()
|
47 |
{
|
48 |
var str = "";
|
49 |
return str;
|
34 |
var str = '<option value="" '+(("" == $(this).attr("dvalue"))?"selected":"")+'></option>';
|
35 |
for (var i=0;i<items.length;i++)
|
36 |
{
|
37 |
+
if (
|
38 |
+
$.inArray(items[i].ftype, ['ftext', 'femail', 'fpassword', 'ftextds', 'femailds']) != -1 &&
|
39 |
+
items[i].name != $(this).attr("dname")
|
40 |
+
)
|
41 |
{
|
42 |
str += '<option value="'+items[i].name+'" '+((items[i].name == $(this).attr("dvalue"))?"selected":"")+'>'+(items[i].title)+'</option>';
|
43 |
+
}
|
44 |
+
}
|
45 |
$(this).html(str);
|
46 |
});
|
47 |
$.fbuilder.controls[ 'ffields' ].prototype.editItemEvents.call(this, evt);
|
48 |
},
|
49 |
+
showSpecialDataInstance: function()
|
50 |
{
|
51 |
var str = "";
|
52 |
return str;
|
js/fields-admin/06_fbuilder.fcheck.js
CHANGED
@@ -215,9 +215,11 @@
|
|
215 |
showChoiceIntance: function()
|
216 |
{
|
217 |
this.choicesVal = ((typeof(this.choicesVal) != "undefined" && this.choicesVal !== null)?this.choicesVal:this.choices.slice(0));
|
218 |
-
var l = this.choices
|
219 |
-
|
220 |
-
|
|
|
|
|
221 |
if (!(typeof(this.choicesDep) != "undefined" && this.choicesDep !== null))
|
222 |
{
|
223 |
this.choicesDep = new Array();
|
@@ -226,20 +228,28 @@
|
|
226 |
this.choicesDep[i] = new Array();
|
227 |
}
|
228 |
}
|
229 |
-
var d = this.choicesDep
|
230 |
-
str = "";
|
231 |
for (var i=0;i<l.length;i++)
|
232 |
{
|
|
|
233 |
str += '<div class="choicesEdit"><input class="choice_check" i="'+i+'" type="checkbox" '+((this.choiceSelected[i])?"checked":"")+'/><input class="choice_text" i="'+i+'" type="text" name="sChoice'+this.name+'" id="sChoice'+this.name+'" value="'+$.fbuilder.htmlEncode($.fbuilder.htmlDecode(l[i]))+'"/><input class="choice_value" i="'+i+'" type="text" name="sChoice'+this.name+'V'+i+'" id="sChoice'+this.name+'V'+i+'" value="'+$.fbuilder.htmlEncode($.fbuilder.htmlDecode(lv[i]))+'"/><div class="choice-ctrls"><a class="choice_down ui-icon ui-icon-arrowthick-1-s" i="'+i+'" n="'+(l.length-1)+'" title="Down"></a><a class="choice_up ui-icon ui-icon-arrowthick-1-n" i="'+i+'" title="Up"></a><a class="choice_add ui-icon ui-icon-circle-plus" i="'+i+'" title="Add another choice."></a><a class="choice_remove ui-icon ui-icon-circle-minus" i="'+i+'" title="Delete this choice."></a></div></div>';
|
234 |
-
|
|
|
235 |
{
|
236 |
-
|
|
|
|
|
|
|
|
|
|
|
237 |
}
|
238 |
-
|
|
|
239 |
{
|
240 |
-
str += '<div class="choicesEditDep"><span>If selected show:</span> <select class="dependencies" i="'+i+'" j="'+
|
241 |
}
|
242 |
}
|
|
|
243 |
return '<div class="choicesSet '+((this.showDep)?"show":"hide")+'"><label>Choices</label> <a class="helpfbuilder dep" text="Dependencies are used to show/hide other fields depending of the option selected in this field.">help?</a> <a href="" class="showHideDependencies">'+((this.showDep)?"Hide":"Show")+' Dependencies</a><div><div class="t">Text</div><div class="t">Value</div><div class="clearer"></div></div>'+str+this.mergeValues()+this.attributeToSubmit()+this.maxChoices()+'</div>';
|
244 |
}
|
245 |
});
|
215 |
showChoiceIntance: function()
|
216 |
{
|
217 |
this.choicesVal = ((typeof(this.choicesVal) != "undefined" && this.choicesVal !== null)?this.choicesVal:this.choices.slice(0));
|
218 |
+
var l = this.choices,
|
219 |
+
lv = this.choicesVal,
|
220 |
+
v = this.choiceSelected,
|
221 |
+
str = '', str1, j,
|
222 |
+
reloadRequired = false;
|
223 |
if (!(typeof(this.choicesDep) != "undefined" && this.choicesDep !== null))
|
224 |
{
|
225 |
this.choicesDep = new Array();
|
228 |
this.choicesDep[i] = new Array();
|
229 |
}
|
230 |
}
|
231 |
+
var d = this.choicesDep;
|
|
|
232 |
for (var i=0;i<l.length;i++)
|
233 |
{
|
234 |
+
str1 = '';
|
235 |
str += '<div class="choicesEdit"><input class="choice_check" i="'+i+'" type="checkbox" '+((this.choiceSelected[i])?"checked":"")+'/><input class="choice_text" i="'+i+'" type="text" name="sChoice'+this.name+'" id="sChoice'+this.name+'" value="'+$.fbuilder.htmlEncode($.fbuilder.htmlDecode(l[i]))+'"/><input class="choice_value" i="'+i+'" type="text" name="sChoice'+this.name+'V'+i+'" id="sChoice'+this.name+'V'+i+'" value="'+$.fbuilder.htmlEncode($.fbuilder.htmlDecode(lv[i]))+'"/><div class="choice-ctrls"><a class="choice_down ui-icon ui-icon-arrowthick-1-s" i="'+i+'" n="'+(l.length-1)+'" title="Down"></a><a class="choice_up ui-icon ui-icon-arrowthick-1-n" i="'+i+'" title="Up"></a><a class="choice_add ui-icon ui-icon-circle-plus" i="'+i+'" title="Add another choice."></a><a class="choice_remove ui-icon ui-icon-circle-minus" i="'+i+'" title="Delete this choice."></a></div></div>';
|
236 |
+
j = d[i].length;
|
237 |
+
if(j)
|
238 |
{
|
239 |
+
while(j--)
|
240 |
+
{
|
241 |
+
if(d[i][j].length && $('.'+d[i][j]).length == 0){ reloadRequired = true; d[i].splice(j,1); continue;}
|
242 |
+
str1 = '<div class="choicesEditDep"><span>If selected show:</span> <select class="dependencies" i="'+i+'" j="'+j+'" dname="'+this.name+'" dvalue="'+d[i][j]+'" ></select><div class="choice-ctrls"><a class="choice_addDep ui-icon ui-icon-circle-plus" i="'+i+'" j="'+j+'" title="Add another dependency."></a><a class="choice_removeDep ui-icon ui-icon-circle-minus" i="'+i+'" j="'+j+'" title="Delete this dependency."></a></div></div>'+str1;
|
243 |
+
}
|
244 |
+
str += str1;
|
245 |
}
|
246 |
+
j = d[i].length;
|
247 |
+
if(!j)
|
248 |
{
|
249 |
+
str += '<div class="choicesEditDep"><span>If selected show:</span> <select class="dependencies" i="'+i+'" j="'+j+'" dname="'+this.name+'" dvalue="" ></select><div class="choice-ctrls"><a class="choice_addDep ui-icon ui-icon-circle-plus" i="'+i+'" j="'+j+'" title="Add another dependency."></a><a class="choice_removeDep ui-icon ui-icon-circle-minus" i="'+i+'" j="'+j+'" title="Delete this dependency."></a></div></div>';
|
250 |
}
|
251 |
}
|
252 |
+
if(reloadRequired) $.fbuilder.reloadItems({'field':this});
|
253 |
return '<div class="choicesSet '+((this.showDep)?"show":"hide")+'"><label>Choices</label> <a class="helpfbuilder dep" text="Dependencies are used to show/hide other fields depending of the option selected in this field.">help?</a> <a href="" class="showHideDependencies">'+((this.showDep)?"Hide":"Show")+' Dependencies</a><div><div class="t">Text</div><div class="t">Value</div><div class="clearer"></div></div>'+str+this.mergeValues()+this.attributeToSubmit()+this.maxChoices()+'</div>';
|
254 |
}
|
255 |
});
|
js/fields-admin/07_fbuilder.fradio.js
CHANGED
@@ -1,225 +1,235 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
{
|
23 |
-
this.
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
var str = "";
|
31 |
-
for (var i=0;i<this.choices.length;i++)
|
32 |
{
|
33 |
-
|
34 |
-
}
|
35 |
-
return '<div class="fields '+this.name+'" id="field'+this.form_identifier+'-'+this.index+'" title="'+this.name+'"><div class="arrow ui-icon ui-icon-play "></div><div title="Delete" class="remove ui-icon ui-icon-trash "></div><div title="Duplicate" class="copy ui-icon ui-icon-copy "></div><label>'+this.title+''+((this.required)?"*":"")+'</label><div class="dfield">'+str+'<span class="uh">'+this.userhelp+'</span></div><div class="clearer"></div></div>';
|
36 |
-
},
|
37 |
-
editItemEvents:function()
|
38 |
-
{
|
39 |
-
$(".choice_text").bind("change keyup", {obj: this}, function(e)
|
40 |
-
{
|
41 |
-
if (e.data.obj.choices[$(this).attr("i")] == e.data.obj.choicesVal[$(this).attr("i")])
|
42 |
-
{
|
43 |
-
$("#"+$(this).attr("id")+"V"+$(this).attr("i")).val($(this).val());
|
44 |
-
e.data.obj.choicesVal[$(this).attr("i")]= $(this).val();
|
45 |
-
}
|
46 |
-
e.data.obj.choices[$(this).attr("i")]= $(this).val();
|
47 |
-
$.fbuilder.reloadItems({'field':e.data.obj});
|
48 |
-
});
|
49 |
-
$(".choice_value").bind("change keyup", {obj: this}, function(e)
|
50 |
{
|
|
|
51 |
e.data.obj.choicesVal[$(this).attr("i")]= $(this).val();
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
{
|
74 |
-
e.data.obj.choices.splice(i-1, 0, e.data.obj.choices.splice(i, 1)[0]);
|
75 |
-
e.data.obj.choicesVal.splice(i-1, 0, e.data.obj.choicesVal.splice(i, 1)[0]);
|
76 |
-
e.data.obj.choicesDep.splice(i-1, 0, e.data.obj.choicesDep.splice(i, 1)[0]);
|
77 |
-
}
|
78 |
-
$.fbuilder.editItem(e.data.obj.index);
|
79 |
-
$.fbuilder.reloadItems({'field':e.data.obj});
|
80 |
-
});
|
81 |
-
$(".choice_down").bind("click", {obj: this}, function(e)
|
82 |
{
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
{
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
});
|
107 |
-
$(".choice_addDep").bind("click", {obj: this}, function(e)
|
108 |
{
|
109 |
-
e.data.obj.choicesDep[$(this).attr("i")]
|
110 |
-
|
111 |
-
|
112 |
-
});
|
113 |
-
$(".choice_remove").bind("click", {obj: this}, function(e)
|
114 |
{
|
115 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
116 |
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
{
|
130 |
-
e.data.obj.choices.splice(i,1);
|
131 |
-
e.data.obj.choicesVal.splice(i,1);
|
132 |
-
e.data.obj.choicesDep.splice(i,1);
|
133 |
-
}
|
134 |
-
$.fbuilder.editItem(e.data.obj.index);
|
135 |
-
$.fbuilder.reloadItems({'field':e.data.obj});
|
136 |
-
});
|
137 |
-
$(".choice_add").bind("click", {obj: this}, function(e)
|
138 |
{
|
139 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
140 |
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
|
|
|
|
148 |
{
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
}
|
156 |
-
else
|
157 |
-
{
|
158 |
-
$(this).parent().addClass("show");
|
159 |
-
$(this).parent().removeClass("hide");
|
160 |
-
$(this).html("Hide Dependencies");
|
161 |
-
e.data.obj.showDep = true;
|
162 |
-
}
|
163 |
-
return false;
|
164 |
-
});
|
165 |
-
$('.dependencies').bind("change", {obj: this}, function(e)
|
166 |
{
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
175 |
{
|
176 |
-
|
177 |
-
for (var i=0;i<items.length;i++)
|
178 |
{
|
179 |
-
|
180 |
-
{
|
181 |
-
str += '<option value="'+items[i].name+'" '+((items[i].name == $(this).attr("dvalue"))?"selected":"")+'>'+(items[i].name)+ ( ( typeof items[i].title != 'undefined' ) ? ' (' + items[i].title + ')' : '' ) + ' </option>';
|
182 |
-
}
|
183 |
}
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
193 |
{
|
194 |
-
|
195 |
-
|
196 |
-
|
|
|
|
|
|
|
|
|
|
|
197 |
{
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
if
|
202 |
{
|
203 |
-
|
204 |
-
for (var i=0;i<l.length;i++)
|
205 |
{
|
206 |
-
|
|
|
207 |
}
|
|
|
208 |
}
|
209 |
-
|
210 |
-
|
211 |
-
for (var i=0;i<l.length;i++)
|
212 |
{
|
213 |
-
str += '<div class="
|
214 |
-
for (var j=0;j<d[i].length;j++)
|
215 |
-
{
|
216 |
-
str += '<div class="choicesEditDep"><span>If selected show:</span> <select class="dependencies" i="'+i+'" j="'+j+'" dname="'+this.name+'" dvalue="'+d[i][j]+'" ></select><div class="choice-ctrls"><a class="choice_addDep ui-icon ui-icon-circle-plus" i="'+i+'" j="'+j+'" title="Add another dependency."></a><a class="choice_removeDep ui-icon ui-icon-circle-minus" i="'+i+'" j="'+j+'" title="Delete this dependency."></a></div></div>';
|
217 |
-
}
|
218 |
-
if (d[i].length==0)
|
219 |
-
{
|
220 |
-
str += '<div class="choicesEditDep"><span>If selected show:</span> <select class="dependencies" i="'+i+'" j="'+d[i].length+'" dname="'+this.name+'" dvalue="" ></select><div class="choice-ctrls"><a class="choice_addDep ui-icon ui-icon-circle-plus" i="'+i+'" j="'+d[i].length+'" title="Add another dependency."></a><a class="choice_removeDep ui-icon ui-icon-circle-minus" i="'+i+'" j="'+d[i].length+'" title="Delete this dependency."></a></div></div>';
|
221 |
-
}
|
222 |
}
|
223 |
-
return '<div class="choicesSet '+((this.showDep)?"show":"hide")+'"><label>Choices</label> <a class="helpfbuilder dep" text="Dependencies are used to show/hide other fields depending of the option selected in this field.">help?</a> <a href="" class="showHideDependencies">'+((this.showDep)?"Hide":"Show")+' Dependencies</a><div><div class="t">Text</div><div class="t">Value</div><div class="clearer"></div></div>'+str+this.attributeToSubmit()+this.allowUntick()+'</div>';
|
224 |
}
|
225 |
-
|
|
|
|
|
|
1 |
+
$.fbuilder.typeList.push(
|
2 |
+
{
|
3 |
+
id:"fradio",
|
4 |
+
name:"Radio Buttons",
|
5 |
+
control_category:1
|
6 |
+
}
|
7 |
+
);
|
8 |
+
$.fbuilder.controls[ 'fradio' ] = function(){};
|
9 |
+
$.extend(
|
10 |
+
$.fbuilder.controls[ 'fradio' ].prototype,
|
11 |
+
$.fbuilder.controls[ 'ffields' ].prototype,
|
12 |
+
{
|
13 |
+
title:"Select a Choice",
|
14 |
+
ftype:"fradio",
|
15 |
+
layout:"one_column",
|
16 |
+
required:false,
|
17 |
+
toSubmit:'text',
|
18 |
+
choiceSelected:"",
|
19 |
+
showDep:false,
|
20 |
+
untickAccepted:true,
|
21 |
+
init:function()
|
22 |
+
{
|
23 |
+
this.choices = new Array("First Choice","Second Choice","Third Choice");
|
24 |
+
this.choicesVal = new Array("First Choice","Second Choice","Third Choice");
|
25 |
+
this.choicesDep = new Array(new Array(),new Array(),new Array());
|
26 |
+
},
|
27 |
+
display:function()
|
28 |
+
{
|
29 |
+
this.choicesVal = ((typeof(this.choicesVal) != "undefined" && this.choicesVal !== null)?this.choicesVal:this.choices.slice(0));
|
30 |
+
var str = "";
|
31 |
+
for (var i=0;i<this.choices.length;i++)
|
32 |
{
|
33 |
+
str += '<div class="'+this.layout+'"><input class="field" disabled="true" type="radio" i="'+i+'" '+(( this.choices[i]+' - '+this.choicesVal[i]==this.choiceSelected)?"checked":"")+'/> '+$.fbuilder.htmlDecode( this.choices[i] )+'</div>';
|
34 |
+
}
|
35 |
+
return '<div class="fields '+this.name+'" id="field'+this.form_identifier+'-'+this.index+'" title="'+this.name+'"><div class="arrow ui-icon ui-icon-play "></div><div title="Delete" class="remove ui-icon ui-icon-trash "></div><div title="Duplicate" class="copy ui-icon ui-icon-copy "></div><label>'+this.title+''+((this.required)?"*":"")+'</label><div class="dfield">'+str+'<span class="uh">'+this.userhelp+'</span></div><div class="clearer"></div></div>';
|
36 |
+
},
|
37 |
+
editItemEvents:function()
|
38 |
+
{
|
39 |
+
$(".choice_text").bind("change keyup", {obj: this}, function(e)
|
|
|
|
|
40 |
{
|
41 |
+
if (e.data.obj.choices[$(this).attr("i")] == e.data.obj.choicesVal[$(this).attr("i")])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
{
|
43 |
+
$("#"+$(this).attr("id")+"V"+$(this).attr("i")).val($(this).val());
|
44 |
e.data.obj.choicesVal[$(this).attr("i")]= $(this).val();
|
45 |
+
}
|
46 |
+
e.data.obj.choices[$(this).attr("i")]= $(this).val();
|
47 |
+
$.fbuilder.reloadItems({'field':e.data.obj});
|
48 |
+
});
|
49 |
+
$(".choice_value").bind("change keyup", {obj: this}, function(e)
|
50 |
+
{
|
51 |
+
e.data.obj.choicesVal[$(this).attr("i")]= $(this).val();
|
52 |
+
$.fbuilder.reloadItems({'field':e.data.obj});
|
53 |
+
});
|
54 |
+
$(".choice_radio").bind("mousedown", function(){$(this).data('previous-status', $(this).is(':checked'));});
|
55 |
+
$(".choice_radio").bind("click", {obj: this}, function(e)
|
56 |
+
{
|
57 |
+
var el = $(this),
|
58 |
+
i = el.attr("i");
|
59 |
|
60 |
+
el.prop('checked', !el.data('previous-status'));
|
61 |
+
e.data.obj.choiceSelected = (el.is(':checked')) ? e.data.obj.choices[i] + ' - ' + e.data.obj.choicesVal[i] : "";
|
62 |
+
$.fbuilder.reloadItems({'field':e.data.obj});
|
63 |
+
});
|
64 |
+
$("#sLayout").bind("change", {obj: this}, function(e)
|
65 |
+
{
|
66 |
+
e.data.obj.layout = $(this).val();
|
67 |
+
$.fbuilder.reloadItems({'field':e.data.obj});
|
68 |
+
});
|
69 |
+
$(".choice_up").bind("click", {obj: this}, function(e)
|
70 |
+
{
|
71 |
+
var i = $(this).attr("i")*1;
|
72 |
+
if (i!=0)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
73 |
{
|
74 |
+
e.data.obj.choices.splice(i-1, 0, e.data.obj.choices.splice(i, 1)[0]);
|
75 |
+
e.data.obj.choicesVal.splice(i-1, 0, e.data.obj.choicesVal.splice(i, 1)[0]);
|
76 |
+
e.data.obj.choicesDep.splice(i-1, 0, e.data.obj.choicesDep.splice(i, 1)[0]);
|
77 |
+
}
|
78 |
+
$.fbuilder.editItem(e.data.obj.index);
|
79 |
+
$.fbuilder.reloadItems({'field':e.data.obj});
|
80 |
+
});
|
81 |
+
$(".choice_down").bind("click", {obj: this}, function(e)
|
82 |
+
{
|
83 |
+
var i = $(this).attr("i")*1;
|
84 |
+
var n = $(this).attr("n")*1;
|
85 |
+
if (i!=n)
|
86 |
{
|
87 |
+
e.data.obj.choices.splice(i, 0, e.data.obj.choices.splice(i+1, 1)[0]);
|
88 |
+
e.data.obj.choicesVal.splice(i, 0, e.data.obj.choicesVal.splice(i+1, 1)[0]);
|
89 |
+
e.data.obj.choicesDep.splice(i, 0, e.data.obj.choicesDep.splice(i+1, 1)[0]);
|
90 |
+
}
|
91 |
+
$.fbuilder.editItem(e.data.obj.index);
|
92 |
+
$.fbuilder.reloadItems({'field':e.data.obj});
|
93 |
+
});
|
94 |
+
$(".choice_removeDep").bind("click", {obj: this}, function(e)
|
95 |
+
{
|
96 |
+
if (e.data.obj.choices.length==1)
|
|
|
|
|
97 |
{
|
98 |
+
e.data.obj.choicesDep[$(this).attr("i")][0]="";
|
99 |
+
}
|
100 |
+
else
|
|
|
|
|
101 |
{
|
102 |
+
e.data.obj.choicesDep[$(this).attr("i")].splice($(this).attr("j"),1);
|
103 |
+
}
|
104 |
+
$.fbuilder.editItem(e.data.obj.index);
|
105 |
+
$.fbuilder.reloadItems({'field':e.data.obj});
|
106 |
+
});
|
107 |
+
$(".choice_addDep").bind("click", {obj: this}, function(e)
|
108 |
+
{
|
109 |
+
e.data.obj.choicesDep[$(this).attr("i")].splice($(this).attr("j")*1+1,0,"");
|
110 |
+
$.fbuilder.editItem(e.data.obj.index);
|
111 |
+
$.fbuilder.reloadItems({'field':e.data.obj});
|
112 |
+
});
|
113 |
+
$(".choice_remove").bind("click", {obj: this}, function(e)
|
114 |
+
{
|
115 |
+
var i = $(this).attr("i");
|
116 |
|
117 |
+
if( e.data.obj.choices[ i ] + ' - ' + e.data.obj.choicesVal[ i ] == e.data.obj.choiceSelected )
|
118 |
+
{
|
119 |
+
e.data.obj.choiceSelected = "";
|
120 |
+
}
|
121 |
|
122 |
+
if (e.data.obj.choices.length==1)
|
123 |
+
{
|
124 |
+
e.data.obj.choices[0]="";
|
125 |
+
e.data.obj.choicesVal[0]="";
|
126 |
+
e.data.obj.choicesDep[0]=new Array();
|
127 |
+
}
|
128 |
+
else
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
129 |
{
|
130 |
+
e.data.obj.choices.splice(i,1);
|
131 |
+
e.data.obj.choicesVal.splice(i,1);
|
132 |
+
e.data.obj.choicesDep.splice(i,1);
|
133 |
+
}
|
134 |
+
$.fbuilder.editItem(e.data.obj.index);
|
135 |
+
$.fbuilder.reloadItems({'field':e.data.obj});
|
136 |
+
});
|
137 |
+
$(".choice_add").bind("click", {obj: this}, function(e)
|
138 |
+
{
|
139 |
+
var i = $(this).attr("i")*1+1;
|
140 |
|
141 |
+
e.data.obj.choices.splice(i,0,"");
|
142 |
+
e.data.obj.choicesVal.splice(i,0,"");
|
143 |
+
e.data.obj.choicesDep.splice(i,0,new Array());
|
144 |
+
$.fbuilder.editItem(e.data.obj.index);
|
145 |
+
$.fbuilder.reloadItems({'field':e.data.obj});
|
146 |
+
});
|
147 |
+
$(".showHideDependencies").bind("click", {obj: this}, function(e)
|
148 |
+
{
|
149 |
+
if (e.data.obj.showDep)
|
150 |
{
|
151 |
+
$(this).parent().removeClass("show");
|
152 |
+
$(this).parent().addClass("hide");
|
153 |
+
$(this).html("Show Dependencies");
|
154 |
+
e.data.obj.showDep = false;
|
155 |
+
}
|
156 |
+
else
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
157 |
{
|
158 |
+
$(this).parent().addClass("show");
|
159 |
+
$(this).parent().removeClass("hide");
|
160 |
+
$(this).html("Hide Dependencies");
|
161 |
+
e.data.obj.showDep = true;
|
162 |
+
}
|
163 |
+
return false;
|
164 |
+
});
|
165 |
+
$('.dependencies').bind("change", {obj: this}, function(e)
|
166 |
+
{
|
167 |
+
e.data.obj.choicesDep[$(this).attr("i")][$(this).attr("j")] = $(this).val();
|
168 |
+
$.fbuilder.reloadItems({'field':e.data.obj});
|
169 |
+
});
|
170 |
+
var me = this,
|
171 |
+
items = me.fBuild.getItems(),
|
172 |
+
evt = [{s:'[name="sToSubmit"]', e:"click", l:"toSubmit"},
|
173 |
+
{s:'[name="sUntickAccepted"]',e:"click", l:"untickAccepted",f:function(el){return el.is(':checked');}}];
|
174 |
+
$('.dependencies').each(function()
|
175 |
+
{
|
176 |
+
var str = '<option value="" '+(("" == $(this).attr("dvalue"))?"selected":"")+'></option>';
|
177 |
+
for (var i=0;i<items.length;i++)
|
178 |
{
|
179 |
+
if (items[i].name != me.name && items[i].ftype != 'fPageBreak')
|
|
|
180 |
{
|
181 |
+
str += '<option value="'+items[i].name+'" '+((items[i].name == $(this).attr("dvalue"))?"selected":"")+'>'+(items[i].name)+ ( ( typeof items[i].title != 'undefined' ) ? ' (' + items[i].title + ')' : '' ) + ' </option>';
|
|
|
|
|
|
|
182 |
}
|
183 |
+
}
|
184 |
+
$(this).html(str);
|
185 |
+
});
|
186 |
+
$.fbuilder.controls[ 'ffields' ].prototype.editItemEvents.call(this,evt);
|
187 |
+
},
|
188 |
+
attributeToSubmit: function()
|
189 |
+
{
|
190 |
+
return '<div class="choicesSet"><label>Value to Submit</label><br /><div class="column width50"><label><input type="radio" name="sToSubmit" value="text" '+((this.toSubmit == 'text') ? ' CHECKED ' : '')+'/> Choice Text</label></div><div class="column width50"><label><input type="radio" name="sToSubmit" value="value" '+((this.toSubmit == 'value') ? ' CHECKED ' : '')+'/> Choice Value</label></div><div class="clearer"></div></div>';
|
191 |
+
},
|
192 |
+
allowUntick: function()
|
193 |
+
{
|
194 |
+
return '<div><label><input type="checkbox" name="sUntickAccepted" '+((this.untickAccepted) ? ' CHECKED ' : '')+'/> Allow Untick Choices</label></div>';
|
195 |
+
},
|
196 |
+
showChoiceIntance: function()
|
197 |
+
{
|
198 |
+
this.choicesVal = ((typeof(this.choicesVal) != "undefined" && this.choicesVal !== null)?this.choicesVal:this.choices.slice(0));
|
199 |
+
var l = this.choices,
|
200 |
+
lv = this.choicesVal,
|
201 |
+
str = '', str1, j,
|
202 |
+
reloadRequired = false;
|
203 |
+
if (!(typeof(this.choicesDep) != "undefined" && this.choicesDep !== null))
|
204 |
{
|
205 |
+
this.choicesDep = new Array();
|
206 |
+
for (var i=0;i<l.length;i++)
|
207 |
+
{
|
208 |
+
this.choicesDep[i] = new Array();
|
209 |
+
}
|
210 |
+
}
|
211 |
+
var d = this.choicesDep;
|
212 |
+
for (var i=0;i<l.length;i++)
|
213 |
{
|
214 |
+
str1 = '';
|
215 |
+
str += '<div class="choicesEdit"><input class="choice_radio" i="'+i+'" type="radio" '+((this.choiceSelected==l[i]+' - '+lv[i])?"checked":"")+' name="choice_radio" /><input class="choice_text" i="'+i+'" type="text" name="sChoice'+this.name+'" id="sChoice'+this.name+'" value="'+$.fbuilder.htmlEncode($.fbuilder.htmlDecode(l[i]))+'"/><input class="choice_value" i="'+i+'" type="text" name="sChoice'+this.name+'V'+i+'" id="sChoice'+this.name+'V'+i+'" value="'+$.fbuilder.htmlEncode($.fbuilder.htmlDecode(lv[i]))+'"/><div class="choice-ctrls"><a class="choice_down ui-icon ui-icon-arrowthick-1-s" i="'+i+'" n="'+(l.length-1)+'" title="Down"></a><a class="choice_up ui-icon ui-icon-arrowthick-1-n" i="'+i+'" title="Up"></a><a class="choice_add ui-icon ui-icon-circle-plus" i="'+i+'" title="Add another choice."></a><a class="choice_remove ui-icon ui-icon-circle-minus" i="'+i+'" title="Delete this choice."></a></div></div>';
|
216 |
+
j = d[i].length;
|
217 |
+
if(j)
|
218 |
{
|
219 |
+
while(j--)
|
|
|
220 |
{
|
221 |
+
if(d[i][j].length && $('.'+d[i][j]).length == 0){ reloadRequired = true; d[i].splice(j,1); continue;}
|
222 |
+
str1 = '<div class="choicesEditDep"><span>If selected show:</span> <select class="dependencies" i="'+i+'" j="'+j+'" dname="'+this.name+'" dvalue="'+d[i][j]+'" ></select><div class="choice-ctrls"><a class="choice_addDep ui-icon ui-icon-circle-plus" i="'+i+'" j="'+j+'" title="Add another dependency."></a><a class="choice_removeDep ui-icon ui-icon-circle-minus" i="'+i+'" j="'+j+'" title="Delete this dependency."></a></div></div>'+str1;
|
223 |
}
|
224 |
+
str += str1;
|
225 |
}
|
226 |
+
j = d[i].length;
|
227 |
+
if(!j)
|
|
|
228 |
{
|
229 |
+
str += '<div class="choicesEditDep"><span>If selected show:</span> <select class="dependencies" i="'+i+'" j="'+j+'" dname="'+this.name+'" dvalue="" ></select><div class="choice-ctrls"><a class="choice_addDep ui-icon ui-icon-circle-plus" i="'+i+'" j="'+j+'" title="Add another dependency."></a><a class="choice_removeDep ui-icon ui-icon-circle-minus" i="'+i+'" j="'+j+'" title="Delete this dependency."></a></div></div>';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
230 |
}
|
|
|
231 |
}
|
232 |
+
if(reloadRequired) $.fbuilder.reloadItems({'field':this});
|
233 |
+
return '<div class="choicesSet '+((this.showDep)?"show":"hide")+'"><label>Choices</label> <a class="helpfbuilder dep" text="Dependencies are used to show/hide other fields depending of the option selected in this field.">help?</a> <a href="" class="showHideDependencies">'+((this.showDep)?"Hide":"Show")+' Dependencies</a><div><div class="t">Text</div><div class="t">Value</div><div class="clearer"></div></div>'+str+this.attributeToSubmit()+this.allowUntick()+'</div>';
|
234 |
+
}
|
235 |
+
});
|
js/fields-admin/08_fbuilder.fdropdown.js
CHANGED
@@ -221,7 +221,9 @@
|
|
221 |
|
222 |
var l = this.choices,
|
223 |
lv = this.choicesVal,
|
224 |
-
og = this.optgroup
|
|
|
|
|
225 |
|
226 |
if (!(typeof(this.choicesDep) != "undefined" && this.choicesDep !== null))
|
227 |
{
|
@@ -232,22 +234,30 @@
|
|
232 |
}
|
233 |
}
|
234 |
var d = this.choicesDep;
|
235 |
-
var str = "";
|
236 |
for (var i=0;i<l.length;i++)
|
237 |
{
|
|
|
238 |
if(typeof og[i] == 'undefined') og[i] = false;
|
239 |
|
240 |
str += '<div class="choicesEdit"><input class="choice_select" i="'+i+'" type="radio" '+((this.choiceSelected==l[i]+' - '+lv[i])?"checked":"")+' name="choice_select" /><input class="choice_text" i="'+i+'" type="text" name="sChoice'+this.name+'" id="sChoice'+this.name+'" value="'+$.fbuilder.htmlEncode(l[i])+'"/><input class="choice_value" i="'+i+'" type="text" name="sChoice'+this.name+'V'+i+'" id="sChoice'+this.name+'V'+i+'" value="'+$.fbuilder.htmlEncode(lv[i])+'"/><input type="checkbox" name="optgroup" i="'+i+'" '+((og[i]) ? ' CHECKED ' : '' )+' class="choice_optgroup" /><div class="choice-ctrls"><a class="choice_down ui-icon ui-icon-arrowthick-1-s" i="'+i+'" n="'+(l.length-1)+'" title="Down"></a><a class="choice_up ui-icon ui-icon-arrowthick-1-n" i="'+i+'" title="Up"></a><a class="choice_add ui-icon ui-icon-circle-plus" i="'+i+'" title="Add another choice."></a><a class="choice_remove ui-icon ui-icon-circle-minus" i="'+i+'" title="Delete this choice."></a></div></div>';
|
241 |
|
242 |
-
|
|
|
243 |
{
|
244 |
-
|
|
|
|
|
|
|
|
|
|
|
245 |
}
|
246 |
-
|
|
|
247 |
{
|
248 |
-
str += '<div class="choicesEditDep"><span>If selected show:</span> <select class="dependencies" i="'+i+'" j="'+
|
249 |
}
|
250 |
}
|
|
|
251 |
return '<div class="choicesSet '+((this.showDep)?"show":"hide")+'"><label>Choices</label> <a class="helpfbuilder dep" text="Dependencies are used to show/hide other fields depending of the option selected in this field.">help?</a> <a href="" class="showHideDependencies">'+((this.showDep)?"Hide":"Show")+' Dependencies</a><div><div class="t">Text</div><div class="t">Value</div><div>optgroup</div><div class="clearer"></div></div>'+str+this.mergeValues()+this.attributeToSubmit()+this.multipleSelection()+'</div>';
|
252 |
}
|
253 |
});
|
221 |
|
222 |
var l = this.choices,
|
223 |
lv = this.choicesVal,
|
224 |
+
og = this.optgroup,
|
225 |
+
str = '', str1, j,
|
226 |
+
reloadRequired = false;
|
227 |
|
228 |
if (!(typeof(this.choicesDep) != "undefined" && this.choicesDep !== null))
|
229 |
{
|
234 |
}
|
235 |
}
|
236 |
var d = this.choicesDep;
|
|
|
237 |
for (var i=0;i<l.length;i++)
|
238 |
{
|
239 |
+
str1 = '';
|
240 |
if(typeof og[i] == 'undefined') og[i] = false;
|
241 |
|
242 |
str += '<div class="choicesEdit"><input class="choice_select" i="'+i+'" type="radio" '+((this.choiceSelected==l[i]+' - '+lv[i])?"checked":"")+' name="choice_select" /><input class="choice_text" i="'+i+'" type="text" name="sChoice'+this.name+'" id="sChoice'+this.name+'" value="'+$.fbuilder.htmlEncode(l[i])+'"/><input class="choice_value" i="'+i+'" type="text" name="sChoice'+this.name+'V'+i+'" id="sChoice'+this.name+'V'+i+'" value="'+$.fbuilder.htmlEncode(lv[i])+'"/><input type="checkbox" name="optgroup" i="'+i+'" '+((og[i]) ? ' CHECKED ' : '' )+' class="choice_optgroup" /><div class="choice-ctrls"><a class="choice_down ui-icon ui-icon-arrowthick-1-s" i="'+i+'" n="'+(l.length-1)+'" title="Down"></a><a class="choice_up ui-icon ui-icon-arrowthick-1-n" i="'+i+'" title="Up"></a><a class="choice_add ui-icon ui-icon-circle-plus" i="'+i+'" title="Add another choice."></a><a class="choice_remove ui-icon ui-icon-circle-minus" i="'+i+'" title="Delete this choice."></a></div></div>';
|
243 |
|
244 |
+
j = d[i].length;
|
245 |
+
if(j)
|
246 |
{
|
247 |
+
while(j--)
|
248 |
+
{
|
249 |
+
if(d[i][j].length && $('.'+d[i][j]).length == 0){ reloadRequired = true; d[i].splice(j,1); continue;}
|
250 |
+
str1 = '<div class="choicesEditDep"><span>If selected show:</span> <select class="dependencies" i="'+i+'" j="'+j+'" dname="'+this.name+'" dvalue="'+d[i][j]+'" ></select><div class="choice-ctrls"><a class="choice_addDep ui-icon ui-icon-circle-plus" i="'+i+'" j="'+j+'" title="Add another dependency."></a><a class="choice_removeDep ui-icon ui-icon-circle-minus" i="'+i+'" j="'+j+'" title="Delete this dependency."></a></div></div>'+str1;
|
251 |
+
}
|
252 |
+
str += str1;
|
253 |
}
|
254 |
+
j = d[i].length;
|
255 |
+
if(!j)
|
256 |
{
|
257 |
+
str += '<div class="choicesEditDep"><span>If selected show:</span> <select class="dependencies" i="'+i+'" j="'+j+'" dname="'+this.name+'" dvalue="" ></select><div class="choice-ctrls"><a class="choice_addDep ui-icon ui-icon-circle-plus" i="'+i+'" j="'+j+'" title="Add another dependency."></a><a class="choice_removeDep ui-icon ui-icon-circle-minus" i="'+i+'" j="'+j+'" title="Delete this dependency."></a></div></div>';
|
258 |
}
|
259 |
}
|
260 |
+
if(reloadRequired) $.fbuilder.reloadItems({'field':this});
|
261 |
return '<div class="choicesSet '+((this.showDep)?"show":"hide")+'"><label>Choices</label> <a class="helpfbuilder dep" text="Dependencies are used to show/hide other fields depending of the option selected in this field.">help?</a> <a href="" class="showHideDependencies">'+((this.showDep)?"Hide":"Show")+' Dependencies</a><div><div class="t">Text</div><div class="t">Value</div><div>optgroup</div><div class="clearer"></div></div>'+str+this.mergeValues()+this.attributeToSubmit()+this.multipleSelection()+'</div>';
|
262 |
}
|
263 |
});
|
js/fields-admin/10_fbuilder.fpassword.js
CHANGED
@@ -37,16 +37,19 @@
|
|
37 |
var str = '<option value="" '+(("" == $(this).attr("dvalue"))?"selected":"")+'></option>';
|
38 |
for (var i=0;i<items.length;i++)
|
39 |
{
|
40 |
-
if (
|
|
|
|
|
|
|
41 |
{
|
42 |
str += '<option value="'+items[i].name+'" '+((items[i].name == $(this).attr("dvalue"))?"selected":"")+'>'+(items[i].title)+'</option>';
|
43 |
}
|
44 |
-
}
|
45 |
$(this).html(str);
|
46 |
-
});
|
47 |
$.fbuilder.controls[ 'ffields' ].prototype.editItemEvents.call(this,evt);
|
48 |
},
|
49 |
-
showSpecialDataInstance: function()
|
50 |
{
|
51 |
return '<div class="column"><label>Min length/characters</label><br /><input name="sMinlength" id="sMinlength" value="'+$.fbuilder.htmlEncode(this.minlength)+'"></div><div class="column"><label>Max length/characters</label><br /><input name="sMaxlength" id="sMaxlength" value="'+$.fbuilder.htmlEncode(this.maxlength)+'"></div><div class="clearer"></div>';
|
52 |
}
|
37 |
var str = '<option value="" '+(("" == $(this).attr("dvalue"))?"selected":"")+'></option>';
|
38 |
for (var i=0;i<items.length;i++)
|
39 |
{
|
40 |
+
if (
|
41 |
+
$.inArray(items[i].ftype, ['ftext', 'femail', 'fpassword', 'ftextds', 'femailds']) != -1 &&
|
42 |
+
items[i].name != $(this).attr("dname")
|
43 |
+
)
|
44 |
{
|
45 |
str += '<option value="'+items[i].name+'" '+((items[i].name == $(this).attr("dvalue"))?"selected":"")+'>'+(items[i].title)+'</option>';
|
46 |
}
|
47 |
+
}
|
48 |
$(this).html(str);
|
49 |
+
});
|
50 |
$.fbuilder.controls[ 'ffields' ].prototype.editItemEvents.call(this,evt);
|
51 |
},
|
52 |
+
showSpecialDataInstance: function()
|
53 |
{
|
54 |
return '<div class="column"><label>Min length/characters</label><br /><input name="sMinlength" id="sMinlength" value="'+$.fbuilder.htmlEncode(this.minlength)+'"></div><div class="column"><label>Max length/characters</label><br /><input name="sMaxlength" id="sMaxlength" value="'+$.fbuilder.htmlEncode(this.maxlength)+'"></div><div class="clearer"></div>';
|
55 |
}
|
js/fields-public/02_fbuilder.fnumber.js
CHANGED
@@ -55,7 +55,7 @@
|
|
55 |
|
56 |
}
|
57 |
parts[0] = str;
|
58 |
-
return s+parts.join(ds);
|
59 |
}
|
60 |
else
|
61 |
{
|
@@ -69,14 +69,15 @@
|
|
69 |
},
|
70 |
show:function()
|
71 |
{
|
72 |
-
var _type = ( this.dformat == 'digits' || ( /^$/.test( this.thousandSeparator ) && /^\s*(\.\s*)?$/.test( this.decimalSymbol ) ) ) ? 'number' : 'text';
|
73 |
|
74 |
-
return '<div class="fields '+this.csslayout+' '+this.name+' cff-number-field" id="field'+this.form_identifier+'-'+this.index+'"><label for="'+this.name+'">'+this.title+''+((this.required)?"<span class='r'>*</span>":"")+'</label><div class="dfield"><input id="'+this.name+'" name="'+this.name+'" '+( ( !/^\s*$/.test( this.min) ) ? 'min="'+$.fbuilder.parseVal( this._getAttr('min'), this.thousandSeparator, this.decimalSymbol )+'" ' : '' )+( ( !/^\s*$/.test(this.max) ) ? ' max="'+$.fbuilder.parseVal( this._getAttr('max'), this.thousandSeparator, this.decimalSymbol )+'" ' : '' )+' class="field '+this.dformat+' '+this.size+((this.required)?" required":"")+'" type="'+_type+'" value="'+$.fbuilder.htmlEncode((this.formatDynamically) ? this.getFormattedValue(this.predefined) : this.predefined)+'" '+((this.readonly)?'readonly':'')+' /><span class="uh">'+this.userhelp+'</span></div><div class="clearer"></div></div>';
|
75 |
},
|
76 |
after_show:function()
|
77 |
{
|
78 |
var me = this;
|
79 |
-
|
|
|
80 |
{
|
81 |
$( document ).on( 'change', '[name="' + me.name + '"]', function(){
|
82 |
this.value = me.getFormattedValue( this.value );
|
@@ -85,7 +86,6 @@
|
|
85 |
|
86 |
if( typeof $[ 'validator' ] != 'undefined' )
|
87 |
{
|
88 |
-
|
89 |
$.validator.methods.number = function(v, el)
|
90 |
{
|
91 |
var f = el.id.match(/_\d+$/),
|
@@ -95,8 +95,7 @@
|
|
95 |
if(f) e = $.fbuilder['forms'][f[0]].getItem(el.name);
|
96 |
if(!e) e = {thousandSeparator: ',', decimalSymbol: '.'};
|
97 |
|
98 |
-
r = new RegExp('^\\s*\\-?\\d+('+esc(e.thousandSeparator)+'\\d{3})*('+esc(e.decimalSymbol)+'\\d+)?\\s*$','i');
|
99 |
-
|
100 |
return this.optional(el) || r.test(v) || $.isNumeric(v);
|
101 |
};
|
102 |
$.validator.methods.min = function(v, el, p)
|
@@ -126,7 +125,8 @@
|
|
126 |
{
|
127 |
var v = $.trim( e.val() );
|
128 |
if(raw) return ($.isNumeric(v) && this.thousandSeparator != '.') ? v : $.fbuilder.parseValStr(v, raw);
|
129 |
-
|
|
|
130 |
}
|
131 |
return 0;
|
132 |
}
|
55 |
|
56 |
}
|
57 |
parts[0] = str;
|
58 |
+
return s+parts.join(ds)+((this.dformat == 'percent') ? '%':'');
|
59 |
}
|
60 |
else
|
61 |
{
|
69 |
},
|
70 |
show:function()
|
71 |
{
|
72 |
+
var _type = ( this.dformat == 'digits' || ( this.dformat != 'percent' && /^$/.test( this.thousandSeparator ) && /^\s*(\.\s*)?$/.test( this.decimalSymbol ) ) ) ? 'number' : 'text';
|
73 |
|
74 |
+
return '<div class="fields '+this.csslayout+' '+this.name+' cff-number-field" id="field'+this.form_identifier+'-'+this.index+'"><label for="'+this.name+'">'+this.title+''+((this.required)?"<span class='r'>*</span>":"")+'</label><div class="dfield"><input id="'+this.name+'" name="'+this.name+'" '+( ( !/^\s*$/.test( this.min) ) ? 'min="'+$.fbuilder.parseVal( this._getAttr('min'), this.thousandSeparator, this.decimalSymbol )+'" ' : '' )+( ( !/^\s*$/.test(this.max) ) ? ' max="'+$.fbuilder.parseVal( this._getAttr('max'), this.thousandSeparator, this.decimalSymbol )+'" ' : '' )+' class="field '+this.dformat+((this.dformat == 'percent') ? ' number' : '')+' '+this.size+((this.required)?" required":"")+'" type="'+_type+'" value="'+$.fbuilder.htmlEncode((this.formatDynamically) ? this.getFormattedValue(this.predefined) : this.predefined)+'" '+((this.readonly)?'readonly':'')+' /><span class="uh">'+this.userhelp+'</span></div><div class="clearer"></div></div>';
|
75 |
},
|
76 |
after_show:function()
|
77 |
{
|
78 |
var me = this;
|
79 |
+
|
80 |
+
if( (me.formatDynamically && me.dformat != 'digits') || me.dformat == 'percent')
|
81 |
{
|
82 |
$( document ).on( 'change', '[name="' + me.name + '"]', function(){
|
83 |
this.value = me.getFormattedValue( this.value );
|
86 |
|
87 |
if( typeof $[ 'validator' ] != 'undefined' )
|
88 |
{
|
|
|
89 |
$.validator.methods.number = function(v, el)
|
90 |
{
|
91 |
var f = el.id.match(/_\d+$/),
|
95 |
if(f) e = $.fbuilder['forms'][f[0]].getItem(el.name);
|
96 |
if(!e) e = {thousandSeparator: ',', decimalSymbol: '.'};
|
97 |
|
98 |
+
r = new RegExp('^\\s*\\-?\\d+('+esc(e.thousandSeparator)+'\\d{3})*('+esc(e.decimalSymbol)+'\\d+)?\\s*\\%?\\s*$','i');
|
|
|
99 |
return this.optional(el) || r.test(v) || $.isNumeric(v);
|
100 |
};
|
101 |
$.validator.methods.min = function(v, el, p)
|
125 |
{
|
126 |
var v = $.trim( e.val() );
|
127 |
if(raw) return ($.isNumeric(v) && this.thousandSeparator != '.') ? v : $.fbuilder.parseValStr(v, raw);
|
128 |
+
v = $.fbuilder.parseVal(v, this.thousandSeparator, this.decimalSymbol);
|
129 |
+
return (this.dformat == 'percent') ? v/100 : v;
|
130 |
}
|
131 |
return 0;
|
132 |
}
|
js/fields-public/06_fbuilder.fcheck.js
CHANGED
@@ -52,7 +52,7 @@
|
|
52 |
showHideDep:function( toShow, toHide, hiddenByContainer )
|
53 |
{
|
54 |
var me = this,
|
55 |
-
item = $( '[id*="'+me.name+'"]' ),
|
56 |
form_identifier = me.form_identifier,
|
57 |
isHidden = (typeof toHide[ me.name ] != 'undefined' || typeof hiddenByContainer[ me.name ] != 'undefined' ),
|
58 |
result = [];
|
@@ -132,6 +132,19 @@
|
|
132 |
$( '[id*="'+n+'"][vt="'+t+'"],[id*="'+n+'"][value="'+t+'"]' ).prop( 'checked', true );
|
133 |
}
|
134 |
$( '[id*="'+n+'"]' ).change();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
135 |
}
|
136 |
}
|
137 |
);
|
52 |
showHideDep:function( toShow, toHide, hiddenByContainer )
|
53 |
{
|
54 |
var me = this,
|
55 |
+
item = $( 'input[id*="'+me.name+'"]' ),
|
56 |
form_identifier = me.form_identifier,
|
57 |
isHidden = (typeof toHide[ me.name ] != 'undefined' || typeof hiddenByContainer[ me.name ] != 'undefined' ),
|
58 |
result = [];
|
132 |
$( '[id*="'+n+'"][vt="'+t+'"],[id*="'+n+'"][value="'+t+'"]' ).prop( 'checked', true );
|
133 |
}
|
134 |
$( '[id*="'+n+'"]' ).change();
|
135 |
+
},
|
136 |
+
setChoices:function(choices)
|
137 |
+
{
|
138 |
+
if($.isPlainObject(choices))
|
139 |
+
{
|
140 |
+
var bk = this.val(true);
|
141 |
+
if('texts' in choices && $.isArray(choices.texts)) this.choices = choices.texts;
|
142 |
+
if('values' in choices && $.isArray(choices.values)) this.choicesVal = choices.values;
|
143 |
+
if('dependencies' in choices && $.isArray(choices.dependencies)) this.choicesDep = choices.dependencies;
|
144 |
+
var html = this.show(),
|
145 |
+
field = $('.'+this.name).replaceWith(html);
|
146 |
+
this.setVal(bk);
|
147 |
+
}
|
148 |
}
|
149 |
}
|
150 |
);
|
js/fields-public/07_fbuilder.fradio.js
CHANGED
@@ -59,7 +59,7 @@
|
|
59 |
showHideDep:function( toShow, toHide, hiddenByContainer )
|
60 |
{
|
61 |
var me = this,
|
62 |
-
item = $( '[id*="'+me.name+'"]' ),
|
63 |
form_identifier = me.form_identifier,
|
64 |
isHidden = ( typeof toHide[ me.name ] != 'undefined' || typeof hiddenByContainer[ me.name ] != 'undefined' ),
|
65 |
result = [];
|
@@ -123,6 +123,19 @@
|
|
123 |
$( '[id*="'+n+'"]' ).prop( 'checked', false );
|
124 |
$( '[id*="'+n+'"][vt="'+t+'"],[id*="'+n+'"][value="'+t+'"]' ).prop( 'checked', true );
|
125 |
$( '[id*="'+n+'"]' ).change();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
126 |
}
|
127 |
}
|
128 |
);
|
59 |
showHideDep:function( toShow, toHide, hiddenByContainer )
|
60 |
{
|
61 |
var me = this,
|
62 |
+
item = $( 'input[id*="'+me.name+'"]' ),
|
63 |
form_identifier = me.form_identifier,
|
64 |
isHidden = ( typeof toHide[ me.name ] != 'undefined' || typeof hiddenByContainer[ me.name ] != 'undefined' ),
|
65 |
result = [];
|
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 |
+
{
|
129 |
+
if($.isPlainObject(choices))
|
130 |
+
{
|
131 |
+
var bk = this.val(true);
|
132 |
+
if('texts' in choices && $.isArray(choices.texts)) this.choices = choices.texts;
|
133 |
+
if('values' in choices && $.isArray(choices.values)) this.choicesVal = choices.values;
|
134 |
+
if('dependencies' in choices && $.isArray(choices.dependencies)) this.choicesDep = choices.dependencies;
|
135 |
+
var html = this.show(),
|
136 |
+
field = $('.'+this.name).replaceWith(html);
|
137 |
+
this.setVal(bk);
|
138 |
+
}
|
139 |
}
|
140 |
}
|
141 |
);
|
js/fields-public/08_fbuilder.fdropdown.js
CHANGED
@@ -147,6 +147,20 @@
|
|
147 |
|
148 |
}
|
149 |
$( '[id="'+n+'"]' ).change();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
150 |
}
|
151 |
}
|
152 |
);
|
147 |
|
148 |
}
|
149 |
$( '[id="'+n+'"]' ).change();
|
150 |
+
},
|
151 |
+
setChoices:function(choices)
|
152 |
+
{
|
153 |
+
if($.isPlainObject(choices))
|
154 |
+
{
|
155 |
+
var bk = this.val(true);
|
156 |
+
if('texts' in choices && $.isArray(choices.texts)) this.choices = choices.texts;
|
157 |
+
if('values' in choices && $.isArray(choices.values)) this.choicesVal = choices.values;
|
158 |
+
if('dependencies' in choices && $.isArray(choices.dependencies)) this.choicesDep = choices.dependencies;
|
159 |
+
if('optgroup' in choices && $.isArray(choices.optgroup)) this.optgroup = choices.optgroup;
|
160 |
+
var html = this.show(),
|
161 |
+
field = $('.'+this.name).replaceWith(html);
|
162 |
+
this.setVal(bk);
|
163 |
+
}
|
164 |
}
|
165 |
}
|
166 |
);
|
js/fields-public/32_fbuilder.fbutton.js
CHANGED
@@ -37,7 +37,7 @@
|
|
37 |
var suffix = e.attr( 'id' ).match(/_\d+$/)[0],
|
38 |
items = $.fbuilder[ 'forms' ][ suffix ].getItems();
|
39 |
|
40 |
-
$.fbuilder[ 'calculator' ].defaultCalc( '#'+e.closest( 'form' ).attr( 'id' ) );
|
41 |
for(var i = 0, h = items.length; i < h; i++ )
|
42 |
{
|
43 |
if(items[i].ftype == 'fsummary')
|
37 |
var suffix = e.attr( 'id' ).match(/_\d+$/)[0],
|
38 |
items = $.fbuilder[ 'forms' ][ suffix ].getItems();
|
39 |
|
40 |
+
$.fbuilder[ 'calculator' ].defaultCalc( '#'+e.closest( 'form' ).attr( 'id' ), false );
|
41 |
for(var i = 0, h = items.length; i < h; i++ )
|
42 |
{
|
43 |
if(items[i].ftype == 'fsummary')
|
js/fields-public/fbuilder.fcalculated.js
CHANGED
@@ -61,13 +61,12 @@
|
|
61 |
'calcualtedfield_changed',
|
62 |
{obj: me},
|
63 |
function( evt ){
|
64 |
-
if( $.fbuilder[ 'calculator' ].getDepList( evt.data.obj.name, evt.data.obj.val(), evt.data.obj.dependencies ) )
|
65 |
{
|
66 |
$.fbuilder.showHideDep(
|
67 |
{
|
68 |
'formIdentifier' : evt.data.obj.form_identifier,
|
69 |
-
'fieldIdentifier': evt.data.obj.name
|
70 |
-
'throwEvent' : false
|
71 |
}
|
72 |
);
|
73 |
}
|
@@ -79,7 +78,7 @@
|
|
79 |
var me = this,
|
80 |
result = [];
|
81 |
|
82 |
-
if($.fbuilder[ 'calculator' ].getDepList(me.name, me.val(), me.dependencies))
|
83 |
{
|
84 |
var item = $( '#'+me.name ),
|
85 |
identifier = me.form_identifier,
|
@@ -348,20 +347,20 @@
|
|
348 |
}
|
349 |
}
|
350 |
},
|
351 |
-
getDepList : function( calculated_field,
|
352 |
{
|
353 |
var list = [], // Fields that comply the rules
|
354 |
list_h = []; // Fields that don't comply the rules
|
355 |
|
356 |
// The value is correct and the field has dependencies
|
357 |
-
if( value !== false && dependencies.length )
|
358 |
{
|
359 |
for( var i = 0, h = dependencies.length; i < h; i++ )
|
360 |
{
|
361 |
try
|
362 |
{
|
363 |
// Get the rule and evaluate
|
364 |
-
var rule = eval(dependencies[i].rule.replace( /value/gi, value
|
365 |
$.each( dependencies[i].fields, function( j, e )
|
366 |
{
|
367 |
if( e != '' )
|
@@ -391,7 +390,7 @@
|
|
391 |
return list.length || list_h.length;
|
392 |
},
|
393 |
|
394 |
-
defaultCalc : function( form_identifier,
|
395 |
{
|
396 |
var form = $( form_identifier ),
|
397 |
fSec = form_identifier.match( /_\d+$/ )[0],
|
@@ -400,7 +399,11 @@
|
|
400 |
// The form exists and has equations
|
401 |
if( form.length )
|
402 |
{
|
403 |
-
if(
|
|
|
|
|
|
|
|
|
404 |
{
|
405 |
this.queued_equations[ fSec ] = form[0].equations.slice( 0 );
|
406 |
this.processQueue( fSec );
|
@@ -568,7 +571,16 @@
|
|
568 |
}
|
569 |
else
|
570 |
{
|
571 |
-
if( t.hasClass( 'depItem' )
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
572 |
{
|
573 |
return;
|
574 |
}
|
@@ -577,16 +589,23 @@
|
|
577 |
});
|
578 |
|
579 |
//Associate an event to the document waiting for the showHideDepEvent and recalculate all equations
|
580 |
-
$(document).
|
581 |
{
|
582 |
-
|
583 |
-
var f, evalequations;
|
584 |
if(form_identifier) f = $('#'+form_identifier);
|
585 |
else f = $('[id*="cp_calculatedfieldsf_pform_"]:eq(0)');
|
|
|
586 |
if(f.length)
|
587 |
{
|
|
|
|
|
588 |
evalequations = f.data( 'evalequations' );
|
589 |
-
if( typeof evalequations == 'undefined' || evalequations*1 == 1 )
|
|
|
|
|
|
|
|
|
590 |
}
|
591 |
});
|
592 |
return obj; // Return the public object
|
61 |
'calcualtedfield_changed',
|
62 |
{obj: me},
|
63 |
function( evt ){
|
64 |
+
if( $.fbuilder[ 'calculator' ].getDepList( evt.data.obj.name, {value: evt.data.obj.val(), raw: evt.data.obj.val(true)}, evt.data.obj.dependencies ) )
|
65 |
{
|
66 |
$.fbuilder.showHideDep(
|
67 |
{
|
68 |
'formIdentifier' : evt.data.obj.form_identifier,
|
69 |
+
'fieldIdentifier': evt.data.obj.name
|
|
|
70 |
}
|
71 |
);
|
72 |
}
|
78 |
var me = this,
|
79 |
result = [];
|
80 |
|
81 |
+
if($.fbuilder[ 'calculator' ].getDepList(me.name, {value: me.val(), raw: me.val(true)}, me.dependencies))
|
82 |
{
|
83 |
var item = $( '#'+me.name ),
|
84 |
identifier = me.form_identifier,
|
347 |
}
|
348 |
}
|
349 |
},
|
350 |
+
getDepList : function( calculated_field, values, dependencies ) // Get the list of dependent fields
|
351 |
{
|
352 |
var list = [], // Fields that comply the rules
|
353 |
list_h = []; // Fields that don't comply the rules
|
354 |
|
355 |
// The value is correct and the field has dependencies
|
356 |
+
if( values.value !== false && dependencies.length )
|
357 |
{
|
358 |
for( var i = 0, h = dependencies.length; i < h; i++ )
|
359 |
{
|
360 |
try
|
361 |
{
|
362 |
// Get the rule and evaluate
|
363 |
+
var rule = eval(dependencies[i].rule.replace(/value\|r/gi, values.raw).replace(/value/gi, values.value));
|
364 |
$.each( dependencies[i].fields, function( j, e )
|
365 |
{
|
366 |
if( e != '' )
|
390 |
return list.length || list_h.length;
|
391 |
},
|
392 |
|
393 |
+
defaultCalc : function( form_identifier, enqueued ) // Evaluate all equations in form
|
394 |
{
|
395 |
var form = $( form_identifier ),
|
396 |
fSec = form_identifier.match( /_\d+$/ )[0],
|
399 |
// The form exists and has equations
|
400 |
if( form.length )
|
401 |
{
|
402 |
+
if(enqueued)
|
403 |
+
{
|
404 |
+
this.processQueue( fSec );
|
405 |
+
}
|
406 |
+
else if( typeof form[0].equations != 'undefined' )
|
407 |
{
|
408 |
this.queued_equations[ fSec ] = form[0].equations.slice( 0 );
|
409 |
this.processQueue( fSec );
|
571 |
}
|
572 |
else
|
573 |
{
|
574 |
+
if( /*t.hasClass( 'depItem' ) ||*/
|
575 |
+
(
|
576 |
+
(
|
577 |
+
t.prop( 'tagName' ) == 'INPUT' &&
|
578 |
+
/(text|number|email|password)/.test(t.attr( 'type' ).toLowerCase()) ||
|
579 |
+
t.prop( 'tagName' ) == 'TEXTAREA'
|
580 |
+
) &&
|
581 |
+
evt.type != 'change'
|
582 |
+
)
|
583 |
+
)
|
584 |
{
|
585 |
return;
|
586 |
}
|
589 |
});
|
590 |
|
591 |
//Associate an event to the document waiting for the showHideDepEvent and recalculate all equations
|
592 |
+
$(document).on( 'showHideDepEvent', function( evt, form_identifier )
|
593 |
{
|
594 |
+
// If evalequations = 0 the equations shouldn't be evaluated dynamically
|
595 |
+
var f, evalequations, first_time;
|
596 |
if(form_identifier) f = $('#'+form_identifier);
|
597 |
else f = $('[id*="cp_calculatedfieldsf_pform_"]:eq(0)');
|
598 |
+
|
599 |
if(f.length)
|
600 |
{
|
601 |
+
first_time = (typeof f.data('first_time') == 'undefined');
|
602 |
+
f.data('first_time', 0);
|
603 |
evalequations = f.data( 'evalequations' );
|
604 |
+
if( typeof evalequations == 'undefined' || evalequations*1 == 1 )
|
605 |
+
{
|
606 |
+
if(first_time) obj.defaultCalc( '#'+f.attr('id') );
|
607 |
+
else obj.defaultCalc( '#'+f.attr('id'), true );
|
608 |
+
}
|
609 |
}
|
610 |
});
|
611 |
return obj; // Return the public object
|
js/jquery.validate.js
CHANGED
@@ -1,9 +1,13 @@
|
|
1 |
/*!
|
2 |
* jQuery Validation Plugin v1.17.0
|
3 |
*
|
|
|
|
|
|
|
|
|
4 |
* https://jqueryvalidation.org/
|
5 |
*
|
6 |
* Copyright (c) 2017 Jörn Zaefferer
|
7 |
* Released under the MIT license
|
8 |
*/
|
9 |
-
fbuilderjQuery=(typeof fbuilderjQuery!='undefined')?fbuilderjQuery:jQuery;(function(factory){if(typeof define==="function"&&define.amd){define(["fbuilderjQuery"],factory);}else if(typeof module==="object"&&module.exports){module.exports=factory(require("fbuilderjQuery"));}else{factory(fbuilderjQuery);}}(function($){$.extend($.fn,{validate:function(options){if(!this.length){if(options&&options.debug&&window.console){console.warn("Nothing selected, can't validate, returning nothing.");} return;} var validator=$.data(this[0],"validator");if(validator){return validator;} this.attr("novalidate","novalidate");validator=new $.validator(options,this[0]);$.data(this[0],"validator",validator);if(validator.settings.onsubmit){this.on("click.validate",":submit",function(event){validator.submitButton=event.currentTarget;if($(this).hasClass("cancel")){validator.cancelSubmit=true;} if($(this).attr("formnovalidate")!==undefined){validator.cancelSubmit=true;}});this.on("submit.validate",function(event){if(validator.settings.debug){event.preventDefault();} function handle(){var hidden,result;if(validator.submitButton&&(validator.settings.submitHandler||validator.formSubmitted)){hidden=$("<input type='hidden'/>").attr("name",validator.submitButton.name).val($(validator.submitButton).val()).appendTo(validator.currentForm);} if(validator.settings.submitHandler){result=validator.settings.submitHandler.call(validator,validator.currentForm,event);if(hidden){hidden.remove();} if(result!==undefined){return result;} return false;} return true;} if(validator.cancelSubmit){validator.cancelSubmit=false;return handle();} if(validator.form()){if(validator.pendingRequest){validator.formSubmitted=true;return false;} return handle();}else{validator.focusInvalid();return false;}});} return validator;},valid:function(){var valid,validator,errorList;if($(this[0]).is("form")){valid=this.validate().form();}else{errorList=[];valid=true;validator=$(this[0].form).validate();this.each(function(){valid=validator.element(this)&&valid;if(!valid){errorList=errorList.concat(validator.errorList);}});validator.errorList=errorList;} return valid;},rules:function(command,argument){var element=this[0],settings,staticRules,existingRules,data,param,filtered;if(element==null){return;} if(!element.form&&element.hasAttribute("contenteditable")){element.form=this.closest("form")[0];element.name=this.attr("name");} if(element.form==null){return;} if(command){settings=$.data(element.form,"validator").settings;staticRules=settings.rules;existingRules=$.validator.staticRules(element);switch(command){case"add":$.extend(existingRules,$.validator.normalizeRule(argument));delete existingRules.messages;staticRules[element.name]=existingRules;if(argument.messages){settings.messages[element.name]=$.extend(settings.messages[element.name],argument.messages);} break;case"remove":if(!argument){delete staticRules[element.name];return existingRules;} filtered={};$.each(argument.split(/\s/),function(index,method){filtered[method]=existingRules[method];delete existingRules[method];});return filtered;}} data=$.validator.normalizeRules($.extend({},$.validator.classRules(element),$.validator.attributeRules(element),$.validator.dataRules(element),$.validator.staticRules(element)),element);if(data.required){param=data.required;delete data.required;data=$.extend({required:param},data);} if(data.remote){param=data.remote;delete data.remote;data=$.extend(data,{remote:param});} return data;}});$.extend($.expr.pseudos||$.expr[":"],{blank:function(a){return!$.trim(""+$(a).val());},filled:function(a){var val=$(a).val();return val!==null&&!!$.trim(""+val);},unchecked:function(a){return!$(a).prop("checked");}});$.validator=function(options,form){this.settings=$.extend(true,{},$.validator.defaults,options);this.currentForm=form;this.init();};$.validator.format=function(source,params){if(arguments.length===1){return function(){var args=$.makeArray(arguments);args.unshift(source);return $.validator.format.apply(this,args);};} if(params===undefined){return source;} if(arguments.length>2&¶ms.constructor!==Array){params=$.makeArray(arguments).slice(1);} if(params.constructor!==Array){params=[params];} $.each(params,function(i,n){source=source.replace(new RegExp("\\{"+i+"\\}","g"),function(){return n;});});return source;};$.extend($.validator,{defaults:{messages:{},groups:{},rules:{},errorClass:"cpefb_error",pendingClass:"pending",validClass:"valid",errorElement:"label",focusCleanup:false,focusInvalid:true,errorContainer:$([]),errorLabelContainer:$([]),onsubmit:true,ignore:":hidden",ignoreTitle:false,onfocusin:function(element){this.lastActive=element;if(this.settings.focusCleanup){if(this.settings.unhighlight){this.settings.unhighlight.call(this,element,this.settings.errorClass,this.settings.validClass);} this.hideThese(this.errorsFor(element));}},onfocusout:function(element){if(!this.checkable(element)&&(element.name in this.submitted||!this.optional(element))){this.element(element);}},onkeyup:function(element,event){var excludedKeys=[16,17,18,20,35,36,37,38,39,40,45,144,225];if(event.which===9&&this.elementValue(element)===""||$.inArray(event.keyCode,excludedKeys)!==-1){return;}else if(element.name in this.submitted||element.name in this.invalid){this.element(element);}},onclick:function(element){if(element.name in this.submitted){this.element(element);}else if(element.parentNode.name in this.submitted){this.element(element.parentNode);}},highlight:function(element,errorClass,validClass){if(element.type==="radio"){this.findByName(element.name).addClass(errorClass).removeClass(validClass);}else{$(element).addClass(errorClass).removeClass(validClass);}},unhighlight:function(element,errorClass,validClass){if(element.type==="radio"){this.findByName(element.name).removeClass(errorClass).addClass(validClass);}else{$(element).removeClass(errorClass).addClass(validClass);}}},setDefaults:function(settings){$.extend($.validator.defaults,settings);},messages:{required:"This field is required.",remote:"Please fix this field.",email:"Please enter a valid email address.",url:"Please enter a valid URL.",date:"Please enter a valid date.",dateISO:"Please enter a valid date (ISO).",number:"Please enter a valid number.",digits:"Please enter only digits.",equalTo:"Please enter the same value again.",maxlength:$.validator.format("Please enter no more than {0} characters."),minlength:$.validator.format("Please enter at least {0} characters."),rangelength:$.validator.format("Please enter a value between {0} and {1} characters long."),range:$.validator.format("Please enter a value between {0} and {1}."),max:$.validator.format("Please enter a value less than or equal to {0}."),min:$.validator.format("Please enter a value greater than or equal to {0}."),step:$.validator.format("Please enter a multiple of {0}.")},autoCreateRanges:false,prototype:{init:function(){this.labelContainer=$(this.settings.errorLabelContainer);this.errorContext=this.labelContainer.length&&this.labelContainer||$(this.currentForm);this.containers=$(this.settings.errorContainer).add(this.settings.errorLabelContainer);this.submitted={};this.valueCache={};this.pendingRequest=0;this.pending={};this.invalid={};this.reset();var groups=(this.groups={}),rules;$.each(this.settings.groups,function(key,value){if(typeof value==="string"){value=value.split(/\s/);} $.each(value,function(index,name){groups[name]=key;});});rules=this.settings.rules;$.each(rules,function(key,value){rules[key]=$.validator.normalizeRule(value);});function delegate(event){if(!this.form&&this.hasAttribute("contenteditable")){this.form=$(this).closest("form")[0];this.name=$(this).attr("name");} var validator=$.data(this.form,"validator"),eventType="on"+event.type.replace(/^validate/,""),settings=validator.settings;if(settings[eventType]&&!$(this).is(settings.ignore)){settings[eventType].call(validator,this,event);}} $(this.currentForm).on("focusin.validate focusout.validate keyup.validate",":text, [type='password'], [type='file'], select, textarea, [type='number'], [type='search'], "+"[type='tel'], [type='url'], [type='email'], [type='datetime'], [type='date'], [type='month'], "+"[type='week'], [type='time'], [type='datetime-local'], [type='range'], [type='color'], "+"[type='radio'], [type='checkbox'], [contenteditable], [type='button']",delegate).on("click.validate","select, option, [type='radio'], [type='checkbox']",delegate);if(this.settings.invalidHandler){$(this.currentForm).on("invalid-form.validate",this.settings.invalidHandler);}},form:function(){this.checkForm();$.extend(this.submitted,this.errorMap);this.invalid=$.extend({},this.errorMap);if(!this.valid()){$(this.currentForm).triggerHandler("invalid-form",[this]);} this.showErrors();return this.valid();},checkForm:function(){this.prepareForm();for(var i=0,elements=(this.currentElements=this.elements());elements[i];i++){this.check(elements[i]);} return this.valid();},element:function(element){var cleanElement=this.clean(element),checkElement=this.validationTargetFor(cleanElement),v=this,result=true,rs,group;if(checkElement===undefined){delete this.invalid[cleanElement.name];}else{this.prepareElement(checkElement);this.currentElements=$(checkElement);group=this.groups[checkElement.name];if(group){$.each(this.groups,function(name,testgroup){if(testgroup===group&&name!==checkElement.name){cleanElement=v.validationTargetFor(v.clean(v.findByName(name)));if(cleanElement&&cleanElement.name in v.invalid){v.currentElements.push(cleanElement);result=v.check(cleanElement)&&result;}}});} rs=this.check(checkElement)!==false;result=result&&rs;if(rs){this.invalid[checkElement.name]=false;}else{this.invalid[checkElement.name]=true;} if(!this.numberOfInvalids()){this.toHide=this.toHide.add(this.containers);} this.showErrors();$(element).attr("aria-invalid",!rs);} return result;},showErrors:function(errors){if(errors){var validator=this;$.extend(this.errorMap,errors);this.errorList=$.map(this.errorMap,function(message,name){return{message:message,element:validator.findByName(name)[0]};});this.successList=$.grep(this.successList,function(element){return!(element.name in errors);});} if(this.settings.showErrors){this.settings.showErrors.call(this,this.errorMap,this.errorList);}else{this.defaultShowErrors();}},resetForm:function(){if($.fn.resetForm){$(this.currentForm).resetForm();} this.invalid={};this.submitted={};this.prepareForm();this.hideErrors();var elements=this.elements().removeData("previousValue").removeAttr("aria-invalid");this.resetElements(elements);},resetElements:function(elements){var i;if(this.settings.unhighlight){for(i=0;elements[i];i++){this.settings.unhighlight.call(this,elements[i],this.settings.errorClass,"");this.findByName(elements[i].name).removeClass(this.settings.validClass);}}else{elements.removeClass(this.settings.errorClass).removeClass(this.settings.validClass);}},numberOfInvalids:function(){return this.objectLength(this.invalid);},objectLength:function(obj){var count=0,i;for(i in obj){if(obj[i]!==undefined&&obj[i]!==null&&obj[i]!==false){count++;}} return count;},hideErrors:function(){this.hideThese(this.toHide);},hideThese:function(errors){errors.not(this.containers).text("");this.addWrapper(errors).hide();},valid:function(){return this.size()===0;},size:function(){return this.errorList.length;},focusInvalid:function(){if(this.settings.focusInvalid){try{$(this.findLastActive()||this.errorList.length&&this.errorList[0].element||[]).filter(":visible").focus().trigger("focusin");}catch(e){}}},findLastActive:function(){var lastActive=this.lastActive;return lastActive&&$.grep(this.errorList,function(n){return n.element.name===lastActive.name;}).length===1&&lastActive;},elements:function(){var validator=this,rulesCache={};return $(this.currentForm).find("input, select, textarea, [contenteditable]").not(":submit, :reset, :image, :disabled").not(this.settings.ignore).filter(function(){var name=this.name||$(this).attr("name");if(!name&&validator.settings.debug&&window.console){console.error("%o has no name assigned",this);} if(this.hasAttribute("contenteditable")){this.form=$(this).closest("form")[0];this.name=name;} if(name in rulesCache||!validator.objectLength($(this).rules())){return false;} rulesCache[name]=true;return true;});},clean:function(selector){return $(selector)[0];},errors:function(){var errorClass=this.settings.errorClass.split(" ").join(".");return $(this.settings.errorElement+"."+errorClass,this.errorContext);},resetInternals:function(){this.successList=[];this.errorList=[];this.errorMap={};this.toShow=$([]);this.toHide=$([]);},reset:function(){this.resetInternals();this.currentElements=$([]);},prepareForm:function(){this.reset();this.toHide=this.errors().add(this.containers);},prepareElement:function(element){this.reset();this.toHide=this.errorsFor(element);},elementValue:function(element){var $element=$(element),type=element.type,val,idx;if(type==="radio"||type==="checkbox"){return this.findByName(element.name).filter(":checked").val();}else if(type==="number"&&typeof element.validity!=="undefined"){return element.validity.badInput?"NaN":$element.val();} if(element.hasAttribute("contenteditable")){val=$element.text();}else{val=$element.val();} if(type==="file"){if(val.substr(0,12)==="C:\\fakepath\\"){return val.substr(12);} idx=val.lastIndexOf("/");if(idx>=0){return val.substr(idx+1);} idx=val.lastIndexOf("\\");if(idx>=0){return val.substr(idx+1);} return val;} if(typeof val==="string"){return val.replace(/\r/g,"");} return val;},check:function(element){element=this.validationTargetFor(this.clean(element));var rules=$(element).rules(),rulesCount=$.map(rules,function(n,i){return i;}).length,dependencyMismatch=false,val=this.elementValue(element),result,method,rule,normalizer;if(typeof rules.normalizer==="function"){normalizer=rules.normalizer;}else if(typeof this.settings.normalizer==="function"){normalizer=this.settings.normalizer;} if(normalizer){val=normalizer.call(element,val);if(typeof val!=="string"){throw new TypeError("The normalizer should return a string value.");} delete rules.normalizer;} for(method in rules){rule={method:method,parameters:rules[method]};try{result=$.validator.methods[method].call(this,val,element,rule.parameters);if(result==="dependency-mismatch"&&rulesCount===1){dependencyMismatch=true;continue;} dependencyMismatch=false;if(result==="pending"){this.toHide=this.toHide.not(this.errorsFor(element));return;} if(!result){this.formatAndAdd(element,rule);return false;}}catch(e){if(this.settings.debug&&window.console){console.log("Exception occurred when checking element "+element.id+", check the '"+rule.method+"' method.",e);} if(e instanceof TypeError){e.message+=". Exception occurred when checking element "+element.id+", check the '"+rule.method+"' method.";} throw e;}} if(dependencyMismatch){return;} if(this.objectLength(rules)){this.successList.push(element);} return true;},customDataMessage:function(element,method){return $(element).data("msg"+method.charAt(0).toUpperCase()+ method.substring(1).toLowerCase())||$(element).data("msg");},customMessage:function(name,method){var m=this.settings.messages[name];return m&&(m.constructor===String?m:m[method]);},findDefined:function(){for(var i=0;i<arguments.length;i++){if(arguments[i]!==undefined){return arguments[i];}} return undefined;},defaultMessage:function(element,rule){if(typeof rule==="string"){rule={method:rule};} var message=this.findDefined(this.customMessage(element.name,rule.method),this.customDataMessage(element,rule.method),!this.settings.ignoreTitle&&element.title||undefined,$.validator.messages[rule.method],"<strong>Warning: No message defined for "+element.name+"</strong>"),theregex=/\$?\{(\d+)\}/g;if(typeof message==="function"){message=message.call(this,rule.parameters,element);}else if(theregex.test(message)){message=$.validator.format(message.replace(theregex,"{$1}"),rule.parameters);} return message;},formatAndAdd:function(element,rule){var message=this.defaultMessage(element,rule);this.errorList.push({message:message,element:element,method:rule.method});this.errorMap[element.name]=message;this.submitted[element.name]=message;},addWrapper:function(toToggle){if(this.settings.wrapper){toToggle=toToggle.add(toToggle.parent(this.settings.wrapper));} return toToggle;},defaultShowErrors:function(){var i,elements,error;for(i=0;this.errorList[i];i++){error=this.errorList[i];if(this.settings.highlight){this.settings.highlight.call(this,error.element,this.settings.errorClass,this.settings.validClass);} this.showLabel(error.element,error.message);} if(this.errorList.length){this.toShow=this.toShow.add(this.containers);} if(this.settings.success){for(i=0;this.successList[i];i++){this.showLabel(this.successList[i]);}} if(this.settings.unhighlight){for(i=0,elements=this.validElements();elements[i];i++){this.settings.unhighlight.call(this,elements[i],this.settings.errorClass,this.settings.validClass);}} this.toHide=this.toHide.not(this.toShow);this.hideErrors();this.addWrapper(this.toShow).show();},validElements:function(){return this.currentElements.not(this.invalidElements());},invalidElements:function(){return $(this.errorList).map(function(){return this.element;});},showLabel:function(element,message){var place,group,errorID,v,error=this.errorsFor(element),elementID=this.idOrName(element),describedBy=$(element).attr("aria-describedby");if(error.length){error.removeClass(this.settings.validClass).addClass(this.settings.errorClass);error.html(message);}else{error=$("<"+this.settings.errorElement+">").attr("id",elementID+"-error").addClass(this.settings.errorClass).html(message||"");place=error;if(this.settings.wrapper){place=error.hide().show().wrap("<"+this.settings.wrapper+"/>").parent();} if(this.labelContainer.length){this.labelContainer.append(place);}else if(this.settings.errorPlacement){this.settings.errorPlacement.call(this,place,$(element));}else{place.insertAfter(element);} if(error.is("label")){error.attr("for",elementID);}else if(error.parents("label[for='"+this.escapeCssMeta(elementID)+"']").length===0){errorID=error.attr("id");if(!describedBy){describedBy=errorID;}else if(!describedBy.match(new RegExp("\\b"+this.escapeCssMeta(errorID)+"\\b"))){describedBy+=" "+errorID;} $(element).attr("aria-describedby",describedBy);group=this.groups[element.name];if(group){v=this;$.each(v.groups,function(name,testgroup){if(testgroup===group){$("[name='"+v.escapeCssMeta(name)+"']",v.currentForm).attr("aria-describedby",error.attr("id"));}});}}} if(!message&&this.settings.success){error.text("");if(typeof this.settings.success==="string"){error.addClass(this.settings.success);}else{this.settings.success(error,element);}} this.toShow=this.toShow.add(error);},errorsFor:function(element){var name=this.escapeCssMeta(this.idOrName(element)),describer=$(element).attr("aria-describedby"),selector="label[for='"+name+"'], label[for='"+name+"'] *";if(describer){selector=selector+", #"+this.escapeCssMeta(describer).replace(/\s+/g,", #");} return this.errors().filter(selector);},escapeCssMeta:function(string){return string.replace(/([\\!"#$%&'()*+,./:;<=>?@\[\]^`{|}~])/g,"\\$1");},idOrName:function(element){return this.groups[element.name]||(this.checkable(element)?element.name:element.id||element.name);},validationTargetFor:function(element){if(this.checkable(element)){element=this.findByName(element.name);} return $(element).not(this.settings.ignore)[0];},checkable:function(element){return(/radio|checkbox/i).test(element.type);},findByName:function(name){return $(this.currentForm).find("[name='"+this.escapeCssMeta(name)+"']");},getLength:function(value,element){switch(element.nodeName.toLowerCase()){case"select":return $("option:selected",element).length;case"input":if(this.checkable(element)){return this.findByName(element.name).filter(":checked").length;}} return value.length;},depend:function(param,element){return this.dependTypes[typeof param]?this.dependTypes[typeof param](param,element):true;},dependTypes:{"boolean":function(param){return param;},"string":function(param,element){return!!$(param,element.form).length;},"function":function(param,element){return param(element);}},optional:function(element){var val=this.elementValue(element);return!$.validator.methods.required.call(this,val,element)&&"dependency-mismatch";},startRequest:function(element){if(!this.pending[element.name]){this.pendingRequest++;$(element).addClass(this.settings.pendingClass);this.pending[element.name]=true;}},stopRequest:function(element,valid){this.pendingRequest--;if(this.pendingRequest<0){this.pendingRequest=0;} delete this.pending[element.name];$(element).removeClass(this.settings.pendingClass);if(valid&&this.pendingRequest===0&&this.formSubmitted&&this.form()){$(this.currentForm).submit();if(this.submitButton){$("input:hidden[name='"+this.submitButton.name+"']",this.currentForm).remove();} this.formSubmitted=false;}else if(!valid&&this.pendingRequest===0&&this.formSubmitted){$(this.currentForm).triggerHandler("invalid-form",[this]);this.formSubmitted=false;}},previousValue:function(element,method){method=typeof method==="string"&&method||"remote";return $.data(element,"previousValue")||$.data(element,"previousValue",{old:null,valid:true,message:this.defaultMessage(element,{method:method})});},destroy:function(){this.resetForm();$(this.currentForm).off(".validate").removeData("validator").find(".validate-equalTo-blur").off(".validate-equalTo").removeClass("validate-equalTo-blur");}},classRuleSettings:{required:{required:true},email:{email:true},url:{url:true},date:{date:true},dateISO:{dateISO:true},number:{number:true},digits:{digits:true},creditcard:{creditcard:true}},addClassRules:function(className,rules){if(className.constructor===String){this.classRuleSettings[className]=rules;}else{$.extend(this.classRuleSettings,className);}},classRules:function(element){var rules={},classes=$(element).attr("class");if(classes){$.each(classes.split(" "),function(){if(this in $.validator.classRuleSettings){$.extend(rules,$.validator.classRuleSettings[this]);}});} return rules;},normalizeAttributeRule:function(rules,type,method,value){if(/min|max|step/.test(method)&&(type===null||/number|range|text/.test(type))){if(!/^\s*$/.test(value))value=Number(value);if(isNaN(value)){value=undefined;}} if(value||value===0){rules[method]=value;}else if(type===method&&type!=="range"){rules[method]=true;}},attributeRules:function(element){var rules={},$element=$(element),type=element.getAttribute("type"),method,value;for(method in $.validator.methods){if(method==="required"){value=element.getAttribute(method);if(value===""){value=true;} value=!!value;}else{value=$element.attr(method);} this.normalizeAttributeRule(rules,type,method,value);} if(rules.maxlength&&/-1|2147483647|524288/.test(rules.maxlength)){delete rules.maxlength;} return rules;},dataRules:function(element){var rules={},$element=$(element),type=element.getAttribute("type"),method,value;for(method in $.validator.methods){value=$element.data("rule"+method.charAt(0).toUpperCase()+method.substring(1).toLowerCase());this.normalizeAttributeRule(rules,type,method,value);} return rules;},staticRules:function(element){var rules={},validator=$.data(element.form,"validator");if(validator.settings.rules){rules=$.validator.normalizeRule(validator.settings.rules[element.name])||{};} return rules;},normalizeRules:function(rules,element){$.each(rules,function(prop,val){if(val===false){delete rules[prop];return;} if(val.param||val.depends){var keepRule=true;switch(typeof val.depends){case"string":keepRule=!!$(val.depends,element.form).length;break;case"function":keepRule=val.depends.call(element,element);break;} if(keepRule){rules[prop]=val.param!==undefined?val.param:true;}else{$.data(element.form,"validator").resetElements($(element));delete rules[prop];}}});$.each(rules,function(rule,parameter){rules[rule]=$.isFunction(parameter)&&rule!=="normalizer"?parameter(element):parameter;});$.each(["minlength","maxlength"],function(){if(rules[this]){rules[this]=Number(rules[this]);}});$.each(["rangelength","range"],function(){var parts;if(rules[this]){if($.isArray(rules[this])){rules[this]=[Number(rules[this][0]),Number(rules[this][1])];}else if(typeof rules[this]==="string"){parts=rules[this].replace(/[\[\]]/g,"").split(/[\s,]+/);rules[this]=[Number(parts[0]),Number(parts[1])];}}});if($.validator.autoCreateRanges){if(rules.min!=null&&rules.max!=null){rules.range=[rules.min,rules.max];delete rules.min;delete rules.max;} if(rules.minlength!=null&&rules.maxlength!=null){rules.rangelength=[rules.minlength,rules.maxlength];delete rules.minlength;delete rules.maxlength;}} return rules;},normalizeRule:function(data){if(typeof data==="string"){var transformed={};$.each(data.split(/\s/),function(){transformed[this]=true;});data=transformed;} return data;},addMethod:function(name,method,message){$.validator.methods[name]=method;$.validator.messages[name]=message!==undefined?message:$.validator.messages[name];if(method.length<3){$.validator.addClassRules(name,$.validator.normalizeRule(name));}},methods:{required:function(value,element,param){if(!this.depend(param,element)){return"dependency-mismatch";} if(element.nodeName.toLowerCase()==="select"){var val=$(element).val();return val&&val.length>0;} if(this.checkable(element)){return this.getLength(value,element)>0;} return value.length>0;},email:function(value,element){return this.optional(element)||/^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/.test(value);},url:function(value,element){return this.optional(element)||/^(?:(?:(?:https?|ftp):)?\/\/)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,})).?)(?::\d{2,5})?(?:[/?#]\S*)?$/i.test(value);},date:function(value,element){return this.optional(element)||!/Invalid|NaN/.test(new Date(value).toString());},dateISO:function(value,element){return this.optional(element)||/^\d{4}[\/\-](0?[1-9]|1[012])[\/\-](0?[1-9]|[12][0-9]|3[01])$/.test(value);},number:function(value,element){return this.optional(element)||/^(?:-?\d+|-?\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/.test(value);},digits:function(value,element){return this.optional(element)||/^\d+$/.test(value);},minlength:function(value,element,param){var length=$.isArray(value)?value.length:this.getLength(value,element);return this.optional(element)||length>=param;},maxlength:function(value,element,param){var length=$.isArray(value)?value.length:this.getLength(value,element);return this.optional(element)||length<=param;},rangelength:function(value,element,param){var length=$.isArray(value)?value.length:this.getLength(value,element);return this.optional(element)||(length>=param[0]&&length<=param[1]);},min:function(value,element,param){return this.optional(element)||value>=param;},max:function(value,element,param){return this.optional(element)||value<=param;},range:function(value,element,param){return this.optional(element)||(value>=param[0]&&value<=param[1]);},step:function(value,element,param){var type=$(element).attr("type"),errorMessage="Step attribute on input type "+type+" is not supported.",supportedTypes=["text","number","range"],re=new RegExp("\\b"+type+"\\b"),notSupported=type&&!re.test(supportedTypes.join()),decimalPlaces=function(num){var match=(""+num).match(/(?:\.(\d+))?$/);if(!match){return 0;} return match[1]?match[1].length:0;},toInt=function(num){return Math.round(num*Math.pow(10,decimals));},valid=true,decimals;if(notSupported){throw new Error(errorMessage);} decimals=decimalPlaces(param);if(decimalPlaces(value)>decimals||toInt(value)%toInt(param)!==0){valid=false;} return this.optional(element)||valid;},equalTo:function(value,element,param){var target=$(param);if(this.settings.onfocusout&&target.not(".validate-equalTo-blur").length){target.addClass("validate-equalTo-blur").on("blur.validate-equalTo",function(){$(element).valid();});} return value===target.val();},remote:function(value,element,param,method){if(this.optional(element)){return"dependency-mismatch";} method=typeof method==="string"&&method||"remote";var previous=this.previousValue(element,method),validator,data,optionDataString;if(!this.settings.messages[element.name]){this.settings.messages[element.name]={};} previous.originalMessage=previous.originalMessage||this.settings.messages[element.name][method];this.settings.messages[element.name][method]=previous.message;param=typeof param==="string"&&{url:param}||param;optionDataString=$.param($.extend({data:value},param.data));if(previous.old===optionDataString){return previous.valid;} previous.old=optionDataString;validator=this;this.startRequest(element);data={};data[element.name]=value;$.ajax($.extend(true,{mode:"abort",port:"validate"+element.name,dataType:"json",data:data,context:validator.currentForm,success:function(response){var valid=response===true||response==="true",errors,message,submitted;validator.settings.messages[element.name][method]=previous.originalMessage;if(valid){submitted=validator.formSubmitted;validator.resetInternals();validator.toHide=validator.errorsFor(element);validator.formSubmitted=submitted;validator.successList.push(element);validator.invalid[element.name]=false;validator.showErrors();}else{errors={};message=response||validator.defaultMessage(element,{method:method,parameters:value});errors[element.name]=previous.message=message;validator.invalid[element.name]=true;validator.showErrors(errors);} previous.valid=valid;validator.stopRequest(element,valid);}},param));return"pending";}}});var pendingRequests={},ajax;if($.ajaxPrefilter){$.ajaxPrefilter(function(settings,_,xhr){var port=settings.port;if(settings.mode==="abort"){if(pendingRequests[port]){pendingRequests[port].abort();} pendingRequests[port]=xhr;}});}else{ajax=$.ajax;$.ajax=function(settings){var mode=("mode"in settings?settings:$.ajaxSettings).mode,port=("port"in settings?settings:$.ajaxSettings).port;if(mode==="abort"){if(pendingRequests[port]){pendingRequests[port].abort();} pendingRequests[port]=ajax.apply(this,arguments);return pendingRequests[port];} return ajax.apply(this,arguments);};} return $;}));
|
1 |
/*!
|
2 |
* jQuery Validation Plugin v1.17.0
|
3 |
*
|
4 |
+
* Modified by CodePeople on 2019/09/10, as follows:
|
5 |
+
* Original code: ,$.validator.messages[rule.method]
|
6 |
+
* Modification: ,this.messages&&this.messages[rule.method]||undefined,$.validator.messages[rule.method]
|
7 |
+
*
|
8 |
* https://jqueryvalidation.org/
|
9 |
*
|
10 |
* Copyright (c) 2017 Jörn Zaefferer
|
11 |
* Released under the MIT license
|
12 |
*/
|
13 |
+
fbuilderjQuery=(typeof fbuilderjQuery!='undefined')?fbuilderjQuery:jQuery;(function(factory){if(typeof define==="function"&&define.amd){define(["fbuilderjQuery"],factory);}else if(typeof module==="object"&&module.exports){module.exports=factory(require("fbuilderjQuery"));}else{factory(fbuilderjQuery);}}(function($){$.extend($.fn,{validate:function(options){if(!this.length){if(options&&options.debug&&window.console){console.warn("Nothing selected, can't validate, returning nothing.");} return;} var validator=$.data(this[0],"validator");if(validator){return validator;} this.attr("novalidate","novalidate");validator=new $.validator(options,this[0]);$.data(this[0],"validator",validator);if(validator.settings.onsubmit){this.on("click.validate",":submit",function(event){validator.submitButton=event.currentTarget;if($(this).hasClass("cancel")){validator.cancelSubmit=true;} if($(this).attr("formnovalidate")!==undefined){validator.cancelSubmit=true;}});this.on("submit.validate",function(event){if(validator.settings.debug){event.preventDefault();} function handle(){var hidden,result;if(validator.submitButton&&(validator.settings.submitHandler||validator.formSubmitted)){hidden=$("<input type='hidden'/>").attr("name",validator.submitButton.name).val($(validator.submitButton).val()).appendTo(validator.currentForm);} if(validator.settings.submitHandler){result=validator.settings.submitHandler.call(validator,validator.currentForm,event);if(hidden){hidden.remove();} if(result!==undefined){return result;} return false;} return true;} if(validator.cancelSubmit){validator.cancelSubmit=false;return handle();} if(validator.form()){if(validator.pendingRequest){validator.formSubmitted=true;return false;} return handle();}else{validator.focusInvalid();return false;}});} return validator;},valid:function(){var valid,validator,errorList;if($(this[0]).is("form")){valid=this.validate().form();}else{errorList=[];valid=true;validator=$(this[0].form).validate();this.each(function(){valid=validator.element(this)&&valid;if(!valid){errorList=errorList.concat(validator.errorList);}});validator.errorList=errorList;} return valid;},rules:function(command,argument){var element=this[0],settings,staticRules,existingRules,data,param,filtered;if(element==null){return;} if(!element.form&&element.hasAttribute("contenteditable")){element.form=this.closest("form")[0];element.name=this.attr("name");} if(element.form==null){return;} if(command){settings=$.data(element.form,"validator").settings;staticRules=settings.rules;existingRules=$.validator.staticRules(element);switch(command){case"add":$.extend(existingRules,$.validator.normalizeRule(argument));delete existingRules.messages;staticRules[element.name]=existingRules;if(argument.messages){settings.messages[element.name]=$.extend(settings.messages[element.name],argument.messages);} break;case"remove":if(!argument){delete staticRules[element.name];return existingRules;} filtered={};$.each(argument.split(/\s/),function(index,method){filtered[method]=existingRules[method];delete existingRules[method];});return filtered;}} data=$.validator.normalizeRules($.extend({},$.validator.classRules(element),$.validator.attributeRules(element),$.validator.dataRules(element),$.validator.staticRules(element)),element);if(data.required){param=data.required;delete data.required;data=$.extend({required:param},data);} if(data.remote){param=data.remote;delete data.remote;data=$.extend(data,{remote:param});} return data;}});$.extend($.expr.pseudos||$.expr[":"],{blank:function(a){return!$.trim(""+$(a).val());},filled:function(a){var val=$(a).val();return val!==null&&!!$.trim(""+val);},unchecked:function(a){return!$(a).prop("checked");}});$.validator=function(options,form){this.settings=$.extend(true,{},$.validator.defaults,options);this.currentForm=form;this.init();};$.validator.format=function(source,params){if(arguments.length===1){return function(){var args=$.makeArray(arguments);args.unshift(source);return $.validator.format.apply(this,args);};} if(params===undefined){return source;} if(arguments.length>2&¶ms.constructor!==Array){params=$.makeArray(arguments).slice(1);} if(params.constructor!==Array){params=[params];} $.each(params,function(i,n){source=source.replace(new RegExp("\\{"+i+"\\}","g"),function(){return n;});});return source;};$.extend($.validator,{defaults:{messages:{},groups:{},rules:{},errorClass:"cpefb_error",pendingClass:"pending",validClass:"valid",errorElement:"label",focusCleanup:false,focusInvalid:true,errorContainer:$([]),errorLabelContainer:$([]),onsubmit:true,ignore:":hidden",ignoreTitle:false,onfocusin:function(element){this.lastActive=element;if(this.settings.focusCleanup){if(this.settings.unhighlight){this.settings.unhighlight.call(this,element,this.settings.errorClass,this.settings.validClass);} this.hideThese(this.errorsFor(element));}},onfocusout:function(element){if(!this.checkable(element)&&(element.name in this.submitted||!this.optional(element))){this.element(element);}},onkeyup:function(element,event){var excludedKeys=[16,17,18,20,35,36,37,38,39,40,45,144,225];if(event.which===9&&this.elementValue(element)===""||$.inArray(event.keyCode,excludedKeys)!==-1){return;}else if(element.name in this.submitted||element.name in this.invalid){this.element(element);}},onclick:function(element){if(element.name in this.submitted){this.element(element);}else if(element.parentNode.name in this.submitted){this.element(element.parentNode);}},highlight:function(element,errorClass,validClass){if(element.type==="radio"){this.findByName(element.name).addClass(errorClass).removeClass(validClass);}else{$(element).addClass(errorClass).removeClass(validClass);}},unhighlight:function(element,errorClass,validClass){if(element.type==="radio"){this.findByName(element.name).removeClass(errorClass).addClass(validClass);}else{$(element).removeClass(errorClass).addClass(validClass);}}},setDefaults:function(settings){$.extend($.validator.defaults,settings);},messages:{required:"This field is required.",remote:"Please fix this field.",email:"Please enter a valid email address.",url:"Please enter a valid URL.",date:"Please enter a valid date.",dateISO:"Please enter a valid date (ISO).",number:"Please enter a valid number.",digits:"Please enter only digits.",equalTo:"Please enter the same value again.",maxlength:$.validator.format("Please enter no more than {0} characters."),minlength:$.validator.format("Please enter at least {0} characters."),rangelength:$.validator.format("Please enter a value between {0} and {1} characters long."),range:$.validator.format("Please enter a value between {0} and {1}."),max:$.validator.format("Please enter a value less than or equal to {0}."),min:$.validator.format("Please enter a value greater than or equal to {0}."),step:$.validator.format("Please enter a multiple of {0}.")},autoCreateRanges:false,prototype:{init:function(){this.labelContainer=$(this.settings.errorLabelContainer);this.errorContext=this.labelContainer.length&&this.labelContainer||$(this.currentForm);this.containers=$(this.settings.errorContainer).add(this.settings.errorLabelContainer);this.submitted={};this.valueCache={};this.pendingRequest=0;this.pending={};this.invalid={};this.reset();var groups=(this.groups={}),rules;$.each(this.settings.groups,function(key,value){if(typeof value==="string"){value=value.split(/\s/);} $.each(value,function(index,name){groups[name]=key;});});rules=this.settings.rules;$.each(rules,function(key,value){rules[key]=$.validator.normalizeRule(value);});function delegate(event){if(!this.form&&this.hasAttribute("contenteditable")){this.form=$(this).closest("form")[0];this.name=$(this).attr("name");} var validator=$.data(this.form,"validator"),eventType="on"+event.type.replace(/^validate/,""),settings=validator.settings;if(settings[eventType]&&!$(this).is(settings.ignore)){settings[eventType].call(validator,this,event);}} $(this.currentForm).on("focusin.validate focusout.validate keyup.validate",":text, [type='password'], [type='file'], select, textarea, [type='number'], [type='search'], "+"[type='tel'], [type='url'], [type='email'], [type='datetime'], [type='date'], [type='month'], "+"[type='week'], [type='time'], [type='datetime-local'], [type='range'], [type='color'], "+"[type='radio'], [type='checkbox'], [contenteditable], [type='button']",delegate).on("click.validate","select, option, [type='radio'], [type='checkbox']",delegate);if(this.settings.invalidHandler){$(this.currentForm).on("invalid-form.validate",this.settings.invalidHandler);}},form:function(){this.checkForm();$.extend(this.submitted,this.errorMap);this.invalid=$.extend({},this.errorMap);if(!this.valid()){$(this.currentForm).triggerHandler("invalid-form",[this]);} this.showErrors();return this.valid();},checkForm:function(){this.prepareForm();for(var i=0,elements=(this.currentElements=this.elements());elements[i];i++){this.check(elements[i]);} return this.valid();},element:function(element){var cleanElement=this.clean(element),checkElement=this.validationTargetFor(cleanElement),v=this,result=true,rs,group;if(checkElement===undefined){delete this.invalid[cleanElement.name];}else{this.prepareElement(checkElement);this.currentElements=$(checkElement);group=this.groups[checkElement.name];if(group){$.each(this.groups,function(name,testgroup){if(testgroup===group&&name!==checkElement.name){cleanElement=v.validationTargetFor(v.clean(v.findByName(name)));if(cleanElement&&cleanElement.name in v.invalid){v.currentElements.push(cleanElement);result=v.check(cleanElement)&&result;}}});} rs=this.check(checkElement)!==false;result=result&&rs;if(rs){this.invalid[checkElement.name]=false;}else{this.invalid[checkElement.name]=true;} if(!this.numberOfInvalids()){this.toHide=this.toHide.add(this.containers);} this.showErrors();$(element).attr("aria-invalid",!rs);} return result;},showErrors:function(errors){if(errors){var validator=this;$.extend(this.errorMap,errors);this.errorList=$.map(this.errorMap,function(message,name){return{message:message,element:validator.findByName(name)[0]};});this.successList=$.grep(this.successList,function(element){return!(element.name in errors);});} if(this.settings.showErrors){this.settings.showErrors.call(this,this.errorMap,this.errorList);}else{this.defaultShowErrors();}},resetForm:function(){if($.fn.resetForm){$(this.currentForm).resetForm();} this.invalid={};this.submitted={};this.prepareForm();this.hideErrors();var elements=this.elements().removeData("previousValue").removeAttr("aria-invalid");this.resetElements(elements);},resetElements:function(elements){var i;if(this.settings.unhighlight){for(i=0;elements[i];i++){this.settings.unhighlight.call(this,elements[i],this.settings.errorClass,"");this.findByName(elements[i].name).removeClass(this.settings.validClass);}}else{elements.removeClass(this.settings.errorClass).removeClass(this.settings.validClass);}},numberOfInvalids:function(){return this.objectLength(this.invalid);},objectLength:function(obj){var count=0,i;for(i in obj){if(obj[i]!==undefined&&obj[i]!==null&&obj[i]!==false){count++;}} return count;},hideErrors:function(){this.hideThese(this.toHide);},hideThese:function(errors){errors.not(this.containers).text("");this.addWrapper(errors).hide();},valid:function(){return this.size()===0;},size:function(){return this.errorList.length;},focusInvalid:function(){if(this.settings.focusInvalid){try{$(this.findLastActive()||this.errorList.length&&this.errorList[0].element||[]).filter(":visible").focus().trigger("focusin");}catch(e){}}},findLastActive:function(){var lastActive=this.lastActive;return lastActive&&$.grep(this.errorList,function(n){return n.element.name===lastActive.name;}).length===1&&lastActive;},elements:function(){var validator=this,rulesCache={};return $(this.currentForm).find("input, select, textarea, [contenteditable]").not(":submit, :reset, :image, :disabled").not(this.settings.ignore).filter(function(){var name=this.name||$(this).attr("name");if(!name&&validator.settings.debug&&window.console){console.error("%o has no name assigned",this);} if(this.hasAttribute("contenteditable")){this.form=$(this).closest("form")[0];this.name=name;} if(name in rulesCache||!validator.objectLength($(this).rules())){return false;} rulesCache[name]=true;return true;});},clean:function(selector){return $(selector)[0];},errors:function(){var errorClass=this.settings.errorClass.split(" ").join(".");return $(this.settings.errorElement+"."+errorClass,this.errorContext);},resetInternals:function(){this.successList=[];this.errorList=[];this.errorMap={};this.toShow=$([]);this.toHide=$([]);},reset:function(){this.resetInternals();this.currentElements=$([]);},prepareForm:function(){this.reset();this.toHide=this.errors().add(this.containers);},prepareElement:function(element){this.reset();this.toHide=this.errorsFor(element);},elementValue:function(element){var $element=$(element),type=element.type,val,idx;if(type==="radio"||type==="checkbox"){return this.findByName(element.name).filter(":checked").val();}else if(type==="number"&&typeof element.validity!=="undefined"){return element.validity.badInput?"NaN":$element.val();} if(element.hasAttribute("contenteditable")){val=$element.text();}else{val=$element.val();} if(type==="file"){if(val.substr(0,12)==="C:\\fakepath\\"){return val.substr(12);} idx=val.lastIndexOf("/");if(idx>=0){return val.substr(idx+1);} idx=val.lastIndexOf("\\");if(idx>=0){return val.substr(idx+1);} return val;} if(typeof val==="string"){return val.replace(/\r/g,"");} return val;},check:function(element){element=this.validationTargetFor(this.clean(element));var rules=$(element).rules(),rulesCount=$.map(rules,function(n,i){return i;}).length,dependencyMismatch=false,val=this.elementValue(element),result,method,rule,normalizer;if(typeof rules.normalizer==="function"){normalizer=rules.normalizer;}else if(typeof this.settings.normalizer==="function"){normalizer=this.settings.normalizer;} if(normalizer){val=normalizer.call(element,val);if(typeof val!=="string"){throw new TypeError("The normalizer should return a string value.");} delete rules.normalizer;} for(method in rules){rule={method:method,parameters:rules[method]};try{result=$.validator.methods[method].call(this,val,element,rule.parameters);if(result==="dependency-mismatch"&&rulesCount===1){dependencyMismatch=true;continue;} dependencyMismatch=false;if(result==="pending"){this.toHide=this.toHide.not(this.errorsFor(element));return;} if(!result){this.formatAndAdd(element,rule);return false;}}catch(e){if(this.settings.debug&&window.console){console.log("Exception occurred when checking element "+element.id+", check the '"+rule.method+"' method.",e);} if(e instanceof TypeError){e.message+=". Exception occurred when checking element "+element.id+", check the '"+rule.method+"' method.";} throw e;}} if(dependencyMismatch){return;} if(this.objectLength(rules)){this.successList.push(element);} return true;},customDataMessage:function(element,method){return $(element).data("msg"+method.charAt(0).toUpperCase()+ method.substring(1).toLowerCase())||$(element).data("msg");},customMessage:function(name,method){var m=this.settings.messages[name];return m&&(m.constructor===String?m:m[method]);},findDefined:function(){for(var i=0;i<arguments.length;i++){if(arguments[i]!==undefined){return arguments[i];}} return undefined;},defaultMessage:function(element,rule){if(typeof rule==="string"){rule={method:rule};} var message=this.findDefined(this.customMessage(element.name,rule.method),this.customDataMessage(element,rule.method),!this.settings.ignoreTitle&&element.title||undefined,this.messages&&this.messages[rule.method]||undefined,$.validator.messages[rule.method],"<strong>Warning: No message defined for "+element.name+"</strong>"),theregex=/\$?\{(\d+)\}/g;if(typeof message==="function"){message=message.call(this,rule.parameters,element);}else if(theregex.test(message)){message=$.validator.format(message.replace(theregex,"{$1}"),rule.parameters);} return message;},formatAndAdd:function(element,rule){var message=this.defaultMessage(element,rule);this.errorList.push({message:message,element:element,method:rule.method});this.errorMap[element.name]=message;this.submitted[element.name]=message;},addWrapper:function(toToggle){if(this.settings.wrapper){toToggle=toToggle.add(toToggle.parent(this.settings.wrapper));} return toToggle;},defaultShowErrors:function(){var i,elements,error;for(i=0;this.errorList[i];i++){error=this.errorList[i];if(this.settings.highlight){this.settings.highlight.call(this,error.element,this.settings.errorClass,this.settings.validClass);} this.showLabel(error.element,error.message);} if(this.errorList.length){this.toShow=this.toShow.add(this.containers);} if(this.settings.success){for(i=0;this.successList[i];i++){this.showLabel(this.successList[i]);}} if(this.settings.unhighlight){for(i=0,elements=this.validElements();elements[i];i++){this.settings.unhighlight.call(this,elements[i],this.settings.errorClass,this.settings.validClass);}} this.toHide=this.toHide.not(this.toShow);this.hideErrors();this.addWrapper(this.toShow).show();},validElements:function(){return this.currentElements.not(this.invalidElements());},invalidElements:function(){return $(this.errorList).map(function(){return this.element;});},showLabel:function(element,message){var place,group,errorID,v,error=this.errorsFor(element),elementID=this.idOrName(element),describedBy=$(element).attr("aria-describedby");if(error.length){error.removeClass(this.settings.validClass).addClass(this.settings.errorClass);error.html(message);}else{error=$("<"+this.settings.errorElement+">").attr("id",elementID+"-error").addClass(this.settings.errorClass).html(message||"");place=error;if(this.settings.wrapper){place=error.hide().show().wrap("<"+this.settings.wrapper+"/>").parent();} if(this.labelContainer.length){this.labelContainer.append(place);}else if(this.settings.errorPlacement){this.settings.errorPlacement.call(this,place,$(element));}else{place.insertAfter(element);} if(error.is("label")){error.attr("for",elementID);}else if(error.parents("label[for='"+this.escapeCssMeta(elementID)+"']").length===0){errorID=error.attr("id");if(!describedBy){describedBy=errorID;}else if(!describedBy.match(new RegExp("\\b"+this.escapeCssMeta(errorID)+"\\b"))){describedBy+=" "+errorID;} $(element).attr("aria-describedby",describedBy);group=this.groups[element.name];if(group){v=this;$.each(v.groups,function(name,testgroup){if(testgroup===group){$("[name='"+v.escapeCssMeta(name)+"']",v.currentForm).attr("aria-describedby",error.attr("id"));}});}}} if(!message&&this.settings.success){error.text("");if(typeof this.settings.success==="string"){error.addClass(this.settings.success);}else{this.settings.success(error,element);}} this.toShow=this.toShow.add(error);},errorsFor:function(element){var name=this.escapeCssMeta(this.idOrName(element)),describer=$(element).attr("aria-describedby"),selector="label[for='"+name+"'], label[for='"+name+"'] *";if(describer){selector=selector+", #"+this.escapeCssMeta(describer).replace(/\s+/g,", #");} return this.errors().filter(selector);},escapeCssMeta:function(string){return string.replace(/([\\!"#$%&'()*+,./:;<=>?@\[\]^`{|}~])/g,"\\$1");},idOrName:function(element){return this.groups[element.name]||(this.checkable(element)?element.name:element.id||element.name);},validationTargetFor:function(element){if(this.checkable(element)){element=this.findByName(element.name);} return $(element).not(this.settings.ignore)[0];},checkable:function(element){return(/radio|checkbox/i).test(element.type);},findByName:function(name){return $(this.currentForm).find("[name='"+this.escapeCssMeta(name)+"']");},getLength:function(value,element){switch(element.nodeName.toLowerCase()){case"select":return $("option:selected",element).length;case"input":if(this.checkable(element)){return this.findByName(element.name).filter(":checked").length;}} return value.length;},depend:function(param,element){return this.dependTypes[typeof param]?this.dependTypes[typeof param](param,element):true;},dependTypes:{"boolean":function(param){return param;},"string":function(param,element){return!!$(param,element.form).length;},"function":function(param,element){return param(element);}},optional:function(element){var val=this.elementValue(element);return!$.validator.methods.required.call(this,val,element)&&"dependency-mismatch";},startRequest:function(element){if(!this.pending[element.name]){this.pendingRequest++;$(element).addClass(this.settings.pendingClass);this.pending[element.name]=true;}},stopRequest:function(element,valid){this.pendingRequest--;if(this.pendingRequest<0){this.pendingRequest=0;} delete this.pending[element.name];$(element).removeClass(this.settings.pendingClass);if(valid&&this.pendingRequest===0&&this.formSubmitted&&this.form()){$(this.currentForm).submit();if(this.submitButton){$("input:hidden[name='"+this.submitButton.name+"']",this.currentForm).remove();} this.formSubmitted=false;}else if(!valid&&this.pendingRequest===0&&this.formSubmitted){$(this.currentForm).triggerHandler("invalid-form",[this]);this.formSubmitted=false;}},previousValue:function(element,method){method=typeof method==="string"&&method||"remote";return $.data(element,"previousValue")||$.data(element,"previousValue",{old:null,valid:true,message:this.defaultMessage(element,{method:method})});},destroy:function(){this.resetForm();$(this.currentForm).off(".validate").removeData("validator").find(".validate-equalTo-blur").off(".validate-equalTo").removeClass("validate-equalTo-blur");}},classRuleSettings:{required:{required:true},email:{email:true},url:{url:true},date:{date:true},dateISO:{dateISO:true},number:{number:true},digits:{digits:true},creditcard:{creditcard:true}},addClassRules:function(className,rules){if(className.constructor===String){this.classRuleSettings[className]=rules;}else{$.extend(this.classRuleSettings,className);}},classRules:function(element){var rules={},classes=$(element).attr("class");if(classes){$.each(classes.split(" "),function(){if(this in $.validator.classRuleSettings){$.extend(rules,$.validator.classRuleSettings[this]);}});} return rules;},normalizeAttributeRule:function(rules,type,method,value){if(/min|max|step/.test(method)&&(type===null||/number|range|text/.test(type))){if(!/^\s*$/.test(value))value=Number(value);if(isNaN(value)){value=undefined;}} if(value||value===0){rules[method]=value;}else if(type===method&&type!=="range"){rules[method]=true;}},attributeRules:function(element){var rules={},$element=$(element),type=element.getAttribute("type"),method,value;for(method in $.validator.methods){if(method==="required"){value=element.getAttribute(method);if(value===""){value=true;} value=!!value;}else{value=$element.attr(method);} this.normalizeAttributeRule(rules,type,method,value);} if(rules.maxlength&&/-1|2147483647|524288/.test(rules.maxlength)){delete rules.maxlength;} return rules;},dataRules:function(element){var rules={},$element=$(element),type=element.getAttribute("type"),method,value;for(method in $.validator.methods){value=$element.data("rule"+method.charAt(0).toUpperCase()+method.substring(1).toLowerCase());this.normalizeAttributeRule(rules,type,method,value);} return rules;},staticRules:function(element){var rules={},validator=$.data(element.form,"validator");if(validator.settings.rules){rules=$.validator.normalizeRule(validator.settings.rules[element.name])||{};} return rules;},normalizeRules:function(rules,element){$.each(rules,function(prop,val){if(val===false){delete rules[prop];return;} if(val.param||val.depends){var keepRule=true;switch(typeof val.depends){case"string":keepRule=!!$(val.depends,element.form).length;break;case"function":keepRule=val.depends.call(element,element);break;} if(keepRule){rules[prop]=val.param!==undefined?val.param:true;}else{$.data(element.form,"validator").resetElements($(element));delete rules[prop];}}});$.each(rules,function(rule,parameter){rules[rule]=$.isFunction(parameter)&&rule!=="normalizer"?parameter(element):parameter;});$.each(["minlength","maxlength"],function(){if(rules[this]){rules[this]=Number(rules[this]);}});$.each(["rangelength","range"],function(){var parts;if(rules[this]){if($.isArray(rules[this])){rules[this]=[Number(rules[this][0]),Number(rules[this][1])];}else if(typeof rules[this]==="string"){parts=rules[this].replace(/[\[\]]/g,"").split(/[\s,]+/);rules[this]=[Number(parts[0]),Number(parts[1])];}}});if($.validator.autoCreateRanges){if(rules.min!=null&&rules.max!=null){rules.range=[rules.min,rules.max];delete rules.min;delete rules.max;} if(rules.minlength!=null&&rules.maxlength!=null){rules.rangelength=[rules.minlength,rules.maxlength];delete rules.minlength;delete rules.maxlength;}} return rules;},normalizeRule:function(data){if(typeof data==="string"){var transformed={};$.each(data.split(/\s/),function(){transformed[this]=true;});data=transformed;} return data;},addMethod:function(name,method,message){$.validator.methods[name]=method;$.validator.messages[name]=message!==undefined?message:$.validator.messages[name];if(method.length<3){$.validator.addClassRules(name,$.validator.normalizeRule(name));}},methods:{required:function(value,element,param){if(!this.depend(param,element)){return"dependency-mismatch";} if(element.nodeName.toLowerCase()==="select"){var val=$(element).val();return val&&val.length>0;} if(this.checkable(element)){return this.getLength(value,element)>0;} return value.length>0;},email:function(value,element){return this.optional(element)||/^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/.test(value);},url:function(value,element){return this.optional(element)||/^(?:(?:(?:https?|ftp):)?\/\/)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,})).?)(?::\d{2,5})?(?:[/?#]\S*)?$/i.test(value);},date:function(value,element){return this.optional(element)||!/Invalid|NaN/.test(new Date(value).toString());},dateISO:function(value,element){return this.optional(element)||/^\d{4}[\/\-](0?[1-9]|1[012])[\/\-](0?[1-9]|[12][0-9]|3[01])$/.test(value);},number:function(value,element){return this.optional(element)||/^(?:-?\d+|-?\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/.test(value);},digits:function(value,element){return this.optional(element)||/^\d+$/.test(value);},minlength:function(value,element,param){var length=$.isArray(value)?value.length:this.getLength(value,element);return this.optional(element)||length>=param;},maxlength:function(value,element,param){var length=$.isArray(value)?value.length:this.getLength(value,element);return this.optional(element)||length<=param;},rangelength:function(value,element,param){var length=$.isArray(value)?value.length:this.getLength(value,element);return this.optional(element)||(length>=param[0]&&length<=param[1]);},min:function(value,element,param){return this.optional(element)||value>=param;},max:function(value,element,param){return this.optional(element)||value<=param;},range:function(value,element,param){return this.optional(element)||(value>=param[0]&&value<=param[1]);},step:function(value,element,param){var type=$(element).attr("type"),errorMessage="Step attribute on input type "+type+" is not supported.",supportedTypes=["text","number","range"],re=new RegExp("\\b"+type+"\\b"),notSupported=type&&!re.test(supportedTypes.join()),decimalPlaces=function(num){var match=(""+num).match(/(?:\.(\d+))?$/);if(!match){return 0;} return match[1]?match[1].length:0;},toInt=function(num){return Math.round(num*Math.pow(10,decimals));},valid=true,decimals;if(notSupported){throw new Error(errorMessage);} decimals=decimalPlaces(param);if(decimalPlaces(value)>decimals||toInt(value)%toInt(param)!==0){valid=false;} return this.optional(element)||valid;},equalTo:function(value,element,param){var target=$(param);if(this.settings.onfocusout&&target.not(".validate-equalTo-blur").length){target.addClass("validate-equalTo-blur").on("blur.validate-equalTo",function(){$(element).valid();});} return value===target.val();},remote:function(value,element,param,method){if(this.optional(element)){return"dependency-mismatch";} method=typeof method==="string"&&method||"remote";var previous=this.previousValue(element,method),validator,data,optionDataString;if(!this.settings.messages[element.name]){this.settings.messages[element.name]={};} previous.originalMessage=previous.originalMessage||this.settings.messages[element.name][method];this.settings.messages[element.name][method]=previous.message;param=typeof param==="string"&&{url:param}||param;optionDataString=$.param($.extend({data:value},param.data));if(previous.old===optionDataString){return previous.valid;} previous.old=optionDataString;validator=this;this.startRequest(element);data={};data[element.name]=value;$.ajax($.extend(true,{mode:"abort",port:"validate"+element.name,dataType:"json",data:data,context:validator.currentForm,success:function(response){var valid=response===true||response==="true",errors,message,submitted;validator.settings.messages[element.name][method]=previous.originalMessage;if(valid){submitted=validator.formSubmitted;validator.resetInternals();validator.toHide=validator.errorsFor(element);validator.formSubmitted=submitted;validator.successList.push(element);validator.invalid[element.name]=false;validator.showErrors();}else{errors={};message=response||validator.defaultMessage(element,{method:method,parameters:value});errors[element.name]=previous.message=message;validator.invalid[element.name]=true;validator.showErrors(errors);} previous.valid=valid;validator.stopRequest(element,valid);}},param));return"pending";}}});var pendingRequests={},ajax;if($.ajaxPrefilter){$.ajaxPrefilter(function(settings,_,xhr){var port=settings.port;if(settings.mode==="abort"){if(pendingRequests[port]){pendingRequests[port].abort();} pendingRequests[port]=xhr;}});}else{ajax=$.ajax;$.ajax=function(settings){var mode=("mode"in settings?settings:$.ajaxSettings).mode,port=("port"in settings?settings:$.ajaxSettings).port;if(mode==="abort"){if(pendingRequests[port]){pendingRequests[port].abort();} pendingRequests[port]=ajax.apply(this,arguments);return pendingRequests[port];} return ajax.apply(this,arguments);};} return $;}));
|
js/modules/01_mathematical_logical/admin/module_admin.js
CHANGED
@@ -44,6 +44,12 @@ fbuilderjQuery[ 'fbuilder' ][ 'modules' ][ 'default' ] = {
|
|
44 |
'logical' : {
|
45 |
'label' : "Logical Operators",
|
46 |
'buttons' : [
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
{ "value" : "IF", "code" : "IF(", "tip" : "Checks whether a condition is met, and returns one value if true, and another if false. <strong>IF(logical_test, value_if_true, value_if_false)</strong>" },
|
48 |
{ "value" : "AND", "code" : "AND(", "tip" : "Checks whether all arguments are true, and return true if all values are true. <strong>AND(logical1,logical2,...)</strong>" },
|
49 |
{ "value" : "OR", "code" : "OR(", "tip" : "Checks whether any of arguments are true. Returns false only if all arguments are false. <strong>OR(logical1,logical2,...)</strong>" },
|
44 |
'logical' : {
|
45 |
'label' : "Logical Operators",
|
46 |
'buttons' : [
|
47 |
+
{ "value" : "==", "code" : "==", "tip" : "Equality operator. <strong>fieldname1 == fieldname2</strong>" },
|
48 |
+
{ "value" : "!=", "code" : "!=", "tip" : "Not equal operator. <strong>fieldname1 != fieldname2</strong>" },
|
49 |
+
{ "value" : "<", "code" : "<", "tip" : "Less than operator. <strong>fieldname1 < fieldname2</strong>" },
|
50 |
+
{ "value" : "<=", "code" : "<=", "tip" : "Less than or equal to operator. <strong>fieldname1 <= fieldname2</strong>" },
|
51 |
+
{ "value" : ">", "code" : ">", "tip" : "Greater than operator. <strong>fieldname1 > fieldname2</strong>" },
|
52 |
+
{ "value" : ">=", "code" : ">=", "tip" : "Greater than or equal to operator. <strong>fieldname1 >= fieldname2</strong>" },
|
53 |
{ "value" : "IF", "code" : "IF(", "tip" : "Checks whether a condition is met, and returns one value if true, and another if false. <strong>IF(logical_test, value_if_true, value_if_false)</strong>" },
|
54 |
{ "value" : "AND", "code" : "AND(", "tip" : "Checks whether all arguments are true, and return true if all values are true. <strong>AND(logical1,logical2,...)</strong>" },
|
55 |
{ "value" : "OR", "code" : "OR(", "tip" : "Checks whether any of arguments are true. Returns false only if all arguments are false. <strong>OR(logical1,logical2,...)</strong>" },
|
pagebuilders/divi/cff.pb.php
ADDED
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class CFF_DIVI extends ET_Builder_Module
|
3 |
+
{
|
4 |
+
|
5 |
+
public $slug = 'et_pb_cff_divi_module';
|
6 |
+
public $vb_support = 'partial';
|
7 |
+
|
8 |
+
public function init()
|
9 |
+
{
|
10 |
+
$this->name = esc_html__('Calculated Fields Form', 'calculated-fields-form');
|
11 |
+
$this->settings_modal_toggles = array(
|
12 |
+
'general' => array(
|
13 |
+
'toggles' => array(
|
14 |
+
'main_content' => esc_html__( 'Form', 'calculated-fields-form' ),
|
15 |
+
),
|
16 |
+
),
|
17 |
+
);
|
18 |
+
}
|
19 |
+
|
20 |
+
public function get_fields()
|
21 |
+
{
|
22 |
+
global $wpdb;
|
23 |
+
$options = array();
|
24 |
+
$default = '';
|
25 |
+
|
26 |
+
$rows = $wpdb->get_results( "SELECT id, form_name FROM ".$wpdb->prefix.CP_CALCULATEDFIELDSF_FORMS_TABLE );
|
27 |
+
foreach ($rows as $item)
|
28 |
+
{
|
29 |
+
$options[$item->id] = $item->form_name;
|
30 |
+
if(empty($default)) $default = $item->id;
|
31 |
+
}
|
32 |
+
|
33 |
+
return array(
|
34 |
+
'form_id' => array(
|
35 |
+
'label' => esc_html__( 'Select form', 'calculated-fields-form' ),
|
36 |
+
'type' => 'select',
|
37 |
+
'options' => $options,
|
38 |
+
'default' => $default,
|
39 |
+
'option_category' => 'basic_option',
|
40 |
+
'description' => esc_html__( 'Select the form.', 'calculated-fields-form' ),
|
41 |
+
'toggle_slug' => 'main_content',
|
42 |
+
),
|
43 |
+
'class_name' => array(
|
44 |
+
'label' => esc_html__( 'Class name', 'calculated-fields-form' ),
|
45 |
+
'type' => 'text',
|
46 |
+
'option_category' => 'basic_option',
|
47 |
+
'toggle_slug' => 'main_content',
|
48 |
+
),
|
49 |
+
'attributes' => array(
|
50 |
+
'label' => esc_html__( 'Additional attributes', 'calculated-fields-form' ),
|
51 |
+
'type' => 'text',
|
52 |
+
'option_category' => 'basic_option',
|
53 |
+
'description' => 'attr1="value attr1" attr1="value attr1"',
|
54 |
+
'toggle_slug' => 'main_content',
|
55 |
+
),
|
56 |
+
);
|
57 |
+
}
|
58 |
+
|
59 |
+
public function render($unprocessed_props, $content = null, $render_slug)
|
60 |
+
{
|
61 |
+
$output = '';
|
62 |
+
$form = @intval($this->props['form_id']);
|
63 |
+
if(!empty($form))
|
64 |
+
{
|
65 |
+
$output = '[CP_CALCULATED_FIELDS id="'.$form.'"';
|
66 |
+
$class_name = sanitize_text_field($this->props['class_name']);
|
67 |
+
if(!empty($class_name)) $output .= ' class="'.esc_attr($class_name).'"';
|
68 |
+
|
69 |
+
$attributes = sanitize_text_field($this->props['attributes']);
|
70 |
+
if(!empty($attributes)) $output .= ' '.$attributes;
|
71 |
+
|
72 |
+
$output .= ']';
|
73 |
+
}
|
74 |
+
return do_shortcode($output);
|
75 |
+
}
|
76 |
+
}
|
77 |
+
|
78 |
+
new CFF_DIVI;
|
pagebuilders/visualcomposer/CFFForm/public/dist/element.bundle.js
CHANGED
@@ -8,7 +8,7 @@
|
|
8 |
/***/ (function(module, exports, __webpack_require__) {
|
9 |
|
10 |
"use strict";
|
11 |
-
eval("\n\nObject.defineProperty(exports, \"__esModule\", {\n\tvalue: true\n});\n\nvar _extends2 = __webpack_require__(/*! babel-runtime/helpers/extends */ \"./node_modules/babel-runtime/helpers/extends.js\");\n\nvar _extends3 = _interopRequireDefault(_extends2);\n\nvar _getPrototypeOf = __webpack_require__(/*! babel-runtime/core-js/object/get-prototype-of */ \"./node_modules/babel-runtime/core-js/object/get-prototype-of.js\");\n\nvar _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);\n\nvar _classCallCheck2 = __webpack_require__(/*! babel-runtime/helpers/classCallCheck */ \"./node_modules/babel-runtime/helpers/classCallCheck.js\");\n\nvar _classCallCheck3 = _interopRequireDefault(_classCallCheck2);\n\nvar _createClass2 = __webpack_require__(/*! babel-runtime/helpers/createClass */ \"./node_modules/babel-runtime/helpers/createClass.js\");\n\nvar _createClass3 = _interopRequireDefault(_createClass2);\n\nvar _possibleConstructorReturn2 = __webpack_require__(/*! babel-runtime/helpers/possibleConstructorReturn */ \"./node_modules/babel-runtime/helpers/possibleConstructorReturn.js\");\n\nvar _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);\n\nvar _get2 = __webpack_require__(/*! babel-runtime/helpers/get */ \"./node_modules/babel-runtime/helpers/get.js\");\n\nvar _get3 = _interopRequireDefault(_get2);\n\nvar _inherits2 = __webpack_require__(/*! babel-runtime/helpers/inherits */ \"./node_modules/babel-runtime/helpers/inherits.js\");\n\nvar _inherits3 = _interopRequireDefault(_inherits2);\n\nvar _react = __webpack_require__(/*! react */ \"./node_modules/react/index.js\");\n\nvar _react2 = _interopRequireDefault(_react);\n\nvar _vcCake = __webpack_require__(/*! vc-cake */ \"./node_modules/vc-cake/index.js\");\n\nvar _vcCake2 = _interopRequireDefault(_vcCake);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nvar vcvAPI = _vcCake2.default.getService('api');\n\nvar CFFFormElement = function (_vcvAPI$elementCompon) {\n\t(0, _inherits3.default)(CFFFormElement, _vcvAPI$elementCompon);\n\n\tfunction CFFFormElement() {\n\t\t(0, _classCallCheck3.default)(this, CFFFormElement);\n\t\treturn (0, _possibleConstructorReturn3.default)(this, (CFFFormElement.__proto__ || (0, _getPrototypeOf2.default)(CFFFormElement)).apply(this, arguments));\n\t}\n\n\t(0, _createClass3.default)(CFFFormElement, [{\n\t\tkey: 'sanitize',\n\t\tvalue: function sanitize(str, args) {\n\t\t\tif (typeof args == 'undefined') args = {};\n\t\t\tif (!('quotes' in args)) args['quotes'] = false;\n\t\t\tif (!('spaces' in args)) args['spaces'] = false;\n\n\t\t\tstr = str.replace(/[^a-zA-Z0-9\\.\\-_\\s\"']/g, '');\n\t\t\tif (!args.quotes) str = str.replace(/'\"/g, '');\n\t\t\tif (!args.spaces) str = str.replace(/\\s/g, '');\n\n\t\t\treturn str;\n\t\t}\n\t}, {\n\t\tkey: 'getTheShortcode',\n\t\tvalue: function getTheShortcode(atts) {\n\t\t\t// Generates the form's shortcode\n\t\t\tvar _atts$fId = atts.fId,\n\t\t\t fId = _atts$fId === undefined ? \"\" : _atts$fId,\n\t\t\t _atts$clssName = atts.clssName,\n\t\t\t clssName = _atts$clssName === undefined ? \"\" : _atts$clssName,\n\t\t\t _atts$attrs = atts.attrs,\n\t\t\t attrs = _atts$attrs === undefined ? \"\" : _atts$attrs;\n\n\t\t\tif (fId == '') return '';\n\t\t\tvar shortcode = '[CP_CALCULATED_FIELDS id=\"' + this.sanitize(fId) + '\"';\n\t\t\tif (clssName != '') shortcode += ' class=\"' + this.sanitize(clssName, { spaces: true }) + '\"';\n\t\t\tif (attrs != '') shortcode += ' ' + this.sanitize(attrs, { quotes: true, spaces: true });\n\t\t\tshortcode += ']';\n\n\t\t\treturn shortcode;\n\t\t}\n\t}, {\n\t\tkey: 'addFormGeneratorForVSEditor',\n\t\tvalue: function addFormGeneratorForVSEditor(base) {\n\t\t\treturn base != '' ? base + '<script>delete fbuilderjQuery.fbuilderGeneratorFlag; if(\"fbuilderjQuery\" in window && \"fbuilderjQueryGenerator\" in fbuilderjQuery) fbuilderjQuery.fbuilderjQueryGenerator();</script>' : base;\n\t\t}\n\t}, {\n\t\tkey: 'componentDidMount',\n\t\tvalue: function componentDidMount() {\n\n\t\t\tvar shortcode = this.addFormGeneratorForVSEditor(this.getTheShortcode(this.props.atts));\n\t\t\t(0, _get3.default)(CFFFormElement.prototype.__proto__ || (0, _getPrototypeOf2.default)(CFFFormElement.prototype), 'updateShortcodeToHtml', this).call(this, shortcode, this.refs.vcvhelper);\n\t\t\tif (!window.wp || !window.wp.shortcode || !window.VCV_API_WPBAKERY_WPB_MAP) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tthis.multipleShortcodesRegex = window.wp.shortcode.regexp(window.VCV_API_WPBAKERY_WPB_MAP().join('|'));\n\t\t\tthis.localShortcodesRegex = new RegExp(this.multipleShortcodesRegex.source);\n\t\t}\n\t}, {\n\t\tkey: 'componentDidUpdate',\n\t\tvalue: function componentDidUpdate(props) {\n\n\t\t\tvar shortcode = this.addFormGeneratorForVSEditor(this.getTheShortcode(this.props.atts));\n\t\t\tvar shortcodeCmp = this.getTheShortcode(props.atts);\n\t\t\t// update only if shortcode changed\n\t\t\tif (shortcode !== shortcodeCmp) {\n\t\t\t\t(0, _get3.default)(CFFFormElement.prototype.__proto__ || (0, _getPrototypeOf2.default)(CFFFormElement.prototype), 'updateShortcodeToHtml', this).call(this, shortcode, this.refs.vcvhelper);\n\t\t\t}\n\t\t}\n\t}, {\n\t\tkey: 'render',\n\t\tvalue: function render() {\n\t\t\tvar _props = this.props,\n\t\t\t id = _props.id,\n\t\t\t atts = _props.atts,\n\t\t\t editor = _props.editor;\n\n\n\t\t\tvar shortcode = this.getTheShortcode(atts);\n\t\t\tvar elementClasses = 'vce-cff-form';\n\t\t\tvar wrapperClasses = 'vce-cff-form-wrapper vce';\n\t\t\tvar customProps = {};\n\n\t\t\tvar doAll = this.applyDO('all');\n\n\t\t\treturn _react2.default.createElement(\n\t\t\t\t'div',\n\t\t\t\t(0, _extends3.default)({ className: elementClasses }, editor, customProps),\n\t\t\t\t_react2.default.createElement(\n\t\t\t\t\t'div',\n\t\t\t\t\t(0, _extends3.default)({ className: wrapperClasses, id: 'el-' + id }, doAll),\n\t\t\t\t\t_react2.default.createElement('style', { className: 'vcvhelper', ref: 'style' }),\n\t\t\t\t\t_react2.default.createElement('div', { className: 'vcvhelper', ref: 'vcvhelper', 'data-vcvs-html': shortcode })\n\t\t\t\t)\n\t\t\t);\n\t\t}\n\t}]);\n\treturn CFFFormElement;\n}(vcvAPI.elementComponent);\n\nexports.default = CFFFormElement;\n\n//# sourceURL=webpack:///./CFFForm/component.js?");
|
12 |
|
13 |
/***/ }),
|
14 |
|
8 |
/***/ (function(module, exports, __webpack_require__) {
|
9 |
|
10 |
"use strict";
|
11 |
+
eval("\n\nObject.defineProperty(exports, \"__esModule\", {\n\tvalue: true\n});\n\nvar _extends2 = __webpack_require__(/*! babel-runtime/helpers/extends */ \"./node_modules/babel-runtime/helpers/extends.js\");\n\nvar _extends3 = _interopRequireDefault(_extends2);\n\nvar _getPrototypeOf = __webpack_require__(/*! babel-runtime/core-js/object/get-prototype-of */ \"./node_modules/babel-runtime/core-js/object/get-prototype-of.js\");\n\nvar _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);\n\nvar _classCallCheck2 = __webpack_require__(/*! babel-runtime/helpers/classCallCheck */ \"./node_modules/babel-runtime/helpers/classCallCheck.js\");\n\nvar _classCallCheck3 = _interopRequireDefault(_classCallCheck2);\n\nvar _createClass2 = __webpack_require__(/*! babel-runtime/helpers/createClass */ \"./node_modules/babel-runtime/helpers/createClass.js\");\n\nvar _createClass3 = _interopRequireDefault(_createClass2);\n\nvar _possibleConstructorReturn2 = __webpack_require__(/*! babel-runtime/helpers/possibleConstructorReturn */ \"./node_modules/babel-runtime/helpers/possibleConstructorReturn.js\");\n\nvar _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);\n\nvar _get2 = __webpack_require__(/*! babel-runtime/helpers/get */ \"./node_modules/babel-runtime/helpers/get.js\");\n\nvar _get3 = _interopRequireDefault(_get2);\n\nvar _inherits2 = __webpack_require__(/*! babel-runtime/helpers/inherits */ \"./node_modules/babel-runtime/helpers/inherits.js\");\n\nvar _inherits3 = _interopRequireDefault(_inherits2);\n\nvar _react = __webpack_require__(/*! react */ \"./node_modules/react/index.js\");\n\nvar _react2 = _interopRequireDefault(_react);\n\nvar _vcCake = __webpack_require__(/*! vc-cake */ \"./node_modules/vc-cake/index.js\");\n\nvar _vcCake2 = _interopRequireDefault(_vcCake);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nvar vcvAPI = _vcCake2.default.getService('api');\n\nvar CFFFormElement = function (_vcvAPI$elementCompon) {\n\t(0, _inherits3.default)(CFFFormElement, _vcvAPI$elementCompon);\n\n\tfunction CFFFormElement() {\n\t\t(0, _classCallCheck3.default)(this, CFFFormElement);\n\t\treturn (0, _possibleConstructorReturn3.default)(this, (CFFFormElement.__proto__ || (0, _getPrototypeOf2.default)(CFFFormElement)).apply(this, arguments));\n\t}\n\n\t(0, _createClass3.default)(CFFFormElement, [{\n\t\tkey: 'sanitize',\n\t\tvalue: function sanitize(str, args) {\n\t\t\tif (typeof args == 'undefined') args = {};\n\t\t\tif (!('quotes' in args)) args['quotes'] = false;\n\t\t\tif (!('spaces' in args)) args['spaces'] = false;\n\n\t\t\tstr = str.replace(/[^a-zA-Z0-9\\.\\-_\\s\"'=]/g, '');\n\t\t\tif (!args.quotes) str = str.replace(/'\"/g, '');\n\t\t\tif (!args.spaces) str = str.replace(/\\s/g, '');\n\n\t\t\treturn str;\n\t\t}\n\t}, {\n\t\tkey: 'getTheShortcode',\n\t\tvalue: function getTheShortcode(atts) {\n\t\t\t// Generates the form's shortcode\n\t\t\tvar _atts$fId = atts.fId,\n\t\t\t fId = _atts$fId === undefined ? \"\" : _atts$fId,\n\t\t\t _atts$clssName = atts.clssName,\n\t\t\t clssName = _atts$clssName === undefined ? \"\" : _atts$clssName,\n\t\t\t _atts$attrs = atts.attrs,\n\t\t\t attrs = _atts$attrs === undefined ? \"\" : _atts$attrs;\n\n\t\t\tif (fId == '') return '';\n\t\t\tvar shortcode = '[CP_CALCULATED_FIELDS id=\"' + this.sanitize(fId) + '\"';\n\t\t\tif (clssName != '') shortcode += ' class=\"' + this.sanitize(clssName, { spaces: true }) + '\"';\n\t\t\tif (attrs != '') shortcode += ' ' + this.sanitize(attrs, { quotes: true, spaces: true });\n\t\t\tshortcode += ']';\n\n\t\t\treturn shortcode;\n\t\t}\n\t}, {\n\t\tkey: 'addFormGeneratorForVSEditor',\n\t\tvalue: function addFormGeneratorForVSEditor(base) {\n\t\t\treturn base != '' ? base + '<script>delete fbuilderjQuery.fbuilderGeneratorFlag; if(\"fbuilderjQuery\" in window && \"fbuilderjQueryGenerator\" in fbuilderjQuery) fbuilderjQuery.fbuilderjQueryGenerator();</script>' : base;\n\t\t}\n\t}, {\n\t\tkey: 'componentDidMount',\n\t\tvalue: function componentDidMount() {\n\n\t\t\tvar shortcode = this.addFormGeneratorForVSEditor(this.getTheShortcode(this.props.atts));\n\t\t\t(0, _get3.default)(CFFFormElement.prototype.__proto__ || (0, _getPrototypeOf2.default)(CFFFormElement.prototype), 'updateShortcodeToHtml', this).call(this, shortcode, this.refs.vcvhelper);\n\t\t\tif (!window.wp || !window.wp.shortcode || !window.VCV_API_WPBAKERY_WPB_MAP) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tthis.multipleShortcodesRegex = window.wp.shortcode.regexp(window.VCV_API_WPBAKERY_WPB_MAP().join('|'));\n\t\t\tthis.localShortcodesRegex = new RegExp(this.multipleShortcodesRegex.source);\n\t\t}\n\t}, {\n\t\tkey: 'componentDidUpdate',\n\t\tvalue: function componentDidUpdate(props) {\n\n\t\t\tvar shortcode = this.addFormGeneratorForVSEditor(this.getTheShortcode(this.props.atts));\n\t\t\tvar shortcodeCmp = this.getTheShortcode(props.atts);\n\t\t\t// update only if shortcode changed\n\t\t\tif (shortcode !== shortcodeCmp) {\n\t\t\t\t(0, _get3.default)(CFFFormElement.prototype.__proto__ || (0, _getPrototypeOf2.default)(CFFFormElement.prototype), 'updateShortcodeToHtml', this).call(this, shortcode, this.refs.vcvhelper);\n\t\t\t}\n\t\t}\n\t}, {\n\t\tkey: 'render',\n\t\tvalue: function render() {\n\t\t\tvar _props = this.props,\n\t\t\t id = _props.id,\n\t\t\t atts = _props.atts,\n\t\t\t editor = _props.editor;\n\n\n\t\t\tvar shortcode = this.getTheShortcode(atts);\n\t\t\tvar elementClasses = 'vce-cff-form';\n\t\t\tvar wrapperClasses = 'vce-cff-form-wrapper vce';\n\t\t\tvar customProps = {};\n\n\t\t\tvar doAll = this.applyDO('all');\n\n\t\t\treturn _react2.default.createElement(\n\t\t\t\t'div',\n\t\t\t\t(0, _extends3.default)({ className: elementClasses }, editor, customProps),\n\t\t\t\t_react2.default.createElement(\n\t\t\t\t\t'div',\n\t\t\t\t\t(0, _extends3.default)({ className: wrapperClasses, id: 'el-' + id }, doAll),\n\t\t\t\t\t_react2.default.createElement('style', { className: 'vcvhelper', ref: 'style' }),\n\t\t\t\t\t_react2.default.createElement('div', { className: 'vcvhelper', ref: 'vcvhelper', 'data-vcvs-html': shortcode })\n\t\t\t\t)\n\t\t\t);\n\t\t}\n\t}]);\n\treturn CFFFormElement;\n}(vcvAPI.elementComponent);\n\nexports.default = CFFFormElement;\n\n//# sourceURL=webpack:///./CFFForm/component.js?");
|
12 |
|
13 |
/***/ }),
|
14 |
|