Calculated Fields Form - Version 1.0.231

Version Description

  • Fixes an issue in the fields validation.
Download this release

Release Info

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

Code changes from version 1.0.229 to 1.0.231

README.txt CHANGED
@@ -871,6 +871,16 @@ A: Please, visit the following entry in our technical blog:
871
872
== Changelog ==
873
874
= 1.0.229 =
875
876
* Fixes an issue with dependencies.
@@ -916,29 +926,8 @@ A: Please, visit the following entry in our technical blog:
916
917
* Includes the Acceptance (GDPR) control for inserting a required checkbox field in the form for asking the users their consent to store and use the information provided.
918
919
- = 1.0.221 =
920
-
921
- * Modifies the Next Page and Previous Page buttons to respond to the keys: space and enter, and to be selected with the tab key.
922
- * Modifies the Checkbox fields to return the original values of the choices selected (without parsing the numbers) when is unticked the attribute for merging the values.
923
- * Modifies the parseValStr function in the fbuilder-pro-public.jquery.js file.
924
- * Modifies the Submit button to respond to the keys: space and enter, and to be selected with the tab key (Professional, Developer and Platinum versions of the plugin).
925
- * Modifies special tag <%fieldname#_urls%> used in the notification emails, and thank you pages, to display each URL in its own line (Professional, Developer and Platinum versions)
926
- * Displays an error message in the form when the coupon is checkes and it is invalid (Professional, Developer and Platinum versions)
927
- * Fixes an issue in the link to the forms' events from the dashboard page (Professional, Developer and Platinum versions)
928
- * Implements the special tags: <%fieldname#_nonblock%><%fieldname#_endnonblock%> to include a block of content if the fieldname# field has not being submitted or it was submitted in blank (Professional, Developer and Platinum versions)
929
-
930
- = 1.0.220 =
931
-
932
- * Modifies the dependencies in radio buttons, checkboxes, drop-down fields, containers and calculated fields.
933
- * Modifies the htmlEncode function in the fbuilder-pro-admin.jquery.js file.
934
- * Fixes an issue with the changes of lines in the exported CSV files with the submissions (Professional, Developer and Platinum versions)
935
- * Allow to exlude the attachments from the notification emails (Professional, Developer and Platinum versions)
936
- * Fixes an issue in the special tag <%fieldname#_urls%> used in the notification emails, and thank you pages (Professional, Developer and Platinum versions)
937
- * In the WooCommerce add-on includes a new hidden tag named woocommerce_cpcff_product_price with the base price of the WooCommerce product (Developer and Platinum versions)
938
- * In the MailChimp add-on allows to select the status of new users, between pending and subscribed (Platinum version)
939
-
940
== Upgrade Notice ==
941
942
- = 1.0.229 =
943
944
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
871
872
== Changelog ==
873
874
+ = 1.0.231 =
875
+
876
+ * Fixes an issue in the fields validation.
877
+
878
+ = 1.0.230 =
879
+
880
+ * Validates the values in currency fields.
881
+ * Improves the validations in the other controls.
882
+ * Improves the code to load the forms in the AMP pages.
883
+
884
= 1.0.229 =
885
886
* Fixes an issue with dependencies.
926
927
* Includes the Acceptance (GDPR) control for inserting a required checkbox field in the form for asking the users their consent to store and use the information provided.
928
929
== Upgrade Notice ==
930
931
+ = 1.0.231 =
932
933
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,15 @@
1
== Changelog ==
2
3
= 1.0.229 =
4
5
* Fixes an issue with dependencies.
1
== Changelog ==
2
3
+ = 1.0.231 =
4
+
5
+ * Fixes an issue in the fields validation.
6
+
7
+ = 1.0.230 =
8
+
9
+ * Validates the values in currency fields.
10
+ * Improves the validations in the other controls.
11
+ * Improves the code to load the forms in the AMP pages.
12
+
13
= 1.0.229 =
14
15
* Fixes an issue with dependencies.
config/cpcff_config.cfg.php CHANGED
@@ -92,6 +92,10 @@ $cpcff_default_texts_array = array(
92
'text' => 'Page {0} of {0}'
93
),
94
'errors' => array(
95
'maxlength' => array(
96
'label' => '"Max length/characters" text',
97
'text' => 'Please enter no more than {0} characters.'
92
'text' => 'Page {0} of {0}'
93
),
94
'errors' => array(
95
+ 'currency' => array(
96
+ 'label' => '"Invalid Currency" text',
97
+ 'text' => 'Please enter a valid currency value.'
98
+ ),
99
'maxlength' => array(
100
'label' => '"Max length/characters" text',
101
'text' => 'Please enter no more than {0} characters.'
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.229
7
Text Domain: calculated-fields-form
8
Author: CodePeople
9
Author URI: https://cff.dwbooster.com
@@ -20,7 +20,7 @@ require_once 'inc/cpcff_session.inc.php';
20
if( !defined('DOING_AJAX') ) CP_SESSION::session_start();
21
22
// Defining main constants
23
- define('CP_CALCULATEDFIELDSF_VERSION', '1.0.229' );
24
define('CP_CALCULATEDFIELDSF_MAIN_FILE_PATH', __FILE__ );
25
define('CP_CALCULATEDFIELDSF_BASE_PATH', dirname( CP_CALCULATEDFIELDSF_MAIN_FILE_PATH ) );
26
define('CP_CALCULATEDFIELDSF_BASE_NAME', plugin_basename( CP_CALCULATEDFIELDSF_MAIN_FILE_PATH ) );
@@ -56,8 +56,7 @@ function cp_calculated_fields_form_check_posted_data() {
56
$cpcff_main->form_preview(
57
array(
58
'shortcode_atts' => array('id' => @intval($_POST['cp_calculatedfieldsf_id'])),
59
- 'page_title' => __('Form Preview', 'calculated-fields-form'),
60
- 'popup' => 1
61
)
62
);
63
}
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.231
7
Text Domain: calculated-fields-form
8
Author: CodePeople
9
Author URI: https://cff.dwbooster.com
20
if( !defined('DOING_AJAX') ) CP_SESSION::session_start();
21
22
// Defining main constants
23
+ define('CP_CALCULATEDFIELDSF_VERSION', '1.0.231' );
24
define('CP_CALCULATEDFIELDSF_MAIN_FILE_PATH', __FILE__ );
25
define('CP_CALCULATEDFIELDSF_BASE_PATH', dirname( CP_CALCULATEDFIELDSF_MAIN_FILE_PATH ) );
26
define('CP_CALCULATEDFIELDSF_BASE_NAME', plugin_basename( CP_CALCULATEDFIELDSF_MAIN_FILE_PATH ) );
56
$cpcff_main->form_preview(
57
array(
58
'shortcode_atts' => array('id' => @intval($_POST['cp_calculatedfieldsf_id'])),
59
+ 'page_title' => __('Form Preview', 'calculated-fields-form')
60
)
61
);
62
}
inc/cpcff_amp.inc.php ADDED
@@ -0,0 +1,214 @@
1
+ <?php
2
+ /**
3
+ * Actions required to include the forms in the AMP pages: CPCFF_AMP class
4
+ *
5
+ * @package CFF.
6
+ * @since 1.0.230
7
+ */
8
+
9
+ if(!class_exists('CPCFF_AMP'))
10
+ {
11
+ /**
12
+ * Class that defines the operations to display the foms in AMP pages.
13
+ *
14
+ * @since 1.0.170
15
+ */
16
+ class CPCFF_AMP
17
+ {
18
+ /**
19
+ * Main plugin object
20
+ */
21
+ private $_main_obj;
22
+
23
+ public function __construct($main_obj)
24
+ {
25
+ $this->_main_obj = $main_obj;
26
+ add_action( 'init', array($this, 'amp_init') ); // for amp pages.
27
+ } // End __construct
28
+
29
+ /**
30
+ * Loads the form's preview in AMP pages.
31
+ *
32
+ * @return void.
33
+ */
34
+ public function amp_init()
35
+ {
36
+ if(!empty($_GET['cff-form']))
37
+ {
38
+ $atts = $this->_params_to_attrs();
39
+ // The AMP page has not been redirected so it is redirected from the server side
40
+ if(
41
+ !headers_sent() &&
42
+ empty($_GET['cff-amp-redirected'])
43
+ )
44
+ {
45
+ $host = $_SERVER['HTTP_HOST'];
46
+ if(preg_match('/^www\./i',$host)) $host = preg_replace('/^www\./i','',$host);
47
+ else $host = "www.$host";
48
+
49
+ $request_uri = $_SERVER['REQUEST_URI'];
50
+ $request_uri .= (strpos($request_uri,'?') === false) ? '?' : '&';
51
+ $request_uri .= 'cff-amp-redirected=1';
52
+
53
+ wp_redirect( "https://$host$request_uri" );
54
+ exit;
55
+ }
56
+ else
57
+ {
58
+ $page_title = (!empty($atts['page_title'])) ? $atts['page_title'] : '';
59
+ print '<!DOCTYPE html><html '.
60
+ ((function_exists( 'is_rtl' ) && is_rtl()) ? 'dir="rtl"' : '').
61
+ '>'.
62
+ '<head>'.
63
+ '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />'.
64
+ '<meta name="viewport" content="width=device-width">'.
65
+ '<title>'.esc_html($page_title).'</title>'.
66
+ '<style>'.
67
+ 'body{background:#FFF;overflow:hidden;margin:0;}'.
68
+ 'html, body {height:100%;position:relative;min-height:100%;display:block;}'.
69
+ '#fbuilder{overflow-x:hidden;overflow-y:auto;height:'.$this->_get_height().'px;padding:5px 32px 5px 5px;box-sizing:border-box!important;}'.
70
+ '</style>';
71
+
72
+ // The AMP page has not been redirected
73
+ // and redirects it with javascript
74
+ if(empty($_GET['cff-amp-redirected']))
75
+ {
76
+ print '<script>'.
77
+ 'var current_url = document.location.href;'.
78
+ 'if(/^https:\/\/www\./i.test(current_url)) current_url = current_url.replace(/^https:\/\/www\./i, "https://");'.
79
+ 'else current_url = current_url.replace(/^https:\/\//i, "https://www.");'.
80
+ 'current_url += (current_url.indexOf("?") == -1) ? "?" : "&"'.
81
+ 'document.location.href=current_url+"cff-amp-redirected=1";'.
82
+ '</script>';
83
+ }
84
+ else
85
+ {
86
+ $message = $this->_main_obj->public_form($atts);
87
+ $message = preg_replace('/<form\s+/i', '<form target="_parent" ', $message, 1);
88
+ ob_start();
89
+ wp_footer();
90
+ $message .= ob_get_contents();
91
+ ob_end_clean();
92
+ }
93
+
94
+ print '</head>'.
95
+ '<body>'.
96
+ $message.
97
+ '</body>'.
98
+ '</html>';
99
+
100
+ exit;
101
+ }
102
+ }
103
+ } // End amp_init
104
+
105
+ /**
106
+ * Checks if the page is AMP or not
107
+ *
108
+ * Checks first for the existence of functions: "is_amp_endpoint" or "ampforwp_is_amp_endpoint",
109
+ * and if they don't exists, checks the URL.
110
+ *
111
+ * @return bool.
112
+ */
113
+ public function is_amp()
114
+ {
115
+ if( function_exists('ampforwp_is_amp_endpoint') ) return ampforwp_is_amp_endpoint();
116
+ elseif( function_exists('is_amp_endpoint') )
117
+ {
118
+ if(defined('AMP_QUERY_VAR')) return is_amp_endpoint();
119
+ }
120
+ return false;
121
+ } // End is_amp
122
+
123
+ /**
124
+ * Returns an iframe tag for loading the a webpage with the form only, specially useful for AMP pages.
125
+ *
126
+ * @return string, the iframe tag's structure for loading a page with the form.
127
+ */
128
+ public function get_iframe( $atts )
129
+ {
130
+ $url = CPCFF_AUXILIARY::site_url();
131
+ $url = preg_replace('/^http\:/i', 'https:', $url);
132
+ $url .= (strpos($url, '?') === false) ? '?' : ':';
133
+ $url .= 'cff-form='.((!empty($atts['id']))?$atts['id'] : '');
134
+ $height = '';
135
+ foreach($atts as $attr_name => $attr_value)
136
+ {
137
+ if('amp_iframe_height' == $attr_name) $height = $attr_value;
138
+ elseif('id' != $attr_name) $url .= '&cff-form-attr-'.$attr_name.'='.$attr_value;
139
+ }
140
+
141
+ if(empty($height)) $height = 500;
142
+
143
+ $url .= '&cff-form-height='.$height;
144
+
145
+ // Fixing the isseu with the origin policy in the amp-iframes
146
+ if(preg_match('/^https:\/\/www\./i', $url)) $url = preg_replace('/^https:\/\/www\./i', 'https://', $url);
147
+ else $url = preg_replace('/^https:\/\//i', 'https://www.', $url);
148
+
149
+ add_action('amp_post_template_css', array($this, 'amp_css') );
150
+ add_filter( 'amp_post_template_data', array($this, 'amp_iframe') );
151
+
152
+ return '<amp-iframe id="cff-form-iframe" src="'.esc_attr( esc_url($url)).'" layout="fixed-height" sandbox="allow-popups allow-forms allow-top-navigation allow-modals allow-scripts allow-same-origin" height="'.esc_attr($height).'"><amp-img src="data:image/svg+xml;utf8;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+PHN2ZyB4bWxuczpkYz0iaHR0cDovL3B1cmwub3JnL2RjL2VsZW1lbnRzLzEuMS8iIHhtbG5zOmNjPSJodHRwOi8vY3JlYXRpdmVjb21tb25zLm9yZy9ucyMiIHhtbG5zOnJkZj0iaHR0cDovL3d3dy53My5vcmcvMTk5OS8wMi8yMi1yZGYtc3ludGF4LW5zIyIgeG1sbnM6c3ZnPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiBpZD0ic3ZnOCIgdmVyc2lvbj0iMS4xIiB2aWV3Qm94PSIwIDAgMTMuMjI5MTY3IDEzLjIyOTE2NyIgaGVpZ2h0PSI1MCIgd2lkdGg9IjUwIj48ZGVmcyBpZD0iZGVmczIiIC8+PG1ldGFkYXRhIGlkPSJtZXRhZGF0YTUiPjxyZGY6UkRGPjxjYzpXb3JrIHJkZjphYm91dD0iIj48ZGM6Zm9ybWF0PmltYWdlL3N2Zyt4bWw8L2RjOmZvcm1hdD48ZGM6dHlwZSByZGY6cmVzb3VyY2U9Imh0dHA6Ly9wdXJsLm9yZy9kYy9kY21pdHlwZS9TdGlsbEltYWdlIiAvPjxkYzp0aXRsZT48L2RjOnRpdGxlPjwvY2M6V29yaz48L3JkZjpSREY+PC9tZXRhZGF0YT48ZyB0cmFuc2Zvcm09InRyYW5zbGF0ZSgwLC0yODMuNzcwODMpIiBpZD0ibGF5ZXIxIiAvPjwvc3ZnPg==" placeholder layout="responsive" width="50" height="50" /></amp-iframe>';
153
+ }
154
+
155
+ /**
156
+ * Includes the CSS rules for the amp version of form
157
+ *
158
+ * @param object, template.
159
+ */
160
+ public function amp_css($template)
161
+ {
162
+ print '#cff-form-iframe{margin:0;}';
163
+ } // End amp_css
164
+
165
+ /**
166
+ * Checks if the amp-iframe.js was included, and includes it if not.
167
+ *
168
+ * @param $data, associative array.
169
+ * @return $data, associative array.
170
+ */
171
+ public function amp_iframe($data)
172
+ {
173
+ if ( empty( $data['amp_component_scripts']['amp-iframe'] ) )
174
+ {
175
+ $data['amp_component_scripts']['amp-iframe'] = 'https://cdn.ampproject.org/v0/amp-iframe-0.1.js';
176
+ }
177
+ return $data;
178
+ } // End amp_iframe
179
+
180
+ /**
181
+ * Converts the URL parameters related with the form in the redirection process required for load the forms into the amp-frames
182
+ *
183
+ * The parameter cff-form is converted in the id attribute,
184
+ * and the parameteres with the name: cff-form-attr-<param>, are converted in the attributes <param>
185
+ *
186
+ * @return array $attrs.
187
+ */
188
+ private function _params_to_attrs()
189
+ {
190
+ $attrs = array();
191
+ if(!empty($_GET))
192
+ {
193
+ foreach($_GET as $param => $value)
194
+ {
195
+ if( $param == 'cff-form')
196
+ $attrs['id'] = @intval($value);
197
+ elseif(preg_match('/^cff\-form\-attr\-/i', $param))
198
+ $attrs[preg_replace('/^cff\-form\-attr\-/i', '', $param)] = $value;
199
+ }
200
+ }
201
+ return $attrs;
202
+ } // End _params_to_attrs
203
+
204
+ /**
205
+ * Reads the form height from the URL parameter cff-form-height, returns 500 by default.
206
+ *
207
+ * @return int.
208
+ */
209
+ private function _get_height()
210
+ {
211
+ return (!empty($_GET['cff-form-height']) && ($height=@intval($_GET['cff-form-height'])) !== 0 ) ? $height : 500;
212
+ }
213
+ }
214
+ }
inc/cpcff_auxiliary.inc.php CHANGED
@@ -228,112 +228,6 @@ if(!class_exists('CPCFF_AUXILIARY'))
228
);
229
} // End is_crawler
230
231
- /**
232
- * Checks if the page is AMP or not
233
- *
234
- * Checks first for the existence of functions: "is_amp_endpoint" or "ampforwp_is_amp_endpoint",
235
- * and if they don't exists, checks the URL.
236
- *
237
- * @since 1.0.190
238
- *
239
- * @return bool.
240
- */
241
- public static function is_amp()
242
- {
243
- if( function_exists('ampforwp_is_amp_endpoint') ) return ampforwp_is_amp_endpoint();
244
- elseif( function_exists('is_amp_endpoint') )
245
- {
246
- if(defined('AMP_QUERY_VAR')) return is_amp_endpoint();
247
- }
248
- return false;
249
- } // End is_amp
250
-
251
- /**
252
- * Returns an iframe tag for loading the a webpage with the form only, specially useful for AMP pages.
253
- *
254
- * @since 1.0.190
255
- * @return string, the iframe tag's structure for loading a page with the form.
256
- */
257
- public static function get_iframe( $atts )
258
- {
259
- $url = self::site_url();
260
- $url = preg_replace('/^http\:/i', 'https:', $url);
261
- $url .= (strpos($url, '?') === false) ? '?' : ':';
262
- $url .= 'cff-form='.((!empty($atts['id']))?$atts['id'] : '');
263
- $height = '';
264
- foreach($atts as $attr_name => $attr_value)
265
- {
266
- if('amp_iframe_height' == $attr_name) $height = $attr_value;
267
- elseif('id' != $attr_name) $url .= '&cff-form-attr-'.$attr_name.'='.$attr_value;
268
- }
269
-
270
- if(empty($height)) $height = 500;
271
-
272
- $url .= '&cff-form-height='.$height;
273
-
274
- // Fixing the isseu with the origin policy in the amp-iframes
275
- if(preg_match('/^https:\/\/www\./i', $url)) $url = preg_replace('/^https:\/\/www\./i', 'https://', $url);
276
- else $url = preg_replace('/^https:\/\//i', 'https://www.', $url);
277
-
278
- add_action('amp_post_template_css', array('CPCFF_AUXILIARY', 'amp_css') );
279
- add_filter( 'amp_post_template_data', array('CPCFF_AUXILIARY', 'amp_iframe') );
280
-
281
- return '<amp-iframe id="cff-form-iframe" src="'.esc_attr( esc_url($url)).'" layout="fixed-height" sandbox="allow-popups allow-forms allow-top-navigation allow-modals allow-scripts allow-same-origin" height="'.esc_attr($height).'"><amp-img src="data:image/svg+xml;utf8;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+PHN2ZyB4bWxuczpkYz0iaHR0cDovL3B1cmwub3JnL2RjL2VsZW1lbnRzLzEuMS8iIHhtbG5zOmNjPSJodHRwOi8vY3JlYXRpdmVjb21tb25zLm9yZy9ucyMiIHhtbG5zOnJkZj0iaHR0cDovL3d3dy53My5vcmcvMTk5OS8wMi8yMi1yZGYtc3ludGF4LW5zIyIgeG1sbnM6c3ZnPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiBpZD0ic3ZnOCIgdmVyc2lvbj0iMS4xIiB2aWV3Qm94PSIwIDAgMTMuMjI5MTY3IDEzLjIyOTE2NyIgaGVpZ2h0PSI1MCIgd2lkdGg9IjUwIj48ZGVmcyBpZD0iZGVmczIiIC8+PG1ldGFkYXRhIGlkPSJtZXRhZGF0YTUiPjxyZGY6UkRGPjxjYzpXb3JrIHJkZjphYm91dD0iIj48ZGM6Zm9ybWF0PmltYWdlL3N2Zyt4bWw8L2RjOmZvcm1hdD48ZGM6dHlwZSByZGY6cmVzb3VyY2U9Imh0dHA6Ly9wdXJsLm9yZy9kYy9kY21pdHlwZS9TdGlsbEltYWdlIiAvPjxkYzp0aXRsZT48L2RjOnRpdGxlPjwvY2M6V29yaz48L3JkZjpSREY+PC9tZXRhZGF0YT48ZyB0cmFuc2Zvcm09InRyYW5zbGF0ZSgwLC0yODMuNzcwODMpIiBpZD0ibGF5ZXIxIiAvPjwvc3ZnPg==" placeholder layout="responsive" width="50" height="50" /></amp-iframe>';
282
- }
283
-
284
- /**
285
- * Includes the CSS rules for the amp version of form
286
- *
287
- * @sinze 1.0.190
288
- *
289
- * @param object, template.
290
- */
291
- public static function amp_css($template)
292
- {
293
- print '#cff-form-iframe{margin:0;}';
294
- } // End amp_css
295
-
296
- /**
297
- * Checks if the amp-iframe.js was included, and includes it if not.
298
- *
299
- * @since 1.0.193
300
- * @param $data, associative array.
301
- * @return $data, associative array.
302
- */
303
- public static function amp_iframe($data)
304
- {
305
- if ( empty( $data['amp_component_scripts']['amp-iframe'] ) )
306
- {
307
- $data['amp_component_scripts']['amp-iframe'] = 'https://cdn.ampproject.org/v0/amp-iframe-0.1.js';
308
- }
309
- return $data;
310
- } // End amp_iframe
311
-
312
- /**
313
- * Converts the corresponding parameters in an associative array.
314
- *
315
- * The parameters with the name cff-form is converted in the id attribute,
316
- * and the parameteres with the name: cff-form-attr-<param>, are converted in the attributes <param>
317
- *
318
- * @since 1.0.190
319
- * @return array $attrs.
320
- */
321
- public static function params_to_attrs()
322
- {
323
- $attrs = array();
324
- if(!empty($_GET))
325
- {
326
- foreach($_GET as $param => $value)
327
- {
328
- if( $param == 'cff-form')
329
- $attrs['id'] = @intval($value);
330
- elseif(preg_match('/^cff\-form\-attr\-/i', $param))
331
- $attrs[preg_replace('/^cff\-form\-attr\-/i', '', $param)] = $value;
332
- }
333
- }
334
- return $attrs;
335
- } // End params_to_attrs
336
-
337
/**
338
* Adds the attribute: property="stylesheet" to the link tag to validate the link tags into the pages' bodies.
339
*
228
);
229
} // End is_crawler
230
231
/**
232
* Adds the attribute: property="stylesheet" to the link tag to validate the link tags into the pages' bodies.
233
*
inc/cpcff_main.inc.php CHANGED
@@ -70,6 +70,15 @@ if(!class_exists('CPCFF_MAIN'))
70
*/
71
private $_forms = array();
72
73
/**
74
* Constructs a CPCFF_MAIN object, and define the hooks to the filters and actions.
75
* The constructor is private because this class is a singleton
@@ -77,6 +86,7 @@ if(!class_exists('CPCFF_MAIN'))
77
private function __construct()
78
{
79
require_once CP_CALCULATEDFIELDSF_BASE_PATH.'/inc/cpcff_form.inc.php';
80
81
// Initializes the $_is_admin property
82
$this->_is_admin = is_admin();
@@ -90,9 +100,11 @@ if(!class_exists('CPCFF_MAIN'))
90
// Load the language file
91
add_action( 'plugins_loaded', array($this, 'plugins_loaded') );
92
93
// Run the initialization code
94
add_action( 'init', array($this, 'init'), 1 );
95
- add_action( 'init', array($this, 'amp_init') ); // for amp pages.
96
97
// Run the initialization code of widgets
98
add_action( 'widgets_init', array($this, 'widgets_init'), 1 );
@@ -160,26 +172,6 @@ if(!class_exists('CPCFF_MAIN'))
160
}
161
} // End init
162
163
- /**
164
- * Loads the form's preview in AMP pages.
165
- *
166
- * @return void.
167
- */
168
- public function amp_init()
169
- {
170
- if(!empty($_GET['cff-form']))
171
- {
172
- $this->form_preview(
173
- array(
174
- 'shortcode_atts' => CPCFF_AUXILIARY::params_to_attrs(),
175
- 'amp' => 1,
176
- 'page_title' => __('CFF Form', 'calculated-fields-form'),
177
- 'height' => (!empty($_REQUEST['cff-form-height'])) ? @intval($_REQUEST['cff-form-height']) : 500
178
- )
179
- );
180
- }
181
- } // End amp_init
182
-
183
/**
184
* Registers the widgets.
185
*
@@ -379,84 +371,13 @@ if(!class_exists('CPCFF_MAIN'))
379
{
380
if(isset($atts['shortcode_atts']))
381
{
382
- $message = '';
383
- // It is a common form's preview or it is an AMP page after be redirected
384
- if(
385
- !empty($atts['popup']) ||
386
- !empty($_GET['cff-amp-redirected'])
387
- )
388
- {
389
- $message = $this->public_form($atts['shortcode_atts']);
390
- if(!empty($atts['amp'])) $message = preg_replace('/<form\s+/i', '<form target="_parent" ', $message, 1);
391
-
392
- ob_start();
393
- wp_footer();
394
- $message .= ob_get_contents();
395
- ob_end_clean();
396
-
397
- $page_title = '';
398
- if(!empty($atts['page_title'])) $page_title = $atts['page_title'];
399
- }
400
-
401
- if(!empty($atts['popup']))
402
- {
403
- wp_die($message, $page_title, 200);
404
- }
405
- else
406
- {
407
- // The AMP page has not been redirected
408
- // and redirects it from server side
409
- if(
410
- !headers_sent() &&
411
- empty($_GET['cff-amp-redirected'])
412
- )
413
- {
414
- $host = $_SERVER['HTTP_HOST'];
415
- if(preg_match('/^www\./i',$host)) $host = preg_replace('/^www\./i','',$host);
416
- else $host = "www.$host";
417
-
418
- $request_uri = $_SERVER['REQUEST_URI'];
419
- $request_uri .= (strpos($request_uri,'?') === false) ? '?' : '&';
420
- $request_uri .= 'cff-amp-redirected=1';
421
- wp_redirect( "https://$host$request_uri" );
422
- }
423
- else
424
- {
425
- print '<!DOCTYPE html><html '.
426
- ((function_exists( 'is_rtl' ) && is_rtl()) ? 'dir="rtl"' : '').
427
- '>'.
428
- '<head>'.
429
- '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />'.
430
- '<meta name="viewport" content="width=device-width">'.
431
- '<title>'.esc_html($page_title).'</title>'.
432
- '<style>'.
433
- 'body{background:#FFF;overflow:hidden;margin:0;}'.
434
- 'html, body {height:100%;position:relative;min-height:100%;display:block;}'.
435
- '#fbuilder{overflow-x:hidden;overflow-y:auto;height:'.intval(@$atts['height']).'px;padding:5px 32px 5px 5px;box-sizing:border-box!important;}'.
436
- '</style>';
437
-
438
- // The AMP page has not been redirected
439
- // and redirects it with javascript
440
- if(empty($_GET['cff-amp-redirected']))
441
- {
442
- print '<script>'.
443
- 'var current_url = document.location.href;'.
444
- 'if(/^https:\/\/www\./i.test(current_url)) current_url = current_url.replace(/^https:\/\/www\./i, "https://");'.
445
- 'else current_url = current_url.replace(/^https:\/\//i, "https://www.");'.
446
- 'current_url += (current_url.indexOf("?") == -1) ? "?" : "&"'.
447
- 'document.location.href=current_url+"cff-amp-redirected=1";'.
448
- '</script>';
449
- }
450
-
451
- print '</head>'.
452
- '<body>'.
453
- $message.
454
- '</body>'.
455
- '</html>';
456
- }
457
-
458
- exit;
459
- }
460
}
461
} // End form_preview
462
@@ -473,9 +394,9 @@ if(!class_exists('CPCFF_MAIN'))
473
// If the website is being visited by crawler, display empty text.
474
if( CPCFF_AUXILIARY::is_crawler() ) return '';
475
if( empty($atts) ) $atts = array();
476
- if(!$this->_is_admin && CPCFF_AUXILIARY::is_amp())
477
{
478
- $content = CPCFF_AUXILIARY::get_iframe($atts);
479
}
480
else
481
{
@@ -796,7 +717,8 @@ if(!class_exists('CPCFF_MAIN'))
796
"equalTo" => $cpcff_texts_array[ 'errors' ][ 'equalTo' ][ 'text' ],
797
"accept" => $cpcff_texts_array[ 'errors' ][ 'accept' ][ 'text' ],
798
"upload_size" => $cpcff_texts_array[ 'errors' ][ 'upload_size' ][ 'text' ],
799
- "phone" => $cpcff_texts_array[ 'errors' ][ 'phone' ][ 'text' ]
800
)
801
);
802
return json_encode( $obj );
70
*/
71
private $_forms = array();
72
73
+ /**
74
+ * Instance of the CPCFF_AMP class to manage the forms in AMP pages
75
+ * Instance property.
76
+ *
77
+ * @sinze 1.0.230
78
+ * @var object $_amp
79
+ */
80
+ private $_amp;
81
+
82
/**
83
* Constructs a CPCFF_MAIN object, and define the hooks to the filters and actions.
84
* The constructor is private because this class is a singleton
86
private function __construct()
87
{
88
require_once CP_CALCULATEDFIELDSF_BASE_PATH.'/inc/cpcff_form.inc.php';
89
+ require_once CP_CALCULATEDFIELDSF_BASE_PATH.'/inc/cpcff_amp.inc.php';
90
91
// Initializes the $_is_admin property
92
$this->_is_admin = is_admin();
100
// Load the language file
101
add_action( 'plugins_loaded', array($this, 'plugins_loaded') );
102
103
+ // Instanciate the AMP object
104
+ $this->_amp = new CPCFF_AMP($this);
105
+
106
// Run the initialization code
107
add_action( 'init', array($this, 'init'), 1 );
108
109
// Run the initialization code of widgets
110
add_action( 'widgets_init', array($this, 'widgets_init'), 1 );
172
}
173
} // End init
174
175
/**
176
* Registers the widgets.
177
*
371
{
372
if(isset($atts['shortcode_atts']))
373
{
374
+ $message = $this->public_form($atts['shortcode_atts']);
375
+ ob_start();
376
+ wp_footer();
377
+ $message .= ob_get_contents();
378
+ ob_end_clean();
379
+ $page_title = (!empty($atts['page_title'])) ? $atts['page_title'] : '';
380
+ wp_die($message, $page_title, 200);
381
}
382
} // End form_preview
383
394
// If the website is being visited by crawler, display empty text.
395
if( CPCFF_AUXILIARY::is_crawler() ) return '';
396
if( empty($atts) ) $atts = array();
397
+ if(!$this->_is_admin && $this->_amp->is_amp())
398
{
399
+ $content = $this->_amp->get_iframe($atts);
400
}
401
else
402
{
717
"equalTo" => $cpcff_texts_array[ 'errors' ][ 'equalTo' ][ 'text' ],
718
"accept" => $cpcff_texts_array[ 'errors' ][ 'accept' ][ 'text' ],
719
"upload_size" => $cpcff_texts_array[ 'errors' ][ 'upload_size' ][ 'text' ],
720
+ "phone" => $cpcff_texts_array[ 'errors' ][ 'phone' ][ 'text' ],
721
+ "currency" => $cpcff_texts_array[ 'errors' ][ 'currency' ][ 'text' ]
722
)
723
);
724
return json_encode( $obj );
js/fbuilder-pro-public.jquery.js CHANGED
@@ -78,7 +78,8 @@
78
minlength: $.validator.format("Please enter at least {0} characters."),
79
equalTo: "Please enter the same value again.",
80
max: $.validator.format("Please enter a value less than or equal to {0}."),
81
- min: $.validator.format("Please enter a value greater than or equal to {0}.")
82
},opt.messages);
83
84
opt.messages.max = $.validator.format(opt.messages.max);
78
minlength: $.validator.format("Please enter at least {0} characters."),
79
equalTo: "Please enter the same value again.",
80
max: $.validator.format("Please enter a value less than or equal to {0}."),
81
+ min: $.validator.format("Please enter a value greater than or equal to {0}."),
82
+ currency: "Please enter a valid currency value."
83
},opt.messages);
84
85
opt.messages.max = $.validator.format(opt.messages.max);
js/fields-public/01_fbuilder.ftext.js CHANGED
@@ -30,14 +30,15 @@
30
var parts = this.regExp.match(/(\/)(.*)(\/)([gimy]{0,4})#x2F;i);
31
this.regExp = ( parts === null ) ? new RegExp(this.regExp) : new RegExp(parts[2],parts[4].toLowerCase());
32
33
- $.validator.addMethod( 'pattern', function( value, element, param )
34
- {
35
- try{
36
- return this.optional(element) || param.test( value );
37
}
38
- catch(err){return true;}
39
- }
40
- );
41
$('#'+this.name).rules('add',{'pattern':this.regExp, messages:{'pattern':this.regExpMssg}});
42
}
43
},
30
var parts = this.regExp.match(/(\/)(.*)(\/)([gimy]{0,4})#x2F;i);
31
this.regExp = ( parts === null ) ? new RegExp(this.regExp) : new RegExp(parts[2],parts[4].toLowerCase());
32
33
+ if(!('pattern' in $.validator.methods))
34
+ $.validator.addMethod( 'pattern', function( value, element, param )
35
+ {
36
+ try{
37
+ return this.optional(element) || param.test( value );
38
+ }
39
+ catch(err){return true;}
40
}
41
+ );
42
$('#'+this.name).rules('add',{'pattern':this.regExp, messages:{'pattern':this.regExpMssg}});
43
}
44
},
js/fields-public/02_fbuilder.fcurrency.js CHANGED
@@ -10,6 +10,7 @@
10
required:false,
11
readonly:false,
12
size:"small",
13
currencyText:"USD",
14
thousandSeparator:",",
15
centSeparator:".",
@@ -19,36 +20,35 @@
19
20
getFormattedValue:function( value )
21
{
22
- this.centSeparator = $.trim(this.centSeparator);
23
- if( /^\s*#x2F;.test( this.centSeparator ) ) this.centSeparator = '.';
24
25
- var v = $.trim( value ), parts = [], counter = 0, str = '', s = '';
26
- v = v.replace( new RegExp( $.fbuilder[ 'escape_symbol' ](this.currencySymbol), 'g' ), '' )
27
- .replace( new RegExp( $.fbuilder[ 'escape_symbol' ](this.currencyText), 'g' ), '' );
28
- v = $.fbuilder.parseVal( v, this.thousandSeparator, this.centSeparator );
29
if( !isNaN( v ) )
30
{
31
- if(v < 0) s = '-';
32
v = ABS(v);
33
parts = v.toString().split(".");
34
35
- if( !/^\s*#x2F;.test( this.thousandSeparator ) )
36
{
37
- for( var i = parts[0].length-1; i >= 0; i--){
38
- counter++;
39
- str = parts[0][i] + str;
40
- if( counter%3 == 0 && i != 0 ) str = this.thousandSeparator + str;
41
-
42
- }
43
- parts[0] = str;
44
}
45
- if( typeof parts[ 1 ] != 'undefined' )
46
{
47
- if(parts[ 1 ].length == 1) parts[ 1 ] += '0';
48
}
49
else parts[ 1 ] = '00';
50
51
- return this.currencySymbol+s+parts.join( this.centSeparator )+this.currencyText;
52
}
53
else
54
{
@@ -57,14 +57,14 @@
57
},
58
show:function()
59
{
60
- return '<div class="fields '+this.csslayout+' cff-currency-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 '+(( this.readonly )? 'readonly' : '' )+' id="'+this.name+'" name="'+this.name+'" class="field '+this.dformat+' '+this.size+((this.required)?" required":"")+'" type="text" value="'+$.fbuilder.htmlEncode( this.getFormattedValue( this.predefined ) )+'" '+( ( !/^\s*#x2F;.test( this.min) ) ? 'min="'+$.fbuilder.parseVal( this.min, this.thousandSeparator, this.centSeparator )+'" ' : '' )+( ( !/^\s*#x2F;.test( this.max) ) ? ' max="'+$.fbuilder.parseVal( this.max, this.thousandSeparator, this.centSeparator )+'" ' : '' )+' /><span class="uh">'+this.userhelp+'</span></div><div class="clearer"></div></div>';
61
},
62
after_show:function()
63
{
64
if( this.formatDynamically )
65
{
66
67
- var me = this;
68
$( document ).on( 'change', '[name="' + me.name + '"]', function(){
69
this.value = me.getFormattedValue( this.value );
70
} );
@@ -72,51 +72,39 @@
72
73
if( typeof $[ 'validator' ] != 'undefined' )
74
{
75
- $.validator.addMethod( 'min', function( value, element, param )
76
- {
77
- var e = element;
78
- if( element.id.match( /_\d+#x2F;) )
79
- {
80
- e = $.fbuilder[ 'forms' ][ element.id.match( /_\d+#x2F;)[ 0 ] ].getItem( element.name )
81
- }
82
- else if(
83
- typeof $.fbuilder[ 'forms' ] != 'undefined' &&
84
- typeof $.fbuilder[ 'forms' ][ '' ] != 'undefined'
85
- )
86
- {
87
- e = $.fbuilder[ 'forms' ][ '' ].getItem( element.name )
88
- }
89
-
90
- var thousandSeparator = ( typeof e.thousandSeparator != 'undefined' ) ? e.thousandSeparator : '',
91
- centSymbol = ( typeof e.centSeparator != 'undefined' && $.trim( e.centSeparator ) ) ? e.centSeparator : '.';
92
-
93
- return this.optional(element) || $.fbuilder.parseVal( value, thousandSeparator, centSymbol ) >= param;
94
- }
95
- );
96
-
97
- $.validator.addMethod( 'max', function( value, element, param )
98
- {
99
- var e = element;
100
- if( element.id.match( /_\d+#x2F;) )
101
- {
102
- e = $.fbuilder[ 'forms' ][ element.id.match( /_\d+#x2F;)[ 0 ] ].getItem( element.name )
103
- }
104
- else if(
105
- typeof $.fbuilder[ 'forms' ] != 'undefined' &&
106
- typeof $.fbuilder[ 'forms' ][ '' ] != 'undefined'
107
- )
108
- {
109
- e = $.fbuilder[ 'forms' ][ '' ].getItem( element.name )
110
- }
111
-
112
-
113
- var thousandSeparator = ( typeof e.thousandSeparator != 'undefined' ) ? e.thousandSeparator : '',
114
- centSymbol = ( typeof e.centSeparator != 'undefined' && $.trim( e.centSeparator ) ) ? e.centSeparator : '.';
115
-
116
- return this.optional(element) || $.fbuilder.parseVal( value, thousandSeparator, centSymbol ) <= param;
117
- }
118
- );
119
-
120
}
121
},
122
val:function()
10
required:false,
11
readonly:false,
12
size:"small",
13
+ currencySymbol:"quot;,
14
currencyText:"USD",
15
thousandSeparator:",",
16
centSeparator:".",
20
21
getFormattedValue:function( value )
22
{
23
+ var ts = this.thousandSeparator,
24
+ cs = ((cs = $.trim(this.centSeparator)) !== '') ? cs : '.',
25
+ v = $.fbuilder.parseVal(value, ts, cs),
26
+ parts = [],
27
+ counter = 0,
28
+ str = '',
29
+ sign = '';
30
31
if( !isNaN( v ) )
32
{
33
+ if(v < 0) sign = '-';
34
v = ABS(v);
35
parts = v.toString().split(".");
36
37
+ for( var i = parts[0].length-1; i >= 0; i--)
38
{
39
+ counter++;
40
+ str = parts[0][i] + str;
41
+ if( counter%3 == 0 && i != 0 ) str = ts + str;
42
}
43
+ parts[0] = str;
44
+
45
+ if(parts[1])
46
{
47
+ if(parts[1].length == 1) parts[1] += '0';
48
}
49
else parts[ 1 ] = '00';
50
51
+ return this.currencySymbol+sign+parts.join(cs)+this.currencyText;
52
}
53
else
54
{
57
},
58
show:function()
59
{
60
+ return '<div class="fields '+this.csslayout+' cff-currency-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 '+(( this.readonly )? 'readonly' : '' )+' id="'+this.name+'" name="'+this.name+'" class="field cffcurrency '+this.size+((this.required)?" required":"")+'" type="text" value="'+$.fbuilder.htmlEncode( this.getFormattedValue( this.predefined ) )+'" '+( ( !/^\s*#x2F;.test( this.min) ) ? 'min="'+$.fbuilder.parseVal( this.min, this.thousandSeparator, this.centSeparator )+'" ' : '' )+( ( !/^\s*#x2F;.test( this.max) ) ? ' max="'+$.fbuilder.parseVal( this.max, this.thousandSeparator, this.centSeparator )+'" ' : '' )+' /><span class="uh">'+this.userhelp+'</span></div><div class="clearer"></div></div>';
61
},
62
after_show:function()
63
{
64
+ var me = this;
65
if( this.formatDynamically )
66
{
67
68
$( document ).on( 'change', '[name="' + me.name + '"]', function(){
69
this.value = me.getFormattedValue( this.value );
70
} );
72
73
if( typeof $[ 'validator' ] != 'undefined' )
74
{
75
+ if(!('cffcurrency' in $.validator.methods))
76
+ $.validator.addMethod(
77
+ 'cffcurrency',
78
+ function(v, el)
79
+ {
80
+ var f = el.id.match( /_\d+#x2F;),
81
+ esc = $.fbuilder.escape_symbol,
82
+ r;
83
+
84
+ e = $.fbuilder['forms'][f[0]].getItem( el.name );
85
+ r = new RegExp('^\\s*('+esc(e.currencySymbol)+')?\\s*\\-?\\d+('+esc(e.thousandSeparator)+'\\d{3})*('+e.centSeparator+'\\d+)?\\s*('+esc(e.currencyText)+')?\\s*#x27;,'i');
86
+
87
+ return this.optional(el) || r.test(v) || $.isNumeric(v);
88
+ },
89
+ $.validator.messages['currency']
90
+ );
91
+ $.validator.methods.min = function(v, el, p)
92
+ {
93
+ var f = el.id.match( /_\d+#x2F;), e;
94
+
95
+ if(f) e = $.fbuilder['forms'][f[0]].getItem(el.name);
96
+ if(e) v = e.val();
97
+ return this.optional(el) || v >= p;
98
+ };
99
+ $.validator.methods.max = function(v, el, p)
100
+ {
101
+ var f = el.id.match( /_\d+#x2F;), e;
102
+
103
+ if(f) e = $.fbuilder['forms'][f[0]].getItem(el.name);
104
+ if(e) v = e.val();
105
+
106
+ return this.optional(el) || v <= p;
107
+ };
108
}
109
},
110
val:function()
js/fields-public/02_fbuilder.fnumber.js CHANGED
@@ -19,27 +19,28 @@
19
formats:new Array("digits","number"),
20
getFormattedValue:function( value )
21
{
22
- this.decimalSymbol = $.trim(this.decimalSymbol);
23
- if( /^\s*#x2F;.test( this.decimalSymbol ) ) this.decimalSymbol = '.';
24
- var v = $.trim( value ), s = '', counter = 0, str = '', parts = [];
25
- v = $.fbuilder.parseVal( v, this.thousandSeparator, this.decimalSymbol );
26
- if( !isNaN( v ) )
27
{
28
if(v < 0) s = '-';
29
v = ABS(v);
30
parts = v.toString().split(".");
31
32
- if( !/^\s*#x2F;.test( this.thousandSeparator ) )
33
- {
34
- for( var i = parts[0].length-1; i >= 0; i--){
35
- counter++;
36
- str = parts[0][i] + str;
37
- if( counter%3 == 0 && i != 0 ) str = this.thousandSeparator + str;
38
39
- }
40
- parts[0] = str;
41
}
42
- return s+parts.join( this.decimalSymbol );
43
}
44
else
45
{
@@ -54,10 +55,9 @@
54
},
55
after_show:function()
56
{
57
if( this.formatDynamically && this.dformat != 'digits' )
58
{
59
-
60
- var me = this;
61
$( document ).on( 'change', '[name="' + me.name + '"]', function(){
62
this.value = me.getFormattedValue( this.value );
63
} );
@@ -65,74 +65,37 @@
65
66
if( typeof $[ 'validator' ] != 'undefined' )
67
{
68
- $.validator.addMethod( 'number', function( value, element )
69
- {
70
- var e = element;
71
- if( element.id.match( /_\d+#x2F;) )
72
- {
73
- e = $.fbuilder[ 'forms' ][ element.id.match( /_\d+#x2F;)[ 0 ] ].getItem( element.name )
74
- }
75
- else if(
76
- typeof $.fbuilder[ 'forms' ] != 'undefined' &&
77
- typeof $.fbuilder[ 'forms' ][ '' ] != 'undefined'
78
- )
79
- {
80
- e = $.fbuilder[ 'forms' ][ '' ].getItem( element.name )
81
- }
82
-
83
- var thousandSeparator = ( typeof e.thousandSeparator != 'undefined' ) ? e.thousandSeparator : '',
84
- decimalSymbol = ( typeof e.decimalSymbol != 'undefined' && $.trim( e.decimalSymbol ) ) ? e.decimalSymbol : '.';
85
-
86
- var regExp = new RegExp( '^-?(?:\\d+|\\d{1,3}(?:' + $.fbuilder.escape_symbol( thousandSeparator ) + '\\d{3})+)?(?:' + $.fbuilder.escape_symbol( decimalSymbol ) + '\\d+)?#x27; );
87
-
88
- return this.optional(element) || regExp.test( value ) || $.isNumeric(value);
89
- }
90
- );
91
92
- $.validator.addMethod( 'min', function( value, element, param )
93
- {
94
- var e = element;
95
- if( element.id.match( /_\d+#x2F;) )
96
- {
97
- e = $.fbuilder[ 'forms' ][ element.id.match( /_\d+#x2F;)[ 0 ] ].getItem( element.name )
98
- }
99
- else if(
100
- typeof $.fbuilder[ 'forms' ] != 'undefined' &&
101
- typeof $.fbuilder[ 'forms' ][ '' ] != 'undefined'
102
- )
103
- {
104
- e = $.fbuilder[ 'forms' ][ '' ].getItem( element.name )
105
- }
106
107
- var thousandSeparator = ( typeof e.thousandSeparator != 'undefined' ) ? e.thousandSeparator : '',
108
- decimalSymbol = ( typeof e.decimalSymbol != 'undefined' && $.trim( e.decimalSymbol ) ) ? e.decimalSymbol : '.';
109
110
- return this.optional(element) || $.fbuilder.parseVal( value, thousandSeparator, decimalSymbol ) >= param;
111
- }
112
- );
113
114
- $.validator.addMethod( 'max', function( value, element, param )
115
- {
116
- var e = element;
117
- if( element.id.match( /_\d+#x2F;) )
118
- {
119
- e = $.fbuilder[ 'forms' ][ element.id.match( /_\d+#x2F;)[ 0 ] ].getItem( element.name )
120
- }
121
- else if(
122
- typeof $.fbuilder[ 'forms' ] != 'undefined' &&
123
- typeof $.fbuilder[ 'forms' ][ '' ] != 'undefined'
124
- )
125
- {
126
- e = $.fbuilder[ 'forms' ][ '' ].getItem( element.name )
127
- }
128
129
- var thousandSeparator = ( typeof e.thousandSeparator != 'undefined' ) ? e.thousandSeparator : '',
130
- decimalSymbol = ( typeof e.decimalSymbol != 'undefined' && $.trim( e.decimalSymbol ) ) ? e.decimalSymbol : '.';
131
132
- return this.optional(element) || $.fbuilder.parseVal( value, thousandSeparator, decimalSymbol ) <= param;
133
- }
134
- );
135
136
}
137
},
138
val:function()
19
formats:new Array("digits","number"),
20
getFormattedValue:function( value )
21
{
22
+ var ts = this.thousandSeparator,
23
+ ds = ((ds=$.trim(this.decimalSymbol)) !== '') ? ds : '.',
24
+ v = $.fbuilder.parseVal(value, ts, ds),
25
+ s = '',
26
+ counter = 0,
27
+ str = '',
28
+ parts = [];
29
+
30
+ if(!isNaN(v))
31
{
32
if(v < 0) s = '-';
33
v = ABS(v);
34
parts = v.toString().split(".");
35
36
+ for(var i = parts[0].length-1; i >= 0; i--){
37
+ counter++;
38
+ str = parts[0][i] + str;
39
+ if(counter%3 == 0 && i != 0) str = ts + str;
40
41
}
42
+ parts[0] = str;
43
+ return s+parts.join(ds);
44
}
45
else
46
{
55
},
56
after_show:function()
57
{
58
+ var me = this;
59
if( this.formatDynamically && this.dformat != 'digits' )
60
{
61
$( document ).on( 'change', '[name="' + me.name + '"]', function(){
62
this.value = me.getFormattedValue( this.value );
63
} );
65
66
if( typeof $[ 'validator' ] != 'undefined' )
67
{
68
69
+ $.validator.methods.number = function(v, el)
70
+ {
71
+ var f = el.id.match(/_\d+#x2F;),
72
+ esc = $.fbuilder.escape_symbol,
73
+ e, r;
74
75
+ if(f) e = $.fbuilder['forms'][f[0]].getItem(el.name);
76
+ if(!e) e = {thousandSeparator: ',', decimalSymbol: '.'};
77
78
+ r = new RegExp('^\\s*\\-?\\d+('+esc(e.thousandSeparator)+'\\d{3})*('+esc(e.decimalSymbol)+'\\d+)?\\s*#x27;,'i');
79
80
+ return this.optional(el) || r.test(v) || $.isNumeric(v);
81
+ };
82
+ $.validator.methods.min = function(v, el, p)
83
+ {
84
+ var f = el.id.match( /_\d+#x2F;), e;
85
86
+ if(f) e = $.fbuilder['forms'][f[0]].getItem(el.name);
87
+ if(e) v = e.val();
88
+ return this.optional(el) || v >= p;
89
+ };
90
+ $.validator.methods.max = function(v, el, p)
91
+ {
92
+ var f = el.id.match( /_\d+#x2F;), e;
93
94
+ if(f) e = $.fbuilder['forms'][f[0]].getItem(el.name);
95
+ if(e) v = e.val();
96
97
+ return this.optional(el) || v <= p;
98
+ };
99
}
100
},
101
val:function()
js/fields-public/04_fbuilder.fdate.js CHANGED
@@ -298,8 +298,8 @@
298
(
299
( minDate == null || date >= minDate ) &&
300
( maxDate == null || date <= maxDate ) &&
301
- me.validateDate( $( e ).datepicker( 'getDate' ), item.working_dates, item.invalidDates )[ 0 ] &&
302
- me.validateTime( e, item )
303
);
304
}
305
return true;
@@ -310,8 +310,8 @@
310
}
311
};
312
313
- $.validator.addMethod("dateddmmyyyy", validator );
314
- $.validator.addMethod("datemmddyyyy", validator );
315
316
me.setDefaultDate();
317
me.setDefaultTime();
298
(
299
( minDate == null || date >= minDate ) &&
300
( maxDate == null || date <= maxDate ) &&
301
+ item.validateDate( $( e ).datepicker( 'getDate' ), item.working_dates, item.invalidDates )[ 0 ] &&
302
+ item.validateTime( e, item )
303
);
304
}
305
return true;
310
}
311
};
312
313
+ if(!('dateddmmyyyy' in $.validator.methods)) $.validator.addMethod("dateddmmyyyy", validator );
314
+ if(!('datemmddyyyy' in $.validator.methods)) $.validator.addMethod("datemmddyyyy", validator );
315
316
me.setDefaultDate();
317
me.setDefaultTime();
js/fields-public/09_fbuilder.ffile.js CHANGED
@@ -21,28 +21,30 @@
21
{
22
var me = this;
23
24
- $.validator.addMethod("accept", function(value, element, param)
25
- {
26
- if( this.optional( element ) ) return true;
27
- else{
28
- param = typeof param === "string" ? param.replace(/,/g, '|') : "png|jpe?g|gif";
29
- var regExpObj = new RegExp(".(" + param + ")quot;, "i");
30
- for( var i = 0, h = element.files.length; i < h; i++ )
31
- if( !element.files[ i ].name.match( regExpObj ) ) return false;
32
- return true;
33
- }
34
- });
35
-
36
- $.validator.addMethod("upload_size", function(value, element,params)
37
- {
38
- if( this.optional( element ) ) return true;
39
- else{
40
- var total = 0;
41
- for( var i = 0, h = element.files.length; i < h; i++ )
42
- total += element.files[ i ].size/1024;
43
- return ( total <= params );
44
- }
45
- });
46
47
$( '#'+me.name ).change( function(){
48
$( this ).siblings( 'span.files-list' ).remove();
21
{
22
var me = this;
23
24
+ if(!('accept' in $.validator.methods))
25
+ $.validator.addMethod("accept", function(value, element, param)
26
+ {
27
+ if( this.optional( element ) ) return true;
28
+ else{
29
+ param = typeof param === "string" ? param.replace(/,/g, '|') : "png|jpe?g|gif";
30
+ var regExpObj = new RegExp(".(" + param + ")quot;, "i");
31
+ for( var i = 0, h = element.files.length; i < h; i++ )
32
+ if( !element.files[ i ].name.match( regExpObj ) ) return false;
33
+ return true;
34
+ }
35
+ });
36
+
37
+ if(!('upload_size' in $.validator.methods))
38
+ $.validator.addMethod("upload_size", function(value, element,params)
39
+ {
40
+ if( this.optional( element ) ) return true;
41
+ else{
42
+ var total = 0;
43
+ for( var i = 0, h = element.files.length; i < h; i++ )
44
+ total += element.files[ i ].size/1024;
45
+ return ( total <= params );
46
+ }
47
+ });
48
49
$( '#'+me.name ).change( function(){
50
$( this ).siblings( 'span.files-list' ).remove();
js/fields-public/11_fbuilder.fphone.js CHANGED
@@ -40,11 +40,12 @@
40
var me = this,
41
tmp = me.dformat.split(' ');
42
43
- $.validator.addMethod("phone", function(value, element)
44
- {
45
- if( this.optional( element ) ) return true;
46
- else return /^\+{0,1}\d*#x2F;.test(value);
47
- });
48
49
for (var i = 0, h = tmp.length; i < h; i++ )
50
{
40
var me = this,
41
tmp = me.dformat.split(' ');
42
43
+ if(!('phone' in $.validator.methods))
44
+ $.validator.addMethod("phone", function(value, element)
45
+ {
46
+ if( this.optional( element ) ) return true;
47
+ else return /^\+{0,1}\d*#x2F;.test(value);
48
+ });
49
50
for (var i = 0, h = tmp.length; i < h; i++ )
51
{