Formidable Forms – Form Builder for WordPress - Version 5.2

Version Description

  • Increased WP version requirement to 5.2.
  • New: Added a new Embed Form modal and a new Embed button that appears in the form builder and form settings pages beside Preview and Update. Now a form can be embedded into a new page or an existing page with just a few clicks.
  • Fix: A Notice was being logged that wp_enqueue_script() was called incorrectly when loading the new Widgets editor since WordPress 5.8.
  • Fix: An unexpected array value in form data would cause some text fields to break in PHP8.
  • Fix: Some AJAX calls for API loaded forms were occasionally targeting the wrong site, causing unwanted redirects.
  • Fix: Dropdown field options were including redundant class="" HTML that has been removed.
Download this release

Release Info

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

Code changes from version 5.1 to 5.2

classes/controllers/FrmAppController.php CHANGED
@@ -15,8 +15,11 @@ class FrmAppController {
15
  add_menu_page( 'Formidable', $menu_name, 'frm_view_forms', 'formidable', 'FrmFormsController::route', self::menu_icon(), self::get_menu_position() );
16
  }
17
 
 
 
 
18
  private static function get_menu_position() {
19
- return apply_filters( 'frm_menu_position', '29.3' );
20
  }
21
 
22
  /**
@@ -434,6 +437,9 @@ class FrmAppController {
434
  }
435
  }
436
 
 
 
 
437
  public static function admin_js() {
438
  $version = FrmAppHelper::plugin_version();
439
  FrmAppHelper::load_admin_wide_js();
@@ -458,6 +464,15 @@ class FrmAppController {
458
  wp_register_script( 'bootstrap_tooltip', FrmAppHelper::plugin_url() . '/js/bootstrap.min.js', array( 'jquery' ), '3.4.1' );
459
  wp_register_style( 'formidable-grids', FrmAppHelper::plugin_url() . '/css/frm_grids.css', array(), $version );
460
 
 
 
 
 
 
 
 
 
 
461
  // load multselect js
462
  $depends_on = array( 'jquery', 'bootstrap_tooltip' );
463
  wp_register_script( 'bootstrap-multiselect', FrmAppHelper::plugin_url() . '/js/bootstrap-multiselect.js', $depends_on, '1.1.1', true );
@@ -466,7 +481,7 @@ class FrmAppController {
466
  $post_type = FrmAppHelper::simple_get( 'post_type', 'sanitize_title' );
467
 
468
  global $pagenow;
469
- if ( strpos( $page, 'formidable' ) === 0 || ( $pagenow == 'edit.php' && $post_type == 'frm_display' ) ) {
470
 
471
  wp_enqueue_script( 'admin-widgets' );
472
  wp_enqueue_style( 'widgets' );
@@ -502,7 +517,7 @@ class FrmAppController {
502
  return;
503
  }
504
 
505
- if ( $post_type == 'frm_display' ) {
506
  wp_enqueue_style( 'formidable-grids' );
507
  wp_enqueue_script( 'jquery-ui-draggable' );
508
  wp_enqueue_script( 'formidable_admin' );
@@ -511,6 +526,95 @@ class FrmAppController {
511
  self::include_info_overlay();
512
  }
513
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
514
  }
515
 
516
  public static function load_lang() {
@@ -678,6 +782,17 @@ class FrmAppController {
678
  return $text;
679
  }
680
 
 
 
 
 
 
 
 
 
 
 
 
681
  /**
682
  * @deprecated 1.07.05
683
  * @codeCoverageIgnore
15
  add_menu_page( 'Formidable', $menu_name, 'frm_view_forms', 'formidable', 'FrmFormsController::route', self::menu_icon(), self::get_menu_position() );
16
  }
17
 
18
+ /**
19
+ * @return int
20
+ */
21
  private static function get_menu_position() {
22
+ return (int) apply_filters( 'frm_menu_position', 29 );
23
  }
24
 
25
  /**
437
  }
438
  }
439
 
440
+ /**
441
+ * @return void
442
+ */
443
  public static function admin_js() {
444
  $version = FrmAppHelper::plugin_version();
445
  FrmAppHelper::load_admin_wide_js();
464
  wp_register_script( 'bootstrap_tooltip', FrmAppHelper::plugin_url() . '/js/bootstrap.min.js', array( 'jquery' ), '3.4.1' );
465
  wp_register_style( 'formidable-grids', FrmAppHelper::plugin_url() . '/css/frm_grids.css', array(), $version );
466
 
467
+ if ( 'formidable' === FrmAppHelper::simple_get( 'page', 'sanitize_title' ) ) {
468
+ $action = FrmAppHelper::get_param( 'frm_action', '', 'sanitize_title' );
469
+ $is_form_index = ! $action || in_array( $action, array( 'list', 'trash' ), true );
470
+ if ( $is_form_index ) {
471
+ // For the existing page dropdown in the Form embed modal.
472
+ wp_enqueue_script( 'jquery-ui-autocomplete' );
473
+ }
474
+ }
475
+
476
  // load multselect js
477
  $depends_on = array( 'jquery', 'bootstrap_tooltip' );
478
  wp_register_script( 'bootstrap-multiselect', FrmAppHelper::plugin_url() . '/js/bootstrap-multiselect.js', $depends_on, '1.1.1', true );
481
  $post_type = FrmAppHelper::simple_get( 'post_type', 'sanitize_title' );
482
 
483
  global $pagenow;
484
+ if ( strpos( $page, 'formidable' ) === 0 || ( $pagenow === 'edit.php' && $post_type === 'frm_display' ) ) {
485
 
486
  wp_enqueue_script( 'admin-widgets' );
487
  wp_enqueue_style( 'widgets' );
517
  return;
518
  }
519
 
520
+ if ( $post_type === 'frm_display' ) {
521
  wp_enqueue_style( 'formidable-grids' );
522
  wp_enqueue_script( 'jquery-ui-draggable' );
523
  wp_enqueue_script( 'formidable_admin' );
526
  self::include_info_overlay();
527
  }
528
  }
529
+
530
+ self::maybe_force_formidable_block_on_gutenberg_page();
531
+ }
532
+
533
+ /**
534
+ * Automatically insert a Formidable block when loading Gutenberg with a $_GET['frmForm'] value set.
535
+ *
536
+ * @since 5.2
537
+ *
538
+ * @return void
539
+ */
540
+ private static function maybe_force_formidable_block_on_gutenberg_page() {
541
+ global $pagenow;
542
+ if ( 'post.php' !== $pagenow ) {
543
+ return;
544
+ }
545
+
546
+ $form_id = FrmAppHelper::simple_get( 'frmForm', 'absint' );
547
+ if ( ! $form_id ) {
548
+ return;
549
+ }
550
+
551
+ ?>
552
+ <script>
553
+ ( function() {
554
+ const handleDomReady = () => {
555
+ if ( 'undefined' === typeof wp || 'undefined' === typeof wp.data || 'function' !== typeof wp.data.subscribe ) {
556
+ return;
557
+ }
558
+
559
+ const closeListener = wp.data.subscribe(
560
+ () => {
561
+ const editor = wp.data.select( 'core/editor' );
562
+
563
+ if ( 'function' !== typeof editor.__unstableIsEditorReady ) {
564
+ closeListener();
565
+ return;
566
+ }
567
+
568
+ const isReady = editor.__unstableIsEditorReady();
569
+ if ( isReady ) {
570
+ closeListener();
571
+ requestAnimationFrame( () => injectFormidableBlock() );
572
+ }
573
+ }
574
+ );
575
+ }
576
+
577
+ document.addEventListener( 'DOMContentLoaded', handleDomReady );
578
+
579
+ const injectFormidableBlock = () => {
580
+ insertedBlock = wp.blocks.createBlock(
581
+ 'formidable/simple-form',
582
+ {
583
+ formId: '<?php echo absint( $form_id ); ?>'
584
+ }
585
+ );
586
+
587
+ const getBlocks = () => wp.data.select( 'core/editor' ).getBlocks();
588
+ const blockList = getBlocks();
589
+
590
+ const closeListener = wp.data.subscribe(
591
+ () => {
592
+ const currentBlocks = getBlocks();
593
+ if ( currentBlocks === blockList ) {
594
+ return;
595
+ }
596
+
597
+ closeListener();
598
+ const block = currentBlocks[ currentBlocks.length - 1 ];
599
+ const interval = setInterval(
600
+ () => {
601
+ const scrollTarget = document.getElementById( 'block-' + block.clientId );
602
+ const form = scrollTarget.querySelector( 'form' );
603
+ if ( form ) {
604
+ scrollTarget.scrollIntoView({ behavior: 'smooth' });
605
+ clearInterval( interval );
606
+ }
607
+ },
608
+ 50
609
+ );
610
+ }
611
+ );
612
+
613
+ wp.data.dispatch( 'core/block-editor' ).insertBlocks( insertedBlock );
614
+ };
615
+ }() );
616
+ </script>
617
+ <?php
618
  }
619
 
620
  public static function load_lang() {
782
  return $text;
783
  }
784
 
785
+ /**
786
+ * Include icons on page for Embed Form modal.
787
+ *
788
+ * @since 5.2
789
+ *
790
+ * @return void
791
+ */
792
+ public static function include_embed_form_icons() {
793
+ require_once FrmAppHelper::plugin_path() . '/classes/views/frm-forms/_embed_form_icons.php';
794
+ }
795
+
796
  /**
797
  * @deprecated 1.07.05
798
  * @codeCoverageIgnore
classes/controllers/FrmFormsController.php CHANGED
@@ -788,7 +788,7 @@ class FrmFormsController {
788
  $columns['name'] = __( 'Form Title', 'formidable' );
789
  $columns['entries'] = __( 'Entries', 'formidable' );
790
  $columns['form_key'] = __( 'Key', 'formidable' );
791
- $columns['shortcode'] = __( 'Shortcodes', 'formidable' );
792
  }
793
 
794
  $columns['created_at'] = __( 'Date', 'formidable' );
@@ -2285,6 +2285,79 @@ class FrmFormsController {
2285
  return FrmAppHelper::plugin_path() . '/classes/views/frm-forms/';
2286
  }
2287
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2288
  /**
2289
  * @deprecated 4.0
2290
  */
788
  $columns['name'] = __( 'Form Title', 'formidable' );
789
  $columns['entries'] = __( 'Entries', 'formidable' );
790
  $columns['form_key'] = __( 'Key', 'formidable' );
791
+ $columns['shortcode'] = __( 'Actions', 'formidable' );
792
  }
793
 
794
  $columns['created_at'] = __( 'Date', 'formidable' );
2285
  return FrmAppHelper::plugin_path() . '/classes/views/frm-forms/';
2286
  }
2287
 
2288
+ /**
2289
+ * Create a page with an embedded formidable Gutenberg block.
2290
+ *
2291
+ * @since 5.2
2292
+ *
2293
+ * @return never
2294
+ */
2295
+ public static function create_page_with_shortcode() {
2296
+ if ( ! current_user_can( 'publish_posts' ) ) {
2297
+ die( 0 );
2298
+ }
2299
+
2300
+ check_ajax_referer( 'frm_ajax', 'nonce' );
2301
+
2302
+ $form_id = FrmAppHelper::get_post_param( 'form_id', '', 'absint' );
2303
+ if ( ! $form_id ) {
2304
+ die( 0 );
2305
+ }
2306
+
2307
+ $postarr = array(
2308
+ 'post_type' => 'page',
2309
+ 'post_content' => '<!-- wp:formidable/simple-form {"formId":"' . $form_id . '"} --><div>[formidable id="' . $form_id . '"]</div><!-- /wp:formidable/simple-form -->',
2310
+ );
2311
+
2312
+ $name = FrmAppHelper::get_post_param( 'name', '', 'sanitize_text_field' );
2313
+ if ( $name ) {
2314
+ $postarr['post_title'] = $name;
2315
+ }
2316
+
2317
+ $success = wp_insert_post( $postarr );
2318
+ if ( ! is_numeric( $success ) || ! $success ) {
2319
+ die( 0 );
2320
+ }
2321
+
2322
+ wp_send_json(
2323
+ array(
2324
+ 'redirect' => get_edit_post_link( $success, 'redirect' ),
2325
+ )
2326
+ );
2327
+ }
2328
+
2329
+ /**
2330
+ * Get page dropdown for AJAX request for embedding form in an existing page.
2331
+ *
2332
+ * @return never
2333
+ */
2334
+ public static function get_page_dropdown() {
2335
+ if ( ! current_user_can( 'publish_posts' ) ) {
2336
+ die( 0 );
2337
+ }
2338
+
2339
+ check_ajax_referer( 'frm_ajax', 'nonce' );
2340
+
2341
+ $html = FrmAppHelper::clip(
2342
+ function() {
2343
+ FrmAppHelper::maybe_autocomplete_pages_options(
2344
+ array(
2345
+ 'field_name' => 'frm_page_dropdown',
2346
+ 'page_id' => '',
2347
+ 'placeholder' => __( 'Select a Page', 'formidable' ),
2348
+ )
2349
+ );
2350
+ }
2351
+ );
2352
+ $post_type_object = get_post_type_object( 'page' );
2353
+ wp_send_json(
2354
+ array(
2355
+ 'html' => $html,
2356
+ 'edit_page_url' => admin_url( sprintf( $post_type_object->_edit_link . '&action=edit', 0 ) ),
2357
+ )
2358
+ );
2359
+ }
2360
+
2361
  /**
2362
  * @deprecated 4.0
2363
  */
