Formidable Forms – Form Builder for WordPress - Version 4.04.05

Version Description

  • When some styling settings are blank, allow inheritance from theme styling.
  • Allow a form action to be updated during form migration.
  • Code: Update javascript codestyling.
Download this release

Release Info

Developer sswells
Plugin Icon 128x128 Formidable Forms – Form Builder for WordPress
Version 4.04.05
Comparing to
See all releases

Code changes from version 4.04.04 to 4.04.05

classes/helpers/FrmAppHelper.php CHANGED
@@ -11,7 +11,7 @@ class FrmAppHelper {
11
  /**
12
  * @since 2.0
13
  */
14
- public static $plug_version = '4.04.04';
15
 
16
  /**
17
  * @since 1.07.02
@@ -2215,7 +2215,7 @@ class FrmAppHelper {
2215
  'saved' => esc_attr( __( 'Saved', 'formidable' ) ),
2216
  'ok' => __( 'OK', 'formidable' ),
2217
  'cancel' => __( 'Cancel', 'formidable' ),
2218
- 'default' => __( 'Default', 'formidable' ),
2219
  'clear_default' => __( 'Clear default value when typing', 'formidable' ),
2220
  'no_clear_default' => __( 'Do not clear default value when typing', 'formidable' ),
2221
  'valid_default' => __( 'Default value will pass form validation', 'formidable' ),
@@ -2237,7 +2237,7 @@ class FrmAppHelper {
2237
  'import_complete' => __( 'Import Complete', 'formidable' ),
2238
  'updating' => __( 'Please wait while your site updates.', 'formidable' ),
2239
  'no_save_warning' => __( 'Warning: There is no way to retrieve unsaved entries.', 'formidable' ),
2240
- 'private' => __( 'Private', 'formidable' ),
2241
  'jquery_ui_url' => self::jquery_ui_base_url(),
2242
  'pro_url' => is_callable( 'FrmProAppHelper::plugin_url' ) ? FrmProAppHelper::plugin_url() : '',
2243
  'no_licenses' => __( 'No new licenses were found', 'formidable' ),
11
  /**
12
  * @since 2.0
13
  */
14
+ public static $plug_version = '4.04.05';
15
 
16
  /**
17
  * @since 1.07.02
2215
  'saved' => esc_attr( __( 'Saved', 'formidable' ) ),
2216
  'ok' => __( 'OK', 'formidable' ),
2217
  'cancel' => __( 'Cancel', 'formidable' ),
2218
+ 'default_label' => __( 'Default', 'formidable' ),
2219
  'clear_default' => __( 'Clear default value when typing', 'formidable' ),
2220
  'no_clear_default' => __( 'Do not clear default value when typing', 'formidable' ),
2221
  'valid_default' => __( 'Default value will pass form validation', 'formidable' ),
2237
  'import_complete' => __( 'Import Complete', 'formidable' ),
2238
  'updating' => __( 'Please wait while your site updates.', 'formidable' ),
2239
  'no_save_warning' => __( 'Warning: There is no way to retrieve unsaved entries.', 'formidable' ),
2240
+ 'private_label' => __( 'Private', 'formidable' ),
2241
  'jquery_ui_url' => self::jquery_ui_base_url(),
2242
  'pro_url' => is_callable( 'FrmProAppHelper::plugin_url' ) ? FrmProAppHelper::plugin_url() : '',
2243
  'no_licenses' => __( 'No new licenses were found', 'formidable' ),
classes/helpers/FrmFormMigratorsHelper.php CHANGED
@@ -76,13 +76,13 @@ class FrmFormMigratorsHelper {
76
 
77
  private static function importable_forms() {
78
  return array(
79
- /*'gf' => array(
80
  'class' => 'FrmGravityImporter',
81
  'plugin' => 'gravityforms/gravityforms.php',
82
  'importer' => 'formidable-gravity-forms-importer/formidable-gravity-forms-importer.php',
83
  'name' => 'Gravity Forms',
84
  'package' => 'https://downloads.wordpress.org/plugin/formidable-gravity-forms-importer.zip',
85
- ),*/
86
  'pf' => array(
87
  'class' => 'FrmPirateImporter',
88
  'plugin' => 'pirate-forms/pirate-forms.php',
76
 
77
  private static function importable_forms() {
78
  return array(
79
+ 'gf' => array(
80
  'class' => 'FrmGravityImporter',
81
  'plugin' => 'gravityforms/gravityforms.php',
82
  'importer' => 'formidable-gravity-forms-importer/formidable-gravity-forms-importer.php',
83
  'name' => 'Gravity Forms',
84
  'package' => 'https://downloads.wordpress.org/plugin/formidable-gravity-forms-importer.zip',
85
+ ),
86
  'pf' => array(
87
  'class' => 'FrmPirateImporter',
88
  'plugin' => 'pirate-forms/pirate-forms.php',
classes/models/FrmFormAction.php CHANGED
@@ -729,7 +729,7 @@ class FrmFormAction {
729
  continue;
730
  }
731
 
732
- self::prepare_logic_value( $condition['hide_opt'] );
733
 
734
  $observed_value = self::get_value_from_entry( $entry, $condition['hide_field'] );
735
 
@@ -758,7 +758,7 @@ class FrmFormAction {
758
  *
759
  * @param array|string $logic_value
760
  */
761
- private static function prepare_logic_value( &$logic_value ) {
762
  if ( is_array( $logic_value ) ) {
763
  $logic_value = reset( $logic_value );
764
  }
@@ -766,6 +766,13 @@ class FrmFormAction {
766
  if ( $logic_value == 'current_user' ) {
767
  $logic_value = get_current_user_id();
768
  }
 
 
 
 
 
 
 
769
  }
770
 
771
  /**
729
  continue;
730
  }
731
 
732
+ self::prepare_logic_value( $condition['hide_opt'], $action, $entry );
733
 
734
  $observed_value = self::get_value_from_entry( $entry, $condition['hide_field'] );
735
 
758
  *
759
  * @param array|string $logic_value
760
  */
761
+ private static function prepare_logic_value( &$logic_value, $action, $entry ) {
762
  if ( is_array( $logic_value ) ) {
763
  $logic_value = reset( $logic_value );
764
  }
766
  if ( $logic_value == 'current_user' ) {
767
  $logic_value = get_current_user_id();
768
  }
769
+
770
+ $logic_value = apply_filters( 'frm_content', $logic_value, $action->menu_order, $entry );
771
+
772
+ /**
773
+ * @since 4.04.05
774
+ */
775
+ $logic_value = apply_filters( 'frm_action_logic_value', $logic_value );
776
  }
777
 
778
  /**
classes/models/FrmFormMigrator.php CHANGED
@@ -423,6 +423,8 @@ abstract class FrmFormMigrator {
423
  foreach ( $action as $key => $value ) {
424
  if ( $key === 'post_title' ) {
425
  $new_action->post_title = $value;
 
 
426
  } elseif ( $key === 'the_post_title' ) {
427
  $new_action->post_content['post_title'] = $value;
428
  } elseif ( is_string( $value ) ) {
423
  foreach ( $action as $key => $value ) {
424
  if ( $key === 'post_title' ) {
425
  $new_action->post_title = $value;
426
+ } elseif ( $key === 'ID' ) {
427
+ $new_action->ID = $value;
428
  } elseif ( $key === 'the_post_title' ) {
429
  $new_action->post_content['post_title'] = $value;
430
  } elseif ( is_string( $value ) ) {
css/_single_theme.css.php CHANGED
@@ -35,54 +35,98 @@ $arrow_icons = FrmStylesHelper::arrow_icons();
35
  <?php } ?>
36
 
37
  .<?php echo esc_html( $style_class ); ?> .frm_form_fields > fieldset{
38
- border-width:<?php echo esc_html( $fieldset . $important ); ?>;
 
 
39
  border-style:solid;
40
- border-color:<?php echo esc_html( $fieldset_color . $important ); ?>;
 
 
41
  margin:0;
42
- padding:<?php echo esc_html( $fieldset_padding . $important ); ?>;
43
- background-color:<?php echo esc_html( $fieldset_bg_color ); ?>;
44
- font-family:<?php echo FrmAppHelper::kses( $font ); // WPCS: XSS ok. ?>;
 
 
 
 
 
 
45
  }
46
 
47
  .<?php echo esc_html( $style_class ); ?> legend + h3,
48
  .<?php echo esc_html( $style_class ); ?> h3.frm_form_title{
49
- font-size:<?php echo esc_html( $title_size . $important ); ?>;
50
- color:<?php echo esc_html( $title_color . $important ); ?>;
51
- font-family:<?php echo FrmAppHelper::kses( $font ); // WPCS: XSS ok. ?>;
52
- margin-top:<?php echo esc_html( $title_margin_top . $important ); ?>;
53
- margin-bottom:<?php echo esc_html( $title_margin_bottom . $important ); ?>;
 
 
 
 
 
 
 
 
 
 
54
  }
55
 
56
  .<?php echo esc_html( $style_class ); ?> .frm_primary_label{
57
- font-family:<?php echo FrmAppHelper::kses( $font ); // WPCS: XSS ok. ?>;
58
- font-size:<?php echo esc_html( $font_size . $important ); ?>;
59
- color:<?php echo esc_html( $label_color . $important ); ?>;
60
- font-weight:<?php echo esc_html( $weight . $important ); ?>;
61
- text-align:<?php echo esc_html( $align . $important ); ?>;
 
 
 
 
 
 
 
 
 
 
62
  margin:0;
63
- padding:<?php echo esc_html( $label_padding . $important ); ?>;
 
 
64
  width:auto;
65
  display:block;
66
  }
67
 
68
  .<?php echo esc_html( $style_class ); ?> .frm_form_field.frm_html_container,
69
  .<?php echo esc_html( $style_class ); ?> .frm_form_field .frm_show_it{
70
- font-family:<?php echo FrmAppHelper::kses( $font . $important ); // WPCS: XSS ok. ?>;
71
- color:<?php echo esc_html( $form_desc_color . $important ); ?>;
 
 
 
 
72
  }
73
 
 
74
  .<?php echo esc_html( $style_class ); ?> .frm_form_field.frm_html_container{
75
  font-size:<?php echo esc_html( $form_desc_size . $important ); ?>;
76
  }
 
77
 
78
  .<?php echo esc_html( $style_class ); ?> .frm_form_field .frm_show_it{
79
- font-size:<?php echo esc_html( $field_font_size . $important ); ?>;
80
- font-weight:<?php echo esc_html( $field_weight ); ?>;
 
 
 
 
81
  }
82
 
 
83
  .<?php echo esc_html( $style_class ); ?> .frm_icon_font{
84
  color:<?php echo esc_html( $label_color . $important ); ?>;
85
  }
 
86
 
87
  .<?php echo esc_html( $style_class ); ?> .frm_icon_font.frm_minus_icon:before{
88
  content:"\e<?php echo esc_html( isset( $minus_icons[ $repeat_icon ] ) ? $minus_icons[ $repeat_icon ]['-'] : $minus_icons[1]['-'] ); ?>";
@@ -94,23 +138,31 @@ $arrow_icons = FrmStylesHelper::arrow_icons();
94
 
95
  .<?php echo esc_html( $style_class ); ?> .frm_icon_font.frm_minus_icon:before,
96
  .<?php echo esc_html( $style_class ); ?> .frm_icon_font.frm_plus_icon:before{
97
- color:<?php echo esc_html( $submit_text_color . $important ); ?>;
 
 
98
  vertical-align:middle;
99
  }
100
 
101
  .<?php echo esc_html( $style_class ); ?> .frm_trigger.active .frm_icon_font.frm_arrow_icon:before{
102
  content:"\e<?php echo esc_html( isset( $arrow_icons[ $collapse_icon ] ) ? $arrow_icons[ $collapse_icon ]['-'] : $arrow_icons[1]['-'] ); ?>";
103
- color:<?php echo esc_html( $section_color . $important ); ?>;
 
 
104
  }
105
 
106
  .<?php echo esc_html( $style_class ); ?> .frm_trigger .frm_icon_font.frm_arrow_icon:before{
107
  content:"\e<?php echo esc_html( isset( $arrow_icons[ $collapse_icon ] ) ? $arrow_icons[ $collapse_icon ]['+'] : $arrow_icons[1]['+'] ); ?>";
108
- color:<?php echo esc_html( $section_color . $important ); ?>;
 
 
109
  }
110
 
 
111
  .<?php echo esc_html( $style_class ); ?> .form-field{
112
  margin-bottom:<?php echo esc_html( $field_margin . $important ); ?>;
113
  }
 
114
  .<?php echo esc_html( $style_class ); ?> .frm_grid,
115
  .<?php echo esc_html( $style_class ); ?> .frm_grid_first,
116
  .<?php echo esc_html( $style_class ); ?> .frm_grid_odd {
@@ -125,24 +177,45 @@ $arrow_icons = FrmStylesHelper::arrow_icons();
125
  .<?php echo esc_html( $style_class ); ?> div.frm_description,
126
  .<?php echo esc_html( $style_class ); ?> .frm-show-form > div.frm_description,
127
  .<?php echo esc_html( $style_class ); ?> .frm_error{
128
- margin:<?php echo esc_html( $description_margin . $important ); ?>;
 
 
129
  padding:0;
130
- font-family:<?php echo FrmAppHelper::kses( $font . $important ); // WPCS: XSS ok. ?>;
131
- font-size:<?php echo esc_html( $description_font_size . $important ); ?>;
132
- color:<?php echo esc_html( $description_color . $important ); ?>;
133
- font-weight:<?php echo esc_html( $description_weight . $important ); ?>;
134
- text-align:<?php echo esc_html( $description_align . $important ); ?>;
135
- font-style:<?php echo esc_html( $description_style . $important ); ?>;
 
 
 
 
 
 
 
 
 
 
 
 
136
  max-width:100%;
137
  }
138
 
139
  /* Form description */
140
  .<?php echo esc_html( $style_class ); ?> .frm-show-form div.frm_description p{
141
- font-size:<?php echo esc_html( $form_desc_size . $important ); ?>;
142
- color:<?php echo esc_html( $form_desc_color . $important ); ?>;
143
- margin-top:<?php echo esc_html( $form_desc_margin_top . $important ); ?>;
144
- margin-bottom:<?php echo esc_html( $form_desc_margin_bottom . $important ); ?>;
145
-
 
 
 
 
 
 
 
146
  }
147
 
148
  /* Left and right labels */
@@ -200,15 +273,27 @@ if ( '' === $field_height || 'auto' === $field_height ) {
200
  }
201
 
202
  .<?php echo esc_html( $style_class ); ?> .frm_scale label{
203
- font-weight:<?php echo esc_html( $check_weight . $important ); ?>;
204
- font-family:<?php echo FrmAppHelper::kses( $font . $important ); // WPCS: XSS ok. ?>;
205
- font-size:<?php echo esc_html( $check_font_size . $important ); ?>;
206
- color:<?php echo esc_html( $check_label_color . $important ); ?>;
 
 
 
 
 
 
 
 
207
  }
208
 
209
  .<?php echo esc_html( $style_class ); ?> .frm_required{
210
- color:<?php echo esc_html( $required_color . $important ); ?>;
211
- font-weight:<?php echo esc_html( $required_weight . $important ); ?>;
 
 
 
 
212
  }
213
 
214
  .<?php echo esc_html( $style_class ); ?> input[type=text],
@@ -222,8 +307,12 @@ if ( '' === $field_height || 'auto' === $field_height ) {
222
  .<?php echo esc_html( $style_class ); ?> textarea,
223
  .<?php echo esc_html( $style_class ); ?> .frm-card-element.StripeElement,
224
  .<?php echo esc_html( $style_class ); ?> .chosen-container{
225
- font-family:<?php echo FrmAppHelper::kses( $font . $important ); // WPCS: XSS ok. ?>;
226
- font-size:<?php echo esc_html( $field_font_size ); ?>;
 
 
 
 
227
  margin-bottom:0<?php echo esc_html( $important ); ?>;
228
  }
229
 
@@ -300,7 +389,9 @@ if ( ! empty( $important ) ) {
300
  .<?php echo esc_html( $style_class ); ?> input[type=file]{
301
  color: <?php echo esc_html( $text_color . $important ); ?>;
302
  padding:0px;
303
- font-family:<?php echo FrmAppHelper::kses( $font . $important ); // WPCS: XSS ok. ?>;
 
 
304
  font-size:<?php echo esc_html( $field_font_size . $important ); ?>;
305
  }
306
 
@@ -407,7 +498,9 @@ if ( ! empty( $important ) ) {
407
  .frm_form_submit_style,
408
  .<?php echo esc_html( $style_class ); ?> .frm-edit-page-btn {
409
  width:<?php echo esc_html( ( $submit_width == '' ? 'auto' : $submit_width ) . $important ); ?>;
410
- font-family:<?php echo FrmAppHelper::kses( $font ); // WPCS: XSS ok. ?>;
 
 
411
  font-size:<?php echo esc_html( $submit_font_size . $important ); ?>;
412
  height:<?php echo esc_html( $submit_height . $important ); ?>;
413
  line-height:normal<?php echo esc_html( $important ); ?>;
@@ -507,7 +600,9 @@ if ( ! empty( $important ) ) {
507
  .<?php echo esc_html( $style_class ); ?>.frm_inline_top .frm_submit::before,
508
  .<?php echo esc_html( $style_class ); ?> .frm_submit.frm_inline_submit::before {
509
  content:"before";
510
- font-family:<?php echo FrmAppHelper::kses( $font ); // WPCS: XSS ok. ?>;
 
 
511
  font-size:<?php echo esc_html( $font_size . $important ); ?>;
512
  color:<?php echo esc_html( $label_color . $important ); ?>;
513
  font-weight:<?php echo esc_html( $weight . $important ); ?>;
@@ -526,13 +621,17 @@ if ( ! empty( $important ) ) {
526
  }
527
 
528
  .<?php echo esc_html( $style_class ); ?> a.frm_save_draft{
529
- font-family:<?php echo FrmAppHelper::kses( $font ); // WPCS: XSS ok. ?>;
 
 
530
  font-size:<?php echo esc_html( $submit_font_size ); ?>;
531
  font-weight:<?php echo esc_html( $submit_weight ); ?>;
532
  }
533
 
534
  .<?php echo esc_html( $style_class ); ?> #frm_field_cptch_number_container{
535
- font-family:<?php echo FrmAppHelper::kses( $font ); // WPCS: XSS ok. ?>;
 
 
536
  font-size:<?php echo esc_html( $font_size . $important ); ?>;
537
  color:<?php echo esc_html( $label_color . $important ); ?>;
538
  font-weight:<?php echo esc_html( $weight . $important ); ?>;
@@ -561,7 +660,9 @@ if ( ! empty( $important ) ) {
561
 
562
  .<?php echo esc_html( $style_class ); ?> .frm_radio label,
563
  .<?php echo esc_html( $style_class ); ?> .frm_checkbox label{
564
- font-family:<?php echo FrmAppHelper::kses( $font . $important ); // WPCS: XSS ok. ?>;
 
 
565
  font-size:<?php echo esc_html( $check_font_size . $important ); ?>;
566
  color:<?php echo esc_html( $check_label_color . $important ); ?>;
567
  font-weight:<?php echo esc_html( $check_weight . $important ); ?>;
@@ -711,18 +812,38 @@ if ( ! empty( $important ) ) {
711
  }
712
 
713
  .<?php echo esc_html( $style_class ); ?> .frm_button{
714
- padding:<?php echo esc_html( $submit_padding . $important ); ?>;
715
- -moz-border-radius:<?php echo esc_html( $border_radius . $important ); ?>;
716
- -webkit-border-radius:<?php echo esc_html( $border_radius . $important ); ?>;
717
- border-radius:<?php echo esc_html( $border_radius . $important ); ?>;
718
- font-size:<?php echo esc_html( $submit_font_size . $important ); ?>;
719
- font-family:<?php echo FrmAppHelper::kses( $font . $important ); // WPCS: XSS ok. ?>;
720
- font-weight:<?php echo esc_html( $submit_weight . $important ); ?>;
721
- color:<?php echo esc_html( $submit_text_color . $important ); ?>;
722
- background: <?php echo esc_html( $submit_bg_color . $important ); ?>;
723
- border-width:<?php echo esc_html( $submit_border_width ); ?>;
724
- border-color: <?php echo esc_html( $submit_border_color . $important ); ?>;
725
- height:<?php echo esc_html( $submit_height . $important ); ?>;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
726
  }
727
 
728
  <?php do_action( 'frm_output_single_style', $settings ); ?>
35
  <?php } ?>
36
 
37
  .<?php echo esc_html( $style_class ); ?> .frm_form_fields > fieldset{
38
+ <?php if ( ! empty( $fieldset ) ) { ?>
39
+ border-width:<?php echo esc_html( $fieldset . $important ); ?>;
40
+ <?php } ?>
41
  border-style:solid;
42
+ <?php if ( ! empty( $fieldset_color ) ) { ?>
43
+ border-color:<?php echo esc_html( $fieldset_color . $important ); ?>;
44
+ <?php } ?>
45
  margin:0;
46
+ <?php if ( ! empty( $fieldset_padding ) ) { ?>
47
+ padding:<?php echo esc_html( $fieldset_padding . $important ); ?>;
48
+ <?php } ?>
49
+ <?php if ( ! empty( $fieldset_bg_color ) ) { ?>
50
+ background-color:<?php echo esc_html( $fieldset_bg_color ); ?>;
51
+ <?php } ?>
52
+ <?php if ( ! empty( $font ) ) { ?>
53
+ font-family:<?php echo FrmAppHelper::kses( $font ); // WPCS: XSS ok. ?>;
54
+ <?php } ?>
55
  }
56
 
57
  .<?php echo esc_html( $style_class ); ?> legend + h3,
58
  .<?php echo esc_html( $style_class ); ?> h3.frm_form_title{
59
+ <?php if ( ! empty( $title_size ) ) { ?>
60
+ font-size:<?php echo esc_html( $title_size . $important ); ?>;
61
+ <?php } ?>
62
+ <?php if ( ! empty( $title_color ) ) { ?>
63
+ color:<?php echo esc_html( $title_color . $important ); ?>;
64
+ <?php } ?>
65
+ <?php if ( ! empty( $font ) ) { ?>
66
+ font-family:<?php echo FrmAppHelper::kses( $font ); // WPCS: XSS ok. ?>;
67
+ <?php } ?>
68
+ <?php if ( ! empty( $title_margin_top ) ) { ?>
69
+ margin-top:<?php echo esc_html( $title_margin_top . $important ); ?>;
70
+ <?php } ?>
71
+ <?php if ( ! empty( $title_margin_bottom ) ) { ?>
72
+ margin-bottom:<?php echo esc_html( $title_margin_bottom . $important ); ?>;
73
+ <?php } ?>
74
  }
75
 
76
  .<?php echo esc_html( $style_class ); ?> .frm_primary_label{
77
+ <?php if ( ! empty( $font ) ) { ?>
78
+ font-family:<?php echo FrmAppHelper::kses( $font ); // WPCS: XSS ok. ?>;
79
+ <?php } ?>
80
+ <?php if ( ! empty( $font_size ) ) { ?>
81
+ font-size:<?php echo esc_html( $font_size . $important ); ?>;
82
+ <?php } ?>
83
+ <?php if ( ! empty( $label_color ) ) { ?>
84
+ color:<?php echo esc_html( $label_color . $important ); ?>;
85
+ <?php } ?>
86
+ <?php if ( ! empty( $weight ) ) { ?>
87
+ font-weight:<?php echo esc_html( $weight . $important ); ?>;
88
+ <?php } ?>
89
+ <?php if ( ! empty( $align ) ) { ?>
90
+ text-align:<?php echo esc_html( $align . $important ); ?>;
91
+ <?php } ?>
92
  margin:0;
93
+ <?php if ( ! empty( $label_padding ) ) { ?>
94
+ padding:<?php echo esc_html( $label_padding . $important ); ?>;
95
+ <?php } ?>
96
  width:auto;
97
  display:block;
98
  }
99
 
100
  .<?php echo esc_html( $style_class ); ?> .frm_form_field.frm_html_container,
101
  .<?php echo esc_html( $style_class ); ?> .frm_form_field .frm_show_it{
102
+ <?php if ( ! empty( $font ) ) { ?>
103
+ font-family:<?php echo FrmAppHelper::kses( $font . $important ); // WPCS: XSS ok. ?>;
104
+ <?php } ?>
105
+ <?php if ( ! empty( $form_desc_color ) ) { ?>
106
+ color:<?php echo esc_html( $form_desc_color . $important ); ?>;
107
+ <?php } ?>
108
  }
109
 
110
+ <?php if ( ! empty( $form_desc_size ) ) { ?>
111
  .<?php echo esc_html( $style_class ); ?> .frm_form_field.frm_html_container{
112
  font-size:<?php echo esc_html( $form_desc_size . $important ); ?>;
113
  }
114
+ <?php } ?>
115
 
116
  .<?php echo esc_html( $style_class ); ?> .frm_form_field .frm_show_it{
117
+ <?php if ( ! empty( $field_font_size ) ) { ?>
118
+ font-size:<?php echo esc_html( $field_font_size . $important ); ?>;
119
+ <?php } ?>
120
+ <?php if ( ! empty( $field_weight ) ) { ?>
121
+ font-weight:<?php echo esc_html( $field_weight ); ?>;
122
+ <?php } ?>
123
  }
124
 
125
+ <?php if ( ! empty( $label_color ) ) { ?>
126
  .<?php echo esc_html( $style_class ); ?> .frm_icon_font{
127
  color:<?php echo esc_html( $label_color . $important ); ?>;
128
  }
129
+ <?php } ?>
130
 
131
  .<?php echo esc_html( $style_class ); ?> .frm_icon_font.frm_minus_icon:before{
132
  content:"\e<?php echo esc_html( isset( $minus_icons[ $repeat_icon ] ) ? $minus_icons[ $repeat_icon ]['-'] : $minus_icons[1]['-'] ); ?>";
138
 
139
  .<?php echo esc_html( $style_class ); ?> .frm_icon_font.frm_minus_icon:before,
140
  .<?php echo esc_html( $style_class ); ?> .frm_icon_font.frm_plus_icon:before{
141
+ <?php if ( ! empty( $submit_text_color ) ) { ?>
142
+ color:<?php echo esc_html( $submit_text_color . $important ); ?>;
143
+ <?php } ?>
144
  vertical-align:middle;
145
  }
146
 
147
  .<?php echo esc_html( $style_class ); ?> .frm_trigger.active .frm_icon_font.frm_arrow_icon:before{
148
  content:"\e<?php echo esc_html( isset( $arrow_icons[ $collapse_icon ] ) ? $arrow_icons[ $collapse_icon ]['-'] : $arrow_icons[1]['-'] ); ?>";
149
+ <?php if ( ! empty( $section_color ) ) { ?>
150
+ color:<?php echo esc_html( $section_color . $important ); ?>;
151
+ <?php } ?>
152
  }
153
 
154
  .<?php echo esc_html( $style_class ); ?> .frm_trigger .frm_icon_font.frm_arrow_icon:before{
155
  content:"\e<?php echo esc_html( isset( $arrow_icons[ $collapse_icon ] ) ? $arrow_icons[ $collapse_icon ]['+'] : $arrow_icons[1]['+'] ); ?>";
156
+ <?php if ( ! empty( $section_color ) ) { ?>
157
+ color:<?php echo esc_html( $section_color . $important ); ?>;
158
+ <?php } ?>
159
  }
160
 
161
+ <?php if ( ! empty( $field_margin ) ) { ?>
162
  .<?php echo esc_html( $style_class ); ?> .form-field{
163
  margin-bottom:<?php echo esc_html( $field_margin . $important ); ?>;
164
  }
165
+ <?php } ?>
166
  .<?php echo esc_html( $style_class ); ?> .frm_grid,
167
  .<?php echo esc_html( $style_class ); ?> .frm_grid_first,
168
  .<?php echo esc_html( $style_class ); ?> .frm_grid_odd {
177
  .<?php echo esc_html( $style_class ); ?> div.frm_description,
178
  .<?php echo esc_html( $style_class ); ?> .frm-show-form > div.frm_description,
179
  .<?php echo esc_html( $style_class ); ?> .frm_error{
180
+ <?php if ( ! empty( $description_margin ) ) { ?>
181
+ margin:<?php echo esc_html( $description_margin . $important ); ?>;
182
+ <?php } ?>
183
  padding:0;
184
+ <?php if ( ! empty( $font ) ) { ?>
185
+ font-family:<?php echo FrmAppHelper::kses( $font . $important ); // WPCS: XSS ok. ?>;
186
+ <?php } ?>
187
+ <?php if ( ! empty( $description_font_size ) ) { ?>
188
+ font-size:<?php echo esc_html( $description_font_size . $important ); ?>;
189
+ <?php } ?>
190
+ <?php if ( ! empty( $description_color ) ) { ?>
191
+ color:<?php echo esc_html( $description_color . $important ); ?>;
192
+ <?php } ?>
193
+ <?php if ( ! empty( $description_weight ) ) { ?>
194
+ font-weight:<?php echo esc_html( $description_weight . $important ); ?>;
195
+ <?php } ?>
196
+ <?php if ( ! empty( $description_align ) ) { ?>
197
+ text-align:<?php echo esc_html( $description_align . $important ); ?>;
198
+ <?php } ?>
199
+ <?php if ( ! empty( $description_style ) ) { ?>
200
+ font-style:<?php echo esc_html( $description_style . $important ); ?>;
201
+ <?php } ?>
202
  max-width:100%;
203
  }
204
 
205
  /* Form description */
206
  .<?php echo esc_html( $style_class ); ?> .frm-show-form div.frm_description p{
207
+ <?php if ( ! empty( $form_desc_size ) ) { ?>
208
+ font-size:<?php echo esc_html( $form_desc_size . $important ); ?>;
209
+ <?php } ?>
210
+ <?php if ( ! empty( $form_desc_color ) ) { ?>
211
+ color:<?php echo esc_html( $form_desc_color . $important ); ?>;
212
+ <?php } ?>
213
+ <?php if ( ! empty( $form_desc_margin_top ) ) { ?>
214
+ margin-top:<?php echo esc_html( $form_desc_margin_top . $important ); ?>;
215
+ <?php } ?>
216
+ <?php if ( ! empty( $form_desc_margin_bottom ) ) { ?>
217
+ margin-bottom:<?php echo esc_html( $form_desc_margin_bottom . $important ); ?>;
218
+ <?php } ?>
219
  }
220
 
221
  /* Left and right labels */
273
  }
274
 
275
  .<?php echo esc_html( $style_class ); ?> .frm_scale label{
276
+ <?php if ( ! empty( $check_weight ) ) { ?>
277
+ font-weight:<?php echo esc_html( $check_weight . $important ); ?>;
278
+ <?php } ?>
279
+ <?php if ( ! empty( $font ) ) { ?>
280
+ font-family:<?php echo FrmAppHelper::kses( $font . $important ); // WPCS: XSS ok. ?>;
281
+ <?php } ?>
282
+ <?php if ( ! empty( $check_font_size ) ) { ?>
283
+ font-size:<?php echo esc_html( $check_font_size . $important ); ?>;
284
+ <?php } ?>
285
+ <?php if ( ! empty( $check_label_color ) ) { ?>
286
+ color:<?php echo esc_html( $check_label_color . $important ); ?>;
287
+ <?php } ?>
288
  }
289
 
290
  .<?php echo esc_html( $style_class ); ?> .frm_required{
291
+ <?php if ( ! empty( $required_color ) ) { ?>
292
+ color:<?php echo esc_html( $required_color . $important ); ?>;
293
+ <?php } ?>
294
+ <?php if ( ! empty( $required_weight ) ) { ?>
295
+ font-weight:<?php echo esc_html( $required_weight . $important ); ?>;
296
+ <?php } ?>
297
  }
298
 
299
  .<?php echo esc_html( $style_class ); ?> input[type=text],
307
  .<?php echo esc_html( $style_class ); ?> textarea,
308
  .<?php echo esc_html( $style_class ); ?> .frm-card-element.StripeElement,
309
  .<?php echo esc_html( $style_class ); ?> .chosen-container{
310
+ <?php if ( ! empty( $font ) ) { ?>
311
+ font-family:<?php echo FrmAppHelper::kses( $font . $important ); // WPCS: XSS ok. ?>;
312
+ <?php } ?>
313
+ <?php if ( ! empty( $field_font_size ) ) { ?>
314
+ font-size:<?php echo esc_html( $field_font_size ); ?>;
315
+ <?php } ?>
316
  margin-bottom:0<?php echo esc_html( $important ); ?>;
317
  }
318
 
389
  .<?php echo esc_html( $style_class ); ?> input[type=file]{
390
  color: <?php echo esc_html( $text_color . $important ); ?>;
391
  padding:0px;
392
+ <?php if ( ! empty( $font ) ) { ?>
393
+ font-family:<?php echo FrmAppHelper::kses( $font . $important ); // WPCS: XSS ok. ?>;
394
+ <?php } ?>
395
  font-size:<?php echo esc_html( $field_font_size . $important ); ?>;
396
  }
397
 
498
  .frm_form_submit_style,
499
  .<?php echo esc_html( $style_class ); ?> .frm-edit-page-btn {
500
  width:<?php echo esc_html( ( $submit_width == '' ? 'auto' : $submit_width ) . $important ); ?>;
501
+ <?php if ( ! empty( $font ) ) { ?>
502
+ font-family:<?php echo FrmAppHelper::kses( $font ); // WPCS: XSS ok. ?>;
503
+ <?php } ?>
504
  font-size:<?php echo esc_html( $submit_font_size . $important ); ?>;
505
  height:<?php echo esc_html( $submit_height . $important ); ?>;
506
  line-height:normal<?php echo esc_html( $important ); ?>;
600
  .<?php echo esc_html( $style_class ); ?>.frm_inline_top .frm_submit::before,
601
  .<?php echo esc_html( $style_class ); ?> .frm_submit.frm_inline_submit::before {
602
  content:"before";
603
+ <?php if ( ! empty( $font ) ) { ?>
604
+ font-family:<?php echo FrmAppHelper::kses( $font ); // WPCS: XSS ok. ?>;
605
+ <?php } ?>
606
  font-size:<?php echo esc_html( $font_size . $important ); ?>;
607
  color:<?php echo esc_html( $label_color . $important ); ?>;
608
  font-weight:<?php echo esc_html( $weight . $important ); ?>;
621
  }
622
 
623
  .<?php echo esc_html( $style_class ); ?> a.frm_save_draft{
624
+ <?php if ( ! empty( $font ) ) { ?>
625
+ font-family:<?php echo FrmAppHelper::kses( $font ); // WPCS: XSS ok. ?>;
626
+ <?php } ?>
627
  font-size:<?php echo esc_html( $submit_font_size ); ?>;
628
  font-weight:<?php echo esc_html( $submit_weight ); ?>;
629
  }
630
 
631
  .<?php echo esc_html( $style_class ); ?> #frm_field_cptch_number_container{
632
+ <?php if ( ! empty( $font ) ) { ?>
633
+ font-family:<?php echo FrmAppHelper::kses( $font ); // WPCS: XSS ok. ?>;
634
+ <?php } ?>
635
  font-size:<?php echo esc_html( $font_size . $important ); ?>;
636
  color:<?php echo esc_html( $label_color . $important ); ?>;
637
  font-weight:<?php echo esc_html( $weight . $important ); ?>;
660
 
661
  .<?php echo esc_html( $style_class ); ?> .frm_radio label,
662
  .<?php echo esc_html( $style_class ); ?> .frm_checkbox label{
663
+ <?php if ( ! empty( $font ) ) { ?>
664
+ font-family:<?php echo FrmAppHelper::kses( $font . $important ); // WPCS: XSS ok. ?>;
665
+ <?php } ?>
666
  font-size:<?php echo esc_html( $check_font_size . $important ); ?>;
667
  color:<?php echo esc_html( $check_label_color . $important ); ?>;
668
  font-weight:<?php echo esc_html( $check_weight . $important ); ?>;
812
  }
813
 
814
  .<?php echo esc_html( $style_class ); ?> .frm_button{
815
+ <?php if ( ! empty( $submit_padding ) ) { ?>
816
+ padding:<?php echo esc_html( $submit_padding . $important ); ?>;
817
+ <?php } ?>
818
+ <?php if ( ! empty( $border_radius ) ) { ?>
819
+ -moz-border-radius:<?php echo esc_html( $border_radius . $important ); ?>;
820
+ -webkit-border-radius:<?php echo esc_html( $border_radius . $important ); ?>;
821
+ border-radius:<?php echo esc_html( $border_radius . $important ); ?>;
822
+ <?php } ?>
823
+ <?php if ( ! empty( $submit_font_size ) ) { ?>
824
+ font-size:<?php echo esc_html( $submit_font_size . $important ); ?>;
825
+ <?php } ?>
826
+ <?php if ( ! empty( $font ) ) { ?>
827
+ font-family:<?php echo FrmAppHelper::kses( $font . $important ); // WPCS: XSS ok. ?>;
828
+ <?php } ?>
829
+ <?php if ( ! empty( $submit_weight ) ) { ?>
830
+ font-weight:<?php echo esc_html( $submit_weight . $important ); ?>;
831
+ <?php } ?>
832
+ <?php if ( ! empty( $submit_text_color ) ) { ?>
833
+ color:<?php echo esc_html( $submit_text_color . $important ); ?>;
834
+ <?php } ?>
835
+ <?php if ( ! empty( $submit_bg_color ) ) { ?>
836
+ background: <?php echo esc_html( $submit_bg_color . $important ); ?>;
837
+ <?php } ?>
838
+ <?php if ( ! empty( $submit_border_width ) ) { ?>
839
+ border-width:<?php echo esc_html( $submit_border_width ); ?>;
840
+ <?php } ?>
841
+ <?php if ( ! empty( $submit_border_color ) ) { ?>
842
+ border-color: <?php echo esc_html( $submit_border_color . $important ); ?>;
843
+ <?php } ?>
844
+ <?php if ( ! empty( $submit_height ) ) { ?>
845
+ height:<?php echo esc_html( $submit_height . $important ); ?>;
846
+ <?php } ?>
847
  }
848
 
849
  <?php do_action( 'frm_output_single_style', $settings ); ?>
css/custom_theme.css.php CHANGED
@@ -412,7 +412,9 @@ a.frm_save_draft{
412
  padding:5px;
413
  border-width:1px;
414
  border-style:solid;
415
- border-color:<?php echo esc_html( $defaults['border_color'] ); ?>;
 
 
416
  border-top:none;
417
  border-left:none;
418
  border-right:none;
@@ -451,9 +453,13 @@ table.form_results.with_frm_style{
451
 
452
  table.form_results.with_frm_style tr td{
453
  text-align:left;
454
- color:<?php echo esc_html( $defaults['text_color'] ); ?>;
 
 
455
  padding:7px 9px;
456
- border-top:1px solid <?php echo esc_html( $defaults['border_color'] ); ?>;
 
 
457
  }
458
 
459
  table.form_results.with_frm_style tr.frm_even,
@@ -463,7 +469,9 @@ table.form_results.with_frm_style tr.frm_even,
463
 
464
  table.form_results.with_frm_style tr.frm_odd,
465
  .frm-grid .frm_odd{
466
- background-color:<?php echo esc_html( FrmStylesHelper::adjust_brightness( $defaults['border_color'], 45 ) ); ?>;
 
 
467
  }
468
 
469
  .frm_collapse .ui-icon{
@@ -535,7 +543,9 @@ table.form_results.with_frm_style tr.frm_odd,
535
 
536
  <?php if ( ! empty( $defaults['bg_color'] ) ) { ?>
537
  #frm_loading .progress-striped .progress-bar{
538
- background-image:linear-gradient(45deg, <?php echo esc_html( $defaults['border_color'] ); ?> 25%, rgba(0, 0, 0, 0) 25%, rgba(0, 0, 0, 0) 50%, <?php echo esc_html( $defaults['border_color'] ); ?> 50%, <?php echo esc_html( $defaults['border_color'] ); ?> 75%, rgba(0, 0, 0, 0) 75%, rgba(0, 0, 0, 0));
 
 
539
  background-size:40px 40px;
540
  }
541
  <?php } ?>
@@ -589,7 +599,9 @@ select.frm_loading_lookup{
589
  padding:5px;
590
  border-width:1px;
591
  border-style:solid;
592
- border-color:<?php echo esc_html( $defaults['border_color'] ); ?>;
 
 
593
  border-left:none;
594
  border-right:none;
595
  }
@@ -620,14 +632,18 @@ select.frm_loading_lookup{
620
  margin-top:20px;
621
  }
622
 
 
623
  .frm_grid_first,
624
  .frm_grid_odd{
625
  background-color:<?php echo esc_html( $defaults['bg_color'] ); ?>;
626
  }
 
627
 
 
628
  .frm_grid{
629
  background-color:<?php echo esc_html( $defaults['bg_color_active'] ); ?>;
630
  }
 
631
 
632
  .frm_grid .frm_primary_label,
633
  .frm_grid_first .frm_primary_label,
412
  padding:5px;
413
  border-width:1px;
414
  border-style:solid;
415
+ <?php if ( ! empty( $defaults['border_color'] ) ) { ?>
416
+ border-color:<?php echo esc_html( $defaults['border_color'] ); ?>;
417
+ <?php } ?>
418
  border-top:none;
419
  border-left:none;
420
  border-right:none;
453
 
454
  table.form_results.with_frm_style tr td{
455
  text-align:left;
456
+ <?php if ( ! empty( $defaults['text_color'] ) ) { ?>
457
+ color:<?php echo esc_html( $defaults['text_color'] ); ?>;
458
+ <?php } ?>
459
  padding:7px 9px;
460
+ <?php if ( ! empty( $defaults['border_color'] ) ) { ?>
461
+ border-top:1px solid <?php echo esc_html( $defaults['border_color'] ); ?>;
462
+ <?php } ?>
463
  }
464
 
465
  table.form_results.with_frm_style tr.frm_even,
469
 
470
  table.form_results.with_frm_style tr.frm_odd,
471
  .frm-grid .frm_odd{
472
+ <?php if ( ! empty( $defaults['border_color'] ) ) { ?>
473
+ background-color:<?php echo esc_html( FrmStylesHelper::adjust_brightness( $defaults['border_color'], 45 ) ); ?>;
474
+ <?php } ?>
475
  }
476
 
477
  .frm_collapse .ui-icon{
543
 
544
  <?php if ( ! empty( $defaults['bg_color'] ) ) { ?>
545
  #frm_loading .progress-striped .progress-bar{
546
+ <?php if ( ! empty( $defaults['border_color'] ) ) { ?>
547
+ background-image:linear-gradient(45deg, <?php echo esc_html( $defaults['border_color'] ); ?> 25%, rgba(0, 0, 0, 0) 25%, rgba(0, 0, 0, 0) 50%, <?php echo esc_html( $defaults['border_color'] ); ?> 50%, <?php echo esc_html( $defaults['border_color'] ); ?> 75%, rgba(0, 0, 0, 0) 75%, rgba(0, 0, 0, 0));
548
+ <?php } ?>
549
  background-size:40px 40px;
550
  }
551
  <?php } ?>
599
  padding:5px;
600
  border-width:1px;
601
  border-style:solid;
602
+ <?php if ( ! empty( $defaults['border_color'] ) ) { ?>
603
+ border-color:<?php echo esc_html( $defaults['border_color'] ); ?>;
604
+ <?php } ?>
605
  border-left:none;
606
  border-right:none;
607
  }
632
  margin-top:20px;
633
  }
634
 
635
+ <?php if ( ! empty( $defaults['bg_color'] ) ) { ?>
636
  .frm_grid_first,
637
  .frm_grid_odd{
638
  background-color:<?php echo esc_html( $defaults['bg_color'] ); ?>;
639
  }
640
+ <?php } ?>
641
 
642
+ <?php if ( ! empty( $defaults['bg_color_active'] ) ) { ?>
643
  .frm_grid{
644
  background-color:<?php echo esc_html( $defaults['bg_color_active'] ); ?>;
645
  }
646
+ <?php } ?>
647
 
648
  .frm_grid .frm_primary_label,
649
  .frm_grid_first .frm_primary_label,
formidable.php CHANGED
@@ -2,7 +2,7 @@
2
  /*
3
  Plugin Name: Formidable Forms
4
  Description: Quickly and easily create drag-and-drop forms
5
- Version: 4.04.04
6
  Plugin URI: https://formidableforms.com/
7
  Author URI: https://formidableforms.com/
8
  Author: Strategy11
2
  /*
3
  Plugin Name: Formidable Forms
4
  Description: Quickly and easily create drag-and-drop forms
5
+ Version: 4.04.05
6
  Plugin URI: https://formidableforms.com/
7
  Author URI: https://formidableforms.com/
8
  Author: Strategy11
js/formidable.js CHANGED
@@ -1,28 +1,36 @@
1
- function frmFrontFormJS(){
 
 
 
 
2
  'use strict';
3
 
4
- /*global jQuery:false, frm_js */
 
5
 
6
  var action = '';
7
  var jsErrors = [];
8
 
9
- function maybeShowLabel(){
10
  /*jshint validthis:true */
11
- var $field = jQuery(this);
12
- var $label = $field.closest('.frm_inside_container').find('.frm_primary_label');
 
13
 
14
- if ( $field.val().length > 0 ) {
15
- $label.addClass('frm_visible');
16
  } else {
17
- $label.removeClass('frm_visible');
18
  }
19
  }
20
 
21
  /* Get the ID of the field that changed*/
22
  function getFieldId( field, fullID ) {
23
- var fieldName = '';
 
 
24
  if ( field instanceof jQuery ) {
25
- fieldName = field.attr('name');
26
  } else {
27
  fieldName = field.name;
28
  }
@@ -33,9 +41,9 @@ function frmFrontFormJS(){
33
 
34
  if ( fieldName === '' ) {
35
  if ( field instanceof jQuery ) {
36
- fieldName = field.data('name');
37
  } else {
38
- fieldName = field.getAttribute('data-name');
39
  }
40
 
41
  if ( typeof fieldName === 'undefined' ) {
@@ -48,54 +56,54 @@ function frmFrontFormJS(){
48
  return 0;
49
  }
50
 
51
- var nameParts = fieldName.replace('item_meta[', '').replace('[]', '').split(']');
52
  //TODO: Fix this for checkboxes and address fields
53
  if ( nameParts.length < 1 ) {
54
  return 0;
55
  }
56
- nameParts = nameParts.filter(function(n){ return n !== ''; });
 
 
57
 
58
- var field_id = nameParts[0];
59
- var isRepeating = false;
60
 
61
  if ( nameParts.length === 1 ) {
62
- return field_id;
63
  }
64
 
65
  if ( nameParts[1] === '[form' || nameParts[1] === '[row_ids' ) {
66
  return 0;
67
  }
68
 
69
-
70
  // Check if 'this' is in a repeating section
71
- if ( jQuery('input[name="item_meta['+ field_id +'][form]"]').length ) {
72
 
73
  // this is a repeatable section with name: item_meta[repeating-section-id][row-id][field-id]
74
- field_id = nameParts[2].replace('[', '');
75
  isRepeating = true;
76
  }
77
 
78
  // Check if 'this' is an other text field and get field ID for it
79
- if ( 'other' === field_id ) {
80
  if ( isRepeating ) {
81
  // name for other fields: item_meta[370][0][other][414]
82
- field_id = nameParts[3].replace('[', '');
83
  } else {
84
  // Other field name: item_meta[other][370]
85
- field_id = nameParts[1].replace('[', '');
86
  }
87
  }
88
 
89
  if ( fullID === true ) {
90
  // For use in the container div id
91
- if ( field_id === nameParts[0] ) {
92
- field_id = field_id +'-'+ nameParts[1].replace('[', '');
93
  } else {
94
- field_id = field_id +'-'+ nameParts[0] +'-'+ nameParts[1].replace('[', '');
95
  }
96
  }
97
 
98
- return field_id;
99
  }
100
 
101
  /**
@@ -106,7 +114,7 @@ function frmFrontFormJS(){
106
  * @param {object} $form
107
  */
108
  function disableSubmitButton( $form ) {
109
- $form.find('input[type="submit"], input[type="button"], button[type="submit"]').attr('disabled','disabled');
110
  }
111
 
112
  /**
@@ -143,24 +151,25 @@ function frmFrontFormJS(){
143
  }
144
 
145
  function validateForm( object ) {
146
- var errors = [];
 
147
 
148
  // Make sure required text field is filled in
149
- var requiredFields = jQuery(object).find(
150
  '.frm_required_field:visible input, .frm_required_field:visible select, .frm_required_field:visible textarea'
151
- ).filter(':not(.frm_optional)');
152
  if ( requiredFields.length ) {
153
- for ( var r = 0, rl = requiredFields.length; r < rl; r++ ) {
154
  errors = checkRequiredField( requiredFields[r], errors );
155
  }
156
  }
157
 
158
- var emailFields = jQuery(object).find('input[type=email]').filter(':visible');
159
- var fields = jQuery(object).find('input,select,textarea');
160
  if ( fields.length ) {
161
- for ( var n = 0, nl = fields.length; n < nl; n++ ) {
162
- var field = fields[n];
163
- var value = field.value;
164
  if ( value !== '' ) {
165
  if ( field.type === 'hidden' ) {
166
  // don't validate
@@ -180,12 +189,12 @@ function frmFrontFormJS(){
180
  return errors;
181
  }
182
 
183
- function maybeValidateChange( field_id, field ) {
184
  if ( field.type === 'url' ) {
185
  maybeAddHttpToUrl( field );
186
  }
187
- if ( jQuery(field).closest('form').hasClass('frm_js_validate') ) {
188
- validateField( field_id, field );
189
  }
190
  }
191
 
@@ -198,16 +207,17 @@ function frmFrontFormJS(){
198
  }
199
 
200
  function validateField( fieldId, field ) {
201
- var errors = [];
 
202
 
203
- var $fieldCont = jQuery(field).closest('.frm_form_field');
204
- if ( $fieldCont.hasClass('frm_required_field') && ! jQuery(field).hasClass('frm_optional') ) {
205
  errors = checkRequiredField( field, errors );
206
  }
207
 
208
  if ( errors.length < 1 ) {
209
  if ( field.type === 'email' ) {
210
- var emailFields = jQuery(field).closest('form').find('input[type=email]');
211
  errors = checkEmailField( field, errors, emailFields );
212
  } else if ( field.type === 'number' ) {
213
  errors = checkNumberField( field, errors );
@@ -217,30 +227,32 @@ function frmFrontFormJS(){
217
  }
218
 
219
  removeFieldError( $fieldCont );
220
- if ( Object.keys(errors).length > 0 ) {
221
- for ( var key in errors ) {
222
  addFieldError( $fieldCont, key, errors );
223
  }
224
  }
225
  }
226
 
227
  function checkRequiredField( field, errors ) {
228
- var fileID = field.getAttribute('data-frmfile');
 
 
 
 
229
  if ( field.type === 'hidden' && fileID === null ) {
230
  return errors;
231
  }
232
 
233
- var val = '';
234
- var fieldID = '';
235
  if ( field.type === 'checkbox' || field.type === 'radio' ) {
236
- var checkGroup = jQuery('input[name="'+field.name+'"]').closest('.frm_required_field').find('input:checked');
237
- jQuery(checkGroup).each(function() {
238
- val = this.value;
239
  });
240
  } else if ( field.type === 'file' || fileID ) {
241
  if ( typeof fileID === 'undefined' ) {
242
  fileID = getFieldId( field, true );
243
- fileID = fileID.replace('file', '');
244
  }
245
 
246
  if ( typeof errors[ fileID ] === 'undefined' ) {
@@ -248,37 +260,37 @@ function frmFrontFormJS(){
248
  }
249
  fieldID = fileID;
250
  } else {
251
- var fieldClasses = field.className;
252
- if ( fieldClasses.indexOf('frm_pos_none') !== -1 ) {
253
  // skip hidden other fields
254
  return errors;
255
  }
256
 
257
- val = jQuery(field).val();
258
  if ( val === null ) {
259
  val = '';
260
  } else if ( typeof val !== 'string' ) {
261
- var tempVal = val;
262
  val = '';
263
- for ( var i = 0; i < tempVal.length; i++ ) {
264
  if ( tempVal[i] !== '' ) {
265
  val = tempVal[i];
266
  }
267
  }
268
  }
269
 
270
- if ( fieldClasses.indexOf('frm_other_input') === -1 ) {
271
  fieldID = getFieldId( field, true );
272
  } else {
273
  fieldID = getFieldId( field, false );
274
  }
275
 
276
- if ( fieldClasses.indexOf('frm_time_select') !== -1 ) {
277
  // set id for time field
278
- fieldID = fieldID.replace('-H', '').replace('-m', '');
279
  }
280
 
281
- var placeholder = field.getAttribute('data-frmplaceholder');
282
  if ( placeholder !== null && val === placeholder ) {
283
  val = '';
284
  }
@@ -288,7 +300,7 @@ function frmFrontFormJS(){
288
  if ( fieldID === '' ) {
289
  fieldID = getFieldId( field, true );
290
  }
291
- if ( !(fieldID in errors) ) {
292
  errors[ fieldID ] = getFieldValidationMessage( field, 'data-reqmsg' );
293
  }
294
  }
@@ -297,9 +309,10 @@ function frmFrontFormJS(){
297
  }
298
 
299
  function getFileVals( fileID ) {
300
- var val = '';
301
- var fileFields = jQuery('input[name="file'+ fileID +'"], input[name="file'+ fileID +'[]"], input[name^="item_meta['+ fileID +']"]');
302
- fileFields.each(function(){
 
303
  if ( val === '' ) {
304
  val = this.value;
305
  }
@@ -308,27 +321,29 @@ function frmFrontFormJS(){
308
  }
309
 
310
  function checkEmailField( field, errors, emailFields ) {
311
- var emailAddress = field.value;
312
- var fieldID = getFieldId( field, true );
 
 
313
  if ( fieldID in errors ) {
314
  return errors;
315
  }
316
 
317
- var isConf = (fieldID.indexOf('conf_') === 0);
318
  if ( emailAddress !== '' || isConf ) {
319
- var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/i;
320
- var invalidMsg = getFieldValidationMessage( field, 'data-invmsg' );
321
  if ( emailAddress !== '' && re.test( emailAddress ) === false ) {
322
  errors[ fieldID ] = invalidMsg;
323
  if ( isConf ) {
324
- errors[ fieldID.replace('conf_', '') ] = '';
325
  }
326
  } else if ( isConf ) {
327
- var confName = field.name.replace('conf_', '');
328
- var match = emailFields.filter('[name="'+ confName +'"]').val();
329
  if ( match !== emailAddress ) {
330
  errors[ fieldID ] = '';
331
- errors[ fieldID.replace('conf_', '') ] = '';
332
  }
333
  }
334
  }
@@ -336,10 +351,12 @@ function frmFrontFormJS(){
336
  }
337
 
338
  function checkNumberField( field, errors ) {
339
- var number = field.value;
340
- if ( number !== '' && isNaN(number / 1) !== false ) {
341
- var fieldID = getFieldId( field, true );
342
- if ( !(fieldID in errors) ) {
 
 
343
  errors[ fieldID ] = getFieldValidationMessage( field, 'data-invmsg' );
344
  }
345
  }
@@ -347,13 +364,14 @@ function frmFrontFormJS(){
347
  }
348
 
349
  function checkPatternField( field, errors ) {
350
- var text = field.value;
351
- var format = getFieldValidationMessage( field, 'pattern' );
 
352
 
353
  if ( format !== '' && text !== '' ) {
354
- var fieldID = getFieldId( field, true );
355
- if ( !(fieldID in errors) ) {
356
- format = new RegExp( '^'+ format +'$', 'i' );
357
  if ( format.test( text ) === false ) {
358
  errors[ fieldID ] = getFieldValidationMessage( field, 'data-invmsg' );
359
  }
@@ -363,14 +381,16 @@ function frmFrontFormJS(){
363
  }
364
 
365
  function hasInvisibleRecaptcha( object ) {
 
 
366
  if ( isGoingToPrevPage( object ) ) {
367
  return false;
368
  }
369
 
370
- var recaptcha = jQuery(object).find('.frm-g-recaptcha[data-size="invisible"], .g-recaptcha[data-size="invisible"]');
371
  if ( recaptcha.length ) {
372
- var recaptchaID = recaptcha.data('rid');
373
- var alreadyChecked = grecaptcha.getResponse( recaptchaID );
374
  if ( alreadyChecked.length === 0 ) {
375
  return recaptcha;
376
  } else {
@@ -382,20 +402,21 @@ function frmFrontFormJS(){
382
  }
383
 
384
  function executeInvisibleRecaptcha( invisibleRecaptcha ) {
385
- var recaptchaID = invisibleRecaptcha.data('rid');
386
  grecaptcha.reset( recaptchaID );
387
  grecaptcha.execute( recaptchaID );
388
  }
389
 
390
  function validateRecaptcha( form, errors ) {
391
- var $recaptcha = jQuery(form).find('.frm-g-recaptcha');
 
392
  if ( $recaptcha.length ) {
393
- var recaptchaID = $recaptcha.data('rid');
394
- var response = grecaptcha.getResponse( recaptchaID );
395
 
396
  if ( response.length === 0 ) {
397
- var fieldContainer = $recaptcha.closest('.frm_form_field');
398
- var fieldID = fieldContainer.attr('id').replace('frm_field_', '').replace('_container', '');
399
  errors[ fieldID ] = '';
400
  }
401
  }
@@ -403,7 +424,7 @@ function frmFrontFormJS(){
403
  }
404
 
405
  function getFieldValidationMessage( field, messageType ) {
406
- var msg = field.getAttribute(messageType);
407
  if ( msg === null ) {
408
  msg = '';
409
  }
@@ -411,7 +432,7 @@ function frmFrontFormJS(){
411
  }
412
 
413
  function shouldJSValidate( object ) {
414
- var validate = jQuery(object).hasClass('frm_js_validate');
415
  if ( validate && typeof frmProForm !== 'undefined' && ( frmProForm.savingDraft( object ) || frmProForm.goingToPreviousPage( object ) ) ) {
416
  validate = false;
417
  }
@@ -419,92 +440,98 @@ function frmFrontFormJS(){
419
  return validate;
420
  }
421
 
422
- function getFormErrors(object, action){
423
- if(typeof action === 'undefined'){
424
- jQuery(object).find('input[name="frm_action"]').val();
 
 
425
  }
426
 
427
- var fieldset = jQuery(object).find('.frm_form_field');
428
- fieldset.addClass('frm_doing_ajax');
429
  jQuery.ajax({
430
- type:'POST',url:frm_js.ajax_url,
431
- data:jQuery(object).serialize() +'&action=frm_entries_'+ action +'&nonce='+frm_js.nonce,
432
- success:function(response){
433
- var defaultResponse = {'content':'', 'errors':{}, 'pass':false };
 
 
 
434
  if ( response === null ) {
435
  response = defaultResponse;
436
  }
437
 
438
- response = response.replace(/^\s+|\s+$/g,'');
439
- if ( response.indexOf('{') === 0 ) {
440
- response = jQuery.parseJSON(response);
441
- }else{
442
  response = defaultResponse;
443
  }
444
 
445
  if ( typeof response.redirect !== 'undefined' ) {
446
- jQuery(document).trigger( 'frmBeforeFormRedirect', [ object, response ] );
447
  window.location = response.redirect;
448
  } else if ( response.content !== '' ) {
449
  // the form or success message was returned
450
 
451
- removeSubmitLoading( jQuery(object) );
452
  if ( frm_js.offset != -1 ) {
453
- frmFrontForm.scrollMsg( jQuery(object), false );
454
  }
455
- var formID = jQuery(object).find('input[name="form_id"]').val();
456
- response.content = response.content.replace(/ frm_pro_form /g, ' frm_pro_form frm_no_hide ');
457
- var replaceContent = jQuery( object ).closest( '.frm_forms' );
458
  removeAddedScripts( replaceContent, formID );
459
  replaceContent.replaceWith( response.content );
460
 
461
- addUrlParam(response);
462
 
463
- if(typeof(frmThemeOverride_frmAfterSubmit) === 'function'){
464
- var pageOrder = jQuery('input[name="frm_page_order_'+ formID +'"]').val();
465
- var formReturned = jQuery(response.content).find('input[name="form_id"]').val();
466
- frmThemeOverride_frmAfterSubmit(formReturned, pageOrder, response.content, object);
467
  }
468
 
469
  afterFormSubmitted( object, response );
470
 
471
- } else if ( Object.keys(response.errors).length ) {
472
  // errors were returned
473
 
474
- removeSubmitLoading( jQuery(object), 'enable' );
475
 
476
  //show errors
477
- var cont_submit = true;
478
  removeAllErrors();
479
 
480
- var show_captcha = false;
481
- var $fieldCont = null;
482
 
483
- for ( var key in response.errors ) {
484
- $fieldCont = jQuery(object).find('#frm_field_'+key+'_container');
 
485
 
486
  if ( $fieldCont.length ) {
487
- if ( ! $fieldCont.is(':visible') ) {
488
- var inCollapsedSection = $fieldCont.closest('.frm_toggle_container');
489
  if ( inCollapsedSection.length ) {
490
- var frmTrigger = inCollapsedSection.prev();
491
- if ( ! frmTrigger.hasClass('frm_trigger') ) {
492
  // If the frmTrigger object is the section description, check to see if the previous element is the trigger
493
- frmTrigger = frmTrigger.prev('.frm_trigger');
494
  }
495
  frmTrigger.click();
496
  }
497
  }
498
 
499
- if ( $fieldCont.is(':visible') ) {
500
  addFieldError( $fieldCont, key, response.errors );
501
 
502
- cont_submit = false;
503
 
504
- var $recaptcha = jQuery(object).find('#frm_field_'+key+'_container .frm-g-recaptcha, #frm_field_'+key+'_container .g-recaptcha');
505
  if ( $recaptcha.length ) {
506
- show_captcha = true;
507
- var recaptchaID = $recaptcha.data('rid');
508
  if ( jQuery().grecaptcha ) {
509
  if ( recaptchaID ) {
510
  grecaptcha.reset( recaptchaID );
@@ -517,19 +544,19 @@ function frmFrontFormJS(){
517
  }
518
  }
519
 
520
- jQuery(document).trigger( 'frmFormErrors', [ object, response ] );
521
 
522
- fieldset.removeClass('frm_doing_ajax');
523
  scrollToFirstField( object );
524
 
525
- if(show_captcha !== true){
526
  replaceCheckedRecaptcha( object, false );
527
  }
528
 
529
- if(cont_submit){
530
  object.submit();
531
- }else{
532
- jQuery(object).prepend(response.error_message);
533
  }
534
  } else {
535
  // there may have been a plugin conflict, or the form is not set to submit with ajax
@@ -540,19 +567,19 @@ function frmFrontFormJS(){
540
  object.submit();
541
  }
542
  },
543
- error:function(){
544
- jQuery(object).find('input[type="submit"], input[type="button"]').removeAttr('disabled');
545
  object.submit();
546
  }
547
  });
548
  }
549
 
550
  function afterFormSubmitted( object, response ) {
551
- var formCompleted = jQuery(response.content).find('.frm_message');
552
  if ( formCompleted.length ) {
553
- jQuery(document).trigger( 'frmFormComplete', [ object, response ] );
554
  } else {
555
- jQuery(document).trigger( 'frmPageChanged', [ object, response ] );
556
  }
557
  }
558
 
@@ -564,47 +591,52 @@ function frmFrontFormJS(){
564
  }
565
  }
566
 
567
- function addUrlParam(response){
 
568
  if ( history.pushState && typeof response.page !== 'undefined' ) {
569
- var url = addQueryVar('frm_page', response.page);
570
- window.history.pushState({"html":response.html}, '', '?'+ url);
571
  }
572
  }
573
 
574
- function addQueryVar(key, value) {
575
- key = encodeURI(key);
576
- value = encodeURI(value);
 
 
577
 
578
- var kvp = document.location.search.substr(1).split('&');
579
 
580
- var i=kvp.length; var x; while(i--) {
581
- x = kvp[i].split('=');
 
582
 
583
- if (x[0]==key) {
584
  x[1] = value;
585
- kvp[i] = x.join('=');
586
  break;
587
  }
588
  }
589
 
590
- if (i<0) {
591
- kvp[kvp.length] = [key,value].join('=');
592
  }
593
 
594
- return kvp.join('&');
595
  }
596
 
597
  function addFieldError( $fieldCont, key, jsErrors ) {
598
- if ( $fieldCont.length && $fieldCont.is(':visible') ) {
599
- $fieldCont.addClass('frm_blank_field');
600
- var input = $fieldCont.find( 'input, select, textarea' ),
601
- id = 'frm_error_field_' + key,
602
- describedBy = input.attr( 'aria-describedby' );
 
603
 
604
- if ( typeof frmThemeOverride_frmPlaceError === 'function' ) {
605
  frmThemeOverride_frmPlaceError( key, jsErrors );
606
  } else {
607
- $fieldCont.append( '<div class="frm_error" id="' + id + '">'+ jsErrors[key] +'</div>' );
608
 
609
  if ( typeof describedBy === 'undefined' ) {
610
  describedBy = id;
@@ -615,17 +647,17 @@ function frmFrontFormJS(){
615
  }
616
  input.attr( 'aria-invalid', true );
617
 
618
- jQuery(document).trigger('frmAddFieldError', [ $fieldCont, key, jsErrors ] );
619
  }
620
  }
621
 
622
  function removeFieldError( $fieldCont ) {
623
- var errorMessage = $fieldCont.find('.frm_error'),
624
- errorId = errorMessage.attr('id'),
625
  input = $fieldCont.find( 'input, select, textarea' ),
626
  describedBy = input.attr( 'aria-describedby' );
627
 
628
- $fieldCont.removeClass('frm_blank_field has-error');
629
  errorMessage.remove();
630
  input.attr( 'aria-invalid', false );
631
 
@@ -636,13 +668,13 @@ function frmFrontFormJS(){
636
  }
637
 
638
  function removeAllErrors() {
639
- jQuery('.form-field').removeClass('frm_blank_field has-error');
640
- jQuery('.form-field .frm_error').replaceWith('');
641
- jQuery('.frm_error_style').remove();
642
  }
643
 
644
  function scrollToFirstField( object ) {
645
- var field = jQuery(object).find('.frm_blank_field:first');
646
  if ( field.length ) {
647
  frmFrontForm.scrollMsg( field, object, true );
648
  }
@@ -660,11 +692,11 @@ function frmFrontFormJS(){
660
  $object.trigger( 'frmStartFormLoading' );
661
  }
662
  }
663
-
664
  function addLoadingClass( $object ) {
665
- var loading_class = isGoingToPrevPage( $object ) ? 'frm_loading_prev' : 'frm_loading_form';
666
 
667
- $object.addClass( loading_class );
668
  }
669
 
670
  function isGoingToPrevPage( $object ) {
@@ -672,12 +704,14 @@ function frmFrontFormJS(){
672
  }
673
 
674
  function removeSubmitLoading( $object, enable, processesRunning ) {
 
 
675
  if ( processesRunning > 0 ) {
676
  return;
677
  }
678
 
679
- var loadingForm = jQuery( '.frm_loading_form' );
680
- loadingForm.removeClass('frm_loading_form');
681
  loadingForm.removeClass( 'frm_loading_prev' );
682
 
683
  loadingForm.trigger( 'frmEndFormLoading' );
@@ -689,78 +723,81 @@ function frmFrontFormJS(){
689
  }
690
 
691
  function showFileLoading( object ) {
692
- var loading = document.getElementById('frm_loading');
 
693
  if ( loading !== null ) {
694
- var file_val = jQuery(object).find('input[type=file]').val();
695
- if ( typeof file_val !== 'undefined' && file_val !== '' ) {
696
- setTimeout(function(){
697
- jQuery(loading).fadeIn('slow');
698
- },2000);
699
  }
700
  }
701
  }
702
 
703
  function replaceCheckedRecaptcha( object, checkPage ) {
704
- var $recapField = jQuery(object).find('.frm-g-recaptcha, .g-recaptcha');
705
- if($recapField.length ){
 
706
  if ( checkPage ) {
707
- var morePages = jQuery(object).find('.frm_next_page').length < 1 || jQuery(object).find('.frm_next_page').val() < 1;
708
  if ( ! morePages ) {
709
  return;
710
  }
711
  }
712
- $recapField.closest('.frm_form_field').replaceWith('<input type="hidden" name="recaptcha_checked" value="'+ frm_js.nonce +'">');
713
  }
714
  }
715
 
716
- function clearDefault(){
717
  /*jshint validthis:true */
718
- toggleDefault(jQuery(this), 'clear');
719
  }
720
 
721
- function replaceDefault(){
722
  /*jshint validthis:true */
723
- toggleDefault(jQuery(this), 'replace');
724
  }
725
 
726
- function toggleDefault($thisField, e){
727
  // TODO: Fix this for a default value that is a number or array
728
- var v = $thisField.data('frmval').replace(/(\n|\r\n)/g, '\r');
 
729
  if ( v === '' || typeof v === 'undefined' ) {
730
  return false;
731
  }
732
- var thisVal = $thisField.val().replace(/(\n|\r\n)/g, '\r');
733
 
734
- if ( 'replace' == e ) {
735
  if ( thisVal === '' ) {
736
- $thisField.addClass('frm_default').val(v);
737
  }
738
  } else if ( thisVal == v ) {
739
- $thisField.removeClass('frm_default').val('');
740
  }
741
  }
742
 
743
- function resendEmail(){
744
  /*jshint validthis:true */
745
- var $link = jQuery(this),
746
- entry_id = this.getAttribute( 'data-eid' ),
747
- form_id = this.getAttribute( 'data-fid' ),
748
  label = $link.find( '.frm_link_label' );
749
  if ( label.length < 1 ) {
750
  label = $link;
751
  }
752
- label.append('<span class="frm-wait"></span>');
753
 
754
  jQuery.ajax({
755
- type:'POST',
756
- url:frm_js.ajax_url,
757
- data:{
758
- action:'frm_entries_send_email',
759
- entry_id:entry_id,
760
- form_id:form_id,
761
- nonce:frm_js.nonce
762
  },
763
- success:function(msg){
764
  var admin = document.getElementById( 'wpbody' );
765
  if ( admin === null ) {
766
  label.html( msg );
@@ -779,11 +816,11 @@ function frmFrontFormJS(){
779
 
780
  function confirmClick() {
781
  /*jshint validthis:true */
782
- var message = jQuery(this).data('frmconfirm');
783
- return confirm(message);
784
  }
785
 
786
- function toggleDiv(){
787
  /*jshint validthis:true */
788
  var div = jQuery( this ).data( 'frmtoggle' );
789
  if ( jQuery( div ).is( ':visible' ) ) {
@@ -799,17 +836,19 @@ function frmFrontFormJS(){
799
  *********************************************/
800
 
801
  function addIndexOfFallbackForIE8() {
802
- if ( !Array.prototype.indexOf ) {
803
- Array.prototype.indexOf = function(elt /*, from*/) {
804
- var len = this.length >>> 0;
 
 
805
 
806
- var from = Number(arguments[1]) || 0;
807
- from = (from < 0) ? Math.ceil(from) : Math.floor(from);
808
- if (from < 0) {
809
  from += len;
810
  }
811
 
812
- for (; from < len; from++) {
813
  if ( from in this && this[from] === elt ) {
814
  return from;
815
  }
@@ -819,36 +858,39 @@ function frmFrontFormJS(){
819
  }
820
  }
821
 
822
- function addTrimFallbackForIE8(){
823
  if ( typeof String.prototype.trim !== 'function' ) {
824
  String.prototype.trim = function() {
825
- return this.replace(/^\s+|\s+$/g, '');
826
  };
827
  }
828
  }
829
 
830
- function addFilterFallbackForIE8(){
831
- if ( !Array.prototype.filter ) {
832
 
833
- Array.prototype.filter = function(fun /*, thisp */) {
 
 
834
 
835
  if ( this === void 0 || this === null ) {
836
  throw new TypeError();
837
  }
838
 
839
- var t = Object( this );
840
- var len = t.length >>> 0;
841
  if ( typeof fun !== 'function' ) {
842
  throw new TypeError();
843
  }
844
 
845
- var res = [];
846
- var thisp = arguments[1];
847
- for (var i = 0; i < len; i++) {
848
  if ( i in t ) {
849
- var val = t[i]; // in case fun mutates this
850
- if (fun.call(thisp, val, i, t))
851
- res.push(val);
 
852
  }
853
  }
854
 
@@ -857,44 +899,46 @@ function frmFrontFormJS(){
857
  }
858
  }
859
 
860
- function addKeysFallbackForIE8(){
861
- if ( !Object.keys ) {
862
- Object.keys = function(obj) {
863
- var keys = [];
 
 
864
 
865
- for (var i in obj) {
866
- if (obj.hasOwnProperty(i)) {
867
- keys.push(i);
868
- }
869
- }
870
 
871
- return keys;
872
- };
873
  }
874
  }
875
 
876
- return{
877
- init: function(){
878
- jQuery(document).off('submit.formidable','.frm-show-form');
879
- jQuery(document).on('submit.formidable','.frm-show-form', frmFrontForm.submitForm);
880
 
881
  jQuery( '.frm-show-form input[onblur], .frm-show-form textarea[onblur]' ).each( function() {
882
  if ( jQuery( this ).val() === '' ) {
883
  jQuery( this ).blur();
884
  }
885
- } );
886
 
887
- jQuery(document).on('focus', '.frm_toggle_default', clearDefault);
888
- jQuery(document).on('blur', '.frm_toggle_default', replaceDefault);
889
- jQuery('.frm_toggle_default').blur();
890
 
891
- jQuery(document.getElementById('frm_resend_email')).click(resendEmail);
892
 
893
- jQuery(document).on('change', '.frm-show-form input[name^="item_meta"], .frm-show-form select[name^="item_meta"], .frm-show-form textarea[name^="item_meta"]', frmFrontForm.fieldValueChanged );
894
- jQuery(document).on('change keyup', '.frm-show-form .frm_inside_container input, .frm-show-form .frm_inside_container select, .frm-show-form .frm_inside_container textarea', maybeShowLabel);
895
 
896
- jQuery(document).on('click', 'a[data-frmconfirm]', confirmClick);
897
- jQuery('a[data-frmtoggle]').click(toggleDiv);
898
 
899
  // Add fallbacks for the beloved IE8
900
  addIndexOfFallbackForIE8();
@@ -908,12 +952,13 @@ function frmFrontFormJS(){
908
  },
909
 
910
  renderRecaptcha: function( captcha ) {
911
- var size = captcha.getAttribute('data-size'),
912
- rendered = captcha.getAttribute('data-rid') !== null,
 
913
  params = {
914
- 'sitekey': captcha.getAttribute('data-sitekey'),
915
  'size': size,
916
- 'theme': captcha.getAttribute('data-theme')
917
  };
918
 
919
  if ( rendered ) {
@@ -921,44 +966,45 @@ function frmFrontFormJS(){
921
  }
922
 
923
  if ( size === 'invisible' ) {
924
- var formID = jQuery(captcha).closest('form').find('input[name="form_id"]').val();
925
- jQuery(captcha).closest('.frm_form_field .frm_primary_label').hide();
926
- params.callback = function(token) {
927
- frmFrontForm.afterRecaptcha(token, formID);
928
  };
929
  }
930
 
931
- var recaptchaID = grecaptcha.render( captcha.id, params );
932
 
933
- captcha.setAttribute('data-rid', recaptchaID);
934
  },
935
 
936
- afterSingleRecaptcha: function(token){
937
- var object = jQuery('.frm-show-form .g-recaptcha').closest('form')[0];
938
  frmFrontForm.submitFormNow( object );
939
  },
940
 
941
- afterRecaptcha: function(token, formID){
942
- var object = jQuery('#frm_form_'+ formID +'_container form')[0];
943
  frmFrontForm.submitFormNow( object );
944
  },
945
 
946
- submitForm: function(e){
947
  frmFrontForm.submitFormManual( e, this );
948
  },
949
 
950
- submitFormManual: function(e, object){
951
- var invisibleRecaptcha = hasInvisibleRecaptcha(object);
 
 
952
 
953
- var classList = object.className.trim().split(/\s+/gi);
954
  if ( classList && invisibleRecaptcha.length < 1 ) {
955
- var isPro = classList.indexOf('frm_pro_form') > -1;
956
  if ( ! isPro ) {
957
  return;
958
  }
959
  }
960
 
961
- if ( jQuery('body').hasClass('wp-admin') && jQuery(object).closest('.frmapi-form').length < 1 ) {
962
  return;
963
  }
964
 
@@ -971,28 +1017,29 @@ function frmFrontFormJS(){
971
  }
972
 
973
  if ( invisibleRecaptcha.length ) {
974
- showLoadingIndicator( jQuery(object) );
975
  executeInvisibleRecaptcha( invisibleRecaptcha );
976
  } else {
977
 
978
- var errors = frmFrontForm.validateFormSubmit( object );
979
 
980
- if ( Object.keys(errors).length === 0 ) {
981
- showSubmitLoading( jQuery(object) );
982
 
983
  frmFrontForm.submitFormNow( object, classList );
984
  }
985
  }
986
  },
987
 
988
- submitFormNow: function(object) {
989
- var classList = object.className.trim().split(/\s+/gi);
990
- if ( classList.indexOf('frm_ajax_submit') > -1 ) {
991
- var hasFileFields = jQuery(object).find('input[type="file"]').filter(function () {
992
- return !!this.value;
 
993
  }).length;
994
  if ( hasFileFields < 1 ) {
995
- action = jQuery(object).find('input[name="frm_action"]').val();
996
  frmFrontForm.checkFormErrors( object, action );
997
  } else {
998
  object.submit();
@@ -1002,8 +1049,8 @@ function frmFrontFormJS(){
1002
  }
1003
  },
1004
 
1005
- validateFormSubmit: function( object ){
1006
- if ( typeof tinyMCE !== 'undefined' && jQuery(object).find('.wp-editor-wrap').length ) {
1007
  tinyMCE.triggerSave();
1008
  }
1009
 
@@ -1012,7 +1059,7 @@ function frmFrontFormJS(){
1012
  if ( shouldJSValidate( object ) ) {
1013
  frmFrontForm.getAjaxFormErrors( object );
1014
 
1015
- if ( Object.keys(jsErrors).length ) {
1016
  frmFrontForm.addAjaxFormErrors( object );
1017
  }
1018
  }
@@ -1021,12 +1068,14 @@ function frmFrontFormJS(){
1021
  },
1022
 
1023
  getAjaxFormErrors: function( object ) {
 
 
1024
  jsErrors = validateForm( object );
1025
- if ( typeof frmThemeOverride_jsErrors === 'function' ) {
1026
- action = jQuery(object).find('input[name="frm_action"]').val();
1027
- var customErrors = frmThemeOverride_jsErrors( action, object );
1028
- if ( Object.keys(customErrors).length ) {
1029
- for ( var key in customErrors ) {
1030
  jsErrors[ key ] = customErrors[ key ];
1031
  }
1032
  }
@@ -1036,10 +1085,11 @@ function frmFrontFormJS(){
1036
  },
1037
 
1038
  addAjaxFormErrors: function( object ) {
 
1039
  removeAllErrors();
1040
 
1041
- for ( var key in jsErrors ) {
1042
- var $fieldCont = jQuery(object).find('#frm_field_'+key+'_container');
1043
 
1044
  if ( $fieldCont.length ) {
1045
  addFieldError( $fieldCont, key, jsErrors );
@@ -1052,221 +1102,234 @@ function frmFrontFormJS(){
1052
  scrollToFirstField( object );
1053
  },
1054
 
1055
- checkFormErrors: function(object, action){
1056
  getFormErrors( object, action );
1057
  },
1058
 
1059
- checkRequiredField: function( field, errors ){
1060
  return checkRequiredField( field, errors );
1061
  },
1062
 
1063
- showSubmitLoading: function( $object ){
1064
  showSubmitLoading( $object );
1065
  },
1066
 
1067
- removeSubmitLoading: function( $object, enable, processesRunning ){
1068
  removeSubmitLoading( $object, enable, processesRunning );
1069
  },
1070
 
1071
- scrollToID: function(id){
1072
- var object = jQuery(document.getElementById(id));
1073
  frmFrontForm.scrollMsg( object, false );
1074
  },
1075
 
1076
  scrollMsg: function( id, object, animate ) {
1077
- var scrollObj = '';
1078
- if(typeof(object) === 'undefined'){
1079
- scrollObj = jQuery(document.getElementById('frm_form_'+id+'_container'));
1080
- if(scrollObj.length < 1 ){
 
1081
  return;
1082
  }
1083
  } else if ( typeof id === 'string' ) {
1084
- scrollObj = jQuery(object).find('#frm_field_'+id+'_container');
1085
  } else {
1086
  scrollObj = id;
1087
  }
1088
 
1089
- var newPos = scrollObj.offset().top;
1090
- if ( !newPos ){
1091
  return;
1092
  }
1093
- newPos = newPos-frm_js.offset;
1094
 
1095
- var m=jQuery('html').css('margin-top');
1096
- var b=jQuery('body').css('margin-top');
1097
- if(m || b){
1098
- newPos = newPos - parseInt(m) - parseInt(b);
1099
  }
1100
 
1101
  if ( newPos && window.innerHeight ) {
1102
- var screenTop = document.documentElement.scrollTop || document.body.scrollTop;
1103
- var screenBottom = screenTop + window.innerHeight;
1104
 
1105
- if( newPos > screenBottom || newPos < screenTop ) {
1106
  // Not in view
1107
  if ( typeof animate === 'undefined' ) {
1108
- jQuery(window).scrollTop(newPos);
1109
- }else{
1110
- jQuery('html,body').animate({scrollTop: newPos}, 500);
1111
  }
1112
  return false;
1113
  }
1114
  }
1115
  },
1116
 
1117
- fieldValueChanged: function(e){
1118
  /*jshint validthis:true */
1119
 
1120
- var field_id = frmFrontForm.getFieldId( this, false );
1121
- if ( ! field_id || typeof field_id === 'undefined' ) {
1122
  return;
1123
  }
1124
 
1125
- if ( e.frmTriggered && e.frmTriggered == field_id ) {
1126
  return;
1127
  }
1128
 
1129
- jQuery(document).trigger( 'frmFieldChanged', [ this, field_id, e ] );
1130
 
1131
  if ( e.selfTriggered !== true ) {
1132
- maybeValidateChange( field_id, this );
1133
  }
1134
  },
1135
 
1136
- savingDraft: function(object){
1137
- console.warn('DEPRECATED: function frmFrontForm.savingDraft in v3.0 use frmProForm.savingDraft');
1138
  if ( typeof frmProForm !== 'undefined' ) {
1139
- return frmProForm.savingDraft(object);
1140
  }
1141
  },
1142
 
1143
- goingToPreviousPage: function(object){
1144
- console.warn('DEPRECATED: function frmFrontForm.goingToPreviousPage in v3.0 use frmProForm.goingToPreviousPage');
1145
  if ( typeof frmProForm !== 'undefined' ) {
1146
- return frmProForm.goingToPreviousPage(object);
1147
  }
1148
  },
1149
 
1150
- hideOrShowFields: function(ids, event ){
1151
- console.warn('DEPRECATED: function frmFrontForm.hideOrShowFields in v3.0 use frmProForm.hideOrShowFields');
1152
  if ( typeof frmProForm !== 'undefined' ) {
1153
  frmProForm.hideOrShowFields();
1154
  }
1155
  },
1156
 
1157
- hidePreviouslyHiddenFields: function(){
1158
- console.warn('DEPRECATED: function frmFrontForm.hidePreviouslyHiddenFields in v3.0 use frmProForm.hidePreviouslyHiddenFields');
1159
  if ( typeof frmProForm !== 'undefined' ) {
1160
  frmProForm.hidePreviouslyHiddenFields();
1161
  }
1162
  },
1163
 
1164
- checkDependentDynamicFields: function(ids){
1165
- console.warn('DEPRECATED: function frmFrontForm.checkDependentDynamicFields in v3.0 use frmProForm.checkDependentDynamicFields');
1166
  if ( typeof frmProForm !== 'undefined' ) {
1167
- frmProForm.checkDependentDynamicFields(ids);
1168
  }
1169
  },
1170
 
1171
- checkDependentLookupFields: function(ids){
1172
- console.warn('DEPRECATED: function frmFrontForm.checkDependentLookupFields in v3.0 use frmProForm.checkDependentLookupFields');
1173
  if ( typeof frmProForm !== 'undefined' ) {
1174
- frmProForm.checkDependentLookupFields(ids);
1175
  }
1176
  },
1177
 
1178
- loadGoogle: function(){
1179
- console.warn('DEPRECATED: function frmFrontForm.loadGoogle in v3.0 use frmProForm.loadGoogle');
1180
  frmProForm.loadGoogle();
1181
  },
1182
 
1183
- removeUsedTimes: function( obj, timeField ) {
1184
- console.warn('DEPRECATED: function frmFrontForm.removeUsedTimes in v3.0 use frmProForm.removeUsedTimes');
1185
- if ( typeof frmProForm !== 'undefined' ) {
1186
- frmProForm.removeUsedTimes();
1187
- }
1188
- },
1189
-
1190
- escapeHtml: function(text){
1191
  return text
1192
- .replace(/&/g, '&amp;')
1193
- .replace(/</g, '&lt;')
1194
- .replace(/>/g, '&gt;')
1195
- .replace(/"/g, '&quot;')
1196
- .replace(/'/g, '&#039;');
1197
  },
1198
 
1199
- invisible: function(classes) {
1200
- jQuery(classes).css('visibility', 'hidden');
1201
  },
1202
 
1203
- visible: function(classes) {
1204
- jQuery(classes).css('visibility', 'visible');
1205
  }
1206
  };
1207
  }
1208
- var frmFrontForm = frmFrontFormJS();
1209
 
1210
- jQuery(document).ready(function($){
1211
  frmFrontForm.init();
1212
  });
1213
 
1214
  function frmRecaptcha() {
1215
- var captchas = jQuery('.frm-g-recaptcha');
1216
- for ( var c = 0, cl = captchas.length; c < cl; c++ ) {
1217
- frmFrontForm.renderRecaptcha( captchas[c] );
 
1218
  }
1219
  }
1220
 
1221
- function frmAfterRecaptcha(token){
1222
- frmFrontForm.afterSingleRecaptcha(token);
1223
  }
1224
 
1225
- function frmUpdateField(entry_id,field_id,value,message,num){
1226
- jQuery(document.getElementById('frm_update_field_'+entry_id+'_'+field_id+'_'+num)).html('<span class="frm-loading-img"></span>');
1227
  jQuery.ajax({
1228
- type:'POST',url:frm_js.ajax_url,
1229
- data:{action:'frm_entries_update_field_ajax', entry_id:entry_id, field_id:field_id, value:value, nonce:frm_js.nonce},
1230
- success:function(){
1231
- if(message.replace(/^\s+|\s+$/g,'') === ''){
1232
- jQuery(document.getElementById('frm_update_field_'+entry_id+'_'+field_id+'_'+num)).fadeOut('slow');
1233
- }else{
1234
- jQuery(document.getElementById('frm_update_field_'+entry_id+'_'+field_id+'_'+num)).replaceWith(message);
 
 
 
 
 
 
 
1235
  }
1236
  }
1237
  });
1238
  }
1239
 
1240
- function frmDeleteEntry(entry_id,prefix){
1241
- console.warn('DEPRECATED: function frmDeleteEntry in v2.0.13 use frmFrontForm.deleteEntry');
1242
- jQuery(document.getElementById('frm_delete_'+entry_id)).replaceWith('<span class="frm-loading-img" id="frm_delete_'+entry_id+'"></span>');
1243
  jQuery.ajax({
1244
- type:'POST',url:frm_js.ajax_url,
1245
- data:{action:'frm_entries_destroy', entry:entry_id, nonce:frm_js.nonce},
1246
- success:function(html){
1247
- if(html.replace(/^\s+|\s+$/g,'') === 'success')
1248
- jQuery(document.getElementById(prefix+entry_id)).fadeOut('slow');
1249
- else
1250
- jQuery(document.getElementById('frm_delete_'+entry_id)).replaceWith(html);
1251
-
 
 
 
 
 
1252
  }
1253
  });
1254
  }
1255
 
1256
- function frmOnSubmit(e){
1257
- console.warn('DEPRECATED: function frmOnSubmit in v2.0 use frmFrontForm.submitForm');
1258
- frmFrontForm.submitForm(e, this);
1259
  }
1260
 
1261
- function frm_resend_email(entry_id,form_id){
1262
- console.warn('DEPRECATED: function frm_resend_email in v2.0');
1263
- var $link = jQuery(document.getElementById('frm_resend_email'));
1264
- $link.append('<span class="spinner" style="display:inline"></span>');
1265
  jQuery.ajax({
1266
- type:'POST',url:frm_js.ajax_url,
1267
- data:{action:'frm_entries_send_email', entry_id:entry_id, form_id:form_id, nonce:frm_js.nonce},
1268
- success:function(msg){
1269
- $link.replaceWith(msg);
 
 
 
 
 
 
1270
  }
1271
  });
1272
  }
1
+ /* exported frmRecaptcha, frmAfterRecaptcha, frmUpdateField, frmDeleteEntry, frmOnSubmit, frm_resend_email */
2
+
3
+ var frmFrontForm;
4
+
5
+ function frmFrontFormJS() {
6
  'use strict';
7
 
8
+ /*global jQuery:false, frm_js, grecaptcha, frmProForm, tinyMCE */
9
+ /*global frmThemeOverride_jsErrors, frmThemeOverride_frmPlaceError, frmThemeOverride_frmAfterSubmit */
10
 
11
  var action = '';
12
  var jsErrors = [];
13
 
14
+ function maybeShowLabel() {
15
  /*jshint validthis:true */
16
+ var $field = jQuery( this ),
17
+ $label = $field.closest( '.frm_inside_container' ).find( '.frm_primary_label' ),
18
+ val = $field.val();
19
 
20
+ if ( val !== null && val.length > 0 ) {
21
+ $label.addClass( 'frm_visible' );
22
  } else {
23
+ $label.removeClass( 'frm_visible' );
24
  }
25
  }
26
 
27
  /* Get the ID of the field that changed*/
28
  function getFieldId( field, fullID ) {
29
+ var nameParts, fieldId,
30
+ isRepeating = false,
31
+ fieldName = '';
32
  if ( field instanceof jQuery ) {
33
+ fieldName = field.attr( 'name' );
34
  } else {
35
  fieldName = field.name;
36
  }
41
 
42
  if ( fieldName === '' ) {
43
  if ( field instanceof jQuery ) {
44
+ fieldName = field.data( 'name' );
45
  } else {
46
+ fieldName = field.getAttribute( 'data-name' );
47
  }
48
 
49
  if ( typeof fieldName === 'undefined' ) {
56
  return 0;
57
  }
58
 
59
+ nameParts = fieldName.replace( 'item_meta[', '' ).replace( '[]', '' ).split( ']' );
60
  //TODO: Fix this for checkboxes and address fields
61
  if ( nameParts.length < 1 ) {
62
  return 0;
63
  }
64
+ nameParts = nameParts.filter( function( n ) {
65
+ return n !== '';
66
+ });
67
 
68
+ fieldId = nameParts[0];
 
69
 
70
  if ( nameParts.length === 1 ) {
71
+ return fieldId;
72
  }
73
 
74
  if ( nameParts[1] === '[form' || nameParts[1] === '[row_ids' ) {
75
  return 0;
76
  }
77
 
 
78
  // Check if 'this' is in a repeating section
79
+ if ( jQuery( 'input[name="item_meta[' + fieldId + '][form]"]' ).length ) {
80
 
81
  // this is a repeatable section with name: item_meta[repeating-section-id][row-id][field-id]
82
+ fieldId = nameParts[2].replace( '[', '' );
83
  isRepeating = true;
84
  }
85
 
86
  // Check if 'this' is an other text field and get field ID for it
87
+ if ( 'other' === fieldId ) {
88
  if ( isRepeating ) {
89
  // name for other fields: item_meta[370][0][other][414]
90
+ fieldId = nameParts[3].replace( '[', '' );
91
  } else {
92
  // Other field name: item_meta[other][370]
93
+ fieldId = nameParts[1].replace( '[', '' );
94
  }
95
  }
96
 
97
  if ( fullID === true ) {
98
  // For use in the container div id
99
+ if ( fieldId === nameParts[0]) {
100
+ fieldId = fieldId + '-' + nameParts[1].replace( '[', '' );
101
  } else {
102
+ fieldId = fieldId + '-' + nameParts[0] + '-' + nameParts[1].replace( '[', '' );
103
  }
104
  }
105
 
106
+ return fieldId;
107
  }
108
 
109
  /**
114
  * @param {object} $form
115
  */
116
  function disableSubmitButton( $form ) {
117
+ $form.find( 'input[type="submit"], input[type="button"], button[type="submit"]' ).attr( 'disabled', 'disabled' );
118
  }
119
 
120
  /**
151
  }
152
 
153
  function validateForm( object ) {
154
+ var r, rl, n, nl, emailFields, fields, field, value, requiredFields,
155
+ errors = [];
156
 
157
  // Make sure required text field is filled in
158
+ requiredFields = jQuery( object ).find(
159
  '.frm_required_field:visible input, .frm_required_field:visible select, .frm_required_field:visible textarea'
160
+ ).filter( ':not(.frm_optional)' );
161
  if ( requiredFields.length ) {
162
+ for ( r = 0, rl = requiredFields.length; r < rl; r++ ) {
163
  errors = checkRequiredField( requiredFields[r], errors );
164
  }
165
  }
166
 
167
+ emailFields = jQuery( object ).find( 'input[type=email]' ).filter( ':visible' );
168
+ fields = jQuery( object ).find( 'input,select,textarea' );
169
  if ( fields.length ) {
170
+ for ( n = 0, nl = fields.length; n < nl; n++ ) {
171
+ field = fields[n];
172
+ value = field.value;
173
  if ( value !== '' ) {
174
  if ( field.type === 'hidden' ) {
175
  // don't validate
189
  return errors;
190
  }
191
 
192
+ function maybeValidateChange( fieldId, field ) {
193
  if ( field.type === 'url' ) {
194
  maybeAddHttpToUrl( field );
195
  }
196
+ if ( jQuery( field ).closest( 'form' ).hasClass( 'frm_js_validate' ) ) {
197
+ validateField( fieldId, field );
198
  }
199
  }
200
 
207
  }
208
 
209
  function validateField( fieldId, field ) {
210
+ var key, emailFields,
211
+ errors = [];
212
 
213
+ var $fieldCont = jQuery( field ).closest( '.frm_form_field' );
214
+ if ( $fieldCont.hasClass( 'frm_required_field' ) && ! jQuery( field ).hasClass( 'frm_optional' ) ) {
215
  errors = checkRequiredField( field, errors );
216
  }
217
 
218
  if ( errors.length < 1 ) {
219
  if ( field.type === 'email' ) {
220
+ emailFields = jQuery( field ).closest( 'form' ).find( 'input[type=email]' );
221
  errors = checkEmailField( field, errors, emailFields );
222
  } else if ( field.type === 'number' ) {
223
  errors = checkNumberField( field, errors );
227
  }
228
 
229
  removeFieldError( $fieldCont );
230
+ if ( Object.keys( errors ).length > 0 ) {
231
+ for ( key in errors ) {
232
  addFieldError( $fieldCont, key, errors );
233
  }
234
  }
235
  }
236
 
237
  function checkRequiredField( field, errors ) {
238
+ var checkGroup, fieldClasses, tempVal, i, placeholder,
239
+ val = '',
240
+ fieldID = '',
241
+ fileID = field.getAttribute( 'data-frmfile' );
242
+
243
  if ( field.type === 'hidden' && fileID === null ) {
244
  return errors;
245
  }
246
 
 
 
247
  if ( field.type === 'checkbox' || field.type === 'radio' ) {
248
+ checkGroup = jQuery( 'input[name="' + field.name + '"]' ).closest( '.frm_required_field' ).find( 'input:checked' );
249
+ jQuery( checkGroup ).each( function() {
250
+ val = this.value;
251
  });
252
  } else if ( field.type === 'file' || fileID ) {
253
  if ( typeof fileID === 'undefined' ) {
254
  fileID = getFieldId( field, true );
255
+ fileID = fileID.replace( 'file', '' );
256
  }
257
 
258
  if ( typeof errors[ fileID ] === 'undefined' ) {
260
  }
261
  fieldID = fileID;
262
  } else {
263
+ fieldClasses = field.className;
264
+ if ( fieldClasses.indexOf( 'frm_pos_none' ) !== -1 ) {
265
  // skip hidden other fields
266
  return errors;
267
  }
268
 
269
+ val = jQuery( field ).val();
270
  if ( val === null ) {
271
  val = '';
272
  } else if ( typeof val !== 'string' ) {
273
+ tempVal = val;
274
  val = '';
275
+ for ( i = 0; i < tempVal.length; i++ ) {
276
  if ( tempVal[i] !== '' ) {
277
  val = tempVal[i];
278
  }
279
  }
280
  }
281
 
282
+ if ( fieldClasses.indexOf( 'frm_other_input' ) === -1 ) {
283
  fieldID = getFieldId( field, true );
284
  } else {
285
  fieldID = getFieldId( field, false );
286
  }
287
 
288
+ if ( fieldClasses.indexOf( 'frm_time_select' ) !== -1 ) {
289
  // set id for time field
290
+ fieldID = fieldID.replace( '-H', '' ).replace( '-m', '' );
291
  }
292
 
293
+ placeholder = field.getAttribute( 'data-frmplaceholder' );
294
  if ( placeholder !== null && val === placeholder ) {
295
  val = '';
296
  }
300
  if ( fieldID === '' ) {
301
  fieldID = getFieldId( field, true );
302
  }
303
+ if ( ! ( fieldID in errors ) ) {
304
  errors[ fieldID ] = getFieldValidationMessage( field, 'data-reqmsg' );
305
  }
306
  }
309
  }
310
 
311
  function getFileVals( fileID ) {
312
+ var val = '',
313
+ fileFields = jQuery( 'input[name="file' + fileID + '"], input[name="file' + fileID + '[]"], input[name^="item_meta[' + fileID + ']"]' );
314
+
315
+ fileFields.each( function() {
316
  if ( val === '' ) {
317
  val = this.value;
318
  }
321
  }
322
 
323
  function checkEmailField( field, errors, emailFields ) {
324
+ var isConf, re, invalidMsg, confName, match,
325
+ emailAddress = field.value,
326
+ fieldID = getFieldId( field, true );
327
+
328
  if ( fieldID in errors ) {
329
  return errors;
330
  }
331
 
332
+ isConf = ( fieldID.indexOf( 'conf_' ) === 0 );
333
  if ( emailAddress !== '' || isConf ) {
334
+ re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/i;
335
+ invalidMsg = getFieldValidationMessage( field, 'data-invmsg' );
336
  if ( emailAddress !== '' && re.test( emailAddress ) === false ) {
337
  errors[ fieldID ] = invalidMsg;
338
  if ( isConf ) {
339
+ errors[ fieldID.replace( 'conf_', '' ) ] = '';
340
  }
341
  } else if ( isConf ) {
342
+ confName = field.name.replace( 'conf_', '' );
343
+ match = emailFields.filter( '[name="' + confName + '"]' ).val();
344
  if ( match !== emailAddress ) {
345
  errors[ fieldID ] = '';
346
+ errors[ fieldID.replace( 'conf_', '' ) ] = '';
347
  }
348
  }
349
  }
351
  }
352
 
353
  function checkNumberField( field, errors ) {
354
+ var fieldID,
355
+ number = field.value;
356
+
357
+ if ( number !== '' && isNaN( number / 1 ) !== false ) {
358
+ fieldID = getFieldId( field, true );
359
+ if ( ! ( fieldID in errors ) ) {
360
  errors[ fieldID ] = getFieldValidationMessage( field, 'data-invmsg' );
361
  }
362
  }
364
  }
365
 
366
  function checkPatternField( field, errors ) {
367
+ var fieldID,
368
+ text = field.value,
369
+ format = getFieldValidationMessage( field, 'pattern' );
370
 
371
  if ( format !== '' && text !== '' ) {
372
+ fieldID = getFieldId( field, true );
373
+ if ( ! ( fieldID in errors ) ) {
374
+ format = new RegExp( '^' + format + '$', 'i' );
375
  if ( format.test( text ) === false ) {
376
  errors[ fieldID ] = getFieldValidationMessage( field, 'data-invmsg' );
377
  }
381
  }
382
 
383
  function hasInvisibleRecaptcha( object ) {
384
+ var recaptcha, recaptchaID, alreadyChecked;
385
+
386
  if ( isGoingToPrevPage( object ) ) {
387
  return false;
388
  }
389
 
390
+ recaptcha = jQuery( object ).find( '.frm-g-recaptcha[data-size="invisible"], .g-recaptcha[data-size="invisible"]' );
391
  if ( recaptcha.length ) {
392
+ recaptchaID = recaptcha.data( 'rid' );
393
+ alreadyChecked = grecaptcha.getResponse( recaptchaID );
394
  if ( alreadyChecked.length === 0 ) {
395
  return recaptcha;
396
  } else {
402
  }
403
 
404
  function executeInvisibleRecaptcha( invisibleRecaptcha ) {
405
+ var recaptchaID = invisibleRecaptcha.data( 'rid' );
406
  grecaptcha.reset( recaptchaID );
407
  grecaptcha.execute( recaptchaID );
408
  }
409
 
410
  function validateRecaptcha( form, errors ) {
411
+ var recaptchaID, response, fieldContainer, fieldID,
412
+ $recaptcha = jQuery( form ).find( '.frm-g-recaptcha' );
413
  if ( $recaptcha.length ) {
414
+ recaptchaID = $recaptcha.data( 'rid' );
415
+ response = grecaptcha.getResponse( recaptchaID );
416
 
417
  if ( response.length === 0 ) {
418
+ fieldContainer = $recaptcha.closest( '.frm_form_field' );
419
+ fieldID = fieldContainer.attr( 'id' ).replace( 'frm_field_', '' ).replace( '_container', '' );
420
  errors[ fieldID ] = '';
421
  }
422
  }
424
  }
425
 
426
  function getFieldValidationMessage( field, messageType ) {
427
+ var msg = field.getAttribute( messageType );
428
  if ( msg === null ) {
429
  msg = '';
430
  }
432
  }
433
 
434
  function shouldJSValidate( object ) {
435
+ var validate = jQuery( object ).hasClass( 'frm_js_validate' );
436
  if ( validate && typeof frmProForm !== 'undefined' && ( frmProForm.savingDraft( object ) || frmProForm.goingToPreviousPage( object ) ) ) {
437
  validate = false;
438
  }
440
  return validate;
441
  }
442
 
443
+ function getFormErrors( object, action ) {
444
+ var fieldset;
445
+
446
+ if ( typeof action === 'undefined' ) {
447
+ jQuery( object ).find( 'input[name="frm_action"]' ).val();
448
  }
449
 
450
+ fieldset = jQuery( object ).find( '.frm_form_field' );
451
+ fieldset.addClass( 'frm_doing_ajax' );
452
  jQuery.ajax({
453
+ type: 'POST', url: frm_js.ajax_url,
454
+ data: jQuery( object ).serialize() + '&action=frm_entries_' + action + '&nonce=' + frm_js.nonce,
455
+ success: function( response ) {
456
+ var formID, replaceContent, pageOrder, formReturned, contSubmit,
457
+ showCaptcha, $fieldCont, key, inCollapsedSection, frmTrigger,
458
+ $recaptcha, recaptchaID,
459
+ defaultResponse = { 'content': '', 'errors': {}, 'pass': false };
460
  if ( response === null ) {
461
  response = defaultResponse;
462
  }
463
 
464
+ response = response.replace( /^\s+|\s+$/g, '' );
465
+ if ( response.indexOf( '{' ) === 0 ) {
466
+ response = jQuery.parseJSON( response );
467
+ } else {
468
  response = defaultResponse;
469
  }
470
 
471
  if ( typeof response.redirect !== 'undefined' ) {
472
+ jQuery( document ).trigger( 'frmBeforeFormRedirect', [ object, response ]);
473
  window.location = response.redirect;
474
  } else if ( response.content !== '' ) {
475
  // the form or success message was returned
476
 
477
+ removeSubmitLoading( jQuery( object ) );
478
  if ( frm_js.offset != -1 ) {
479
+ frmFrontForm.scrollMsg( jQuery( object ), false );
480
  }
481
+ formID = jQuery( object ).find( 'input[name="form_id"]' ).val();
482
+ response.content = response.content.replace( / frm_pro_form /g, ' frm_pro_form frm_no_hide ' );
483
+ replaceContent = jQuery( object ).closest( '.frm_forms' );
484
  removeAddedScripts( replaceContent, formID );
485
  replaceContent.replaceWith( response.content );
486
 
487
+ addUrlParam( response );
488
 
489
+ if ( typeof frmThemeOverride_frmAfterSubmit === 'function' ) { // eslint-disable-line camelcase
490
+ pageOrder = jQuery( 'input[name="frm_page_order_' + formID + '"]' ).val();
491
+ formReturned = jQuery( response.content ).find( 'input[name="form_id"]' ).val();
492
+ frmThemeOverride_frmAfterSubmit( formReturned, pageOrder, response.content, object );
493
  }
494
 
495
  afterFormSubmitted( object, response );
496
 
497
+ } else if ( Object.keys( response.errors ).length ) {
498
  // errors were returned
499
 
500
+ removeSubmitLoading( jQuery( object ), 'enable' );
501
 
502
  //show errors
503
+ contSubmit = true;
504
  removeAllErrors();
505
 
506
+ showCaptcha = false;
507
+ $fieldCont = null;
508
 
509
+ for ( key in response.errors ) {
510
+
511
+ $fieldCont = jQuery( object ).find( '#frm_field_' + key + '_container' );
512
 
513
  if ( $fieldCont.length ) {
514
+ if ( ! $fieldCont.is( ':visible' ) ) {
515
+ inCollapsedSection = $fieldCont.closest( '.frm_toggle_container' );
516
  if ( inCollapsedSection.length ) {
517
+ frmTrigger = inCollapsedSection.prev();
518
+ if ( ! frmTrigger.hasClass( 'frm_trigger' ) ) {
519
  // If the frmTrigger object is the section description, check to see if the previous element is the trigger
520
+ frmTrigger = frmTrigger.prev( '.frm_trigger' );
521
  }
522
  frmTrigger.click();
523
  }
524
  }
525
 
526
+ if ( $fieldCont.is( ':visible' ) ) {
527
  addFieldError( $fieldCont, key, response.errors );
528
 
529
+ contSubmit = false;
530
 
531
+ $recaptcha = jQuery( object ).find( '#frm_field_' + key + '_container .frm-g-recaptcha, #frm_field_' + key + '_container .g-recaptcha' );
532
  if ( $recaptcha.length ) {
533
+ showCaptcha = true;
534
+ recaptchaID = $recaptcha.data( 'rid' );
535
  if ( jQuery().grecaptcha ) {
536
  if ( recaptchaID ) {
537
  grecaptcha.reset( recaptchaID );
544
  }
545
  }
546
 
547
+ jQuery( document ).trigger( 'frmFormErrors', [ object, response ]);
548
 
549
+ fieldset.removeClass( 'frm_doing_ajax' );
550
  scrollToFirstField( object );
551
 
552
+ if ( showCaptcha !== true ) {
553
  replaceCheckedRecaptcha( object, false );
554
  }
555
 
556
+ if ( contSubmit ) {
557
  object.submit();
558
+ } else {
559
+ jQuery( object ).prepend( response.error_message );
560
  }
561
  } else {
562
  // there may have been a plugin conflict, or the form is not set to submit with ajax
567
  object.submit();
568
  }
569
  },
570
+ error: function() {
571
+ jQuery( object ).find( 'input[type="submit"], input[type="button"]' ).removeAttr( 'disabled' );
572
  object.submit();
573
  }
574
  });
575
  }
576
 
577
  function afterFormSubmitted( object, response ) {
578
+ var formCompleted = jQuery( response.content ).find( '.frm_message' );
579
  if ( formCompleted.length ) {
580
+ jQuery( document ).trigger( 'frmFormComplete', [ object, response ]);
581
  } else {
582
+ jQuery( document ).trigger( 'frmPageChanged', [ object, response ]);
583
  }
584
  }
585
 
591
  }
592
  }
593
 
594
+ function addUrlParam( response ) {
595
+ var url;
596
  if ( history.pushState && typeof response.page !== 'undefined' ) {
597
+ url = addQueryVar( 'frm_page', response.page );
598
+ window.history.pushState({ 'html': response.html }, '', '?' + url );
599
  }
600
  }
601
 
602
+ function addQueryVar( key, value ) {
603
+ var kvp, i, x;
604
+
605
+ key = encodeURI( key );
606
+ value = encodeURI( value );
607
 
608
+ kvp = document.location.search.substr( 1 ).split( '&' );
609
 
610
+ i = kvp.length;
611
+ while ( i-- ) {
612
+ x = kvp[i].split( '=' );
613
 
614
+ if ( x[0] == key ) {
615
  x[1] = value;
616
+ kvp[i] = x.join( '=' );
617
  break;
618
  }
619
  }
620
 
621
+ if ( i < 0 ) {
622
+ kvp[ kvp.length ] = [ key, value ].join( '=' );
623
  }
624
 
625
+ return kvp.join( '&' );
626
  }
627
 
628
  function addFieldError( $fieldCont, key, jsErrors ) {
629
+ var input, id, describedBy;
630
+ if ( $fieldCont.length && $fieldCont.is( ':visible' ) ) {
631
+ $fieldCont.addClass( 'frm_blank_field' );
632
+ input = $fieldCont.find( 'input, select, textarea' );
633
+ id = 'frm_error_field_' + key;
634
+ describedBy = input.attr( 'aria-describedby' );
635
 
636
+ if ( typeof frmThemeOverride_frmPlaceError === 'function' ) { // eslint-disable-line camelcase
637
  frmThemeOverride_frmPlaceError( key, jsErrors );
638
  } else {
639
+ $fieldCont.append( '<div class="frm_error" id="' + id + '">' + jsErrors[key] + '</div>' );
640
 
641
  if ( typeof describedBy === 'undefined' ) {
642
  describedBy = id;
647
  }
648
  input.attr( 'aria-invalid', true );
649
 
650
+ jQuery( document ).trigger( 'frmAddFieldError', [ $fieldCont, key, jsErrors ]);
651
  }
652
  }
653
 
654
  function removeFieldError( $fieldCont ) {
655
+ var errorMessage = $fieldCont.find( '.frm_error' ),
656
+ errorId = errorMessage.attr( 'id' ),
657
  input = $fieldCont.find( 'input, select, textarea' ),
658
  describedBy = input.attr( 'aria-describedby' );
659
 
660
+ $fieldCont.removeClass( 'frm_blank_field has-error' );
661
  errorMessage.remove();
662
  input.attr( 'aria-invalid', false );
663
 
668
  }
669
 
670
  function removeAllErrors() {
671
+ jQuery( '.form-field' ).removeClass( 'frm_blank_field has-error' );
672
+ jQuery( '.form-field .frm_error' ).replaceWith( '' );
673
+ jQuery( '.frm_error_style' ).remove();
674
  }
675
 
676
  function scrollToFirstField( object ) {
677
+ var field = jQuery( object ).find( '.frm_blank_field:first' );
678
  if ( field.length ) {
679
  frmFrontForm.scrollMsg( field, object, true );
680
  }
692
  $object.trigger( 'frmStartFormLoading' );
693
  }
694
  }
695
+
696
  function addLoadingClass( $object ) {
697
+ var loadingClass = isGoingToPrevPage( $object ) ? 'frm_loading_prev' : 'frm_loading_form';
698
 
699
+ $object.addClass( loadingClass );
700
  }
701
 
702
  function isGoingToPrevPage( $object ) {
704
  }
705
 
706
  function removeSubmitLoading( $object, enable, processesRunning ) {
707
+ var loadingForm;
708
+
709
  if ( processesRunning > 0 ) {
710
  return;
711
  }
712
 
713
+ loadingForm = jQuery( '.frm_loading_form' );
714
+ loadingForm.removeClass( 'frm_loading_form' );
715
  loadingForm.removeClass( 'frm_loading_prev' );
716
 
717
  loadingForm.trigger( 'frmEndFormLoading' );
723
  }
724
 
725
  function showFileLoading( object ) {
726
+ var fileval,
727
+ loading = document.getElementById( 'frm_loading' );
728
  if ( loading !== null ) {
729
+ fileval = jQuery( object ).find( 'input[type=file]' ).val();
730
+ if ( typeof fileval !== 'undefined' && fileval !== '' ) {
731
+ setTimeout( function() {
732
+ jQuery( loading ).fadeIn( 'slow' );
733
+ }, 2000 );
734
  }
735
  }
736
  }
737
 
738
  function replaceCheckedRecaptcha( object, checkPage ) {
739
+ var morePages,
740
+ $recapField = jQuery( object ).find( '.frm-g-recaptcha, .g-recaptcha' );
741
+ if ( $recapField.length ) {
742
  if ( checkPage ) {
743
+ morePages = jQuery( object ).find( '.frm_next_page' ).length < 1 || jQuery( object ).find( '.frm_next_page' ).val() < 1;
744
  if ( ! morePages ) {
745
  return;
746
  }
747
  }
748
+ $recapField.closest( '.frm_form_field' ).replaceWith( '<input type="hidden" name="recaptcha_checked" value="' + frm_js.nonce + '">' );
749
  }
750
  }
751
 
752
+ function clearDefault() {
753
  /*jshint validthis:true */
754
+ toggleDefault( jQuery( this ), 'clear' );
755
  }
756
 
757
+ function replaceDefault() {
758
  /*jshint validthis:true */
759
+ toggleDefault( jQuery( this ), 'replace' );
760
  }
761
 
762
+ function toggleDefault( $thisField, e ) {
763
  // TODO: Fix this for a default value that is a number or array
764
+ var thisVal,
765
+ v = $thisField.data( 'frmval' ).replace( /(\n|\r\n)/g, '\r' );
766
  if ( v === '' || typeof v === 'undefined' ) {
767
  return false;
768
  }
769
+ thisVal = $thisField.val().replace( /(\n|\r\n)/g, '\r' );
770
 
771
+ if ( 'replace' === e ) {
772
  if ( thisVal === '' ) {
773
+ $thisField.addClass( 'frm_default' ).val( v );
774
  }
775
  } else if ( thisVal == v ) {
776
+ $thisField.removeClass( 'frm_default' ).val( '' );
777
  }
778
  }
779
 
780
+ function resendEmail() {
781
  /*jshint validthis:true */
782
+ var $link = jQuery( this ),
783
+ entryId = this.getAttribute( 'data-eid' ),
784
+ formId = this.getAttribute( 'data-fid' ),
785
  label = $link.find( '.frm_link_label' );
786
  if ( label.length < 1 ) {
787
  label = $link;
788
  }
789
+ label.append( '<span class="frm-wait"></span>' );
790
 
791
  jQuery.ajax({
792
+ type: 'POST',
793
+ url: frm_js.ajax_url,
794
+ data: {
795
+ action: 'frm_entries_send_email',
796
+ entry_id: entryId,
797
+ form_id: formId,
798
+ nonce: frm_js.nonce
799
  },
800
+ success: function( msg ) {
801
  var admin = document.getElementById( 'wpbody' );
802
  if ( admin === null ) {
803
  label.html( msg );
816
 
817
  function confirmClick() {
818
  /*jshint validthis:true */
819
+ var message = jQuery( this ).data( 'frmconfirm' );
820
+ return confirm( message );
821
  }
822
 
823
+ function toggleDiv() {
824
  /*jshint validthis:true */
825
  var div = jQuery( this ).data( 'frmtoggle' );
826
  if ( jQuery( div ).is( ':visible' ) ) {
836
  *********************************************/
837
 
838
  function addIndexOfFallbackForIE8() {
839
+ var len, from;
840
+
841
+ if ( ! Array.prototype.indexOf ) {
842
+ Array.prototype.indexOf = function( elt /*, from*/ ) {
843
+ len = this.length >>> 0;
844
 
845
+ from = Number( arguments[1]) || 0;
846
+ from = ( from < 0 ) ? Math.ceil( from ) : Math.floor( from );
847
+ if ( from < 0 ) {
848
  from += len;
849
  }
850
 
851
+ for ( ; from < len; from++ ) {
852
  if ( from in this && this[from] === elt ) {
853
  return from;
854
  }
858
  }
859
  }
860
 
861
+ function addTrimFallbackForIE8() {
862
  if ( typeof String.prototype.trim !== 'function' ) {
863
  String.prototype.trim = function() {
864
+ return this.replace( /^\s+|\s+$/g, '' );
865
  };
866
  }
867
  }
868
 
869
+ function addFilterFallbackForIE8() {
870
+ var t, len, res, thisp, i, val;
871
 
872
+ if ( ! Array.prototype.filter ) {
87