classes/controllers/FrmHooksController.php CHANGED
@@ -201,6 +201,8 @@ class FrmHooksController {
201
  add_action( 'wp_ajax_frm_forms_trash', 'FrmFormsController::ajax_trash' );
202
  add_action( 'wp_ajax_frm_install_form', 'FrmFormsController::build_new_form' );
203
  add_action( 'wp_ajax_frm_build_template', 'FrmFormsController::build_template' );
 
 
204
 
205
  add_action( 'wp_ajax_frm_dismiss_migrator', 'FrmFormMigratorsHelper::dismiss_migrator' );
206
 
201
  add_action( 'wp_ajax_frm_forms_trash', 'FrmFormsController::ajax_trash' );
202
  add_action( 'wp_ajax_frm_install_form', 'FrmFormsController::build_new_form' );
203
  add_action( 'wp_ajax_frm_build_template', 'FrmFormsController::build_template' );
204
+ add_action( 'wp_ajax_frm_create_page_with_shortcode', 'FrmFormsController::create_page_with_shortcode' );
205
+ add_action( 'wp_ajax_get_page_dropdown', 'FrmFormsController::get_page_dropdown' );
206
 
207
  add_action( 'wp_ajax_frm_dismiss_migrator', 'FrmFormMigratorsHelper::dismiss_migrator' );
208
 
classes/controllers/FrmSimpleBlocksController.php CHANGED
@@ -14,7 +14,7 @@ class FrmSimpleBlocksController {
14
  wp_register_script(
15
  'formidable-form-selector',
16
  FrmAppHelper::plugin_url() . '/js/formidable_blocks.js',
17
- array( 'wp-blocks', 'wp-i18n', 'wp-element', 'wp-components', 'wp-editor' ),
18
  $version,
19
  true
20
  );
14
  wp_register_script(
15
  'formidable-form-selector',
16
  FrmAppHelper::plugin_url() . '/js/formidable_blocks.js',
17
+ array( 'wp-blocks', 'wp-i18n', 'wp-element', 'wp-components', 'wp-block-editor' ),
18
  $version,
19
  true
20
  );
classes/controllers/FrmStylesController.php CHANGED
@@ -448,19 +448,31 @@ class FrmStylesController {
448
  $defaults = $frm_style->get_defaults();
449
  $style = '';
450
 
451
- include( FrmAppHelper::plugin_path() . '/css/_single_theme.css.php' );
452
  wp_die();
453
  }
454
 
 
 
 
455
  public static function load_saved_css() {
456
  $css = get_transient( 'frmpro_css' );
457
 
458
  ob_start();
459
- include( FrmAppHelper::plugin_path() . '/css/custom_theme.css.php' );
460
  $output = ob_get_clean();
 
461
 
462
- echo self::replace_relative_url( $output ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
 
 
 
 
 
 
 
463
 
 
464
  wp_die();
465
  }
466
 
448
  $defaults = $frm_style->get_defaults();
449
  $style = '';
450
 
451
+ include FrmAppHelper::plugin_path() . '/css/_single_theme.css.php';
452
  wp_die();
453
  }
454
 
455
+ /**
456
+ * @return void
457
+ */
458
  public static function load_saved_css() {
459
  $css = get_transient( 'frmpro_css' );
460
 
461
  ob_start();
462
+ include FrmAppHelper::plugin_path() . '/css/custom_theme.css.php';
463
  $output = ob_get_clean();
464
+ $output = self::replace_relative_url( $output );
465
 
466
+ /**
467
+ * The API needs to load font icons through a custom URL.
468
+ *
469
+ * @since 5.2
470
+ *
471
+ * @param string $output
472
+ */
473
+ $output = apply_filters( 'frm_saved_css', $output );
474
 
475
+ echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
476
  wp_die();
477
  }
478
 
classes/helpers/FrmAppHelper.php CHANGED
@@ -11,7 +11,7 @@ class FrmAppHelper {
11
  /**
12
  * @since 2.0
13
  */
14
- public static $plug_version = '5.1';
15
 
16
  /**
17
  * @since 1.07.02
11
  /**
12
  * @since 2.0
13
  */
14
+ public static $plug_version = '5.2';
15
 
16
  /**
17
  * @since 1.07.02
classes/helpers/FrmFormsListHelper.php CHANGED
@@ -249,10 +249,8 @@ class FrmFormsListHelper extends FrmListHelper {
249
  $val = '<abbr title="' . esc_attr( gmdate( 'Y/m/d g:i:s A', strtotime( $item->created_at ) ) ) . '">' . $date . '</abbr>';
250
  break;
251
  case 'shortcode':
252
- $val = '<input type="text" readonly="readonly" class="frm_select_box" value="' . esc_attr( '[formidable id=' . $item->id . ']' ) . '" /><br/>';
253
- if ( 'excerpt' == $mode ) {
254
- $val .= '<input type="text" readonly="readonly" class="frm_select_box" value="' . esc_attr( '[formidable key=' . $item->form_key . ']' ) . '" />';
255
- }
256
  break;
257
  case 'entries':
258
  if ( isset( $item->options['no_save'] ) && $item->options['no_save'] ) {
249
  $val = '<abbr title="' . esc_attr( gmdate( 'Y/m/d g:i:s A', strtotime( $item->created_at ) ) ) . '">' . $date . '</abbr>';
250
  break;
251
  case 'shortcode':
252
+ $val = '<a href="#" class="frm-embed-form" role="button" aria-label="' . esc_html__( 'Embed Form', 'formidable' ) . '">' . FrmAppHelper::icon_by_class( 'frmfont frm_code_icon', array( 'echo' => false ) ) . '</a>';
253
+ $val = apply_filters( 'frm_form_list_actions', $val, array( 'form' => $item ) );
 
 
254
  break;
255
  case 'entries':
256
  if ( isset( $item->options['no_save'] ) && $item->options['no_save'] ) {
classes/models/fields/FrmFieldType.php CHANGED
@@ -859,9 +859,14 @@ DEFAULT_HTML;
859
  * If the value includes intentional entities, don't lose them.
860
  *
861
  * @since 4.03.01
 
 
862
  */
863
  protected function prepare_esc_value() {
864
  $value = $this->field['value'];
 
 
 
865
  if ( strpos( $value, '&lt;' ) !== false ) {
866
  $value = htmlentities( $value );
867
  }
859
  * If the value includes intentional entities, don't lose them.
860
  *
861
  * @since 4.03.01
862
+ *
863
+ * @return string
864
  */
865
  protected function prepare_esc_value() {
866
  $value = $this->field['value'];
867
+ if ( is_array( $value ) ) {
868
+ $value = implode( ', ', $value );
869
+ }
870
  if ( strpos( $value, '&lt;' ) !== false ) {
871
  $value = htmlentities( $value );
872
  }
classes/views/frm-fields/front-end/dropdown-field.php CHANGED
@@ -23,16 +23,18 @@ if ( isset( $field['post_field'] ) && $field['post_field'] == 'post_category' &&
23
 
24
  $placeholder = FrmFieldsController::add_placeholder_to_select( $field );
25
 
26
- $skipped = false;
27
- $other_opt = false;
28
  $other_checked = false;
 
29
  if ( empty( $field['options'] ) ) {
30
  $field['options'] = array();
31
  }
 
32
  foreach ( $field['options'] as $opt_key => $opt ) {
33
  $field_val = FrmFieldsHelper::get_value_from_array( $opt, $opt_key, $field );
34
- $opt = FrmFieldsHelper::get_label_from_array( $opt, $opt_key, $field );
35
- $selected = FrmAppHelper::check_selected( $field['value'], $field_val );
36
  if ( $other_opt === false ) {
37
  $other_args = FrmFieldsHelper::prepare_other_input( compact( 'field', 'field_name', 'opt_key' ), $other_opt, $selected );
38
  if ( FrmFieldsHelper::is_other_opt( $opt_key ) && $selected ) {
@@ -44,11 +46,24 @@ if ( isset( $field['post_field'] ) && $field['post_field'] == 'post_category' &&
44
  $skipped = true;
45
  continue;
46
  }
 
 
 
 
 
 
 
 
 
 
47
  ?>
48
- <option value="<?php echo esc_attr( $field_val ); ?>" <?php echo $selected ? ' selected="selected"' : ''; ?> class="<?php echo esc_attr( FrmFieldsHelper::is_other_opt( $opt_key ) ? 'frm_other_trigger' : '' ); ?>">
49
  <?php echo esc_html( $opt == '' ? ' ' : $opt ); ?>
50
  </option>
51
- <?php } ?>
 
 
 
52
  </select>
53
  <?php
54
 
@@ -57,12 +72,12 @@ if ( isset( $field['post_field'] ) && $field['post_field'] == 'post_category' &&
57
  array(
58
  'other_opt' => $other_opt,
59
  'read_only' => $read_only,
60
- 'checked' => $other_checked,
61
- 'name' => $other_args['name'],
62
- 'value' => $other_args['value'],
63
- 'field' => $field,
64
- 'html_id' => $html_id,
65
- 'opt_key' => false,
66
  )
67
  );
68
  }
23
 
24
  $placeholder = FrmFieldsController::add_placeholder_to_select( $field );
25
 
26
+ $skipped = false;
27
+ $other_opt = false;
28
  $other_checked = false;
29
+
30
  if ( empty( $field['options'] ) ) {
31
  $field['options'] = array();
32
  }
33
+
34
  foreach ( $field['options'] as $opt_key => $opt ) {
35
  $field_val = FrmFieldsHelper::get_value_from_array( $opt, $opt_key, $field );
36
+ $opt = FrmFieldsHelper::get_label_from_array( $opt, $opt_key, $field );
37
+ $selected = FrmAppHelper::check_selected( $field['value'], $field_val );
38
  if ( $other_opt === false ) {
39
  $other_args = FrmFieldsHelper::prepare_other_input( compact( 'field', 'field_name', 'opt_key' ), $other_opt, $selected );
40
  if ( FrmFieldsHelper::is_other_opt( $opt_key ) && $selected ) {
46
  $skipped = true;
47
  continue;
48
  }
49
+
50
+ $option_params = array(
51
+ 'value' => $field_val,
52
+ );
53
+ if ( $selected ) {
54
+ $option_params['selected'] = 'selected';
55
+ }
56
+ if ( FrmFieldsHelper::is_other_opt( $opt_key ) ) {
57
+ $option_params['class'] = 'frm_other_trigger';
58
+ }
59
  ?>
60
+ <option <?php FrmAppHelper::array_to_html_params( $option_params, true ); ?>>
61
  <?php echo esc_html( $opt == '' ? ' ' : $opt ); ?>
62
  </option>
63
+ <?php
64
+ unset( $option_params );
65
+ }
66
+ ?>
67
  </select>
68
  <?php
69
 
72
  array(
73
  'other_opt' => $other_opt,
74
  'read_only' => $read_only,
75
+ 'checked' => $other_checked,
76
+ 'name' => $other_args['name'],
77
+ 'value' => $other_args['value'],
78
+ 'field' => $field,
79
+ 'html_id' => $html_id,
80
+ 'opt_key' => false,
81
  )
82
  );
83
  }
classes/views/frm-forms/_embed_form_icons.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( ! defined( 'ABSPATH' ) ) {
3
+ die( 'You are not allowed to call this page directly.' );
4
+ }
5
+ ?>
6
+ <div class="frm_hidden">
7
+ <?php
8
+ FrmAppHelper::icon_by_class( 'frmfont frm_clone_icon' );
9
+ FrmAppHelper::icon_by_class( 'frmfont frm_file_icon' );
10
+ ?>
11
+ <svg id="frm_copy_embed_form_icon" class="frmsvg">
12
+ <use xlink:href="#frm_clone_icon"></use>
13
+ </svg>
14
+ <svg id="frm_select_existing_page_icon" class="frmsvg">
15
+ <use xlink:href="#frm_file_icon"></use>
16
+ </svg>
17
+ <svg id="frm_create_new_page_icon" class="frmsvg">
18
+ <use xlink:href="#frm_plus_icon"></use>
19
+ </svg>
20
+ <svg id="frm_insert_manually_icon" class="frmsvg">
21
+ <use xlink:href="#frm_code_icon"></use>
22
+ </svg>
23
+ </div>
classes/views/frm-forms/_publish_box.php CHANGED
@@ -3,7 +3,9 @@ if ( ! defined( 'ABSPATH' ) ) {
3
  die( 'You are not allowed to call this page directly.' );
4
  }
5
 
6
- if ( 'settings' == FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' ) ) {
 
 
7
  $class = 'frm_submit_settings_btn';
8
  } else {
9
  $class = 'frm_submit_' . ( ( isset( $values['ajax_load'] ) && $values['ajax_load'] ) ? '' : 'no_' ) . 'ajax';
@@ -42,4 +44,8 @@ if ( 'settings' == FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' ) )
42
  <?php } ?>
43
  </div>
44
 
 
 
 
 
45
  <div class="clear"></div>
3
  die( 'You are not allowed to call this page directly.' );
4
  }
5
 
6
+ FrmAppController::include_embed_form_icons();
7
+
8
+ if ( 'settings' === FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' ) ) {
9
  $class = 'frm_submit_settings_btn';
10
  } else {
11
  $class = 'frm_submit_' . ( ( isset( $values['ajax_load'] ) && $values['ajax_load'] ) ? '' : 'no_' ) . 'ajax';
44
  <?php } ?>
45
  </div>
46
 
47
+ <a id="frm-embed-action" href="#" role="button" class="frm_submit_form button-secondary frm-button-secondary frm_button_submit">
48
+ <?php esc_html_e( 'Embed', 'formidable' ); ?>
49
+ </a>
50
+
51
  <div class="clear"></div>
classes/views/frm-forms/list.php CHANGED
@@ -12,6 +12,7 @@ if ( ! defined( 'ABSPATH' ) ) {
12
  'import_link' => true,
13
  )
14
  );
 
15
  ?>
16
  <div class="wrap">
17
  <?php
@@ -46,3 +47,4 @@ if ( $wp_list_table->total_items === 1 && empty( $_REQUEST['s'] ) && $wp_list_ta
46
  <?php do_action( 'frm_page_footer', array( 'table' => $wp_list_table ) ); ?>
47
  </div>
48
  </div>
 
12
  'import_link' => true,
13
  )
14
  );
15
+ FrmAppController::include_embed_form_icons();
16
  ?>
17
  <div class="wrap">
18
  <?php
47
  <?php do_action( 'frm_page_footer', array( 'table' => $wp_list_table ) ); ?>
48
  </div>
49
  </div>
50
+
classes/views/frm-forms/new-form-overlay.php CHANGED
@@ -3,7 +3,7 @@ if ( ! defined( 'ABSPATH' ) ) {
3
  die( 'You are not allowed to call this page directly.' );
4
  }
5
  ?>
6
- <div id="frm_new_form_modal" class="frm_hidden <?php echo esc_attr( $modal_class ); ?>" frm-page="create">
7
  <div class="metabox-holder">
8
  <div class="postbox">
9
  <div>
3
  die( 'You are not allowed to call this page directly.' );
4
  }
5
  ?>
6
+ <div id="frm_new_form_modal" class="frm_hidden frm_common_modal <?php echo esc_attr( $modal_class ); ?>" frm-page="create">
7
  <div class="metabox-holder">
8
  <div class="postbox">
9
  <div>
classes/views/frm-forms/settings-advanced.php CHANGED
@@ -29,26 +29,7 @@ if ( ! defined( 'ABSPATH' ) ) {
29
  <textarea id="frm_form_description" name="description" cols="50" rows="4"><?php echo FrmAppHelper::esc_textarea( $values['description'] ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></textarea>
30
  </p>
31
 
32
-
33
  <?php if ( ! $values['is_template'] ) { ?>
34
- <p class="frm6 frm_form_field">
35
- <label>
36
- <?php esc_html_e( 'Embed Shortcode', 'formidable' ); ?>
37
- </label>
38
- <input type="text" readonly="readonly" class="frm_select_box" value="[formidable id=<?php echo esc_attr( $values['id'] ); ?>]" />
39
- </p>
40
- <p class="frm6 frm_form_field">
41
- <label>&nbsp;</label>
42
- <input type="text" readonly="readonly" class="frm_select_box" value="[formidable id=<?php echo esc_attr( $values['id'] ); ?> title=true description=true]" />
43
- </p>
44
-
45
- <a href="#edit_frm_shortcode" class="edit-frm_shortcode hide-if-no-js" tabindex='4'><?php esc_html_e( 'Insert with PHP', 'formidable' ); ?></a>
46
- <p id="frm_shortcodediv" class="hide-if-js">
47
- <label>
48
- <?php esc_html_e( 'Embed in Template', 'formidable' ); ?>
49
- </label>
50
- <input type="text" readonly="readonly" class="frm_select_box frm_insert_in_template" value="&lt;?php echo FrmFormsController::get_form_shortcode( array( 'id' => <?php echo absint( $values['id'] ); ?>, 'title' => false, 'description' => false ) ); ?&gt;" />
51
- </p>
52
  <?php $first_h3 = ''; ?>
53
 
54
  <?php if ( has_action( 'frm_settings_buttons' ) ) { ?>
29
  <textarea id="frm_form_description" name="description" cols="50" rows="4"><?php echo FrmAppHelper::esc_textarea( $values['description'] ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></textarea>
30
  </p>
31
 
 
32
  <?php if ( ! $values['is_template'] ) { ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
  <?php $first_h3 = ''; ?>
34
 
35
  <?php if ( has_action( 'frm_settings_buttons' ) ) { ?>
css/frm_admin.css CHANGED
@@ -309,6 +309,10 @@ ul.frm_form_nav > li {
309
  display: inline-block;
310
  }
311
 
 
 
 
 
312
  .post-type-frm_display #advanced-sortables h2.hndle,
313
  .post-type-frm_display #side-sortables h2.hndle,
314
  .post-type-frm_display #normal-sortables h2.hndle,
@@ -451,7 +455,8 @@ ul.frm_form_nav > li {
451
  #frm-preview-action,
452
  #frm-publishing > input[type=submit],
453
  #frm-publishing > .button,
454
- #frm-publishing > button {
 
455
  float: right;
456
  margin: 0 10px 0 0;
457
  }
@@ -1867,25 +1872,25 @@ h2.frm-h2 + .howto {
1867
  overflow: hidden;
1868
  }
1869
 
1870
- #frm_new_form_modal .postbox > div:first-child {
1871
  padding: 30px 20px;
1872
  position: relative;
1873
  border-bottom: 1px solid var(--grey-border);
1874
  }
1875
 
1876
- #frm_new_form_modal .postbox > div:first-child > div:first-child {
1877
  display: inline-block;
1878
  font-size: 24px;
1879
  color: #282F36;
1880
  }
1881
 
1882
- #frm_new_form_modal .postbox > div:first-child > div:last-child {
1883
  position: absolute;
1884
  right: 20px;
1885
  top: 37px;
1886
  }
1887
 
1888
- #frm_new_form_modal .postbox > div:first-child > div:last-child a {
1889
  color: var(--grey);
1890
  }
1891
 
@@ -2359,6 +2364,112 @@ li[data-preview] .frm-hover-icons .frm-preview-form,
2359
  margin-left: -1em;
2360
  }
2361
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2362
  /* Bulk Options */
2363
  #frm-bulk-modal .frm_grid_container {
2364
  border-top: 1px solid var(--grey-border);
309
  display: inline-block;
310
  }
311
 
312
+ ul.frm_form_nav > li:last-of-type {
313
+ margin-right: 0;
314
+ }
315
+
316
  .post-type-frm_display #advanced-sortables h2.hndle,
317
  .post-type-frm_display #side-sortables h2.hndle,
318
  .post-type-frm_display #normal-sortables h2.hndle,
455
  #frm-preview-action,
456
  #frm-publishing > input[type=submit],
457
  #frm-publishing > .button,
458
+ #frm-publishing > button,
459
+ #frm-embed-action {
460
  float: right;
461
  margin: 0 10px 0 0;
462
  }
1872
  overflow: hidden;
1873
  }
1874
 
1875
+ #wpwrap ~ .frm-dialog .frm_common_modal .postbox > div:first-child {
1876
  padding: 30px 20px;
1877
  position: relative;
1878
  border-bottom: 1px solid var(--grey-border);
1879
  }
1880
 
1881
+ #wpwrap ~ .frm-dialog .frm_common_modal .postbox > div:first-child > div:first-child {
1882
  display: inline-block;
1883
  font-size: 24px;
1884
  color: #282F36;
1885
  }
1886
 
1887
+ #wpwrap ~ .frm-dialog .frm_common_modal .postbox > div:first-child > div:last-child {
1888
  position: absolute;
1889
  right: 20px;
1890
  top: 37px;
1891
  }
1892
 
1893
+ #wpwrap ~ .frm-dialog .frm_common_modal .postbox > div:first-child > div:last-child a {
1894
  color: var(--grey);
1895
  }
1896
 
2364
  margin-left: -1em;
2365
  }
2366
 
2367
+ /* Embed Form Modal */
2368
+
2369
+ #frm_form_embed_modal label {
2370
+ font-size: 14px;
2371
+ line-height: 25px;
2372
+ color: rgba(40, 47, 54, 0.8);
2373
+ font-weight: 600;
2374
+ }
2375
+
2376
+ .frm_embed_form_content {
2377
+ padding: 20px;
2378
+ }
2379
+
2380
+ .frm_embed_form_content.frm-loading-page-options {
2381
+ display: flex;
2382
+ justify-content: center;
2383
+ }
2384
+
2385
+ #frm_form_embed_modal .frm_embed_example {
2386
+ background: #F6F7FB;
2387
+ border: 1px solid #E3E8EB;
2388
+ border-radius: 6px;
2389
+ color: rgba(40, 47, 54, 0.85);
2390
+ font-size: 14px;
2391
+ padding: 10px 30px 10px 10px;
2392
+ width: 100%;
2393
+ margin-bottom: 15px;
2394
+ height: auto !important;
2395
+ resize: none;
2396
+ }
2397
+
2398
+ #frm_form_embed_modal textarea.frm_embed_example {
2399
+ padding-bottom: 0;
2400
+ }
2401
+
2402
+ .frm_embed_form_content > div a {
2403
+ position: absolute;
2404
+ right: 0;
2405
+ top: 8px;
2406
+ }
2407
+
2408
+ .frm_embed_form_content > div {
2409
+ position: relative;
2410
+ }
2411
+
2412
+ .frm_embed_form_content svg[id^="frm_copy_embed_"] {
2413
+ position: absolute;
2414
+ top: 35px;
2415
+ right: 10px;
2416
+ cursor: pointer;
2417
+ opacity: 0.5;
2418
+ }
2419
+
2420
+ .frm-embed-modal-option {
2421
+ border-radius: 6px;
2422
+ border: 1px solid #E3E8EB;
2423
+ padding: 20px;
2424
+ cursor: pointer;
2425
+ }
2426
+
2427
+ .frm-embed-modal-option + .frm-embed-modal-option {
2428
+ margin-top: 10px;
2429
+ }
2430
+
2431
+ #frm_form_embed_modal .frm-modal-cancel {
2432
+ display: none;
2433
+ }
2434
+
2435
+ #frm_form_embed_modal.frm-on-page-2 .frm-modal-cancel {
2436
+ display: inline;
2437
+ }
2438
+
2439
+ .frm-embed-form-icon-wrapper {
2440
+ background: var(--primary-color);
2441
+ border-radius: 4px;
2442
+ padding: 10px;
2443
+ color: #fff;
2444
+ display: inline-block;
2445
+ vertical-align: top;
2446
+ }
2447
+
2448
+ .frm-embed-form-icon-wrapper + div {
2449
+ display: inline-block;
2450
+ padding-left: 13px;
2451
+ transform: translateY(-4px);
2452
+ }
2453
+
2454
+ .frm-embed-modal-option:after {
2455
+ content: "\e913" !important;
2456
+ font-family: "s11-fp" !important;
2457
+ font-size: 18px;
2458
+ position: absolute;
2459
+ right: 10px;
2460
+ top: 50%;
2461
+ transform: translateY(-50%);
2462
+ }
2463
+
2464
+ .frm_embed_form_content ul {
2465
+ max-height: 300px;
2466
+ overflow-y: scroll;
2467
+ }
2468
+
2469
+ .frm-embed-form-modal-wrapper.frm-dialog {
2470
+ overflow: visible;
2471
+ }
2472
+
2473
  /* Bulk Options */
2474
  #frm-bulk-modal .frm_grid_container {
2475
  border-top: 1px solid var(--grey-border);
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: 5.1
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: 5.2
6
  Plugin URI: https://formidableforms.com/
7
  Author URI: https://formidableforms.com/
8
  Author: Strategy11
images/icons.svg CHANGED
@@ -359,9 +359,9 @@
359
  </symbol>
360
  <symbol id="frm_calendar_icon" viewBox="0 0 18 18"><path fill-rule="evenodd" clip-rule="evenodd" d="M6.4.8c.4 0 .7.3.7.7v.8H11v-.8a.8.8 0 011.5 0v.8h3.3c.9 0 1.6.6 1.6 1.5v12c0 .8-.7 1.4-1.6 1.4H2.3c-.9 0-1.5-.6-1.5-1.4v-12c0-.9.6-1.5 1.4-1.5h3.4v-.8c0-.4.4-.8.8-.8zm-.8 3H2.3v3h13.4v-3h-3.3v.7a.8.8 0 01-1.5 0v-.8H7v.8a.8.8 0 01-1.5 0v-.8zm10.2 4.5h-3.4v3h3.3v-3zm0 4.4h-3.4v3h3.3v-3zm-5 3v-3H7.2v3H11zm-5.2 0v-3H2.3v3h3.3zm-3.3-4.4h3.3v-3H2.3v3zm4.8-3v3H11v-3H7z"/>
361
  </symbol>
362
- <symbol id="frm_code_icon" viewBox="0 0 23 20">
363
  <title>code</title>
364
- <path d="M9.2 18l-1.5-.4c-.2 0-.3-.1-.3-.3L13 2.2l.4-.2 1.5.4c.2 0 .3.1.3.3L9.6 17.8c0 .2-.3.2-.4.2zm-3.3-2.7L7 14c.2-.1.2-.3 0-.4L3 10l4-3.7c.2 0 .2-.3 0-.4L6 4.7a.3.3 0 0 0-.4 0L0 9.7v.5l5.4 5c.1.2.3.2.4 0zm11.1 0l5.4-5v-.5l-5.4-5a.3.3 0 0 0-.4 0l-1 1c-.2.2-.2.4 0 .5l4 3.7-4 3.7c-.2 0-.2.3 0 .4l1 1.2h.4z"/>
365
  </symbol>
366
  <symbol id="frm_tag_icon" viewBox="0 0 20 20">
367
  <title>tag</title>
359
  </symbol>
360
  <symbol id="frm_calendar_icon" viewBox="0 0 18 18"><path fill-rule="evenodd" clip-rule="evenodd" d="M6.4.8c.4 0 .7.3.7.7v.8H11v-.8a.8.8 0 011.5 0v.8h3.3c.9 0 1.6.6 1.6 1.5v12c0 .8-.7 1.4-1.6 1.4H2.3c-.9 0-1.5-.6-1.5-1.4v-12c0-.9.6-1.5 1.4-1.5h3.4v-.8c0-.4.4-.8.8-.8zm-.8 3H2.3v3h13.4v-3h-3.3v.7a.8.8 0 01-1.5 0v-.8H7v.8a.8.8 0 01-1.5 0v-.8zm10.2 4.5h-3.4v3h3.3v-3zm0 4.4h-3.4v3h3.3v-3zm-5 3v-3H7.2v3H11zm-5.2 0v-3H2.3v3h3.3zm-3.3-4.4h3.3v-3H2.3v3zm4.8-3v3H11v-3H7z"/>
361
  </symbol>
362
+ <symbol id="frm_code_icon" viewBox="0 0 20 20" fill="none">
363
  <title>code</title>
364
+ <path d="M13.3335 15L18.3335 10L13.3335 5" stroke="currentColor" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round"/><path d="M6.6665 5L1.6665 10L6.6665 15" stroke="currentColor" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round"/>
365
  </symbol>
366
  <symbol id="frm_tag_icon" viewBox="0 0 20 20">
367
  <title>tag</title>
js/formidable.js CHANGED
@@ -533,7 +533,7 @@ function frmFrontFormJS() {
533
  }
534
 
535
  function getFormErrors( object, action ) {
536
- var fieldset;
537
 
538
  if ( typeof action === 'undefined' ) {
539
  jQuery( object ).find( 'input[name="frm_action"]' ).val();
@@ -541,141 +541,167 @@ function frmFrontFormJS() {
541
 
542
  fieldset = jQuery( object ).find( '.frm_form_field' );
543
  fieldset.addClass( 'frm_doing_ajax' );
544
- jQuery.ajax({
545
- type: 'POST', url: frm_js.ajax_url,
546
- data: jQuery( object ).serialize() + '&action=frm_entries_' + action + '&nonce=' + frm_js.nonce,
547
- success: function( response ) {
548
- var formID, replaceContent, pageOrder, formReturned, contSubmit, delay,
549
- $fieldCont, key, inCollapsedSection, frmTrigger,
550
- defaultResponse = { 'content': '', 'errors': {}, 'pass': false };
551
- if ( response === null ) {
552
- response = defaultResponse;
553
- }
554
 
555
- response = response.replace( /^\s+|\s+$/g, '' );
556
- if ( response.indexOf( '{' ) === 0 ) {
557
- response = JSON.parse( response );
558
- } else {
559
- response = defaultResponse;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
560
  }
 
 
 
 
 
561
 
562
- if ( typeof response.redirect !== 'undefined' ) {
563
- jQuery( document ).trigger( 'frmBeforeFormRedirect', [ object, response ]);
564
- window.location = response.redirect;
565
- } else if ( response.content !== '' ) {
566
- // the form or success message was returned
567
 
568
- removeSubmitLoading( jQuery( object ) );
569
- if ( frm_js.offset != -1 ) {
570
- frmFrontForm.scrollMsg( jQuery( object ), false );
571
- }
572
- formID = jQuery( object ).find( 'input[name="form_id"]' ).val();
573
- response.content = response.content.replace( / frm_pro_form /g, ' frm_pro_form frm_no_hide ' );
574
- replaceContent = jQuery( object ).closest( '.frm_forms' );
575
- removeAddedScripts( replaceContent, formID );
576
- delay = maybeSlideOut( replaceContent, response.content );
577
 
578
- setTimeout(
579
- function() {
580
- var container, input, previousInput;
581
 
582
- replaceContent.replaceWith( response.content );
 
 
 
 
583
 
584
- addUrlParam( response );
 
 
 
585
 
586
- if ( typeof frmThemeOverride_frmAfterSubmit === 'function' ) { // eslint-disable-line camelcase
587
- pageOrder = jQuery( 'input[name="frm_page_order_' + formID + '"]' ).val();
588
- formReturned = jQuery( response.content ).find( 'input[name="form_id"]' ).val();
589
- frmThemeOverride_frmAfterSubmit( formReturned, pageOrder, response.content, object );
590
  }
 
591
 
592
- if ( typeof response.recaptcha !== 'undefined' ) {
593
- container = jQuery( '#frm_form_' + formID + '_container' ).find( '.frm_fields_container' );
594
- input = '<input type="hidden" name="recaptcha_checked" value="' + response.recaptcha + '">';
595
- previousInput = container.find( 'input[name="recaptcha_checked"]' );
 
 
596
 
597
- if ( previousInput.length ) {
598
- previousInput.replaceWith( input );
599
- } else {
600
- container.append( input );
601
- }
602
- }
603
 
604
- afterFormSubmitted( object, response );
605
- },
606
- delay
607
- );
608
- } else if ( Object.keys( response.errors ).length ) {
609
- // errors were returned
610
-
611
- removeSubmitLoading( jQuery( object ), 'enable' );
612
-
613
- //show errors
614
- contSubmit = true;
615
- removeAllErrors();
616
-
617
- $fieldCont = null;
618
-
619
- for ( key in response.errors ) {
620
- $fieldCont = jQuery( object ).find( '#frm_field_' + key + '_container' );
621
-
622
- if ( $fieldCont.length ) {
623
- if ( ! $fieldCont.is( ':visible' ) ) {
624
- inCollapsedSection = $fieldCont.closest( '.frm_toggle_container' );
625
- if ( inCollapsedSection.length ) {
626
- frmTrigger = inCollapsedSection.prev();
627
- if ( ! frmTrigger.hasClass( 'frm_trigger' ) ) {
628
- // If the frmTrigger object is the section description, check to see if the previous element is the trigger
629
- frmTrigger = frmTrigger.prev( '.frm_trigger' );
630
- }
631
- frmTrigger.trigger( 'click' );
632
  }
 
633
  }
 
634
 
635
- if ( $fieldCont.is( ':visible' ) ) {
636
- addFieldError( $fieldCont, key, response.errors );
637
- contSubmit = false;
638
- }
639
  }
640
  }
 
641
 
642
- jQuery( object ).find( '.frm-g-recaptcha, .g-recaptcha' ).each( function() {
643
- var $recaptcha = jQuery( this ),
644
- recaptchaID = $recaptcha.data( 'rid' );
645
 
646
- if ( typeof grecaptcha !== 'undefined' && grecaptcha ) {
647
- if ( recaptchaID ) {
648
- grecaptcha.reset( recaptchaID );
649
- } else {
650
- grecaptcha.reset();
651
- }
652
  }
653
- });
 
654
 
655
- jQuery( document ).trigger( 'frmFormErrors', [ object, response ]);
656
 
657
- fieldset.removeClass( 'frm_doing_ajax' );
658
- scrollToFirstField( object );
659
 
660
- if ( contSubmit ) {
661
- object.submit();
662
- } else {
663
- jQuery( object ).prepend( response.error_message );
664
- checkForErrorsAndMaybeSetFocus();
665
- }
666
  } else {
667
- // there may have been a plugin conflict, or the form is not set to submit with ajax
 
 
 
 
668
 
669
- showFileLoading( object );
670
 
671
- object.submit();
672
- }
673
- },
674
- error: function() {
675
- jQuery( object ).find( 'input[type="submit"], input[type="button"]' ).prop( 'disabled', false );
676
  object.submit();
677
  }
678
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
679
  }
680
 
681
  function afterFormSubmitted( object, response ) {
533
  }
534
 
535
  function getFormErrors( object, action ) {
536
+ var fieldset, data, success, error;
537
 
538
  if ( typeof action === 'undefined' ) {
539
  jQuery( object ).find( 'input[name="frm_action"]' ).val();
541
 
542
  fieldset = jQuery( object ).find( '.frm_form_field' );
543
  fieldset.addClass( 'frm_doing_ajax' );
 
 
 
 
 
 
 
 
 
 
544
 
545
+ data = jQuery( object ).serialize() + '&action=frm_entries_' + action + '&nonce=' + frm_js.nonce;
546
+
547
+ success = function( response ) {
548
+ var formID, replaceContent, pageOrder, formReturned, contSubmit, delay,
549
+ $fieldCont, key, inCollapsedSection, frmTrigger,
550
+ defaultResponse = { 'content': '', 'errors': {}, 'pass': false };
551
+ if ( response === null ) {
552
+ response = defaultResponse;
553
+ }
554
+
555
+ response = response.replace( /^\s+|\s+$/g, '' );
556
+ if ( response.indexOf( '{' ) === 0 ) {
557
+ response = JSON.parse( response );
558
+ } else {
559
+ response = defaultResponse;
560
+ }
561
+
562
+ if ( typeof response.redirect !== 'undefined' ) {
563
+ jQuery( document ).trigger( 'frmBeforeFormRedirect', [ object, response ]);
564
+ window.location = response.redirect;
565
+ } else if ( response.content !== '' ) {
566
+ // the form or success message was returned
567
+
568
+ removeSubmitLoading( jQuery( object ) );
569
+ if ( frm_js.offset != -1 ) {
570
+ frmFrontForm.scrollMsg( jQuery( object ), false );
571
  }
572
+ formID = jQuery( object ).find( 'input[name="form_id"]' ).val();
573
+ response.content = response.content.replace( / frm_pro_form /g, ' frm_pro_form frm_no_hide ' );
574
+ replaceContent = jQuery( object ).closest( '.frm_forms' );
575
+ removeAddedScripts( replaceContent, formID );
576
+ delay = maybeSlideOut( replaceContent, response.content );
577
 
578
+ setTimeout(
579
+ function() {
580
+ var container, input, previousInput;
 
 
581
 
582
+ replaceContent.replaceWith( response.content );
 
 
 
 
 
 
 
 
583
 
584
+ addUrlParam( response );
 
 
585
 
586
+ if ( typeof frmThemeOverride_frmAfterSubmit === 'function' ) { // eslint-disable-line camelcase
587
+ pageOrder = jQuery( 'input[name="frm_page_order_' + formID + '"]' ).val();
588
+ formReturned = jQuery( response.content ).find( 'input[name="form_id"]' ).val();
589
+ frmThemeOverride_frmAfterSubmit( formReturned, pageOrder, response.content, object );
590
+ }
591
 
592
+ if ( typeof response.recaptcha !== 'undefined' ) {
593
+ container = jQuery( '#frm_form_' + formID + '_container' ).find( '.frm_fields_container' );
594
+ input = '<input type="hidden" name="recaptcha_checked" value="' + response.recaptcha + '">';
595
+ previousInput = container.find( 'input[name="recaptcha_checked"]' );
596
 
597
+ if ( previousInput.length ) {
598
+ previousInput.replaceWith( input );
599
+ } else {
600
+ container.append( input );
601
  }
602
+ }
603
 
604
+ afterFormSubmitted( object, response );
605
+ },
606
+ delay
607
+ );
608
+ } else if ( Object.keys( response.errors ).length ) {
609
+ // errors were returned
610
 
611
+ removeSubmitLoading( jQuery( object ), 'enable' );
 
 
 
 
 
612
 
613
+ //show errors
614
+ contSubmit = true;
615
+ removeAllErrors();
616
+
617
+ $fieldCont = null;
618
+
619
+ for ( key in response.errors ) {
620
+ $fieldCont = jQuery( object ).find( '#frm_field_' + key + '_container' );
621
+
622
+ if ( $fieldCont.length ) {
623
+ if ( ! $fieldCont.is( ':visible' ) ) {
624
+ inCollapsedSection = $fieldCont.closest( '.frm_toggle_container' );
625
+ if ( inCollapsedSection.length ) {
626
+ frmTrigger = inCollapsedSection.prev();
627
+ if ( ! frmTrigger.hasClass( 'frm_trigger' ) ) {
628
+ // If the frmTrigger object is the section description, check to see if the previous element is the trigger
629
+ frmTrigger = frmTrigger.prev( '.frm_trigger' );
 
 
 
 
 
 
 
 
 
 
 
630
  }
631
+ frmTrigger.trigger( 'click' );
632
  }
633
+ }
634
 
635
+ if ( $fieldCont.is( ':visible' ) ) {
636
+ addFieldError( $fieldCont, key, response.errors );
637
+ contSubmit = false;
 
638
  }
639
  }
640
+ }
641
 
642
+ jQuery( object ).find( '.frm-g-recaptcha, .g-recaptcha' ).each( function() {
643
+ var $recaptcha = jQuery( this ),
644
+ recaptchaID = $recaptcha.data( 'rid' );
645
 
646
+ if ( typeof grecaptcha !== 'undefined' && grecaptcha ) {
647
+ if ( recaptchaID ) {
648
+ grecaptcha.reset( recaptchaID );
649
+ } else {
650
+ grecaptcha.reset();
 
651
  }
652
+ }
653
+ });
654
 
655
+ jQuery( document ).trigger( 'frmFormErrors', [ object, response ]);
656
 
657
+ fieldset.removeClass( 'frm_doing_ajax' );
658
+ scrollToFirstField( object );
659
 
660
+ if ( contSubmit ) {
661
+ object.submit();
 
 
 
 
662
  } else {
663
+ jQuery( object ).prepend( response.error_message );
664
+ checkForErrorsAndMaybeSetFocus();
665
+ }
666
+ } else {
667
+ // there may have been a plugin conflict, or the form is not set to submit with ajax
668
 
669
+ showFileLoading( object );
670
 
 
 
 
 
 
671
  object.submit();
672
  }
673
+ };
674
+
675
+ error = function() {
676
+ jQuery( object ).find( 'input[type="submit"], input[type="button"]' ).prop( 'disabled', false );
677
+ object.submit();
678
+ };
679
+
680
+ postToAjaxUrl( object, data, success, error );
681
+ }
682
+
683
+ function postToAjaxUrl( form, data, success, error ) {
684
+ var ajaxUrl, action, ajaxParams;
685
+
686
+ ajaxUrl = frm_js.ajax_url;
687
+ action = form.getAttribute( 'action' );
688
+
689
+ if ( 'string' === typeof action && -1 !== action.indexOf( '?action=frm_forms_preview' ) ) {
690
+ ajaxUrl = action.split( '?action=frm_forms_preview' )[0];
691
+ }
692
+
693
+ ajaxParams = {
694
+ type: 'POST',
695
+ url: ajaxUrl,
696
+ data: data,
697
+ success: success
698
+ };
699
+
700
+ if ( 'function' === typeof error ) {
701
+ ajaxParams.error = error;
702
+ }
703
+
704
+ jQuery.ajax( ajaxParams );
705
  }
706
 
707
  function afterFormSubmitted( object, response ) {
js/formidable.min.js CHANGED
@@ -18,41 +18,41 @@ getFieldId(field,true);if(!(fieldID in errors))errors[fieldID]=getFieldValidatio
18
  recaptchaID,alreadyChecked;if(isGoingToPrevPage(object))return false;recaptcha=jQuery(object).find('.frm-g-recaptcha[data-size="invisible"], .g-recaptcha[data-size="invisible"]');if(recaptcha.length){recaptchaID=recaptcha.data("rid");alreadyChecked=grecaptcha.getResponse(recaptchaID);if(alreadyChecked.length===0)return recaptcha;else return false}else return false}function executeInvisibleRecaptcha(invisibleRecaptcha){var recaptchaID=invisibleRecaptcha.data("rid");grecaptcha.reset(recaptchaID);grecaptcha.execute(recaptchaID)}
19
  function validateRecaptcha(form,errors){var recaptchaID,response,fieldContainer,fieldID,$recaptcha=jQuery(form).find(".frm-g-recaptcha");if($recaptcha.length){recaptchaID=$recaptcha.data("rid");try{response=grecaptcha.getResponse(recaptchaID)}catch(e){if(jQuery(form).find('input[name="recaptcha_checked"]').length)return errors;else response=""}if(response.length===0){fieldContainer=$recaptcha.closest(".frm_form_field");fieldID=fieldContainer.attr("id").replace("frm_field_","").replace("_container",
20
  "");errors[fieldID]=""}}return errors}function getFieldValidationMessage(field,messageType){var msg,errorHtml;msg=field.getAttribute(messageType);if(null===msg)msg="";if(""!==msg&&shouldWrapErrorHtmlAroundMessageType(messageType)){errorHtml=field.getAttribute("data-error-html");if(null!==errorHtml){errorHtml=errorHtml.replace(/\+/g,"%20");msg=decodeURIComponent(errorHtml).replace("[error]",msg);msg=msg.replace("[key]",getFieldId(field,false))}}return msg}function shouldWrapErrorHtmlAroundMessageType(type){return"pattern"!==
21
- type}function shouldJSValidate(object){var validate=jQuery(object).hasClass("frm_js_validate");if(validate&&typeof frmProForm!=="undefined"&&(frmProForm.savingDraft(object)||frmProForm.goingToPreviousPage(object)))validate=false;return validate}function getFormErrors(object,action){var fieldset;if(typeof action==="undefined")jQuery(object).find('input[name="frm_action"]').val();fieldset=jQuery(object).find(".frm_form_field");fieldset.addClass("frm_doing_ajax");jQuery.ajax({type:"POST",url:frm_js.ajax_url,
22
- data:jQuery(object).serialize()+"&action=frm_entries_"+action+"&nonce="+frm_js.nonce,success:function(response){var formID,replaceContent,pageOrder,formReturned,contSubmit,delay,$fieldCont,key,inCollapsedSection,frmTrigger,defaultResponse={"content":"","errors":{},"pass":false};if(response===null)response=defaultResponse;response=response.replace(/^\s+|\s+$/g,"");if(response.indexOf("{")===0)response=JSON.parse(response);else response=defaultResponse;if(typeof response.redirect!=="undefined"){jQuery(document).trigger("frmBeforeFormRedirect",
23
  [object,response]);window.location=response.redirect}else if(response.content!==""){removeSubmitLoading(jQuery(object));if(frm_js.offset!=-1)frmFrontForm.scrollMsg(jQuery(object),false);formID=jQuery(object).find('input[name="form_id"]').val();response.content=response.content.replace(/ frm_pro_form /g," frm_pro_form frm_no_hide ");replaceContent=jQuery(object).closest(".frm_forms");removeAddedScripts(replaceContent,formID);delay=maybeSlideOut(replaceContent,response.content);setTimeout(function(){var container,
24
  input,previousInput;replaceContent.replaceWith(response.content);addUrlParam(response);if(typeof frmThemeOverride_frmAfterSubmit==="function"){pageOrder=jQuery('input[name="frm_page_order_'+formID+'"]').val();formReturned=jQuery(response.content).find('input[name="form_id"]').val();frmThemeOverride_frmAfterSubmit(formReturned,pageOrder,response.content,object)}if(typeof response.recaptcha!=="undefined"){container=jQuery("#frm_form_"+formID+"_container").find(".frm_fields_container");input='<input type="hidden" name="recaptcha_checked" value="'+
25
  response.recaptcha+'">';previousInput=container.find('input[name="recaptcha_checked"]');if(previousInput.length)previousInput.replaceWith(input);else container.append(input)}afterFormSubmitted(object,response)},delay)}else if(Object.keys(response.errors).length){removeSubmitLoading(jQuery(object),"enable");contSubmit=true;removeAllErrors();$fieldCont=null;for(key in response.errors){$fieldCont=jQuery(object).find("#frm_field_"+key+"_container");if($fieldCont.length){if(!$fieldCont.is(":visible")){inCollapsedSection=
26
  $fieldCont.closest(".frm_toggle_container");if(inCollapsedSection.length){frmTrigger=inCollapsedSection.prev();if(!frmTrigger.hasClass("frm_trigger"))frmTrigger=frmTrigger.prev(".frm_trigger");frmTrigger.trigger("click")}}if($fieldCont.is(":visible")){addFieldError($fieldCont,key,response.errors);contSubmit=false}}}jQuery(object).find(".frm-g-recaptcha, .g-recaptcha").each(function(){var $recaptcha=jQuery(this),recaptchaID=$recaptcha.data("rid");if(typeof grecaptcha!=="undefined"&&grecaptcha)if(recaptchaID)grecaptcha.reset(recaptchaID);
27
- else grecaptcha.reset()});jQuery(document).trigger("frmFormErrors",[object,response]);fieldset.removeClass("frm_doing_ajax");scrollToFirstField(object);if(contSubmit)object.submit();else{jQuery(object).prepend(response.error_message);checkForErrorsAndMaybeSetFocus()}}else{showFileLoading(object);object.submit()}},error:function(){jQuery(object).find('input[type="submit"], input[type="button"]').prop("disabled",false);object.submit()}})}function afterFormSubmitted(object,response){var formCompleted=
28
- jQuery(response.content).find(".frm_message");if(formCompleted.length)jQuery(document).trigger("frmFormComplete",[object,response]);else jQuery(document).trigger("frmPageChanged",[object,response])}function removeAddedScripts(formContainer,formID){var endReplace=jQuery(".frm_end_ajax_"+formID);if(endReplace.length){formContainer.nextUntil(".frm_end_ajax_"+formID).remove();endReplace.remove()}}function maybeSlideOut(oldContent,newContent){var c,newClass="frm_slideout";if(newContent.indexOf(" frm_slide")!==
29
- -1){c=oldContent.children();if(newContent.indexOf(" frm_going_back")!==-1)newClass+=" frm_going_back";c.removeClass("frm_going_back");c.addClass(newClass);return 300}return 0}function addUrlParam(response){var url;if(history.pushState&&typeof response.page!=="undefined"){url=addQueryVar("frm_page",response.page);window.history.pushState({"html":response.html},"","?"+url)}}function addQueryVar(key,value){var kvp,i,x;key=encodeURI(key);value=encodeURI(value);kvp=document.location.search.substr(1).split("&");
30
- i=kvp.length;while(i--){x=kvp[i].split("=");if(x[0]==key){x[1]=value;kvp[i]=x.join("=");break}}if(i<0)kvp[kvp.length]=[key,value].join("=");return kvp.join("&")}function addFieldError($fieldCont,key,jsErrors){var input,id,describedBy;if($fieldCont.length&&$fieldCont.is(":visible")){$fieldCont.addClass("frm_blank_field");input=$fieldCont.find("input, select, textarea");id="frm_error_field_"+key;describedBy=input.attr("aria-describedby");if(typeof frmThemeOverride_frmPlaceError==="function")frmThemeOverride_frmPlaceError(key,
31
- jsErrors);else{if(-1!==jsErrors[key].indexOf("<div"))$fieldCont.append(jsErrors[key]);else $fieldCont.append('<div class="frm_error" role="alert" id="'+id+'">'+jsErrors[key]+"</div>");if(typeof describedBy==="undefined")describedBy=id;else if(describedBy.indexOf(id)===-1)describedBy=describedBy+" "+id;input.attr("aria-describedby",describedBy)}input.attr("aria-invalid",true);input.attr("aria-describedby",id);jQuery(document).trigger("frmAddFieldError",[$fieldCont,key,jsErrors])}}function removeFieldError($fieldCont){var errorMessage=
32
- $fieldCont.find(".frm_error"),errorId=errorMessage.attr("id"),input=$fieldCont.find("input, select, textarea"),describedBy=input.attr("aria-describedby");$fieldCont.removeClass("frm_blank_field has-error");errorMessage.remove();input.attr("aria-invalid",false);input.removeAttr("aria-describedby");if(typeof describedBy!=="undefined"){describedBy=describedBy.replace(errorId,"");input.attr("aria-describedby",describedBy)}}function removeAllErrors(){jQuery(".form-field").removeClass("frm_blank_field has-error");
33
- jQuery(".form-field .frm_error").replaceWith("");jQuery(".frm_error_style").remove()}function scrollToFirstField(object){var field=jQuery(object).find(".frm_blank_field").first();if(field.length)frmFrontForm.scrollMsg(field,object,true)}function showSubmitLoading($object){showLoadingIndicator($object);disableSubmitButton($object);disableSaveDraft($object)}function showLoadingIndicator($object){if(!$object.hasClass("frm_loading_form")&&!$object.hasClass("frm_loading_prev")){addLoadingClass($object);
34
- $object.trigger("frmStartFormLoading")}}function addLoadingClass($object){var loadingClass=isGoingToPrevPage($object)?"frm_loading_prev":"frm_loading_form";$object.addClass(loadingClass)}function isGoingToPrevPage($object){return typeof frmProForm!=="undefined"&&frmProForm.goingToPreviousPage($object)}function removeSubmitLoading($object,enable,processesRunning){var loadingForm;if(processesRunning>0)return;loadingForm=jQuery(".frm_loading_form");loadingForm.removeClass("frm_loading_form");loadingForm.removeClass("frm_loading_prev");
35
- loadingForm.trigger("frmEndFormLoading");if(enable==="enable"){enableSubmitButton(loadingForm);enableSaveDraft(loadingForm)}}function showFileLoading(object){var fileval,loading=document.getElementById("frm_loading");if(loading!==null){fileval=jQuery(object).find("input[type=file]").val();if(typeof fileval!=="undefined"&&fileval!=="")setTimeout(function(){jQuery(loading).fadeIn("slow")},2E3)}}function clearDefault(){toggleDefault(jQuery(this),"clear")}function replaceDefault(){toggleDefault(jQuery(this),
36
- "replace")}function toggleDefault($thisField,e){var thisVal,v=$thisField.data("frmval").replace(/(\n|\r\n)/g,"\r");if(v===""||typeof v==="undefined")return false;thisVal=$thisField.val().replace(/(\n|\r\n)/g,"\r");if("replace"===e){if(thisVal==="")$thisField.addClass("frm_default").val(v)}else if(thisVal==v)$thisField.removeClass("frm_default").val("")}function resendEmail(){var $link=jQuery(this),entryId=this.getAttribute("data-eid"),formId=this.getAttribute("data-fid"),label=$link.find(".frm_link_label");
37
- if(label.length<1)label=$link;label.append('<span class="frm-wait"></span>');jQuery.ajax({type:"POST",url:frm_js.ajax_url,data:{action:"frm_entries_send_email",entry_id:entryId,form_id:formId,nonce:frm_js.nonce},success:function(msg){var admin=document.getElementById("wpbody");if(admin===null)label.html(msg);else{label.html("");$link.after(msg)}}});return false}function confirmClick(){var message=jQuery(this).data("frmconfirm");return confirm(message)}function toggleDiv(){var div=jQuery(this).data("frmtoggle");
38
- if(jQuery(div).is(":visible"))jQuery(div).slideUp("fast");else jQuery(div).slideDown("fast");return false}function addIndexOfFallbackForIE8(){var len,from;if(!Array.prototype.indexOf)Array.prototype.indexOf=function(elt){len=this.length>>>0;from=Number(arguments[1])||0;from=from<0?Math.ceil(from):Math.floor(from);if(from<0)from+=len;for(;from<len;from++)if(from in this&&this[from]===elt)return from;return-1}}function addTrimFallbackForIE8(){if(typeof String.prototype.trim!=="function")String.prototype.trim=
39
- function(){return this.replace(/^\s+|\s+$/g,"")}}function addFilterFallbackForIE8(){var t,len,res,thisp,i,val;if(!Array.prototype.filter)Array.prototype.filter=function(fun){if(this===void 0||this===null)throw new TypeError;t=Object(this);len=t.length>>>0;if(typeof fun!=="function")throw new TypeError;res=[];thisp=arguments[1];for(i=0;i<len;i++)if(i in t){val=t[i];if(fun.call(thisp,val,i,t))res.push(val)}return res}}function addKeysFallbackForIE8(){var keys,i;if(!Object.keys)Object.keys=function(obj){keys=
40
- [];for(i in obj)if(obj.hasOwnProperty(i))keys.push(i);return keys}}function onHoneypotFieldChange(){var css=jQuery(this).css("box-shadow");if(css.match(/inset/))this.parentNode.removeChild(this)}function changeFocusWhenClickComboFieldLabel(){var label;var comboInputsContainer=document.querySelectorAll(".frm_combo_inputs_container");comboInputsContainer.forEach(function(inputsContainer){if(!inputsContainer.closest(".frm_form_field"))return;label=inputsContainer.closest(".frm_form_field").querySelector(".frm_primary_label");
41
- if(!label)return;label.addEventListener("click",function(e){inputsContainer.querySelector(".frm_form_field:first-child input, .frm_form_field:first-child select, .frm_form_field:first-child textarea").focus()})})}function checkForErrorsAndMaybeSetFocus(){var errors,element,timeoutCallback;errors=document.querySelectorAll(".frm_form_field .frm_error");if(!errors.length)return;element=errors[0];do{element=element.previousSibling;if(-1!==["input","select","textarea"].indexOf(element.nodeName.toLowerCase())){element.focus();
42
- break}if("undefined"!==typeof element.classList){if(element.classList.contains("html-active"))timeoutCallback=function(){var textarea=element.querySelector("textarea");if(null!==textarea)textarea.focus()};else if(element.classList.contains("tmce-active"))timeoutCallback=function(){tinyMCE.activeEditor.focus()};if("function"===typeof timeoutCallback){setTimeout(timeoutCallback,0);break}}}while(element.previousSibling)}return{init:function(){jQuery(document).off("submit.formidable",".frm-show-form");
43
- jQuery(document).on("submit.formidable",".frm-show-form",frmFrontForm.submitForm);jQuery(".frm-show-form input[onblur], .frm-show-form textarea[onblur]").each(function(){if(jQuery(this).val()==="")jQuery(this).trigger("blur")});jQuery(document).on("focus",".frm_toggle_default",clearDefault);jQuery(document).on("blur",".frm_toggle_default",replaceDefault);jQuery(".frm_toggle_default").trigger("blur");jQuery(document.getElementById("frm_resend_email")).on("click",resendEmail);jQuery(document).on("change",
44
- '.frm-show-form input[name^="item_meta"], .frm-show-form select[name^="item_meta"], .frm-show-form textarea[name^="item_meta"]',frmFrontForm.fieldValueChanged);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);jQuery(document).on("change","[id^=frm_email_]",onHoneypotFieldChange);jQuery(document).on("click","a[data-frmconfirm]",confirmClick);jQuery("a[data-frmtoggle]").on("click",
45
- toggleDiv);checkForErrorsAndMaybeSetFocus();changeFocusWhenClickComboFieldLabel();addIndexOfFallbackForIE8();addTrimFallbackForIE8();addFilterFallbackForIE8();addKeysFallbackForIE8()},getFieldId:function(field,fullID){return getFieldId(field,fullID)},renderRecaptcha:function(captcha){var formID,recaptchaID,size=captcha.getAttribute("data-size"),rendered=captcha.getAttribute("data-rid")!==null,params={"sitekey":captcha.getAttribute("data-sitekey"),"size":size,"theme":captcha.getAttribute("data-theme")};
46
- if(rendered)return;if(size==="invisible"){formID=jQuery(captcha).closest("form").find('input[name="form_id"]').val();jQuery(captcha).closest(".frm_form_field .frm_primary_label").hide();params.callback=function(token){frmFrontForm.afterRecaptcha(token,formID)}}recaptchaID=grecaptcha.render(captcha.id,params);captcha.setAttribute("data-rid",recaptchaID)},afterSingleRecaptcha:function(){var object=jQuery(".frm-show-form .g-recaptcha").closest("form")[0];frmFrontForm.submitFormNow(object)},afterRecaptcha:function(token,
47
- formID){var object=jQuery("#frm_form_"+formID+"_container form")[0];frmFrontForm.submitFormNow(object)},submitForm:function(e){frmFrontForm.submitFormManual(e,this)},submitFormManual:function(e,object){var isPro,errors,invisibleRecaptcha=hasInvisibleRecaptcha(object),classList=object.className.trim().split(/\s+/gi);if(classList&&invisibleRecaptcha.length<1){isPro=classList.indexOf("frm_pro_form")>-1;if(!isPro)return}if(jQuery("body").hasClass("wp-admin")&&jQuery(object).closest(".frmapi-form").length<
48
- 1)return;e.preventDefault();if(typeof frmProForm!=="undefined"&&typeof frmProForm.submitAllowed==="function")if(!frmProForm.submitAllowed(object))return;if(invisibleRecaptcha.length){showLoadingIndicator(jQuery(object));executeInvisibleRecaptcha(invisibleRecaptcha)}else{errors=frmFrontForm.validateFormSubmit(object);if(Object.keys(errors).length===0){showSubmitLoading(jQuery(object));frmFrontForm.submitFormNow(object,classList)}}},submitFormNow:function(object){var hasFileFields,antispamInput,classList=
49
- object.className.trim().split(/\s+/gi);if(object.hasAttribute("data-token")&&null===object.querySelector('[name="antispam_token"]')){antispamInput=document.createElement("input");antispamInput.type="hidden";antispamInput.name="antispam_token";antispamInput.value=object.getAttribute("data-token");object.appendChild(antispamInput)}if(classList.indexOf("frm_ajax_submit")>-1){hasFileFields=jQuery(object).find('input[type="file"]').filter(function(){return!!this.value}).length;if(hasFileFields<1){action=
50
- jQuery(object).find('input[name="frm_action"]').val();frmFrontForm.checkFormErrors(object,action)}else object.submit()}else object.submit()},validateFormSubmit:function(object){if(typeof tinyMCE!=="undefined"&&jQuery(object).find(".wp-editor-wrap").length)tinyMCE.triggerSave();jsErrors=[];if(shouldJSValidate(object)){frmFrontForm.getAjaxFormErrors(object);if(Object.keys(jsErrors).length)frmFrontForm.addAjaxFormErrors(object)}return jsErrors},getAjaxFormErrors:function(object){var customErrors,key;
51
- jsErrors=validateForm(object);if(typeof frmThemeOverride_jsErrors==="function"){action=jQuery(object).find('input[name="frm_action"]').val();customErrors=frmThemeOverride_jsErrors(action,object);if(Object.keys(customErrors).length)for(key in customErrors)jsErrors[key]=customErrors[key]}return jsErrors},addAjaxFormErrors:function(object){var key,$fieldCont;removeAllErrors();for(key in jsErrors){$fieldCont=jQuery(object).find("#frm_field_"+key+"_container");if($fieldCont.length)addFieldError($fieldCont,
52
- key,jsErrors);else delete jsErrors[key]}scrollToFirstField(object);checkForErrorsAndMaybeSetFocus()},checkFormErrors:function(object,action){getFormErrors(object,action)},checkRequiredField:function(field,errors){return checkRequiredField(field,errors)},showSubmitLoading:function($object){showSubmitLoading($object)},removeSubmitLoading:function($object,enable,processesRunning){removeSubmitLoading($object,enable,processesRunning)},scrollToID:function(id){var object=jQuery(document.getElementById(id));
53
- frmFrontForm.scrollMsg(object,false)},scrollMsg:function(id,object,animate){var newPos,m,b,screenTop,screenBottom,scrollObj="";if(typeof object==="undefined"){scrollObj=jQuery(document.getElementById("frm_form_"+id+"_container"));if(scrollObj.length<1)return}else if(typeof id==="string")scrollObj=jQuery(object).find("#frm_field_"+id+"_container");else scrollObj=id;jQuery(scrollObj).trigger("focus");newPos=scrollObj.offset().top;if(!newPos||frm_js.offset==="-1")return;newPos=newPos-frm_js.offset;m=
54
- jQuery("html").css("margin-top");b=jQuery("body").css("margin-top");if(m||b)newPos=newPos-parseInt(m)-parseInt(b);if(newPos&&window.innerHeight){screenTop=document.documentElement.scrollTop||document.body.scrollTop;screenBottom=screenTop+window.innerHeight;if(newPos>screenBottom||newPos<screenTop){if(typeof animate==="undefined")jQuery(window).scrollTop(newPos);else jQuery("html,body").animate({scrollTop:newPos},500);return false}}},fieldValueChanged:function(e){var fieldId=frmFrontForm.getFieldId(this,
55
- false);if(!fieldId||typeof fieldId==="undefined")return;if(e.frmTriggered&&e.frmTriggered==fieldId)return;jQuery(document).trigger("frmFieldChanged",[this,fieldId,e]);if(e.selfTriggered!==true)maybeValidateChange(this)},savingDraft:function(object){console.warn("DEPRECATED: function frmFrontForm.savingDraft in v3.0 use frmProForm.savingDraft");if(typeof frmProForm!=="undefined")return frmProForm.savingDraft(object)},goingToPreviousPage:function(object){console.warn("DEPRECATED: function frmFrontForm.goingToPreviousPage in v3.0 use frmProForm.goingToPreviousPage");
56
  if(typeof frmProForm!=="undefined")return frmProForm.goingToPreviousPage(object)},hideOrShowFields:function(){console.warn("DEPRECATED: function frmFrontForm.hideOrShowFields in v3.0 use frmProForm.hideOrShowFields");if(typeof frmProForm!=="undefined")frmProForm.hideOrShowFields()},hidePreviouslyHiddenFields:function(){console.warn("DEPRECATED: function frmFrontForm.hidePreviouslyHiddenFields in v3.0 use frmProForm.hidePreviouslyHiddenFields");if(typeof frmProForm!=="undefined")frmProForm.hidePreviouslyHiddenFields()},
57
  checkDependentDynamicFields:function(ids){console.warn("DEPRECATED: function frmFrontForm.checkDependentDynamicFields in v3.0 use frmProForm.checkDependentDynamicFields");if(typeof frmProForm!=="undefined")frmProForm.checkDependentDynamicFields(ids)},checkDependentLookupFields:function(ids){console.warn("DEPRECATED: function frmFrontForm.checkDependentLookupFields in v3.0 use frmProForm.checkDependentLookupFields");if(typeof frmProForm!=="undefined")frmProForm.checkDependentLookupFields(ids)},loadGoogle:function(){console.warn("DEPRECATED: function frmFrontForm.loadGoogle in v3.0 use frmProForm.loadGoogle");
58
  frmProForm.loadGoogle()},escapeHtml:function(text){return text.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")},invisible:function(classes){jQuery(classes).css("visibility","hidden")},visible:function(classes){jQuery(classes).css("visibility","visible")}}}frmFrontForm=frmFrontFormJS();jQuery(document).ready(function(){frmFrontForm.init()});
18
  recaptchaID,alreadyChecked;if(isGoingToPrevPage(object))return false;recaptcha=jQuery(object).find('.frm-g-recaptcha[data-size="invisible"], .g-recaptcha[data-size="invisible"]');if(recaptcha.length){recaptchaID=recaptcha.data("rid");alreadyChecked=grecaptcha.getResponse(recaptchaID);if(alreadyChecked.length===0)return recaptcha;else return false}else return false}function executeInvisibleRecaptcha(invisibleRecaptcha){var recaptchaID=invisibleRecaptcha.data("rid");grecaptcha.reset(recaptchaID);grecaptcha.execute(recaptchaID)}
19
  function validateRecaptcha(form,errors){var recaptchaID,response,fieldContainer,fieldID,$recaptcha=jQuery(form).find(".frm-g-recaptcha");if($recaptcha.length){recaptchaID=$recaptcha.data("rid");try{response=grecaptcha.getResponse(recaptchaID)}catch(e){if(jQuery(form).find('input[name="recaptcha_checked"]').length)return errors;else response=""}if(response.length===0){fieldContainer=$recaptcha.closest(".frm_form_field");fieldID=fieldContainer.attr("id").replace("frm_field_","").replace("_container",
20
  "");errors[fieldID]=""}}return errors}function getFieldValidationMessage(field,messageType){var msg,errorHtml;msg=field.getAttribute(messageType);if(null===msg)msg="";if(""!==msg&&shouldWrapErrorHtmlAroundMessageType(messageType)){errorHtml=field.getAttribute("data-error-html");if(null!==errorHtml){errorHtml=errorHtml.replace(/\+/g,"%20");msg=decodeURIComponent(errorHtml).replace("[error]",msg);msg=msg.replace("[key]",getFieldId(field,false))}}return msg}function shouldWrapErrorHtmlAroundMessageType(type){return"pattern"!==
21
+ type}function shouldJSValidate(object){var validate=jQuery(object).hasClass("frm_js_validate");if(validate&&typeof frmProForm!=="undefined"&&(frmProForm.savingDraft(object)||frmProForm.goingToPreviousPage(object)))validate=false;return validate}function getFormErrors(object,action){var fieldset,data,success,error;if(typeof action==="undefined")jQuery(object).find('input[name="frm_action"]').val();fieldset=jQuery(object).find(".frm_form_field");fieldset.addClass("frm_doing_ajax");data=jQuery(object).serialize()+
22
+ "&action=frm_entries_"+action+"&nonce="+frm_js.nonce;success=function(response){var formID,replaceContent,pageOrder,formReturned,contSubmit,delay,$fieldCont,key,inCollapsedSection,frmTrigger,defaultResponse={"content":"","errors":{},"pass":false};if(response===null)response=defaultResponse;response=response.replace(/^\s+|\s+$/g,"");if(response.indexOf("{")===0)response=JSON.parse(response);else response=defaultResponse;if(typeof response.redirect!=="undefined"){jQuery(document).trigger("frmBeforeFormRedirect",
23
  [object,response]);window.location=response.redirect}else if(response.content!==""){removeSubmitLoading(jQuery(object));if(frm_js.offset!=-1)frmFrontForm.scrollMsg(jQuery(object),false);formID=jQuery(object).find('input[name="form_id"]').val();response.content=response.content.replace(/ frm_pro_form /g," frm_pro_form frm_no_hide ");replaceContent=jQuery(object).closest(".frm_forms");removeAddedScripts(replaceContent,formID);delay=maybeSlideOut(replaceContent,response.content);setTimeout(function(){var container,
24
  input,previousInput;replaceContent.replaceWith(response.content);addUrlParam(response);if(typeof frmThemeOverride_frmAfterSubmit==="function"){pageOrder=jQuery('input[name="frm_page_order_'+formID+'"]').val();formReturned=jQuery(response.content).find('input[name="form_id"]').val();frmThemeOverride_frmAfterSubmit(formReturned,pageOrder,response.content,object)}if(typeof response.recaptcha!=="undefined"){container=jQuery("#frm_form_"+formID+"_container").find(".frm_fields_container");input='<input type="hidden" name="recaptcha_checked" value="'+
25
  response.recaptcha+'">';previousInput=container.find('input[name="recaptcha_checked"]');if(previousInput.length)previousInput.replaceWith(input);else container.append(input)}afterFormSubmitted(object,response)},delay)}else if(Object.keys(response.errors).length){removeSubmitLoading(jQuery(object),"enable");contSubmit=true;removeAllErrors();$fieldCont=null;for(key in response.errors){$fieldCont=jQuery(object).find("#frm_field_"+key+"_container");if($fieldCont.length){if(!$fieldCont.is(":visible")){inCollapsedSection=
26
  $fieldCont.closest(".frm_toggle_container");if(inCollapsedSection.length){frmTrigger=inCollapsedSection.prev();if(!frmTrigger.hasClass("frm_trigger"))frmTrigger=frmTrigger.prev(".frm_trigger");frmTrigger.trigger("click")}}if($fieldCont.is(":visible")){addFieldError($fieldCont,key,response.errors);contSubmit=false}}}jQuery(object).find(".frm-g-recaptcha, .g-recaptcha").each(function(){var $recaptcha=jQuery(this),recaptchaID=$recaptcha.data("rid");if(typeof grecaptcha!=="undefined"&&grecaptcha)if(recaptchaID)grecaptcha.reset(recaptchaID);
27
+ else grecaptcha.reset()});jQuery(document).trigger("frmFormErrors",[object,response]);fieldset.removeClass("frm_doing_ajax");scrollToFirstField(object);if(contSubmit)object.submit();else{jQuery(object).prepend(response.error_message);checkForErrorsAndMaybeSetFocus()}}else{showFileLoading(object);object.submit()}};error=function(){jQuery(object).find('input[type="submit"], input[type="button"]').prop("disabled",false);object.submit()};postToAjaxUrl(object,data,success,error)}function postToAjaxUrl(form,
28
+ data,success,error){var ajaxUrl,action,ajaxParams;ajaxUrl=frm_js.ajax_url;action=form.getAttribute("action");if("string"===typeof action&&-1!==action.indexOf("?action=frm_forms_preview"))ajaxUrl=action.split("?action=frm_forms_preview")[0];ajaxParams={type:"POST",url:ajaxUrl,data:data,success:success};if("function"===typeof error)ajaxParams.error=error;jQuery.ajax(ajaxParams)}function afterFormSubmitted(object,response){var formCompleted=jQuery(response.content).find(".frm_message");if(formCompleted.length)jQuery(document).trigger("frmFormComplete",
29
+ [object,response]);else jQuery(document).trigger("frmPageChanged",[object,response])}function removeAddedScripts(formContainer,formID){var endReplace=jQuery(".frm_end_ajax_"+formID);if(endReplace.length){formContainer.nextUntil(".frm_end_ajax_"+formID).remove();endReplace.remove()}}function maybeSlideOut(oldContent,newContent){var c,newClass="frm_slideout";if(newContent.indexOf(" frm_slide")!==-1){c=oldContent.children();if(newContent.indexOf(" frm_going_back")!==-1)newClass+=" frm_going_back";c.removeClass("frm_going_back");
30
+ c.addClass(newClass);return 300}return 0}function addUrlParam(response){var url;if(history.pushState&&typeof response.page!=="undefined"){url=addQueryVar("frm_page",response.page);window.history.pushState({"html":response.html},"","?"+url)}}function addQueryVar(key,value){var kvp,i,x;key=encodeURI(key);value=encodeURI(value);kvp=document.location.search.substr(1).split("&");i=kvp.length;while(i--){x=kvp[i].split("=");if(x[0]==key){x[1]=value;kvp[i]=x.join("=");break}}if(i<0)kvp[kvp.length]=[key,value].join("=");
31
+ return kvp.join("&")}function addFieldError($fieldCont,key,jsErrors){var input,id,describedBy;if($fieldCont.length&&$fieldCont.is(":visible")){$fieldCont.addClass("frm_blank_field");input=$fieldCont.find("input, select, textarea");id="frm_error_field_"+key;describedBy=input.attr("aria-describedby");if(typeof frmThemeOverride_frmPlaceError==="function")frmThemeOverride_frmPlaceError(key,jsErrors);else{if(-1!==jsErrors[key].indexOf("<div"))$fieldCont.append(jsErrors[key]);else $fieldCont.append('<div class="frm_error" role="alert" id="'+
32
+ id+'">'+jsErrors[key]+"</div>");if(typeof describedBy==="undefined")describedBy=id;else if(describedBy.indexOf(id)===-1)describedBy=describedBy+" "+id;input.attr("aria-describedby",describedBy)}input.attr("aria-invalid",true);input.attr("aria-describedby",id);jQuery(document).trigger("frmAddFieldError",[$fieldCont,key,jsErrors])}}function removeFieldError($fieldCont){var errorMessage=$fieldCont.find(".frm_error"),errorId=errorMessage.attr("id"),input=$fieldCont.find("input, select, textarea"),describedBy=
33
+ input.attr("aria-describedby");$fieldCont.removeClass("frm_blank_field has-error");errorMessage.remove();input.attr("aria-invalid",false);input.removeAttr("aria-describedby");if(typeof describedBy!=="undefined"){describedBy=describedBy.replace(errorId,"");input.attr("aria-describedby",describedBy)}}function removeAllErrors(){jQuery(".form-field").removeClass("frm_blank_field has-error");jQuery(".form-field .frm_error").replaceWith("");jQuery(".frm_error_style").remove()}function scrollToFirstField(object){var field=
34
+ jQuery(object).find(".frm_blank_field").first();if(field.length)frmFrontForm.scrollMsg(field,object,true)}function showSubmitLoading($object){showLoadingIndicator($object);disableSubmitButton($object);disableSaveDraft($object)}function showLoadingIndicator($object){if(!$object.hasClass("frm_loading_form")&&!$object.hasClass("frm_loading_prev")){addLoadingClass($object);$object.trigger("frmStartFormLoading")}}function addLoadingClass($object){var loadingClass=isGoingToPrevPage($object)?"frm_loading_prev":
35
+ "frm_loading_form";$object.addClass(loadingClass)}function isGoingToPrevPage($object){return typeof frmProForm!=="undefined"&&frmProForm.goingToPreviousPage($object)}function removeSubmitLoading($object,enable,processesRunning){var loadingForm;if(processesRunning>0)return;loadingForm=jQuery(".frm_loading_form");loadingForm.removeClass("frm_loading_form");loadingForm.removeClass("frm_loading_prev");loadingForm.trigger("frmEndFormLoading");if(enable==="enable"){enableSubmitButton(loadingForm);enableSaveDraft(loadingForm)}}
36
+ function showFileLoading(object){var fileval,loading=document.getElementById("frm_loading");if(loading!==null){fileval=jQuery(object).find("input[type=file]").val();if(typeof fileval!=="undefined"&&fileval!=="")setTimeout(function(){jQuery(loading).fadeIn("slow")},2E3)}}function clearDefault(){toggleDefault(jQuery(this),"clear")}function replaceDefault(){toggleDefault(jQuery(this),"replace")}function toggleDefault($thisField,e){var thisVal,v=$thisField.data("frmval").replace(/(\n|\r\n)/g,"\r");if(v===
37
+ ""||typeof v==="undefined")return false;thisVal=$thisField.val().replace(/(\n|\r\n)/g,"\r");if("replace"===e){if(thisVal==="")$thisField.addClass("frm_default").val(v)}else if(thisVal==v)$thisField.removeClass("frm_default").val("")}function resendEmail(){var $link=jQuery(this),entryId=this.getAttribute("data-eid"),formId=this.getAttribute("data-fid"),label=$link.find(".frm_link_label");if(label.length<1)label=$link;label.append('<span class="frm-wait"></span>');jQuery.ajax({type:"POST",url:frm_js.ajax_url,
38
+ data:{action:"frm_entries_send_email",entry_id:entryId,form_id:formId,nonce:frm_js.nonce},success:function(msg){var admin=document.getElementById("wpbody");if(admin===null)label.html(msg);else{label.html("");$link.after(msg)}}});return false}function confirmClick(){var message=jQuery(this).data("frmconfirm");return confirm(message)}function toggleDiv(){var div=jQuery(this).data("frmtoggle");if(jQuery(div).is(":visible"))jQuery(div).slideUp("fast");else jQuery(div).slideDown("fast");return false}function addIndexOfFallbackForIE8(){var len,
39
+ from;if(!Array.prototype.indexOf)Array.prototype.indexOf=function(elt){len=this.length>>>0;from=Number(arguments[1])||0;from=from<0?Math.ceil(from):Math.floor(from);if(from<0)from+=len;for(;from<len;from++)if(from in this&&this[from]===elt)return from;return-1}}function addTrimFallbackForIE8(){if(typeof String.prototype.trim!=="function")String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g,"")}}function addFilterFallbackForIE8(){var t,len,res,thisp,i,val;if(!Array.prototype.filter)Array.prototype.filter=
40
+ function(fun){if(this===void 0||this===null)throw new TypeError;t=Object(this);len=t.length>>>0;if(typeof fun!=="function")throw new TypeError;res=[];thisp=arguments[1];for(i=0;i<len;i++)if(i in t){val=t[i];if(fun.call(thisp,val,i,t))res.push(val)}return res}}function addKeysFallbackForIE8(){var keys,i;if(!Object.keys)Object.keys=function(obj){keys=[];for(i in obj)if(obj.hasOwnProperty(i))keys.push(i);return keys}}function onHoneypotFieldChange(){var css=jQuery(this).css("box-shadow");if(css.match(/inset/))this.parentNode.removeChild(this)}
41
+ function changeFocusWhenClickComboFieldLabel(){var label;var comboInputsContainer=document.querySelectorAll(".frm_combo_inputs_container");comboInputsContainer.forEach(function(inputsContainer){if(!inputsContainer.closest(".frm_form_field"))return;label=inputsContainer.closest(".frm_form_field").querySelector(".frm_primary_label");if(!label)return;label.addEventListener("click",function(e){inputsContainer.querySelector(".frm_form_field:first-child input, .frm_form_field:first-child select, .frm_form_field:first-child textarea").focus()})})}
42
+ function checkForErrorsAndMaybeSetFocus(){var errors,element,timeoutCallback;errors=document.querySelectorAll(".frm_form_field .frm_error");if(!errors.length)return;element=errors[0];do{element=element.previousSibling;if(-1!==["input","select","textarea"].indexOf(element.nodeName.toLowerCase())){element.focus();break}if("undefined"!==typeof element.classList){if(element.classList.contains("html-active"))timeoutCallback=function(){var textarea=element.querySelector("textarea");if(null!==textarea)textarea.focus()};
43
+ else if(element.classList.contains("tmce-active"))timeoutCallback=function(){tinyMCE.activeEditor.focus()};if("function"===typeof timeoutCallback){setTimeout(timeoutCallback,0);break}}}while(element.previousSibling)}return{init:function(){jQuery(document).off("submit.formidable",".frm-show-form");jQuery(document).on("submit.formidable",".frm-show-form",frmFrontForm.submitForm);jQuery(".frm-show-form input[onblur], .frm-show-form textarea[onblur]").each(function(){if(jQuery(this).val()==="")jQuery(this).trigger("blur")});
44
+ jQuery(document).on("focus",".frm_toggle_default",clearDefault);jQuery(document).on("blur",".frm_toggle_default",replaceDefault);jQuery(".frm_toggle_default").trigger("blur");jQuery(document.getElementById("frm_resend_email")).on("click",resendEmail);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);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",
45
+ maybeShowLabel);jQuery(document).on("change","[id^=frm_email_]",onHoneypotFieldChange);jQuery(document).on("click","a[data-frmconfirm]",confirmClick);jQuery("a[data-frmtoggle]").on("click",toggleDiv);checkForErrorsAndMaybeSetFocus();changeFocusWhenClickComboFieldLabel();addIndexOfFallbackForIE8();addTrimFallbackForIE8();addFilterFallbackForIE8();addKeysFallbackForIE8()},getFieldId:function(field,fullID){return getFieldId(field,fullID)},renderRecaptcha:function(captcha){var formID,recaptchaID,size=
46
+ captcha.getAttribute("data-size"),rendered=captcha.getAttribute("data-rid")!==null,params={"sitekey":captcha.getAttribute("data-sitekey"),"size":size,"theme":captcha.getAttribute("data-theme")};if(rendered)return;if(size==="invisible"){formID=jQuery(captcha).closest("form").find('input[name="form_id"]').val();jQuery(captcha).closest(".frm_form_field .frm_primary_label").hide();params.callback=function(token){frmFrontForm.afterRecaptcha(token,formID)}}recaptchaID=grecaptcha.render(captcha.id,params);
47
+ captcha.setAttribute("data-rid",recaptchaID)},afterSingleRecaptcha:function(){var object=jQuery(".frm-show-form .g-recaptcha").closest("form")[0];frmFrontForm.submitFormNow(object)},afterRecaptcha:function(token,formID){var object=jQuery("#frm_form_"+formID+"_container form")[0];frmFrontForm.submitFormNow(object)},submitForm:function(e){frmFrontForm.submitFormManual(e,this)},submitFormManual:function(e,object){var isPro,errors,invisibleRecaptcha=hasInvisibleRecaptcha(object),classList=object.className.trim().split(/\s+/gi);
48
+ if(classList&&invisibleRecaptcha.length<1){isPro=classList.indexOf("frm_pro_form")>-1;if(!isPro)return}if(jQuery("body").hasClass("wp-admin")&&jQuery(object).closest(".frmapi-form").length<1)return;e.preventDefault();if(typeof frmProForm!=="undefined"&&typeof frmProForm.submitAllowed==="function")if(!frmProForm.submitAllowed(object))return;if(invisibleRecaptcha.length){showLoadingIndicator(jQuery(object));executeInvisibleRecaptcha(invisibleRecaptcha)}else{errors=frmFrontForm.validateFormSubmit(object);
49
+ if(Object.keys(errors).length===0){showSubmitLoading(jQuery(object));frmFrontForm.submitFormNow(object,classList)}}},submitFormNow:function(object){var hasFileFields,antispamInput,classList=object.className.trim().split(/\s+/gi);if(object.hasAttribute("data-token")&&null===object.querySelector('[name="antispam_token"]')){antispamInput=document.createElement("input");antispamInput.type="hidden";antispamInput.name="antispam_token";antispamInput.value=object.getAttribute("data-token");object.appendChild(antispamInput)}if(classList.indexOf("frm_ajax_submit")>
50
+ -1){hasFileFields=jQuery(object).find('input[type="file"]').filter(function(){return!!this.value}).length;if(hasFileFields<1){action=jQuery(object).find('input[name="frm_action"]').val();frmFrontForm.checkFormErrors(object,action)}else object.submit()}else object.submit()},validateFormSubmit:function(object){if(typeof tinyMCE!=="undefined"&&jQuery(object).find(".wp-editor-wrap").length)tinyMCE.triggerSave();jsErrors=[];if(shouldJSValidate(object)){frmFrontForm.getAjaxFormErrors(object);if(Object.keys(jsErrors).length)frmFrontForm.addAjaxFormErrors(object)}return jsErrors},
51
+ getAjaxFormErrors:function(object){var customErrors,key;jsErrors=validateForm(object);if(typeof frmThemeOverride_jsErrors==="function"){action=jQuery(object).find('input[name="frm_action"]').val();customErrors=frmThemeOverride_jsErrors(action,object);if(Object.keys(customErrors).length)for(key in customErrors)jsErrors[key]=customErrors[key]}return jsErrors},addAjaxFormErrors:function(object){var key,$fieldCont;removeAllErrors();for(key in jsErrors){$fieldCont=jQuery(object).find("#frm_field_"+key+
52
+ "_container");if($fieldCont.length)addFieldError($fieldCont,key,jsErrors);else delete jsErrors[key]}scrollToFirstField(object);checkForErrorsAndMaybeSetFocus()},checkFormErrors:function(object,action){getFormErrors(object,action)},checkRequiredField:function(field,errors){return checkRequiredField(field,errors)},showSubmitLoading:function($object){showSubmitLoading($object)},removeSubmitLoading:function($object,enable,processesRunning){removeSubmitLoading($object,enable,processesRunning)},scrollToID:function(id){var object=
53
+ jQuery(document.getElementById(id));frmFrontForm.scrollMsg(object,false)},scrollMsg:function(id,object,animate){var newPos,m,b,screenTop,screenBottom,scrollObj="";if(typeof object==="undefined"){scrollObj=jQuery(document.getElementById("frm_form_"+id+"_container"));if(scrollObj.length<1)return}else if(typeof id==="string")scrollObj=jQuery(object).find("#frm_field_"+id+"_container");else scrollObj=id;jQuery(scrollObj).trigger("focus");newPos=scrollObj.offset().top;if(!newPos||frm_js.offset==="-1")return;
54
+ newPos=newPos-frm_js.offset;m=jQuery("html").css("margin-top");b=jQuery("body").css("margin-top");if(m||b)newPos=newPos-parseInt(m)-parseInt(b);if(newPos&&window.innerHeight){screenTop=document.documentElement.scrollTop||document.body.scrollTop;screenBottom=screenTop+window.innerHeight;if(newPos>screenBottom||newPos<screenTop){if(typeof animate==="undefined")jQuery(window).scrollTop(newPos);else jQuery("html,body").animate({scrollTop:newPos},500);return false}}},fieldValueChanged:function(e){var fieldId=
55
+ frmFrontForm.getFieldId(this,false);if(!fieldId||typeof fieldId==="undefined")return;if(e.frmTriggered&&e.frmTriggered==fieldId)return;jQuery(document).trigger("frmFieldChanged",[this,fieldId,e]);if(e.selfTriggered!==true)maybeValidateChange(this)},savingDraft:function(object){console.warn("DEPRECATED: function frmFrontForm.savingDraft in v3.0 use frmProForm.savingDraft");if(typeof frmProForm!=="undefined")return frmProForm.savingDraft(object)},goingToPreviousPage:function(object){console.warn("DEPRECATED: function frmFrontForm.goingToPreviousPage in v3.0 use frmProForm.goingToPreviousPage");
56
  if(typeof frmProForm!=="undefined")return frmProForm.goingToPreviousPage(object)},hideOrShowFields:function(){console.warn("DEPRECATED: function frmFrontForm.hideOrShowFields in v3.0 use frmProForm.hideOrShowFields");if(typeof frmProForm!=="undefined")frmProForm.hideOrShowFields()},hidePreviouslyHiddenFields:function(){console.warn("DEPRECATED: function frmFrontForm.hidePreviouslyHiddenFields in v3.0 use frmProForm.hidePreviouslyHiddenFields");if(typeof frmProForm!=="undefined")frmProForm.hidePreviouslyHiddenFields()},
57
  checkDependentDynamicFields:function(ids){console.warn("DEPRECATED: function frmFrontForm.checkDependentDynamicFields in v3.0 use frmProForm.checkDependentDynamicFields");if(typeof frmProForm!=="undefined")frmProForm.checkDependentDynamicFields(ids)},checkDependentLookupFields:function(ids){console.warn("DEPRECATED: function frmFrontForm.checkDependentLookupFields in v3.0 use frmProForm.checkDependentLookupFields");if(typeof frmProForm!=="undefined")frmProForm.checkDependentLookupFields(ids)},loadGoogle:function(){console.warn("DEPRECATED: function frmFrontForm.loadGoogle in v3.0 use frmProForm.loadGoogle");
58
  frmProForm.loadGoogle()},escapeHtml:function(text){return text.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")},invisible:function(classes){jQuery(classes).css("visibility","hidden")},visible:function(classes){jQuery(classes).css("visibility","visible")}}}frmFrontForm=frmFrontFormJS();jQuery(document).ready(function(){frmFrontForm.init()});
js/formidable_admin.js CHANGED
@@ -3564,9 +3564,19 @@ function frmAdminBuildJS() {
3564
  function div( atts ) {
3565
  var element = document.createElement( 'div' );
3566
  if ( 'object' === typeof atts ) {
3567
- if ( 'undefined' !== typeof atts.id ) {
3568
  element.id = atts.id;
3569
  }
 
 
 
 
 
 
 
 
 
 
3570
  }
3571
  return element;
3572
  }
@@ -7100,6 +7110,7 @@ function frmAdminBuildJS() {
7100
  dismiss.setAttribute( 'tabindex', -1 );
7101
 
7102
  $modal = initModal( '#frm_new_form_modal', '600px' );
 
7103
  $modal.attr( 'frm-page', 'create' );
7104
  $modal.find( '#template-search-input' ).val( '' ).trigger( 'change' );
7105
  $modal.dialog( 'open' );
@@ -8277,6 +8288,465 @@ function frmAdminBuildJS() {
8277
  }
8278
  }
8279
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8280
  function initSelectionAutocomplete() {
8281
  if ( jQuery.fn.autocomplete ) {
8282
  initAutocomplete( 'page' );
@@ -8588,8 +9058,8 @@ function frmAdminBuildJS() {
8588
  }
8589
 
8590
  function initModal( id, width ) {
8591
- var $info = jQuery( id );
8592
- if ( $info.length < 1 ) {
8593
  return false;
8594
  }
8595
 
@@ -8597,7 +9067,7 @@ function frmAdminBuildJS() {
8597
  width = '550px';
8598
  }
8599
 
8600
- $info.dialog({
8601
  dialogClass: 'frm-dialog',
8602
  modal: true,
8603
  autoOpen: false,
@@ -8622,7 +9092,9 @@ function frmAdminBuildJS() {
8622
  optionType.value = '';
8623
  }
8624
  }
8625
- });
 
 
8626
 
8627
  return $info;
8628
  }
@@ -8952,6 +9424,7 @@ function frmAdminBuildJS() {
8952
  }
8953
 
8954
  loadTooltips();
 
8955
  initUpgradeModal();
8956
 
8957
  // used on build, form settings, and view settings
3564
  function div( atts ) {
3565
  var element = document.createElement( 'div' );
3566
  if ( 'object' === typeof atts ) {
3567
+ if ( 'string' === typeof atts.id ) {
3568
  element.id = atts.id;
3569
  }
3570
+ if ( 'string' === typeof atts.class ) {
3571
+ element.className = atts.class;
3572
+ }
3573
+ if ( 'object' === typeof atts.child ) {
3574
+ element.appendChild( atts.child );
3575
+ } else if ( 'undefined' !== typeof atts.children ) {
3576
+ atts.children.forEach( child => element.appendChild( child ) );
3577
+ } else if ( 'undefined' !== typeof atts.text ) {
3578
+ element.appendChild( document.createTextNode( atts.text ) );
3579
+ }
3580
  }
3581
  return element;
3582
  }
7110
  dismiss.setAttribute( 'tabindex', -1 );
7111
 
7112
  $modal = initModal( '#frm_new_form_modal', '600px' );
7113
+ offsetModalY( $modal, '50px' );
7114
  $modal.attr( 'frm-page', 'create' );
7115
  $modal.find( '#template-search-input' ).val( '' ).trigger( 'change' );
7116
  $modal.dialog( 'open' );
8288
  }
8289
  }
8290
 
8291
+ function initEmbedFormModal() {
8292
+ document.addEventListener( 'click', listenForFormEmbedClick );
8293
+ }
8294
+
8295
+ function listenForFormEmbedClick( event ) {
8296
+ var clicked = false;
8297
+
8298
+ const element = event.target;
8299
+ const tag = element.tagName.toLowerCase();
8300
+
8301
+ switch ( tag ) {
8302
+ case 'a':
8303
+ clicked = 'frm-embed-action' === element.id || element.classList.contains( 'frm-embed-form' );
8304
+ break;
8305
+
8306
+ case 'svg':
8307
+ clicked = element.parentNode.classList.contains( 'frm-embed-form' );
8308
+ break;
8309
+ }
8310
+
8311
+ if ( clicked ) {
8312
+ event.preventDefault();
8313
+
8314
+ const row = element.closest( 'tr' );
8315
+ let formId, formKey;
8316
+
8317
+ if ( row ) {
8318
+ formId = parseInt( row.querySelector( '.column-id' ).textContent );
8319
+ formKey = row.querySelector( '.column-form_key' ).textContent;
8320
+ } else {
8321
+ formId = document.getElementById( 'form_id' ).value;
8322
+
8323
+ const formKeyInput = document.getElementById( 'frm_form_key' );
8324
+ if ( formKeyInput ) {
8325
+ formKey = formKeyInput.value;
8326
+ } else {
8327
+ const previewDrop = document.getElementById( 'frm-previewDrop' );
8328
+ if ( previewDrop ) {
8329
+ formKey = previewDrop.nextElementSibling.querySelector( 'li a' ).getAttribute( 'href' ).split( 'form=' )[1];
8330
+ }
8331
+ }
8332
+ }
8333
+
8334
+ openFormEmbedModal( formId, formKey );
8335
+ }
8336
+ }
8337
+
8338
+ function openFormEmbedModal( formId, formKey ) {
8339
+ const modalId = 'frm_form_embed_modal';
8340
+
8341
+ let modal = document.getElementById( modalId );
8342
+
8343
+ if ( ! modal ) {
8344
+ modal = createEmptyModal( modalId );
8345
+ modal.classList.add( 'frm_common_modal' );
8346
+
8347
+ const title = div({ child: document.createTextNode( __( 'Embed form', 'formidable' ) ), class: 'frm-modal-title' });
8348
+
8349
+ const a = document.createElement( 'a' );
8350
+ a.textContent = __( 'Cancel', 'formidable' );
8351
+ a.className = 'dismiss';
8352
+
8353
+ const postbox = modal.querySelector( '.postbox' );
8354
+
8355
+ postbox.appendChild(
8356
+ div({
8357
+ class: 'frm_modal_top',
8358
+ children: [
8359
+ title,
8360
+ div({ child: a })
8361
+ ]
8362
+ })
8363
+ );
8364
+ postbox.appendChild(
8365
+ div({ class: 'frm_modal_content' })
8366
+ );
8367
+ postbox.appendChild(
8368
+ div({ class: 'frm_modal_footer' })
8369
+ );
8370
+ } else {
8371
+ modal.classList.remove( 'frm-on-page-2' );
8372
+ }
8373
+
8374
+ const content = modal.querySelector( '.frm_modal_content' );
8375
+ content.innerHTML = '';
8376
+ content.appendChild( getEmbedFormModalOptions( formId, formKey ) );
8377
+
8378
+ const footer = modal.querySelector( '.frm_modal_footer' );
8379
+ if ( ! footer.querySelector( 'a' ) ) {
8380
+ const doneButton = document.createElement( 'a' );
8381
+ doneButton.textContent = __( 'Done', 'formidable' );
8382
+ doneButton.className = 'button button-primary frm-button-primary dismiss';
8383
+ doneButton.href = '#';
8384
+ footer.appendChild( doneButton );
8385
+
8386
+ const cancelButton = document.createElement( 'a' );
8387
+ cancelButton.href = '#';
8388
+ cancelButton.className = 'button button-secondary frm-modal-cancel';
8389
+ cancelButton.textContent = __( 'Back', 'formidable' );
8390
+ cancelButton.addEventListener(
8391
+ 'click',
8392
+ function( event ) {
8393
+ event.preventDefault();
8394
+ openFormEmbedModal( formId, formKey );
8395
+ }
8396
+ );
8397
+ footer.appendChild( cancelButton );
8398
+ } else {
8399
+ const doneButton = modal.querySelector( '.frm_modal_footer .button-primary' );
8400
+ doneButton.textContent = __( 'Done', 'formidable' );
8401
+ doneButton.parentNode.replaceChild( doneButton.cloneNode( true ), doneButton );
8402
+ }
8403
+
8404
+ const $modal = jQuery( modal );
8405
+ if ( ! $modal.hasClass( 'frm-dialog' ) ) {
8406
+ initModal( $modal );
8407
+ }
8408
+
8409
+ offsetModalY( $modal, '50px' );
8410
+
8411
+ scrollToTop();
8412
+ $modal.dialog( 'open' );
8413
+
8414
+ $modal.parent().addClass( 'frm-embed-form-modal-wrapper' );
8415
+ }
8416
+
8417
+ function createEmptyModal( id ) {
8418
+ const modal = div({ id: id, class: 'frm-modal' });
8419
+ const postbox = div({ class: 'postbox' });
8420
+ const metaboxHolder = div({ class: 'metabox-holder', child: postbox });
8421
+ modal.appendChild( metaboxHolder );
8422
+ document.body.appendChild( modal );
8423
+ return modal;
8424
+ }
8425
+
8426
+ function scrollToTop() {
8427
+ if ( 'scrollRestoration' in history ) {
8428
+ history.scrollRestoration = 'manual';
8429
+ }
8430
+ window.scrollTo( 0, 0 );
8431
+ }
8432
+
8433
+ function offsetModalY( $modal, amount ) {
8434
+ const position = {
8435
+ my: 'top',
8436
+ at: 'top+' + amount,
8437
+ of: window
8438
+ };
8439
+ $modal.dialog( 'option', 'position', position );
8440
+ }
8441
+
8442
+ function getEmbedFormModalOptions( form