Version Description
- Add frm_action_triggers hook for adding custom triggers into the actions
- Add frm_{action name here}_action_options hook so any action can be altered
- Prevent extra form actions when a form is duplicated
- Load correct version of formidable.js based on wp-config debugging constant (Thanks @naomicbush for the contributions!)
- Revert get_sortable_columns changes for < WP 4.0 support
- Pro Features:
- Allow calculations inside repeating sections and embedded forms
- Set default values for conditional checkboxes and radio fields and inside conditional sections
- A few changes to the way section fields create divs
Download this release
Release Info
Developer | sswells |
Plugin | Formidable Forms – Form Builder for WordPress |
Version | 2.0.10 |
Comparing to | |
See all releases |
Code changes from version 2.0.09 to 2.0.10
- classes/controllers/FrmEntriesController.php +24 -0
- classes/controllers/FrmFormsController.php +13 -1
- classes/helpers/FrmAppHelper.php +1 -1
- classes/helpers/FrmEntriesListHelper.php +0 -23
- classes/helpers/FrmFormsListHelper.php +0 -10
- classes/models/FrmDb.php +4 -2
- classes/models/FrmFormAction.php +2 -1
- classes/views/frm-entries/form.php +6 -0
- classes/views/frm-form-actions/_action_inside.php +2 -2
- classes/views/frm-forms/add_field.php +14 -9
- css/_single_theme.css.php +3 -0
- css/custom_theme.css.php +6 -0
- css/frm_admin.css +15 -2
- formidable.php +1 -1
- js/formidable.js +1990 -0
- js/formidable.min.js +55 -53
- readme.txt +12 -1
classes/controllers/FrmEntriesController.php
CHANGED
@@ -11,6 +11,7 @@ class FrmEntriesController {
|
|
11 |
$frm_settings = FrmAppHelper::get_settings();
|
12 |
add_filter( 'manage_' . sanitize_title( $frm_settings->menu ) . '_page_formidable-entries_columns', 'FrmEntriesController::manage_columns' );
|
13 |
add_filter( 'get_user_option_manage' . sanitize_title( $frm_settings->menu ) . '_page_formidable-entriescolumnshidden', 'FrmEntriesController::hidden_columns' );
|
|
|
14 |
}
|
15 |
}
|
16 |
|
@@ -195,6 +196,29 @@ class FrmEntriesController {
|
|
195 |
return $save;
|
196 |
}
|
197 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
198 |
public static function hidden_columns($result) {
|
199 |
global $frm_vars;
|
200 |
|
11 |
$frm_settings = FrmAppHelper::get_settings();
|
12 |
add_filter( 'manage_' . sanitize_title( $frm_settings->menu ) . '_page_formidable-entries_columns', 'FrmEntriesController::manage_columns' );
|
13 |
add_filter( 'get_user_option_manage' . sanitize_title( $frm_settings->menu ) . '_page_formidable-entriescolumnshidden', 'FrmEntriesController::hidden_columns' );
|
14 |
+
add_filter( 'manage_' . sanitize_title( $frm_settings->menu ) . '_page_formidable-entries_sortable_columns', 'FrmEntriesController::sortable_columns' );
|
15 |
}
|
16 |
}
|
17 |
|
196 |
return $save;
|
197 |
}
|
198 |
|
199 |
+
public static function sortable_columns() {
|
200 |
+
$form_id = FrmForm::get_current_form_id();
|
201 |
+
$fields = FrmField::get_all_for_form( $form_id );
|
202 |
+
|
203 |
+
$columns = array(
|
204 |
+
$form_id . '_id' => 'id',
|
205 |
+
$form_id . '_created_at' => 'created_at',
|
206 |
+
$form_id . '_updated_at' => 'updated_at',
|
207 |
+
$form_id . '_ip' => 'ip',
|
208 |
+
$form_id . '_item_key' => 'item_key',
|
209 |
+
$form_id . '_is_draft' => 'is_draft',
|
210 |
+
);
|
211 |
+
|
212 |
+
foreach ( $fields as $field ) {
|
213 |
+
if ( $field->type != 'checkbox' && ( ! isset( $field->field_options['post_field'] ) || $field->field_options['post_field'] == '' ) ) {
|
214 |
+
// Can't sort on checkboxes because they are stored serialized, or post fields
|
215 |
+
$columns[ $form_id . '_' . $field->field_key ] = 'meta_' . $field->id;
|
216 |
+
}
|
217 |
+
}
|
218 |
+
|
219 |
+
return $columns;
|
220 |
+
}
|
221 |
+
|
222 |
public static function hidden_columns($result) {
|
223 |
global $frm_vars;
|
224 |
|
classes/controllers/FrmFormsController.php
CHANGED
@@ -8,6 +8,7 @@ class FrmFormsController {
|
|
8 |
add_filter('get_user_option_managetoplevel_page_formidablecolumnshidden', 'FrmFormsController::hidden_columns' );
|
9 |
|
10 |
add_filter('manage_toplevel_page_formidable_columns', 'FrmFormsController::get_columns', 0 );
|
|
|
11 |
}
|
12 |
|
13 |
public static function head() {
|
@@ -522,6 +523,16 @@ class FrmFormsController {
|
|
522 |
return $columns;
|
523 |
}
|
524 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
525 |
public static function hidden_columns( $result ) {
|
526 |
$return = false;
|
527 |
foreach ( (array) $result as $r ) {
|
@@ -1151,7 +1162,8 @@ class FrmFormsController {
|
|
1151 |
|
1152 |
public static function front_head() {
|
1153 |
$version = FrmAppHelper::plugin_version();
|
1154 |
-
|
|
|
1155 |
wp_register_script( 'jquery-placeholder', FrmAppHelper::plugin_url() . '/js/jquery/jquery.placeholder.js', array( 'jquery' ), '2.0.7', true );
|
1156 |
|
1157 |
if ( FrmAppHelper::is_admin() ) {
|
8 |
add_filter('get_user_option_managetoplevel_page_formidablecolumnshidden', 'FrmFormsController::hidden_columns' );
|
9 |
|
10 |
add_filter('manage_toplevel_page_formidable_columns', 'FrmFormsController::get_columns', 0 );
|
11 |
+
add_filter('manage_toplevel_page_formidable_sortable_columns', 'FrmFormsController::get_sortable_columns' );
|
12 |
}
|
13 |
|
14 |
public static function head() {
|
523 |
return $columns;
|
524 |
}
|
525 |
|
526 |
+
public static function get_sortable_columns() {
|
527 |
+
return array(
|
528 |
+
'id' => 'id',
|
529 |
+
'name' => 'name',
|
530 |
+
'description' => 'description',
|
531 |
+
'form_key' => 'form_key',
|
532 |
+
'created_at' => 'created_at',
|
533 |
+
);
|
534 |
+
}
|
535 |
+
|
536 |
public static function hidden_columns( $result ) {
|
537 |
$return = false;
|
538 |
foreach ( (array) $result as $r ) {
|
1162 |
|
1163 |
public static function front_head() {
|
1164 |
$version = FrmAppHelper::plugin_version();
|
1165 |
+
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
|
1166 |
+
wp_register_script( 'formidable', FrmAppHelper::plugin_url() . "/js/formidable{$suffix}.js", array( 'jquery' ), $version, true );
|
1167 |
wp_register_script( 'jquery-placeholder', FrmAppHelper::plugin_url() . '/js/jquery/jquery.placeholder.js', array( 'jquery' ), '2.0.7', true );
|
1168 |
|
1169 |
if ( FrmAppHelper::is_admin() ) {
|
classes/helpers/FrmAppHelper.php
CHANGED
@@ -10,7 +10,7 @@ class FrmAppHelper {
|
|
10 |
/**
|
11 |
* @since 2.0
|
12 |
*/
|
13 |
-
public static $plug_version = '2.0.
|
14 |
|
15 |
/**
|
16 |
* @since 1.07.02
|
10 |
/**
|
11 |
* @since 2.0
|
12 |
*/
|
13 |
+
public static $plug_version = '2.0.10';
|
14 |
|
15 |
/**
|
16 |
* @since 1.07.02
|
classes/helpers/FrmEntriesListHelper.php
CHANGED
@@ -73,29 +73,6 @@ class FrmEntriesListHelper extends FrmListHelper {
|
|
73 |
// Searching is a pro feature
|
74 |
}
|
75 |
|
76 |
-
protected function get_sortable_columns() {
|
77 |
-
$form_id = FrmForm::get_current_form_id();
|
78 |
-
$fields = FrmField::get_all_for_form( $form_id );
|
79 |
-
|
80 |
-
$columns = array(
|
81 |
-
$form_id . '_id' => 'id',
|
82 |
-
$form_id . '_created_at' => 'created_at',
|
83 |
-
$form_id . '_updated_at' => 'updated_at',
|
84 |
-
$form_id . '_ip' => 'ip',
|
85 |
-
$form_id . '_item_key' => 'item_key',
|
86 |
-
$form_id . '_is_draft' => 'is_draft',
|
87 |
-
);
|
88 |
-
|
89 |
-
foreach ( $fields as $field ) {
|
90 |
-
if ( $field->type != 'checkbox' && ( ! isset( $field->field_options['post_field'] ) || $field->field_options['post_field'] == '' ) ) {
|
91 |
-
// Can't sort on checkboxes because they are stored serialized, or post fields
|
92 |
-
$columns[ $form_id . '_' . $field->field_key ] = 'meta_' . $field->id;
|
93 |
-
}
|
94 |
-
}
|
95 |
-
|
96 |
-
return $columns;
|
97 |
-
}
|
98 |
-
|
99 |
public function single_row( $item, $style = '' ) {
|
100 |
// Set up the hover actions for this user
|
101 |
$actions = array();
|
73 |
// Searching is a pro feature
|
74 |
}
|
75 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
76 |
public function single_row( $item, $style = '' ) {
|
77 |
// Set up the hover actions for this user
|
78 |
$actions = array();
|
classes/helpers/FrmFormsListHelper.php
CHANGED
@@ -158,16 +158,6 @@ class FrmFormsListHelper extends FrmListHelper {
|
|
158 |
<?php
|
159 |
}
|
160 |
|
161 |
-
protected function get_sortable_columns() {
|
162 |
-
return array(
|
163 |
-
'id' => 'id',
|
164 |
-
'name' => 'name',
|
165 |
-
'description' => 'description',
|
166 |
-
'form_key' => 'form_key',
|
167 |
-
'created_at' => 'created_at',
|
168 |
-
);
|
169 |
-
}
|
170 |
-
|
171 |
public function get_views() {
|
172 |
|
173 |
$statuses = array(
|
158 |
<?php
|
159 |
}
|
160 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
161 |
public function get_views() {
|
162 |
|
163 |
$statuses = array(
|
classes/models/FrmDb.php
CHANGED
@@ -46,8 +46,10 @@ class FrmDb {
|
|
46 |
do_action('frm_after_install');
|
47 |
|
48 |
/**** update the styling settings ****/
|
49 |
-
|
50 |
-
|
|
|
|
|
51 |
}
|
52 |
|
53 |
public function collation() {
|
46 |
do_action('frm_after_install');
|
47 |
|
48 |
/**** update the styling settings ****/
|
49 |
+
if ( is_admin() ) {
|
50 |
+
$frm_style = new FrmStyle();
|
51 |
+
$frm_style->update( 'default' );
|
52 |
+
}
|
53 |
}
|
54 |
|
55 |
public function collation() {
|
classes/models/FrmFormAction.php
CHANGED
@@ -88,6 +88,7 @@ class FrmFormAction {
|
|
88 |
'tooltip' => $name,
|
89 |
);
|
90 |
|
|
|
91 |
$this->action_options = wp_parse_args( $action_options, $default_options );
|
92 |
$this->control_options = wp_parse_args( $control_options, array( 'id_base' => $this->id_base ) );
|
93 |
}
|
@@ -175,7 +176,7 @@ class FrmFormAction {
|
|
175 |
}
|
176 |
|
177 |
$this->form_id = $old_id;
|
178 |
-
$actions = $this->get_all();
|
179 |
|
180 |
$this->form_id = $form_id;
|
181 |
foreach ( $actions as $action ) {
|
88 |
'tooltip' => $name,
|
89 |
);
|
90 |
|
91 |
+
$action_options = apply_filters( 'frm_' . $id_base . '_action_options', $action_options );
|
92 |
$this->action_options = wp_parse_args( $action_options, $default_options );
|
93 |
$this->control_options = wp_parse_args( $control_options, array( 'id_base' => $this->id_base ) );
|
94 |
}
|
176 |
}
|
177 |
|
178 |
$this->form_id = $old_id;
|
179 |
+
$actions = $this->get_all( $old_id );
|
180 |
|
181 |
$this->form_id = $form_id;
|
182 |
foreach ( $actions as $action ) {
|
classes/views/frm-entries/form.php
CHANGED
@@ -38,6 +38,12 @@ if ( FrmAppHelper::is_admin() && ! $frm_settings->lock_keys ) { ?>
|
|
38 |
do_action('frm_entry_form', $form, $form_action, $errors);
|
39 |
|
40 |
global $frm_vars;
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
// close open collapsible toggle div
|
42 |
if ( isset($frm_vars['collapse_div']) && $frm_vars['collapse_div'] ) {
|
43 |
echo "</div>\n";
|
38 |
do_action('frm_entry_form', $form, $form_action, $errors);
|
39 |
|
40 |
global $frm_vars;
|
41 |
+
// close open section div
|
42 |
+
if ( isset( $frm_vars['div'] ) && $frm_vars['div'] ) {
|
43 |
+
echo "</div>\n";
|
44 |
+
unset( $frm_vars['div'] );
|
45 |
+
}
|
46 |
+
|
47 |
// close open collapsible toggle div
|
48 |
if ( isset($frm_vars['collapse_div']) && $frm_vars['collapse_div'] ) {
|
49 |
echo "</div>\n";
|
classes/views/frm-form-actions/_action_inside.php
CHANGED
@@ -32,11 +32,11 @@ if ( count( $action_control->action_options['event'] ) == 1 || $action_control->
|
|
32 |
?>
|
33 |
<p><label><?php _e( 'Trigger this action after', 'formidable' ) ?></label>
|
34 |
<?php
|
35 |
-
$event_labels = array(
|
36 |
'create' => __( 'Create', 'formidable' ),
|
37 |
'update' => __( 'Update', 'formidable' ),
|
38 |
'delete' => __( 'Delete', 'formidable' ),
|
39 |
-
);
|
40 |
|
41 |
foreach ( $action_control->action_options['event'] as $event ) { ?>
|
42 |
<label for="frm_action_event_<?php echo esc_attr( $event ) ?>" class="frm_action_events">
|
32 |
?>
|
33 |
<p><label><?php _e( 'Trigger this action after', 'formidable' ) ?></label>
|
34 |
<?php
|
35 |
+
$event_labels = apply_filters( 'frm_action_triggers', array(
|
36 |
'create' => __( 'Create', 'formidable' ),
|
37 |
'update' => __( 'Update', 'formidable' ),
|
38 |
'delete' => __( 'Delete', 'formidable' ),
|
39 |
+
) );
|
40 |
|
41 |
foreach ( $action_control->action_options['event'] as $event ) { ?>
|
42 |
<label for="frm_action_event_<?php echo esc_attr( $event ) ?>" class="frm_action_events">
|
classes/views/frm-forms/add_field.php
CHANGED
@@ -158,16 +158,8 @@ if ( $display['options'] ) { ?>
|
|
158 |
<div class="widget-inside">
|
159 |
<table class="form-table frm_clear_none">
|
160 |
<?php $field_types = FrmFieldsHelper::get_field_types($field['type']); ?>
|
161 |
-
|
162 |
<td>
|
163 |
-
<div class="hide-if-no-js edit-slug-box frm_help" title="<?php esc_attr_e( 'The field key can be used as an alternative to the field ID in many cases.', 'formidable' ) ?>">
|
164 |
-
<?php _e( 'Field Key:', 'formidable' ) ?>
|
165 |
-
<div class="<?php echo $frm_settings->lock_keys ? 'frm_field_key' : 'frm_ipe_field_key" title="'. esc_attr( __( 'Click to edit.', 'formidable' ) ); ?>" ><?php echo esc_html( $field['field_key'] ); ?></div>
|
166 |
-
<?php if ( ! $frm_settings->lock_keys ) { ?>
|
167 |
-
<input type="hidden" name="field_options[field_key_<?php echo esc_attr( $field['id'] ) ?>]" value="<?php echo esc_attr( $field['field_key'] ); ?>" />
|
168 |
-
<?php } ?>
|
169 |
-
</div>
|
170 |
-
|
171 |
<select <?php if ( count($field_types) == 1 ) { ?>disabled="disabled"<?php } else { ?>name="field_options[type_<?php echo esc_attr( $field['id'] ) ?>]"<?php } ?>>
|
172 |
<?php
|
173 |
foreach ( $field_types as $fkey => $ftype ) { ?>
|
@@ -212,6 +204,19 @@ if ( $display['options'] ) { ?>
|
|
212 |
<?php } ?>
|
213 |
</td>
|
214 |
</tr>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
215 |
|
216 |
<?php
|
217 |
if ( $display['css'] ) { ?>
|
158 |
<div class="widget-inside">
|
159 |
<table class="form-table frm_clear_none">
|
160 |
<?php $field_types = FrmFieldsHelper::get_field_types($field['type']); ?>
|
161 |
+
<tr><td class="frm_150_width"><label><?php _e( 'Field Type', 'formidable' ) ?></label></td>
|
162 |
<td>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
163 |
<select <?php if ( count($field_types) == 1 ) { ?>disabled="disabled"<?php } else { ?>name="field_options[type_<?php echo esc_attr( $field['id'] ) ?>]"<?php } ?>>
|
164 |
<?php
|
165 |
foreach ( $field_types as $fkey => $ftype ) { ?>
|
204 |
<?php } ?>
|
205 |
</td>
|
206 |
</tr>
|
207 |
+
<tr>
|
208 |
+
<td class="frm_150_width">
|
209 |
+
<div class="hide-if-no-js edit-slug-box frm_help" title="<?php esc_attr_e( 'The field key can be used as an alternative to the field ID in many cases.', 'formidable' ) ?>">
|
210 |
+
<?php _e( 'Field Key', 'formidable' ) ?>
|
211 |
+
</td>
|
212 |
+
<td>
|
213 |
+
<div class="<?php echo $frm_settings->lock_keys ? 'frm_field_key' : 'frm_ipe_field_key" title="'. esc_attr( __( 'Click to edit.', 'formidable' ) ); ?>" ><?php echo esc_html( $field['field_key'] ); ?></div>
|
214 |
+
<?php if ( ! $frm_settings->lock_keys ) { ?>
|
215 |
+
<input type="hidden" name="field_options[field_key_<?php echo esc_attr( $field['id'] ) ?>]" value="<?php echo esc_attr( $field['field_key'] ); ?>" />
|
216 |
+
<?php } ?>
|
217 |
+
</div>
|
218 |
+
</td>
|
219 |
+
</tr>
|
220 |
|
221 |
<?php
|
222 |
if ( $display['css'] ) { ?>
|
css/_single_theme.css.php
CHANGED
@@ -248,6 +248,9 @@ if ( ! isset($collapse_icon) ) {
|
|
248 |
.<?php echo $style_class ?> .frm_inline_container label.frm_primary_label,
|
249 |
.<?php echo $style_class ?> .frm_inline_container:not(.frm_dynamic_select_container) .frm_opt_container{
|
250 |
display:inline<?php echo $important ?>;
|
|
|
|
|
|
|
251 |
margin-right:10px<?php echo $important ?>;
|
252 |
}
|
253 |
|
248 |
.<?php echo $style_class ?> .frm_inline_container label.frm_primary_label,
|
249 |
.<?php echo $style_class ?> .frm_inline_container:not(.frm_dynamic_select_container) .frm_opt_container{
|
250 |
display:inline<?php echo $important ?>;
|
251 |
+
}
|
252 |
+
|
253 |
+
.<?php echo $style_class ?> .frm_inline_container.frm_scale_container label.frm_primary_label{
|
254 |
margin-right:10px<?php echo $important ?>;
|
255 |
}
|
256 |
|
css/custom_theme.css.php
CHANGED
@@ -63,6 +63,12 @@ legend.frm_hidden{
|
|
63 |
width:auto;
|
64 |
}
|
65 |
|
|
|
|
|
|
|
|
|
|
|
|
|
66 |
.with_frm_style .frm_right_container label.frm_primary_label,
|
67 |
.with_frm_style .frm_pos_right{
|
68 |
display:inline;
|
63 |
width:auto;
|
64 |
}
|
65 |
|
66 |
+
.with_frm_style .frm_inline_container label.frm_primary_label,
|
67 |
+
.with_frm_style .frm_inline_container:not(.frm_dynamic_select_container) .frm_opt_container{
|
68 |
+
display:inline;
|
69 |
+
margin-right:10px;
|
70 |
+
}
|
71 |
+
|
72 |
.with_frm_style .frm_right_container label.frm_primary_label,
|
73 |
.with_frm_style .frm_pos_right{
|
74 |
display:inline;
|
css/frm_admin.css
CHANGED
@@ -669,6 +669,16 @@ textarea.inplace_field{
|
|
669 |
border: 1px solid #DDD;
|
670 |
cursor:text;
|
671 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
672 |
.frm_ipe_form_key.editInPlace-active, .frm_ipe_field_key.editInPlace-active{
|
673 |
white-space:normal;
|
674 |
width:auto;
|
@@ -716,8 +726,7 @@ textarea.inplace_field{
|
|
716 |
/* End In place edit */
|
717 |
|
718 |
.frm_field_key{background-color:#F7F7F7;}
|
719 |
-
|
720 |
-
.edit-slug-box{color:#777;}
|
721 |
#frm_form_editor_container #edit-slug-box {padding:0;}
|
722 |
table td, .form-table tr td{vertical-align:top;}
|
723 |
|
@@ -2076,6 +2085,10 @@ Responsive Design
|
|
2076 |
background: none;
|
2077 |
border:none;
|
2078 |
}
|
|
|
|
|
|
|
|
|
2079 |
}
|
2080 |
@media only screen and (max-width: 1050px) {
|
2081 |
.frm_drag_inst{font-size: 20px;}
|
669 |
border: 1px solid #DDD;
|
670 |
cursor:text;
|
671 |
}
|
672 |
+
.frm_ipe_field_key,
|
673 |
+
.frm_field_key {
|
674 |
+
float: none;
|
675 |
+
margin: 1px;
|
676 |
+
padding: 3px 5px;
|
677 |
+
width:14em;
|
678 |
+
}
|
679 |
+
.frm_ipe_field_key .inplace_field {
|
680 |
+
width: 14.5em !important;
|
681 |
+
}
|
682 |
.frm_ipe_form_key.editInPlace-active, .frm_ipe_field_key.editInPlace-active{
|
683 |
white-space:normal;
|
684 |
width:auto;
|
726 |
/* End In place edit */
|
727 |
|
728 |
.frm_field_key{background-color:#F7F7F7;}
|
729 |
+
|
|
|
730 |
#frm_form_editor_container #edit-slug-box {padding:0;}
|
731 |
table td, .form-table tr td{vertical-align:top;}
|
732 |
|
2085 |
background: none;
|
2086 |
border:none;
|
2087 |
}
|
2088 |
+
.frm_inline_label {
|
2089 |
+
display: block;
|
2090 |
+
margin: 5px 0;
|
2091 |
+
}
|
2092 |
}
|
2093 |
@media only screen and (max-width: 1050px) {
|
2094 |
.frm_drag_inst{font-size: 20px;}
|
formidable.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
/*
|
3 |
Plugin Name: Formidable
|
4 |
Description: Quickly and easily create drag-and-drop forms
|
5 |
-
Version: 2.0.
|
6 |
Plugin URI: http://formidablepro.com/
|
7 |
Author URI: http://strategy11.com
|
8 |
Author: Strategy11
|
2 |
/*
|
3 |
Plugin Name: Formidable
|
4 |
Description: Quickly and easily create drag-and-drop forms
|
5 |
+
Version: 2.0.10
|
6 |
Plugin URI: http://formidablepro.com/
|
7 |
Author URI: http://strategy11.com
|
8 |
Author: Strategy11
|
js/formidable.js
ADDED
@@ -0,0 +1,1990 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
function frmFrontFormJS(){
|
2 |
+
'use strict';
|
3 |
+
var show_fields = [];
|
4 |
+
var hide_later = [];
|
5 |
+
var hidden_fields = [];
|
6 |
+
var frm_checked_dep = [];
|
7 |
+
var addingRow = '';
|
8 |
+
var action = '';
|
9 |
+
var jsErrors = [];
|
10 |
+
|
11 |
+
function setNextPage(e){
|
12 |
+
/*jshint validthis:true */
|
13 |
+
var $thisObj = jQuery(this);
|
14 |
+
var thisType = $thisObj.attr('type');
|
15 |
+
if ( thisType !== 'submit' ) {
|
16 |
+
e.preventDefault();
|
17 |
+
}
|
18 |
+
|
19 |
+
var f = $thisObj.parents('form:first');
|
20 |
+
var v = '';
|
21 |
+
var d = '';
|
22 |
+
var thisName = this.name;
|
23 |
+
if ( thisName === 'frm_prev_page' || this.className.indexOf('frm_prev_page') !== -1 ) {
|
24 |
+
v = jQuery(f).find('.frm_next_page').attr('id').replace('frm_next_p_', '');
|
25 |
+
} else if ( thisName === 'frm_save_draft' || this.className.indexOf('frm_save_draft') !== -1 ) {
|
26 |
+
d = 1;
|
27 |
+
}
|
28 |
+
|
29 |
+
jQuery('.frm_next_page').val(v);
|
30 |
+
jQuery('.frm_saving_draft').val(d);
|
31 |
+
|
32 |
+
if ( thisType !== 'submit' ) {
|
33 |
+
f.trigger('submit');
|
34 |
+
}
|
35 |
+
}
|
36 |
+
|
37 |
+
function toggleSection(){
|
38 |
+
/*jshint validthis:true */
|
39 |
+
jQuery(this).parent().children('.frm_toggle_container').slideToggle('fast');
|
40 |
+
jQuery(this).toggleClass('active').children('.ui-icon-triangle-1-e, .ui-icon-triangle-1-s')
|
41 |
+
.toggleClass('ui-icon-triangle-1-s ui-icon-triangle-1-e');
|
42 |
+
}
|
43 |
+
|
44 |
+
// Remove the frm_transparent class from a single file upload field when it changes
|
45 |
+
// Hide the old file when a new file is uploaded
|
46 |
+
function showFileUploadText(){
|
47 |
+
/*jshint validthis:true */
|
48 |
+
this.className = this.className.replace( 'frm_transparent', '');
|
49 |
+
var currentClass = this.parentNode.getElementsByTagName('a')[0].className;
|
50 |
+
if ( currentClass.indexOf('frm_clear_file_link') == -1 ) {
|
51 |
+
currentClass += ' frm_hidden';
|
52 |
+
}
|
53 |
+
}
|
54 |
+
|
55 |
+
/**
|
56 |
+
* Show "Other" text box when Other item is checked/selected
|
57 |
+
* Hide and clear text box when item is unchecked/unselected
|
58 |
+
*/
|
59 |
+
function showOtherText(){
|
60 |
+
/*jshint validthis:true */
|
61 |
+
var type = this.type;
|
62 |
+
var other = false;
|
63 |
+
var select = false;
|
64 |
+
|
65 |
+
// Dropdowns
|
66 |
+
if ( type === 'select-one' ) {
|
67 |
+
select = true;
|
68 |
+
var curOpt = this.options[this.selectedIndex];
|
69 |
+
if ( curOpt.className === 'frm_other_trigger' ) {
|
70 |
+
other = true;
|
71 |
+
}
|
72 |
+
} else if ( type === 'select-multiple' ) {
|
73 |
+
select = true;
|
74 |
+
var allOpts = this.options;
|
75 |
+
other = false;
|
76 |
+
for ( var i = 0; i < allOpts.length; i++ ) {
|
77 |
+
if ( allOpts[i].className === 'frm_other_trigger' ) {
|
78 |
+
if ( allOpts[i].selected ) {
|
79 |
+
other = true;
|
80 |
+
break;
|
81 |
+
}
|
82 |
+
}
|
83 |
+
}
|
84 |
+
}
|
85 |
+
if ( select ) {
|
86 |
+
var otherField = jQuery(this).parent().children('.frm_other_input');
|
87 |
+
|
88 |
+
if ( other ) {
|
89 |
+
// Remove frm_pos_none
|
90 |
+
otherField[0].className = otherField[0].className.replace( 'frm_pos_none', '' );
|
91 |
+
} else {
|
92 |
+
// Add frm_pos_none
|
93 |
+
if ( otherField[0].className.indexOf( 'frm_pos_none' ) < 1 ) {
|
94 |
+
otherField[0].className = otherField[0].className + ' frm_pos_none';
|
95 |
+
}
|
96 |
+
otherField[0].value = '';
|
97 |
+
}
|
98 |
+
|
99 |
+
// Radio
|
100 |
+
} else if ( type === 'radio' ) {
|
101 |
+
if ( jQuery(this).is(':checked' ) ) {
|
102 |
+
jQuery(this).closest('.frm_radio').children('.frm_other_input').removeClass('frm_pos_none');
|
103 |
+
jQuery(this).closest('.frm_radio').siblings().children('.frm_other_input').addClass('frm_pos_none').val('');
|
104 |
+
}
|
105 |
+
// Checkboxes
|
106 |
+
} else if ( type === 'checkbox' ) {
|
107 |
+
if ( this.checked ) {
|
108 |
+
jQuery(this).closest('.frm_checkbox').children('.frm_other_input').removeClass('frm_pos_none');
|
109 |
+
} else {
|
110 |
+
jQuery(this).closest('.frm_checkbox').children('.frm_other_input').addClass('frm_pos_none').val('');
|
111 |
+
}
|
112 |
+
}
|
113 |
+
}
|
114 |
+
|
115 |
+
function maybeCheckDependent(e){
|
116 |
+
/*jshint validthis:true */
|
117 |
+
|
118 |
+
var field_id = getFieldId( this );
|
119 |
+
if ( ! field_id || typeof field_id === 'undefined' ) {
|
120 |
+
return;
|
121 |
+
}
|
122 |
+
|
123 |
+
var reset = 'reset';
|
124 |
+
if ( e.frmTriggered ) {
|
125 |
+
if ( e.frmTriggered == field_id ) {
|
126 |
+
return;
|
127 |
+
}
|
128 |
+
reset = 'persist';
|
129 |
+
}
|
130 |
+
|
131 |
+
checkDependentField('und', field_id, null, jQuery(this), reset);
|
132 |
+
doCalculation(field_id, jQuery(this));
|
133 |
+
}
|
134 |
+
|
135 |
+
/* Get the ID of the field that changed*/
|
136 |
+
function getFieldId( field ) {
|
137 |
+
var fieldName = '';
|
138 |
+
if ( field instanceof jQuery ) {
|
139 |
+
fieldName = field.attr('name');
|
140 |
+
} else {
|
141 |
+
fieldName = field.name;
|
142 |
+
}
|
143 |
+
var nameParts = fieldName.replace('item_meta[', '').split(']');
|
144 |
+
var field_id = nameParts[0];
|
145 |
+
var isRepeating = false;
|
146 |
+
|
147 |
+
// Check if 'this' is in a repeating section
|
148 |
+
if ( jQuery('input[name="item_meta['+ field_id +'][form]"]').length ) {
|
149 |
+
// this is a repeatable section with name: item_meta[370][0][414]
|
150 |
+
field_id = nameParts[2].replace('[', '');
|
151 |
+
isRepeating = true;
|
152 |
+
}
|
153 |
+
|
154 |
+
// Check if 'this' is an other text field and get field ID for it
|
155 |
+
if ( 'other' === field_id ) {
|
156 |
+
if ( isRepeating ) {
|
157 |
+
// name for other fields: item_meta[370][0][other][414]
|
158 |
+
field_id = nameParts[3].replace('[', '');
|
159 |
+
} else {
|
160 |
+
// Other field name: item_meta[other][370]
|
161 |
+
field_id = nameParts[1].replace('[', '');
|
162 |
+
}
|
163 |
+
}
|
164 |
+
|
165 |
+
return field_id;
|
166 |
+
}
|
167 |
+
|
168 |
+
function checkDependentField(selected, field_id, rec, parentField, reset){
|
169 |
+
var rules = getRulesForField( field_id );
|
170 |
+
if ( typeof rules === 'undefined' ) {
|
171 |
+
return;
|
172 |
+
}
|
173 |
+
|
174 |
+
if ( typeof(rec) === 'undefined' || rec === null ) {
|
175 |
+
//stop recursion?
|
176 |
+
rec = 'go';
|
177 |
+
}
|
178 |
+
|
179 |
+
if ( reset !== 'persist' ) {
|
180 |
+
show_fields = []; // reset this variable after each click
|
181 |
+
hidden_fields = [];
|
182 |
+
}
|
183 |
+
|
184 |
+
var isRepeat = maybeSetRowId( parentField );
|
185 |
+
|
186 |
+
var len = rules.length;
|
187 |
+
for ( var i = 0, l = len; i < l; i++ ) {
|
188 |
+
if ( rules[i].FieldName === field_id ) {
|
189 |
+
hideOrShowField(i, rules[i], field_id, selected, rec, parentField);
|
190 |
+
} else {
|
191 |
+
hideOrShowField(i, rules[i], field_id, selected, rec);
|
192 |
+
}
|
193 |
+
|
194 |
+
if ( i === ( len - 1 ) ) {
|
195 |
+
hideFieldLater(rec);
|
196 |
+
if ( isRepeat ) {
|
197 |
+
addingRow = '';
|
198 |
+
}
|
199 |
+
}
|
200 |
+
}
|
201 |
+
}
|
202 |
+
|
203 |
+
function maybeSetRowId( parentField ) {
|
204 |
+
var isRepeat = false;
|
205 |
+
if ( addingRow === '' && typeof parentField !== 'undefined' && parentField !== null ) {
|
206 |
+
if ( parentField.length > 1 ) {
|
207 |
+
parentField = parentField.eq(0);
|
208 |
+
}
|
209 |
+
isRepeat = parentField.closest('.frm_repeat_sec, .frm_repeat_inline, .frm_repeat_grid');
|
210 |
+
if ( typeof isRepeat !== 'undefined' ) {
|
211 |
+
addingRow = isRepeat.attr('id');
|
212 |
+
isRepeat = true;
|
213 |
+
} else {
|
214 |
+
isRepeat = false;
|
215 |
+
}
|
216 |
+
}
|
217 |
+
return isRepeat;
|
218 |
+
}
|
219 |
+
|
220 |
+
function getRulesForField( field_id ) {
|
221 |
+
if ( typeof __FRMRULES === 'undefined' || typeof __FRMRULES[field_id] === 'undefined' ) {
|
222 |
+
return;
|
223 |
+
}
|
224 |
+
|
225 |
+
var rules = compileRules( __FRMRULES[field_id] );
|
226 |
+
return rules;
|
227 |
+
}
|
228 |
+
|
229 |
+
function compileRules( rules ) {
|
230 |
+
var this_opts = [];
|
231 |
+
for ( var i = 0, l = rules.length; i < l; i++ ) {
|
232 |
+
var rule = rules[i];
|
233 |
+
if ( typeof rule !== 'undefined' ) {
|
234 |
+
for ( var j = 0, rcl = rule.Conditions.length; j < rcl; j++ ) {
|
235 |
+
var c = rule.Conditions[j];
|
236 |
+
c.HideField = rule.Setting.FieldName;
|
237 |
+
c.MatchType = rule.MatchType;
|
238 |
+
c.Show = rule.Show;
|
239 |
+
this_opts.push(c);
|
240 |
+
}
|
241 |
+
}
|
242 |
+
}
|
243 |
+
return this_opts;
|
244 |
+
}
|
245 |
+
|
246 |
+
function hideOrShowField(i, f, field_id, selected, rec, parentField){
|
247 |
+
f.inputName = 'item_meta['+ f.FieldName +']';
|
248 |
+
f.hiddenName = 'item_meta['+ f.HideField +']';
|
249 |
+
f.containerID = 'frm_field_'+ f.FieldName +'_container';
|
250 |
+
f.hideContainerID = 'frm_field_'+ f.HideField +'_container';
|
251 |
+
f.hideBy = '#';
|
252 |
+
var getRepeat = false;
|
253 |
+
|
254 |
+
if ( typeof parentField !== 'undefined' && parentField !== null ) {
|
255 |
+
if ( parentField.length > 1 ) {
|
256 |
+
parentField = parentField.eq(0);
|
257 |
+
}
|
258 |
+
|
259 |
+
if ( typeof parentField.attr('name') === 'undefined' ) {
|
260 |
+
return;
|
261 |
+
}
|
262 |
+
|
263 |
+
// Accommodate for "other" options
|
264 |
+
f.inputName = parentField.attr('name').replace( '[other]', '' ).replace('[]', '');
|
265 |
+
|
266 |
+
var container = parentField.closest('.frm_repeat_sec, .frm_repeat_inline, .frm_repeat_grid');
|
267 |
+
if ( container.length ) {
|
268 |
+
var repeatInput = container.find('.frm_field_'+ f.FieldName +'_container');
|
269 |
+
f.containerID = repeatInput.attr('id');
|
270 |
+
f.hideContainerID = f.containerID.replace(f.FieldName, f.HideField);
|
271 |
+
f.hiddenName = f.inputName.replace('['+ f.FieldName +']', '['+ f.HideField +']');
|
272 |
+
}
|
273 |
+
} else {
|
274 |
+
setEmptyKeyInArray(f);
|
275 |
+
getRepeat = true;
|
276 |
+
parentField = jQuery('input[name^="'+ f.inputName +'"], textarea[name^="'+ f.inputName +'"], select[name^="'+ f.inputName +'"]');
|
277 |
+
|
278 |
+
if ( parentField.length < 1 ) {
|
279 |
+
// logic triggered on page load for fields in repeating section
|
280 |
+
var parentClass = '.'+ f.containerID;
|
281 |
+
if ( addingRow !== '' ) {
|
282 |
+
parentClass = '#' + addingRow +' '+ parentClass;
|
283 |
+
}
|
284 |
+
|
285 |
+
var parentContainer = jQuery(parentClass);
|
286 |
+
if ( parentContainer.length ) {
|
287 |
+
parentField = parentContainer.find('input, textarea, select');
|
288 |
+
if ( parentField.length ) {
|
289 |
+
if ( addingRow === '' ) {
|
290 |
+
var lastId = '';
|
291 |
+
parentField.each(function(){
|
292 |
+
var thisId = jQuery(this).closest('.frm_form_field').attr('id');
|
293 |
+
if ( thisId != lastId ) { // don't trigger radio/checkbox multiple times
|
294 |
+
hideOrShowField(i, f, f.FieldName, selected, rec, jQuery(this));
|
295 |
+
}
|
296 |
+
lastId = thisId;
|
297 |
+
});
|
298 |
+
} else {
|
299 |
+
hideOrShowField(i, f, field_id, selected, rec, parentField);
|
300 |
+
}
|
301 |
+
} else {
|
302 |
+
show_fields[f.hideContainerID][i] = false;
|
303 |
+
hideFieldNow(i, f, rec);
|
304 |
+
}
|
305 |
+
return;
|
306 |
+
}
|
307 |
+
}
|
308 |
+
|
309 |
+
if ( parentField.length > 1 ) {
|
310 |
+
parentField = parentField.eq(0);
|
311 |
+
}
|
312 |
+
}
|
313 |
+
|
314 |
+
setEmptyKeyInArray(f);
|
315 |
+
|
316 |
+
// check if only the dependent field is in a repeating section
|
317 |
+
var hideContainer = document.getElementById(f.hideContainerID);
|
318 |
+
if(hideContainer === null){
|
319 |
+
// it is a repeating section, use the class
|
320 |
+
f.hideBy = '.';
|
321 |
+
}
|
322 |
+
|
323 |
+
if ( f.FieldName !== field_id || typeof selected === 'undefined' || selected === 'und' ) {
|
324 |
+
if ( ( f.Type === 'radio' || f.Type === 'data-radio' ) && parentField.attr('type') === 'radio' ) {
|
325 |
+
selected = jQuery('input[name="'+ f.inputName +'"]:checked').val();
|
326 |
+
if ( typeof selected === 'undefined' ) {
|
327 |
+
selected = '';
|
328 |
+
}
|
329 |
+
} else if ( f.Type === 'select' || f.Type === 'time' || f.Type === 'data-select' || ( f.Type !== 'checkbox' && f.Type !== 'data-checkbox' ) ) {
|
330 |
+
selected = parentField.val();
|
331 |
+
}
|
332 |
+
}
|
333 |
+
|
334 |
+
if ( typeof selected === 'undefined' ) {
|
335 |
+
if ( parentField.length === 0 ) {
|
336 |
+
return; // the parent field is currently getting processed
|
337 |
+
}
|
338 |
+
selected = parentField.val();
|
339 |
+
}
|
340 |
+
|
341 |
+
if ( typeof selected === 'undefined' ) {
|
342 |
+
// check for repeating/embedded field
|
343 |
+
if ( getRepeat === true ) {
|
344 |
+
var repeat = jQuery('.'+ f.containerID +' input, .'+ f.containerID +' select, .'+ f.containerID +' textarea');
|
345 |
+
if ( repeat.length ) {
|
346 |
+
repeat.each(function(){
|
347 |
+
hideOrShowField(i, f, f.FieldName, selected, rec, jQuery(this));
|
348 |
+
});
|
349 |
+
return;
|
350 |
+
}
|
351 |
+
}
|
352 |
+
selected = '';
|
353 |
+
}
|
354 |
+
|
355 |
+
// get selected checkbox values
|
356 |
+
var checkVals = [];
|
357 |
+
if ( f.Type === 'checkbox' || f.Type === 'data-checkbox' ) {
|
358 |
+
checkVals = getCheckedVal(f.containerID, f.inputName);
|
359 |
+
|
360 |
+
if ( checkVals.length ) {
|
361 |
+
selected = checkVals;
|
362 |
+
}else{
|
363 |
+
selected = '';
|
364 |
+
}
|
365 |
+
}
|
366 |
+
|
367 |
+
if ( selected === '' || selected.length < 1 ) {
|
368 |
+
show_fields[f.hideContainerID][i] = false;
|
369 |
+
} else {
|
370 |
+
show_fields[f.hideContainerID][i] = {'funcName':'getDataOpts', 'f':f, 'sel':selected};
|
371 |
+
}
|
372 |
+
|
373 |
+
if ( f.Type === 'checkbox' || (f.Type === 'data-checkbox' && typeof f.LinkedField === 'undefined') ) {
|
374 |
+
show_fields[f.hideContainerID][i] = false;
|
375 |
+
|
376 |
+
var match = false;
|
377 |
+
if ( selected !== '') {
|
378 |
+
if ( f.Condition === '!=' ) {
|
379 |
+
show_fields[f.hideContainerID][i] = true;
|
380 |
+
}
|
381 |
+
for ( var b = 0; b<selected.length; b++ ) {
|
382 |
+
match = operators(f.Condition, f.Value, selected[b]);
|
383 |
+
if ( f.Condition === '!=' ) {
|
384 |
+
if ( show_fields[f.hideContainerID][i] === true && match === false ) {
|
385 |
+
show_fields[f.hideContainerID][i] = false;
|
386 |
+
}
|
387 |
+
} else if(show_fields[f.hideContainerID][i] === false && match){
|
388 |
+
show_fields[f.hideContainerID][i] = true;
|
389 |
+
}
|
390 |
+
}
|
391 |
+
} else {
|
392 |
+
match = operators(f.Condition, f.Value, '');
|
393 |
+
if(show_fields[f.hideContainerID][i] === false && match){
|
394 |
+
show_fields[f.hideContainerID][i] = true;
|
395 |
+
}
|
396 |
+
}
|
397 |
+
} else if ( typeof f.LinkedField !== 'undefined' && f.Type.indexOf('data-') === 0 ) {
|
398 |
+
if ( typeof f.DataType === 'undefined' || f.DataType === 'data' ) {
|
399 |
+
if ( selected === '' ) {
|
400 |
+
hideAndClearDynamicField( f.hideContainerID, f.hideBy, f.HideField, 'hide' );
|
401 |
+
} else if ( f.Type === 'data-radio' ) {
|
402 |
+
if ( typeof f.DataType === 'undefined' ) {
|
403 |
+
show_fields[f.hideContainerID][i] = operators(f.Condition, f.Value, selected);
|
404 |
+
} else {
|
405 |
+
show_fields[f.hideContainerID][i] = {'funcName':'getData','f':f,'sel':selected};
|
406 |
+
}
|
407 |
+
} else if ( f.Type === 'data-checkbox' || ( f.Type === 'data-select' && isNotEmptyArray( selected ) ) ) {
|
408 |
+
hideAndClearDynamicField( f.hideContainerID, f.hideBy, f.HideField, 'show' );
|
409 |
+
show_fields[f.hideContainerID][i] = true;
|
410 |
+
getData(f, selected, 1);
|
411 |
+
} else if ( f.Type === 'data-select' ) {
|
412 |
+
show_fields[f.hideContainerID][i] = {'funcName':'getData','f':f,'sel':selected};
|
413 |
+
}
|
414 |
+
}
|
415 |
+
}else if ( typeof f.Value === 'undefined' && f.Type.indexOf('data') === 0 ) {
|
416 |
+
if ( selected === '' ) {
|
417 |
+
f.Value = '1';
|
418 |
+
} else {
|
419 |
+
f.Value = selected;
|
420 |
+
}
|
421 |
+
show_fields[f.hideContainerID][i] = operators(f.Condition, f.Value, selected);
|
422 |
+
f.Value = undefined;
|
423 |
+
}else{
|
424 |
+
show_fields[f.hideContainerID][i] = operators(f.Condition, f.Value, selected);
|
425 |
+
}
|
426 |
+
|
427 |
+
hideFieldNow(i, f, rec);
|
428 |
+
}
|
429 |
+
|
430 |
+
function setEmptyKeyInArray(f) {
|
431 |
+
if ( typeof show_fields[f.hideContainerID] === 'undefined' ) {
|
432 |
+
show_fields[f.hideContainerID] = [];
|
433 |
+
}
|
434 |
+
}
|
435 |
+
|
436 |
+
function hideAndClearDynamicField(hideContainer, hideBy, field_id, hide){
|
437 |
+
if ( jQuery.inArray(hideContainer, hidden_fields) === -1 ) {
|
438 |
+
hidden_fields[ field_id ] = hideContainer;
|
439 |
+
if(hideBy === '.'){
|
440 |
+
hideContainer = jQuery('.'+hideContainer);
|
441 |
+
}else{
|
442 |
+
hideContainer = jQuery(document.getElementById(hideContainer));
|
443 |
+
}
|
444 |
+
if ( hide === 'hide' ) {
|
445 |
+
hideContainer.hide();
|
446 |
+
}
|
447 |
+
hideContainer.find('.frm_data_field_container').empty();
|
448 |
+
}
|
449 |
+
}
|
450 |
+
|
451 |
+
function hideAndClearField( container, f ) {
|
452 |
+
container.hide();
|
453 |
+
if ( jQuery.inArray(container.attr('id'), hidden_fields) === -1 ) {
|
454 |
+
var field_id = f.HideField;
|
455 |
+
hidden_fields[ field_id ] = container.attr('id');
|
456 |
+
|
457 |
+
var inputs = getInputsInContainer( container );
|
458 |
+
if ( inputs.length ){
|
459 |
+
inputs.prop('checked', false).prop('selectedIndex', 0);
|
460 |
+
inputs.not(':checkbox, :radio, select').val('');
|
461 |
+
var i = false;
|
462 |
+
inputs.each(function(){
|
463 |
+
if ( this.tagName == 'SELECT' ) {
|
464 |
+
var autocomplete = document.getElementById( this.id + '_chosen' );
|
465 |
+
if ( autocomplete !== null ) {
|
466 |
+
jQuery(this).trigger('chosen:updated');
|
467 |
+
}
|
468 |
+
}
|
469 |
+
|
470 |
+
if ( i === false ) {
|
471 |
+
triggerChange( jQuery(this) );
|
472 |
+
}
|
473 |
+
i = true;
|
474 |
+
});
|
475 |
+
}
|
476 |
+
}
|
477 |
+
}
|
478 |
+
|
479 |
+
function getInputsInContainer( container ) {
|
480 |
+
return container.find('select[name^="item_meta"], textarea[name^="item_meta"], input[name^="item_meta"]:not([type=hidden])');
|
481 |
+
}
|
482 |
+
|
483 |
+
function showFieldAndSetValue( container, f ) {
|
484 |
+
var inputs = getInputsInContainer( container );
|
485 |
+
setDefaultValue( inputs );
|
486 |
+
doCalcForSingleField( f.HideField, inputs );
|
487 |
+
container.show();
|
488 |
+
}
|
489 |
+
|
490 |
+
function setDefaultValue( input ) {
|
491 |
+
var inputLenth = input.length;
|
492 |
+
if ( inputLenth ) {
|
493 |
+
for ( var i = 0, l = inputLenth; i < l; i++ ) {
|
494 |
+
var field = jQuery(input[i]);
|
495 |
+
var defaultValue = field.data('frmval');
|
496 |
+
if ( typeof defaultValue !== 'undefined' ) {
|
497 |
+
if ( ! field.is(':checkbox, :radio') ) {
|
498 |
+
field.val( defaultValue );
|
499 |
+
triggerChange( field );
|
500 |
+
} else if ( field.val() == defaultValue || ( jQuery.isArray(defaultValue) && jQuery.inArray(field.val(), defaultValue) !== -1 ) ) {
|
501 |
+
field.prop('checked', true);
|
502 |
+
triggerChange( field );
|
503 |
+
}
|
504 |
+
}
|
505 |
+
}
|
506 |
+
}
|
507 |
+
}
|
508 |
+
|
509 |
+
function triggerChange( input, fieldKey ) {
|
510 |
+
if ( typeof fieldKey === 'undefined' ) {
|
511 |
+
fieldKey = 'dependent';
|
512 |
+
}
|
513 |
+
input.trigger({ type:'change', selfTriggered:true, frmTriggered:fieldKey });
|
514 |
+
}
|
515 |
+
|
516 |
+
function hideFieldNow(i, f, rec){
|
517 |
+
if ( f.MatchType === 'all' || show_fields[f.hideContainerID][i] === false ) {
|
518 |
+
hide_later.push({
|
519 |
+
'result':show_fields[f.hideContainerID][i], 'show':f.Show,
|
520 |
+
'match':f.MatchType, 'FieldName':f.FieldName, 'HideField':f.HideField,
|
521 |
+
'hideContainerID':f.hideContainerID, 'hideBy':f.hideBy
|
522 |
+
});
|
523 |
+
return;
|
524 |
+
}
|
525 |
+
|
526 |
+
var display = 'none';
|
527 |
+
if ( f.Show === 'show' ) {
|
528 |
+
if ( show_fields[f.hideContainerID][i] !== true ) {
|
529 |
+
showField(show_fields[f.hideContainerID][i], f.FieldName, rec);
|
530 |
+
return;
|
531 |
+
}
|
532 |
+
display = '';
|
533 |
+
}
|
534 |
+
|
535 |
+
var hideClass;
|
536 |
+
if(f.hideBy === '.'){
|
537 |
+
hideClass = jQuery('.'+f.hideContainerID);
|
538 |
+
}else{
|
539 |
+
hideClass = jQuery( document.getElementById(f.hideContainerID) );
|
540 |
+
}
|
541 |
+
|
542 |
+
if(hideClass.length){
|
543 |
+
if ( display === 'none' ) {
|
544 |
+
hideAndClearField( hideClass, f );
|
545 |
+
} else {
|
546 |
+
showFieldAndSetValue( hideClass, f );
|
547 |
+
}
|
548 |
+
}
|
549 |
+
}
|
550 |
+
|
551 |
+
function hideFieldLater(rec){
|
552 |
+
jQuery.each(hide_later, function(hkey,hvalue){
|
553 |
+
delete hide_later[hkey];
|
554 |
+
if ( typeof hvalue === 'undefined' || typeof hvalue.result === 'undefined' ) {
|
555 |
+
return;
|
556 |
+
}
|
557 |
+
|
558 |
+
var container = jQuery(hvalue.hideBy + hvalue.hideContainerID);
|
559 |
+
var hideField = hvalue.show;
|
560 |
+
if ( container.length ) {
|
561 |
+
if ( ( hvalue.match === 'any' && (jQuery.inArray(true, show_fields[hvalue.hideContainerID]) === -1) ) ||
|
562 |
+
( hvalue.match === 'all' && (jQuery.inArray(false, show_fields[hvalue.hideContainerID]) > -1) ) ) {
|
563 |
+
if ( hvalue.show === 'show' ) {
|
564 |
+
hideField = 'hide';
|
565 |
+
} else {
|
566 |
+
hideField = 'show';
|
567 |
+
}
|
568 |
+
}
|
569 |
+
|
570 |
+
if ( hideField === 'show' ) {
|
571 |
+
showFieldAndSetValue( container, hvalue );
|
572 |
+
if ( typeof hvalue.result !== false && typeof hvalue.result !== true ) {
|
573 |
+
showField( hvalue.result, hvalue.FieldName, rec );
|
574 |
+
}
|
575 |
+
} else {
|
576 |
+
hideAndClearField(container, hvalue);
|
577 |
+
}
|
578 |
+
}
|
579 |
+
});
|
580 |
+
}
|
581 |
+
|
582 |
+
function operators(op, a, b){
|
583 |
+
if ( typeof b === 'undefined' ) {
|
584 |
+
b = '';
|
585 |
+
}
|
586 |
+
if(jQuery.isArray(b) && jQuery.inArray(a,b) > -1){
|
587 |
+
b = a;
|
588 |
+
}
|
589 |
+
if(String(a).search(/^\s*(\+|-)?((\d+(\.\d+)?)|(\.\d+))\s*$/) !== -1){
|
590 |
+
a = parseFloat(a);
|
591 |
+
b = parseFloat(b);
|
592 |
+
}
|
593 |
+
if ( String(a).indexOf('"') != '-1' && operators(op, a.replace('"', '"'), b) ) {
|
594 |
+
return true;
|
595 |
+
}
|
596 |
+
|
597 |
+
var theOperators = {
|
598 |
+
'==': function(c,d){ return c == d; },
|
599 |
+
'!=': function(c,d){ return c != d; },
|
600 |
+
'<': function(c,d){ return c > d; },
|
601 |
+
'>': function(c,d){ return c < d; },
|
602 |
+
'LIKE': function(c,d){
|
603 |
+
if(!d){
|
604 |
+
/* If no value, then assume no match */
|
605 |
+
return 0;
|
606 |
+
}
|
607 |
+
return d.indexOf(c) != -1;
|
608 |
+
},
|
609 |
+
'not LIKE': function(c,d){
|
610 |
+
if(!d){
|
611 |
+
/* If no value, then assume no match */
|
612 |
+
return 1;
|
613 |
+
}
|
614 |
+
return d.indexOf(c) == -1;
|
615 |
+
}
|
616 |
+
};
|
617 |
+
return theOperators[op](a, b);
|
618 |
+
}
|
619 |
+
|
620 |
+
function showField(funcInfo, field_id, rec){
|
621 |
+
if ( funcInfo.funcName == 'getDataOpts' ) {
|
622 |
+
getDataOpts(funcInfo.f, funcInfo.sel, field_id, rec);
|
623 |
+
} else if ( funcInfo.funcName == 'getData' ) {
|
624 |
+
getData(funcInfo.f, funcInfo.sel, 0);
|
625 |
+
}
|
626 |
+
}
|
627 |
+
|
628 |
+
function getData(f,selected,append){
|
629 |
+
var fcont = document.getElementById(f.hideContainerID);
|
630 |
+
var cont = jQuery(fcont).find('.frm_data_field_container');
|
631 |
+
if ( cont.length === 0 ) {
|
632 |
+
return true;
|
633 |
+
}
|
634 |
+
|
635 |
+
if ( !append ) {
|
636 |
+
cont.html('<span class="frm-loading-img"></span>');
|
637 |
+
}
|
638 |
+
|
639 |
+
jQuery.ajax({
|
640 |
+
type:'POST',url:frm_js.ajax_url,
|
641 |
+
data:{
|
642 |
+
action:'frm_fields_ajax_get_data', entry_id:selected,
|
643 |
+
field_id:f.LinkedField, current_field:f.HideField,
|
644 |
+
hide_id:f.hideContainerID, nonce:frm_js.nonce
|
645 |
+
},
|
646 |
+
success:function(html){
|
647 |
+
if ( append ) {
|
648 |
+
cont.append(html);
|
649 |
+
} else {
|
650 |
+
cont.html(html);
|
651 |
+
}
|
652 |
+
|
653 |
+
var parentField = cont.children('input');
|
654 |
+
var val = parentField.val();
|
655 |
+
if ( ( html === '' && ! append ) || val === '' ) {
|
656 |
+
fcont.style.display = 'none';
|
657 |
+
} else {
|
658 |
+
fcont.style.display = '';
|
659 |
+
}
|
660 |
+
|
661 |
+
triggerChange( parentField );
|
662 |
+
|
663 |
+
return true;
|
664 |
+
}
|
665 |
+
});
|
666 |
+
}
|
667 |
+
|
668 |
+
function getDataOpts(f,selected,field_id,rec) {
|
669 |
+
//don't check the same field twice when more than a 2-level dependency, and parent is not on this page
|
670 |
+
if(rec == 'stop' && (jQuery.inArray(f.HideField, frm_checked_dep) > -1) && f.parentField && f.parentField.attr('type') == 'hidden'){
|
671 |
+
return;
|
672 |
+
}
|
673 |
+
|
674 |
+
var hiddenInput = jQuery('input[name^="'+ f.hiddenName +'"], select[name^="'+ f.hiddenName +'"]:not(":disabled"), textarea[name^="'+ f.hiddenName +'"]');
|
675 |
+
|
676 |
+
var prev = [];
|
677 |
+
hiddenInput.each(function(){
|
678 |
+
if ( this.type === 'radio' || this.type === 'checkbox' ) {
|
679 |
+
if ( this.checked === true ) {
|
680 |
+
prev.push(jQuery(this).val());
|
681 |
+
}
|
682 |
+
} else {
|
683 |
+
prev.push(jQuery(this).val());
|
684 |
+
}
|
685 |
+
});
|
686 |
+
|
687 |
+
if(f.DataType == 'select'){
|
688 |
+
if((rec == 'stop' || jQuery('#'+ f.hideContainerID +' .frm-loading-img').length) && (jQuery.inArray(f.HideField, frm_checked_dep) > -1)){
|
689 |
+
return;
|
690 |
+
}
|
691 |
+
}
|
692 |
+
|
693 |
+
if(prev.length === 0){
|
694 |
+
prev = '';
|
695 |
+
}
|
696 |
+
|
697 |
+
frm_checked_dep.push(f.HideField);
|
698 |
+
|
699 |
+
var fcont = document.getElementById(f.hideContainerID);
|
700 |
+
//don't get values for fields that are to remain hidden on the page
|
701 |
+
var $dataField = jQuery(fcont).find('.frm_data_field_container');
|
702 |
+
if($dataField.length === 0 && hiddenInput.length ){
|
703 |
+
checkDependentField(prev, f.HideField, 'stop', hiddenInput);
|
704 |
+
return false;
|
705 |
+
}
|
706 |
+
|
707 |
+
if ( f.Value !== '' ) {
|
708 |
+
var match = operators(f.Condition, f.Value, selected);
|
709 |
+
if ( !match ) {
|
710 |
+
fcont.style.display = 'none';
|
711 |
+
$dataField.html('');
|
712 |
+
checkDependentField('', f.HideField, 'stop', hiddenInput);
|
713 |
+
return false;
|
714 |
+
}
|
715 |
+
}
|
716 |
+
|
717 |
+
$dataField.html('<span class="frm-loading-img" style="visibility:visible;display:inline;"></span>');
|
718 |
+
|
719 |
+
// save the current f value for use after ajax
|
720 |
+
var hiddenName = f.hiddenName;
|
721 |
+
var dataType = f.DataType;
|
722 |
+
|
723 |
+
jQuery.ajax({
|
724 |
+
type:'POST',
|
725 |
+
url:frm_js.ajax_url,
|
726 |
+
data:{
|
727 |
+
action:'frm_fields_ajax_data_options', hide_field:field_id,
|
728 |
+
entry_id:selected, selected_field_id:f.LinkedField, field_id:f.HideField,
|
729 |
+
hide_id:f.hideContainerID, nonce:frm_js.nonce
|
730 |
+
},
|
731 |
+
success:function(html){
|
732 |
+
$dataField.html(html);
|
733 |
+
var parentField = $dataField.find('select, input, textarea');
|
734 |
+
var val = 1;
|
735 |
+
if ( parentField.attr('type') == 'hidden' ) {
|
736 |
+
val = parentField.val();
|
737 |
+
}
|
738 |
+
|
739 |
+
if ( html === '' || val === '' ) {
|
740 |
+
fcont.style.display = 'none';
|
741 |
+
prev = '';
|
742 |
+
}else if(f.MatchType != 'all'){
|
743 |
+
fcont.style.display = '';
|
744 |
+
}
|
745 |
+
|
746 |
+
if(html !== '' && prev !== ''){
|
747 |
+
if(!jQuery.isArray(prev)){
|
748 |
+
var new_prev = [];
|
749 |
+
new_prev.push(prev);
|
750 |
+
prev = new_prev;
|
751 |
+
}
|
752 |
+
|
753 |
+
//select options that were selected previously
|
754 |
+
jQuery.each(prev, function(ckey,cval){
|
755 |
+
if ( typeof(cval) === 'undefined' || cval === '' ) {
|
756 |
+
return;
|
757 |
+
}
|
758 |
+
if ( dataType == 'checkbox' || dataType == 'radio' ) {
|
759 |
+
if ( parentField.length > 1 ) {
|
760 |
+
parentField.filter('[value="' + cval+ '"]').attr('checked','checked');
|
761 |
+
} else if ( parentField.val() == cval ){
|
762 |
+
parentField.attr('checked','checked');
|
763 |
+
}
|
764 |
+
} else if ( dataType == 'select' ) {
|
765 |
+
var selOpt = parentField.children('option[value="'+ cval +'"]');
|
766 |
+
if(selOpt.length){
|
767 |
+
selOpt.prop('selected', true);
|
768 |
+
}else{
|
769 |
+
//remove options that no longer exist
|
770 |
+
prev.splice(ckey, 1);
|
771 |
+
}
|
772 |
+
}else{
|
773 |
+
parentField.val(cval);
|
774 |
+
}
|
775 |
+
});
|
776 |
+
}
|
777 |
+
|
778 |
+
if(parentField.hasClass('frm_chzn') && jQuery().chosen){
|
779 |
+
jQuery('.frm_chzn').chosen({allow_single_deselect:true});
|
780 |
+
}
|
781 |
+
|
782 |
+
triggerChange( parentField );
|
783 |
+
}
|
784 |
+
});
|
785 |
+
}
|
786 |
+
|
787 |
+
function doCalculation(field_id, triggerField){
|
788 |
+
if ( typeof __FRMCALC === 'undefined' ) {
|
789 |
+
// there are no calculations on this page
|
790 |
+
return;
|
791 |
+
}
|
792 |
+
|
793 |
+
var all_calcs = __FRMCALC;
|
794 |
+
var calc = all_calcs.fields[field_id];
|
795 |
+
if ( typeof calc === 'undefined' ) {
|
796 |
+
// this field is not used in a calculation
|
797 |
+
return;
|
798 |
+
}
|
799 |
+
|
800 |
+
var keys = calc.total;
|
801 |
+
var len = keys.length;
|
802 |
+
var vals = [];
|
803 |
+
|
804 |
+
// loop through each calculation this field is used in
|
805 |
+
for ( var i = 0, l = len; i < l; i++ ) {
|
806 |
+
|
807 |
+
// If field is hidden with conditional logic or if it's on a different page, don't do the calc
|
808 |
+
var calcFieldId = all_calcs.calc[ keys[i] ].field_id;
|
809 |
+
var t = document.getElementById( 'frm_field_' + calcFieldId + '_container' );
|
810 |
+
if ( t !== null && t.offsetHeight === 0 ) {
|
811 |
+
continue;
|
812 |
+
}
|
813 |
+
|
814 |
+
doSingleCalculation( all_calcs, keys[i], vals, triggerField );
|
815 |
+
}
|
816 |
+
}
|
817 |
+
|
818 |
+
function doSingleCalculation( all_calcs, field_key, vals, triggerField ) {
|
819 |
+
var thisCalc = all_calcs.calc[ field_key ];
|
820 |
+
var thisFullCalc = thisCalc.calc;
|
821 |
+
|
822 |
+
var totalField = jQuery( document.getElementById('field_'+ field_key) );
|
823 |
+
var fieldInfo = { 'triggerField': triggerField, 'inSection': false, 'thisFieldCall': 'input[id^="field_'+ field_key+'-"]' };
|
824 |
+
if ( totalField.length < 1 && typeof triggerField !== 'undefined' ) {
|
825 |
+
// check if the total field is inside of a repeating/embedded form
|
826 |
+
fieldInfo.inSection = true;
|
827 |
+
fieldInfo.thisFieldId = objectSearch( all_calcs.fieldsWithCalc, field_key );
|
828 |
+
totalField = getSiblingField( fieldInfo );
|
829 |
+
}
|
830 |
+
|
831 |
+
// loop through the fields in this calculation
|
832 |
+
thisFullCalc = getValsForSingleCalc( thisCalc, thisFullCalc, all_calcs, vals, fieldInfo );
|
833 |
+
|
834 |
+
// Set the number of decimal places
|
835 |
+
var dec = thisCalc.calc_dec;
|
836 |
+
|
837 |
+
// allow .toFixed for reverse compatability
|
838 |
+
if ( thisFullCalc.indexOf(').toFixed(') ) {
|
839 |
+
var calcParts = thisFullCalc.split(').toFixed(');
|
840 |
+
if ( isNumeric(calcParts[1]) ) {
|
841 |
+
dec = calcParts[1];
|
842 |
+
thisFullCalc = thisFullCalc.replace(').toFixed(' + dec, '');
|
843 |
+
}
|
844 |
+
}
|
845 |
+
|
846 |
+
var total = parseFloat(eval(thisFullCalc));
|
847 |
+
|
848 |
+
// Set decimal points
|
849 |
+
if ( isNumeric( dec ) ) {
|
850 |
+
total = total.toFixed(dec);
|
851 |
+
}
|
852 |
+
|
853 |
+
if ( typeof total === 'undefined' ) {
|
854 |
+
total = 0;
|
855 |
+
}
|
856 |
+
|
857 |
+
if ( totalField.val() != total ) {
|
858 |
+
totalField.val(total);
|
859 |
+
triggerChange( totalField, field_key );
|
860 |
+
}
|
861 |
+
}
|
862 |
+
|
863 |
+
function getValsForSingleCalc( thisCalc, thisFullCalc, all_calcs, vals, fieldInfo ) {
|
864 |
+
var fCount = thisCalc.fields.length;
|
865 |
+
for ( var f = 0, c = fCount; f < c; f++ ) {
|
866 |
+
var field = {
|
867 |
+
'triggerField': fieldInfo.triggerField, 'thisFieldId': thisCalc.fields[f],
|
868 |
+
'inSection': fieldInfo.inSection,
|
869 |
+
'valKey': fieldInfo.inSection +''+ thisCalc.fields[f],
|
870 |
+
'thisField': all_calcs.fields[ thisCalc.fields[f] ],
|
871 |
+
'thisFieldCall': 'input'+ all_calcs.fieldKeys[ thisCalc.fields[f] ]
|
872 |
+
};
|
873 |
+
|
874 |
+
field = getCallForField( field, all_calcs );
|
875 |
+
vals = getCalcFieldId(field, all_calcs, vals);
|
876 |
+
|
877 |
+
if ( typeof vals[field.valKey] === 'undefined' || isNaN(vals[field.valKey]) ) {
|
878 |
+
vals[field.valKey] = 0;
|
879 |
+
}
|
880 |
+
|
881 |
+
var findVar = '['+ field.thisFieldId +']';
|
882 |
+
findVar = findVar.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1");
|
883 |
+
thisFullCalc = thisFullCalc.replace(new RegExp(findVar, 'g'), vals[field.valKey]);
|
884 |
+
}
|
885 |
+
return thisFullCalc;
|
886 |
+
}
|
887 |
+
|
888 |
+
function getCallForField( field, all_calcs ) {
|
889 |
+
if ( field.thisField.type == 'checkbox' || field.thisField.type == 'select' ) {
|
890 |
+
field.thisFieldCall = field.thisFieldCall +':checked,select'+ all_calcs.fieldKeys[field.thisFieldId] +' option:selected,'+ field.thisFieldCall+'[type=hidden]';
|
891 |
+
} else if ( field.thisField.type == 'radio' || field.thisField.type == 'scale' ) {
|
892 |
+
field.thisFieldCall = field.thisFieldCall +':checked,'+ field.thisFieldCall +'[type=hidden]';
|
893 |
+
} else if ( field.thisField.type == 'textarea' ) {
|
894 |
+
field.thisFieldCall = field.thisFieldCall + ',textarea'+ all_calcs.fieldKeys[field.thisFieldId];
|
895 |
+
}
|
896 |
+
return field;
|
897 |
+
}
|
898 |
+
|
899 |
+
function doCalcForSingleField( field_id, triggerField ) {
|
900 |
+
if ( typeof __FRMCALC === 'undefined' ) {
|
901 |
+
// there are no calculations on this page
|
902 |
+
return;
|
903 |
+
}
|
904 |
+
var all_calcs = __FRMCALC;
|
905 |
+
var field_key = all_calcs.fieldsWithCalc[ field_id ];
|
906 |
+
if ( typeof field_key === 'undefined' ) {
|
907 |
+
// this field has no calculation
|
908 |
+
return;
|
909 |
+
}
|
910 |
+
|
911 |
+
var vals = [];
|
912 |
+
doSingleCalculation( all_calcs, field_key, vals, triggerField );
|
913 |
+
}
|
914 |
+
|
915 |
+
function getCalcFieldId( field, all_calcs, vals ) {
|
916 |
+
if ( typeof vals[field.valKey] !== 'undefined' && vals[field.valKey] !== 0 ) {
|
917 |
+
return vals;
|
918 |
+
}
|
919 |
+
|
920 |
+
vals[field.valKey] = 0;
|
921 |
+
|
922 |
+
var calcField;
|
923 |
+
if ( field.inSection === false ) {
|
924 |
+
calcField = jQuery(field.thisFieldCall);
|
925 |
+
} else {
|
926 |
+
calcField = getSiblingField( field );
|
927 |
+
if ( calcField === null || typeof calcField === 'undefined' ) {
|
928 |
+
calcField = jQuery(field.thisFieldCall);
|
929 |
+
}
|
930 |
+
}
|
931 |
+
|
932 |
+
if ( calcField === null || typeof calcField === 'undefined' || calcField.length < 1 ) {
|
933 |
+
return vals;
|
934 |
+
}
|
935 |
+
|
936 |
+
calcField.each(function(){
|
937 |
+
var thisVal = getOptionValue( field.thisField, this );
|
938 |
+
|
939 |
+
if ( field.thisField.type == 'date' ) {
|
940 |
+
var d = jQuery.datepicker.parseDate(all_calcs.date, thisVal);
|
941 |
+
if ( d !== null ) {
|
942 |
+
vals[field.valKey] = Math.ceil(d/(1000*60*60*24));
|
943 |
+
}
|
944 |
+
}
|
945 |
+
|
946 |
+
var n = thisVal;
|
947 |
+
|
948 |
+
if ( n !== '' && n !== 0 ) {
|
949 |
+
n = n.trim();
|
950 |
+
n = parseFloat(n.replace(/,/g,'').match(/-?[\d\.]+$/));
|
951 |
+
}
|
952 |
+
|
953 |
+
if ( typeof n === 'undefined' || isNaN(n) || n === '' ) {
|
954 |
+
n = 0;
|
955 |
+
}
|
956 |
+
vals[field.valKey] += n;
|
957 |
+
});
|
958 |
+
|
959 |
+
return vals;
|
960 |
+
}
|
961 |
+
|
962 |
+
function getSiblingField( field ) {
|
963 |
+
if ( typeof field.triggerField === 'undefined' ) {
|
964 |
+
return null;
|
965 |
+
}
|
966 |
+
var container = field.triggerField.closest('.frm_repeat_sec, .frm_repeat_inline, .frm_repeat_grid');
|
967 |
+
if ( container.length ) {
|
968 |
+
var inputClass = '.frm_field_'+ field.thisFieldId +'_container ';
|
969 |
+
var fieldCallParts = field.thisFieldCall.split(',');
|
970 |
+
var siblingFieldCall = '';
|
971 |
+
for ( var i = 0, l = fieldCallParts.length; i < l; i++ ) {
|
972 |
+
if ( siblingFieldCall !== '' ) {
|
973 |
+
siblingFieldCall = siblingFieldCall +',';
|
974 |
+
}
|
975 |
+
siblingFieldCall = siblingFieldCall + inputClass + fieldCallParts[i].replace('[id=', '[id^=');
|
976 |
+
}
|
977 |
+
return container.find(siblingFieldCall);
|
978 |
+
}
|
979 |
+
return null;
|
980 |
+
}
|
981 |
+
|
982 |
+
function getOptionValue( thisField, currentOpt ) {
|
983 |
+
var thisVal;
|
984 |
+
|
985 |
+
// If current option is an other option, get other value
|
986 |
+
if ( isOtherOption( thisField, currentOpt ) ) {
|
987 |
+
thisVal = getOtherValueAnyField( thisField, currentOpt );
|
988 |
+
} else if ( (currentOpt.type === 'checkbox' || currentOpt.type === 'radio') && currentOpt.checked ) {
|
989 |
+
thisVal = currentOpt.value;
|
990 |
+
} else {
|
991 |
+
thisVal = jQuery(currentOpt).val();
|
992 |
+
}
|
993 |
+
|
994 |
+
if ( typeof thisVal === 'undefined' ) {
|
995 |
+
thisVal = '';
|
996 |
+
}
|
997 |
+
return thisVal;
|
998 |
+
}
|
999 |
+
|
1000 |
+
/* Check if current option is an "Other" option (not an Other text field) */
|
1001 |
+
function isOtherOption( thisField, currentOpt ) {
|
1002 |
+
var isOtherOpt = false;
|
1003 |
+
|
1004 |
+
// If hidden, check for a value
|
1005 |
+
if ( currentOpt.type == 'hidden' ) {
|
1006 |
+
if ( getOtherValueLimited( currentOpt ) !== '' ) {
|
1007 |
+
isOtherOpt = true;
|
1008 |
+
}
|
1009 |
+
} else if ( thisField.type == 'select' ) {
|
1010 |
+
// If a visible dropdown field
|
1011 |
+
var optClass = currentOpt.className;
|
1012 |
+
if ( optClass && optClass.indexOf( 'frm_other_trigger' ) > -1 ) {
|
1013 |
+
isOtherOpt = true;
|
1014 |
+
}
|
1015 |
+
} else if ( thisField.type == 'checkbox' || thisField.type == 'radio' ) {
|
1016 |
+
// If visible checkbox/radio field
|
1017 |
+
if ( currentOpt.id.indexOf( '-other_' ) > -1 && currentOpt.id.indexOf( '-otext' ) < 0 ) {
|
1018 |
+
isOtherOpt = true;
|
1019 |
+
}
|
1020 |
+
}
|
1021 |
+
|
1022 |
+
return isOtherOpt;
|
1023 |
+
}
|
1024 |
+
|
1025 |
+
/* Get the value from an "Other" text field */
|
1026 |
+
/* Does NOT work for visible select fields */
|
1027 |
+
function getOtherValueLimited( currentOpt ){
|
1028 |
+
var otherVal = '';
|
1029 |
+
var otherText = document.getElementById( currentOpt.id + '-otext' );
|
1030 |
+
if ( otherText !== null && otherText.value !== '' ) {
|
1031 |
+
otherVal = otherText.value;
|
1032 |
+
}
|
1033 |
+
return otherVal;
|
1034 |
+
}
|
1035 |
+
|
1036 |
+
/* Get value from Other text field */
|
1037 |
+
function getOtherValueAnyField( thisField, currentOpt ) {
|
1038 |
+
var otherVal = 0;
|
1039 |
+
|
1040 |
+
if ( thisField.type == 'select' ) {
|
1041 |
+
if ( currentOpt.type == 'hidden' ) {
|
1042 |
+
if ( isCurrentOptRepeating( currentOpt ) ) {
|
1043 |
+
// Do nothing because regular doCalculation code takes care of it
|
1044 |
+
} else {
|
1045 |
+
otherVal = getOtherValueLimited( currentOpt );
|
1046 |
+
}
|
1047 |
+
} else {
|
1048 |
+
otherVal = getOtherSelectValue( currentOpt );
|
1049 |
+
}
|
1050 |
+
} else if ( thisField.type == 'checkbox' || thisField.type == 'radio' ) {
|
1051 |
+
if ( currentOpt.type == 'hidden' ) {
|
1052 |
+
// Do nothing because regular doCalculation code takes care of it
|
1053 |
+
} else {
|
1054 |
+
otherVal = getOtherValueLimited( currentOpt );
|
1055 |
+
}
|
1056 |
+
}
|
1057 |
+
|
1058 |
+
return otherVal;
|
1059 |
+
}
|
1060 |
+
|
1061 |
+
/* Check if current option is in a repeating section */
|
1062 |
+
function isCurrentOptRepeating( currentOpt ) {
|
1063 |
+
var isRepeating = false;
|
1064 |
+
var parts = currentOpt.name.split( '[' );
|
1065 |
+
if ( parts.length > 2 ) {
|
1066 |
+
isRepeating = true;
|
1067 |
+
}
|
1068 |
+
return isRepeating;
|
1069 |
+
}
|
1070 |
+
|
1071 |
+
/* Get value from Other text field in a visible dropdown field */
|
1072 |
+
function getOtherSelectValue( currentOpt ) {
|
1073 |
+
return jQuery(currentOpt).closest('.frm_other_container').find('.frm_other_input').val();
|
1074 |
+
}
|
1075 |
+
|
1076 |
+
function validateForm( action, object ) {
|
1077 |
+
var errors = [];
|
1078 |
+
|
1079 |
+
// Make sure required text field is filled in
|
1080 |
+
var requiredFields = jQuery(object).find('.frm_required_field input, .frm_required_field select, .frm_required_field textarea');
|
1081 |
+
if ( requiredFields.length ) {
|
1082 |
+
for ( var r = 0, rl = requiredFields.length; r < rl; r++ ) {
|
1083 |
+
// this won't work with radio/checkbox
|
1084 |
+
errors = checkRequiredField( requiredFields[r], errors );
|
1085 |
+
}
|
1086 |
+
}
|
1087 |
+
|
1088 |
+
// Make sure required email field is filled in
|
1089 |
+
var emailFields = jQuery(object).find('input[type=email]');
|
1090 |
+
if ( emailFields.length ) {
|
1091 |
+
for ( var e = 0, el = emailFields.length; e < el; e++ ) {
|
1092 |
+
errors = checkEmailField( emailFields[e], errors, emailFields );
|
1093 |
+
}
|
1094 |
+
}
|
1095 |
+
return errors;
|
1096 |
+
}
|
1097 |
+
|
1098 |
+
function checkRequiredField( field, errors ) {
|
1099 |
+
if ( jQuery(field).val() === '' ) {
|
1100 |
+
var rFieldID = getFieldId( field );
|
1101 |
+
errors[ rFieldID ] = '';
|
1102 |
+
}
|
1103 |
+
return errors;
|
1104 |
+
}
|
1105 |
+
|
1106 |
+
function checkEmailField( field, errors, emailFields ) {
|
1107 |
+
var emailAddress = field.value;
|
1108 |
+
var fieldID = getFieldId( field );
|
1109 |
+
var isConf = (fieldID.indexOf('conf_') === 0);
|
1110 |
+
if ( emailAddress !== '' || isConf ) {
|
1111 |
+
var re = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
|
1112 |
+
if ( re.test( emailAddress ) === false ) {
|
1113 |
+
errors[ fieldID ] = '';
|
1114 |
+
if ( isConf ) {
|
1115 |
+
errors[ fieldID.replace('conf_', '') ] = '';
|
1116 |
+
}
|
1117 |
+
} else if ( isConf ) {
|
1118 |
+
var confName = field.name.replace('conf_', '');
|
1119 |
+
var match = emailFields.filter('[name="'+ confName +'"]').val();
|
1120 |
+
if ( match !== emailAddress ) {
|
1121 |
+
errors[ fieldID ] = '';
|
1122 |
+
errors[ fieldID.replace('conf_', '') ] = '';
|
1123 |
+
}
|
1124 |
+
}
|
1125 |
+
}
|
1126 |
+
return errors;
|
1127 |
+
}
|
1128 |
+
|
1129 |
+
function getFormErrors(object, action){
|
1130 |
+
jQuery(object).find('input[type="submit"], input[type="button"]').attr('disabled','disabled');
|
1131 |
+
jQuery(object).find('.frm_ajax_loading').addClass('frm_loading_now');
|
1132 |
+
|
1133 |
+
if(typeof action == 'undefined'){
|
1134 |
+
jQuery(object).find('input[name="frm_action"]').val();
|
1135 |
+
}
|
1136 |
+
|
1137 |
+
jQuery.ajax({
|
1138 |
+
type:'POST',url:frm_js.ajax_url,
|
1139 |
+
data:jQuery(object).serialize() +'&action=frm_entries_'+ action +'&nonce='+frm_js.nonce,
|
1140 |
+
success:function(errObj){
|
1141 |
+
errObj = errObj.replace(/^\s+|\s+$/g,'');
|
1142 |
+
if(errObj.indexOf('{') === 0){
|
1143 |
+
errObj = jQuery.parseJSON(errObj);
|
1144 |
+
}
|
1145 |
+
if(errObj === '' || !errObj || errObj === '0' || (typeof(errObj) != 'object' && errObj.indexOf('<!DOCTYPE') === 0)){
|
1146 |
+
var $loading = document.getElementById('frm_loading');
|
1147 |
+
if($loading !== null){
|
1148 |
+
var file_val=jQuery(object).find('input[type=file]').val();
|
1149 |
+
if(typeof(file_val) != 'undefined' && file_val !== ''){
|
1150 |
+
setTimeout(function(){
|
1151 |
+
jQuery($loading).fadeIn('slow');
|
1152 |
+
},2000);
|
1153 |
+
}
|
1154 |
+
}
|
1155 |
+
var $recapField = jQuery(object).find('.g-recaptcha');
|
1156 |
+
if($recapField.length && (jQuery(object).find('.frm_next_page').length < 1 || jQuery(object).find('.frm_next_page').val() < 1)){
|
1157 |
+
$recapField.closest('.frm_form_field').replaceWith('<input type="hidden" name="recaptcha_checked" value="'+ frm_js.nonce +'">');
|
1158 |
+
}
|
1159 |
+
|
1160 |
+
object.submit();
|
1161 |
+
}else if(typeof errObj != 'object'){
|
1162 |
+
jQuery(object).find('.frm_ajax_loading').removeClass('frm_loading_now');
|
1163 |
+
var formID = jQuery(object).find('input[name="form_id"]').val();
|
1164 |
+
jQuery(object).closest( '#frm_form_'+ formID +'_container' ).replaceWith(errObj);
|
1165 |
+
frmFrontForm.scrollMsg( formID );
|
1166 |
+
|
1167 |
+
if(typeof(frmThemeOverride_frmAfterSubmit) == 'function'){
|
1168 |
+
var pageOrder = jQuery('input[name="frm_page_order_'+ formID +'"]').val();
|
1169 |
+
var formReturned = jQuery(errObj).find('input[name="form_id"]').val();
|
1170 |
+
frmThemeOverride_frmAfterSubmit(formReturned, pageOrder, errObj, object);
|
1171 |
+
}
|
1172 |
+
|
1173 |
+
var entryIdField = jQuery(object).find('input[name="id"]');
|
1174 |
+
if(entryIdField.length){
|
1175 |
+
jQuery(document.getElementById('frm_edit_'+ entryIdField.val())).find('a').addClass('frm_ajax_edited').click();
|
1176 |
+
}
|
1177 |
+
}else{
|
1178 |
+
jQuery(object).find('input[type="submit"], input[type="button"]').removeAttr('disabled');
|
1179 |
+
jQuery(object).find('.frm_ajax_loading').removeClass('frm_loading_now');
|
1180 |
+
|
1181 |
+
//show errors
|
1182 |
+
var cont_submit=true;
|
1183 |
+
jQuery('.form-field').removeClass('frm_blank_field');
|
1184 |
+
jQuery('.form-field .frm_error').replaceWith('');
|
1185 |
+
var jump = '';
|
1186 |
+
var show_captcha = false;
|
1187 |
+
var $fieldCont = null;
|
1188 |
+
for (var key in errObj){
|
1189 |
+
$fieldCont = jQuery(object).find(jQuery(document.getElementById('frm_field_'+key+'_container')));
|
1190 |
+
|
1191 |
+
if ( $fieldCont.length ) {
|
1192 |
+
if ( ! $fieldCont.is(':visible') ) {
|
1193 |
+
var inCollapsedSection = $fieldCont.closest('.frm_toggle_container');
|
1194 |
+
if ( inCollapsedSection.length ) {
|
1195 |
+
inCollapsedSection.prev('.frm_trigger').click();
|
1196 |
+
}
|
1197 |
+
}
|
1198 |
+
if ( $fieldCont.is(':visible') ) {
|
1199 |
+
cont_submit = false;
|
1200 |
+
if ( jump === '' ) {
|
1201 |
+
frmFrontForm.scrollMsg( key, object, true );
|
1202 |
+
jump = '#frm_field_'+key+'_container';
|
1203 |
+
}
|
1204 |
+
var $recapcha = jQuery(object).find('#frm_field_'+key+'_container .g-recaptcha');
|
1205 |
+
if ( $recapcha.length ) {
|
1206 |
+
show_captcha = true;
|
1207 |
+
grecaptcha.reset();
|
1208 |
+
}
|
1209 |
+
|
1210 |
+
$fieldCont.addClass('frm_blank_field');
|
1211 |
+
if ( typeof frmThemeOverride_frmPlaceError == 'function' ) {
|
1212 |
+
frmThemeOverride_frmPlaceError(key,errObj);
|
1213 |
+
} else {
|
1214 |
+
$fieldCont.append('<div class="frm_error">'+errObj[key]+'</div>');
|
1215 |
+
}
|
1216 |
+
}
|
1217 |
+
}else if(key == 'redirect'){
|
1218 |
+
window.location = errObj[key];
|
1219 |
+
return;
|
1220 |
+
}
|
1221 |
+
}
|
1222 |
+
if(show_captcha !== true){
|
1223 |
+
jQuery(object).find('.g-recaptcha').closest('.frm_form_field').replaceWith('<input type="hidden" name="recaptcha_checked" value="'+ frm_js.nonce +'">');
|
1224 |
+
}
|
1225 |
+
if(cont_submit){
|
1226 |
+
object.submit();
|
1227 |
+
}
|
1228 |
+
}
|
1229 |
+
},
|
1230 |
+
error:function(){
|
1231 |
+
jQuery(object).find('input[type="submit"], input[type="button"]').removeAttr('disabled');object.submit();
|
1232 |
+
}
|
1233 |
+
});
|
1234 |
+
}
|
1235 |
+
|
1236 |
+
function clearDefault(){
|
1237 |
+
/*jshint validthis:true */
|
1238 |
+
toggleDefault(jQuery(this), 'clear');
|
1239 |
+
}
|
1240 |
+
|
1241 |
+
function replaceDefault(){
|
1242 |
+
/*jshint validthis:true */
|
1243 |
+
toggleDefault(jQuery(this), 'replace');
|
1244 |
+
}
|
1245 |
+
|
1246 |
+
function toggleDefault($thisField, e){
|
1247 |
+
var v = $thisField.data('frmval').replace(/(\n|\r\n)/g, '\r');
|
1248 |
+
if ( v === '' || typeof v == 'undefined' ) {
|
1249 |
+
return false;
|
1250 |
+
}
|
1251 |
+
var thisVal = $thisField.val().replace(/(\n|\r\n)/g, '\r');
|
1252 |
+
|
1253 |
+
if ( 'replace' == e ) {
|
1254 |
+
if ( thisVal === '' ) {
|
1255 |
+
$thisField.addClass('frm_default').val(v);
|
1256 |
+
}
|
1257 |
+
} else if ( thisVal == v ) {
|
1258 |
+
$thisField.removeClass('frm_default').val('');
|
1259 |
+
}
|
1260 |
+
}
|
1261 |
+
|
1262 |
+
function resendEmail(){
|
1263 |
+
/*jshint validthis:true */
|
1264 |
+
var $link = jQuery(this);
|
1265 |
+
var entry_id = $link.data('eid');
|
1266 |
+
var form_id = $link.data('fid');
|
1267 |
+
$link.append('<span class="spinner" style="display:inline"></span>');
|
1268 |
+
jQuery.ajax({
|
1269 |
+
type:'POST',url:frm_js.ajax_url,
|
1270 |
+
data:{action:'frm_entries_send_email', entry_id:entry_id, form_id:form_id, nonce:frm_js.nonce},
|
1271 |
+
success:function(msg){
|
1272 |
+
$link.replaceWith(msg);
|
1273 |
+
}
|
1274 |
+
});
|
1275 |
+
return false;
|
1276 |
+
}
|
1277 |
+
|
1278 |
+
/* Google Tables */
|
1279 |
+
|
1280 |
+
function prepareGraphTypes( graphs, graphType ) {
|
1281 |
+
for ( var num = 0; num < graphs.length; num++ ) {
|
1282 |
+
prepareGraphs( graphs[num], graphType );
|
1283 |
+
}
|
1284 |
+
}
|
1285 |
+
|
1286 |
+
function prepareGraphs( opts, type ) {
|
1287 |
+
google.load('visualization', '1.0', {'packages':[type], 'callback': function(){
|
1288 |
+
if ( type == 'table' ) {
|
1289 |
+
compileGoogleTable( opts );
|
1290 |
+
} else {
|
1291 |
+
compileGraph( opts );
|
1292 |
+
}
|
1293 |
+
}});
|
1294 |
+
}
|
1295 |
+
|
1296 |
+
function compileGoogleTable(opts){
|
1297 |
+
var data = new google.visualization.DataTable();
|
1298 |
+
|
1299 |
+
var showID = false;
|
1300 |
+
if ( jQuery.inArray('id', opts.options.fields) !== -1 ) {
|
1301 |
+
showID = true;
|
1302 |
+
data.addColumn('number',frm_js.id);
|
1303 |
+
}
|
1304 |
+
|
1305 |
+
var colCount = opts.fields.length;
|
1306 |
+
var type = 'string';
|
1307 |
+
for ( var i = 0, l = colCount; i < l; i++ ) {
|
1308 |
+
var thisCol = opts.fields[i];
|
1309 |
+
type = getGraphType(thisCol);
|
1310 |
+
|
1311 |
+
data.addColumn(type, thisCol.name);
|
1312 |
+
}
|
1313 |
+
|
1314 |
+
var showEdit = false;
|
1315 |
+
if ( opts.options.edit_link ) {
|
1316 |
+
showEdit = true;
|
1317 |
+
data.addColumn('string', opts.options.edit_link);
|
1318 |
+
}
|
1319 |
+
|
1320 |
+
var showDelete = false;
|
1321 |
+
if ( opts.options.delete_link ) {
|
1322 |
+
showDelete = true;
|
1323 |
+
data.addColumn('string', opts.options.delete_link);
|
1324 |
+
}
|
1325 |
+
|
1326 |
+
var col = 0;
|
1327 |
+
if ( opts.entries !== null ) {
|
1328 |
+
var entryCount = opts.entries.length;
|
1329 |
+
data.addRows(entryCount);
|
1330 |
+
|
1331 |
+
var row = 0;
|
1332 |
+
|
1333 |
+
for ( var e = 0, len = entryCount; e < len; e++ ) {
|
1334 |
+
col = 0;
|
1335 |
+
var entry = opts.entries[e];
|
1336 |
+
if ( showID ) {
|
1337 |
+
data.setCell(row, col, entry.id);
|
1338 |
+
col++;
|
1339 |
+
}
|
1340 |
+
|
1341 |
+
for ( var field = 0, fieldCount = colCount; field < fieldCount; field++ ) {
|
1342 |
+
var thisEntryCol = opts.fields[field];
|
1343 |
+
type = getGraphType(thisEntryCol);
|
1344 |
+
|
1345 |
+
var fieldVal = entry.metas[thisEntryCol.id];
|
1346 |
+
if ( type == 'number' && ( fieldVal === null || fieldVal === '' ) ) {
|
1347 |
+
fieldVal = 0;
|
1348 |
+
} else if ( type == 'boolean' ) {
|
1349 |
+
if ( fieldVal === null || fieldVal == 'false' || fieldVal === false ) {
|
1350 |
+
fieldVal = false;
|
1351 |
+
} else {
|
1352 |
+
fieldVal = true;
|
1353 |
+
}
|
1354 |
+
}
|
1355 |
+
|
1356 |
+
data.setCell(row, col, fieldVal);
|
1357 |
+
|
1358 |
+
col++;
|
1359 |
+
}
|
1360 |
+
|
1361 |
+
if ( showEdit ) {
|
1362 |
+
if ( typeof entry.editLink !== 'undefined' ) {
|
1363 |
+
data.setCell(row, col, '<a href="'+ entry.editLink +'">'+ opts.options.edit_link +'</a>');
|
1364 |
+
} else {
|
1365 |
+
data.setCell(row, col, '');
|
1366 |
+
}
|
1367 |
+
col++;
|
1368 |
+
}
|
1369 |
+
|
1370 |
+
if ( showDelete ) {
|
1371 |
+
if ( typeof entry.deleteLink !== 'undefined' ) {
|
1372 |
+
data.setCell(row, col,'<a href="'+ entry.deleteLink +'" class="frm_delete_link" onclick="return confirm('+ opts.options.confirm +')">'+ opts.options.delete_link +'</a>');
|
1373 |
+
} else {
|
1374 |
+
data.setCell(row, col, '');
|
1375 |
+
}
|
1376 |
+
}
|
1377 |
+
|
1378 |
+
row++;
|
1379 |
+
}
|
1380 |
+
} else {
|
1381 |
+
data.addRows(1);
|
1382 |
+
col = 0;
|
1383 |
+
|
1384 |
+
for ( i = 0, l = colCount; i < l; i++ ) {
|
1385 |
+
if ( col > 0 ) {
|
1386 |
+
data.setCell(0, col, '');
|
1387 |
+
} else {
|
1388 |
+
data.setCell(0, col, opts.options.no_entries);
|
1389 |
+
}
|
1390 |
+
col++;
|
1391 |
+
}
|
1392 |
+
}
|
1393 |
+
|
1394 |
+
var chart = new google.visualization.Table(document.getElementById('frm_google_table_'+ opts.options.form_id));
|
1395 |
+
chart.draw( data, opts.graphOpts );
|
1396 |
+
}
|
1397 |
+
|
1398 |
+
function getGraphType(field){
|
1399 |
+
var type = 'string';
|
1400 |
+
if ( field.type == 'number' ){
|
1401 |
+
type = 'number';
|
1402 |
+
} else if ( field.type == 'checkbox' || field.type == 'select' ) {
|
1403 |
+
var optCount = field.options.length;
|
1404 |
+
if ( field.type == 'select' && field.options[0] === '' ) {
|
1405 |
+
if ( field.field_options.post_field == 'post_status' ) {
|
1406 |
+
optCount = 3;
|
1407 |
+
} else {
|
1408 |
+
optCount = optCount - 1;
|
1409 |
+
}
|
1410 |
+
}
|
1411 |
+
if ( optCount == 1 ) {
|
1412 |
+
type = 'boolean';
|
1413 |
+
}
|
1414 |
+
}
|
1415 |
+
return type;
|
1416 |
+
}
|
1417 |
+
|
1418 |
+
function compileGraph(opts){
|
1419 |
+
var data = new google.visualization.DataTable();
|
1420 |
+
var useSepCol = false;
|
1421 |
+
var useTooltip = false;
|
1422 |
+
|
1423 |
+
// add the rows
|
1424 |
+
var rowCount = opts.rows.length;
|
1425 |
+
if ( rowCount > 0 ) {
|
1426 |
+
if ( opts.type == 'table' ) {
|
1427 |
+
useSepCol = true;
|
1428 |
+
var lastRow = opts.rows[rowCount - 1];
|
1429 |
+
var count = lastRow[0] + 1;
|
1430 |
+
data.addRows(count);
|
1431 |
+
|
1432 |
+
for ( var r = 0, len = rowCount; r < len; r++ ) {
|
1433 |
+
data.setCell( opts.rows[r] ); //data.setCell(0, 0, 'Mike');
|
1434 |
+
}
|
1435 |
+
}else{
|
1436 |
+
var firstRow = opts.rows[0];
|
1437 |
+
if ( typeof firstRow.tooltip != 'undefined' ) {
|
1438 |
+
useSepCol = true;
|
1439 |
+
useTooltip = true;
|
1440 |
+
|
1441 |
+
// reset the tooltip key to numeric
|
1442 |
+
for ( var row = 0, rc = rowCount; row < rc; row++ ) {
|
1443 |
+
var tooltip = opts.rows[row].tooltip;
|
1444 |
+
delete opts.rows[row].tooltip;
|
1445 |
+
|
1446 |
+
var rowArray = Object.keys(opts.rows[row]).map( function(k){
|
1447 |
+
return opts.rows[row][k];
|
1448 |
+
} );
|
1449 |
+
|
1450 |
+
opts.rows[row] = rowArray;
|
1451 |
+
opts.rows[row].push(tooltip);
|
1452 |
+
}
|
1453 |
+
}
|
1454 |
+
}
|
1455 |
+
}
|
1456 |
+
|
1457 |
+
// add the columns
|
1458 |
+
var colCount = opts.cols.length;
|
1459 |
+
if ( useSepCol ) {
|
1460 |
+
if ( colCount > 0 ) {
|
1461 |
+
for ( var i = 0, l = colCount; i < l; i++ ) {
|
1462 |
+
var col = opts.cols[i];
|
1463 |
+
data.addColumn(col.type, col.name);
|
1464 |
+
}
|
1465 |
+
}
|
1466 |
+
if ( useTooltip ) {
|
1467 |
+
data.addColumn({type:'string',role:'tooltip'});
|
1468 |
+
data.addRows(opts.rows);
|
1469 |
+
}
|
1470 |
+
} else {
|
1471 |
+
var graphData = [];
|
1472 |
+
graphData[0] = [];
|
1473 |
+
for ( var c = 0, cur = colCount; c < cur; c++ ) {
|
1474 |
+
graphData[0].push(opts.cols[c].name);
|
1475 |
+
}
|
1476 |
+
graphData = graphData.concat(opts.rows);
|
1477 |
+
data = google.visualization.arrayToDataTable(graphData);
|
1478 |
+
}
|
1479 |
+
|
1480 |
+
var type = (opts.type.charAt(0).toUpperCase() + opts.type.slice(1)) + 'Chart';
|
1481 |
+
var chart = new google.visualization[type](document.getElementById('chart_'+ opts.graph_id));
|
1482 |
+
|
1483 |
+
chart.draw(data, opts.options);
|
1484 |
+
}
|
1485 |
+
|
1486 |
+
/* File Fields */
|
1487 |
+
function nextUpload(){
|
1488 |
+
/*jshint validthis:true */
|
1489 |
+
var obj = jQuery(this);
|
1490 |
+
var id = obj.data('fid');
|
1491 |
+
obj.wrap('<div class="frm_file_names frm_uploaded_files">');
|
1492 |
+
var files = obj.get(0).files;
|
1493 |
+
for ( var i = 0; i < files.length; i++ ) {
|
1494 |
+
if ( 0 === i ) {
|
1495 |
+
obj.after(files[i].name+' <a href="#" class="frm_clear_file_link">'+frm_js.remove+'</a>');
|
1496 |
+
} else {
|
1497 |
+
obj.after(files[i].name +'<br/>');
|
1498 |
+
}
|
1499 |
+
}
|
1500 |
+
|
1501 |
+
obj.hide();
|
1502 |
+
|
1503 |
+
var fileName = 'file'+ id;
|
1504 |
+
var fname = obj.attr('name');
|
1505 |
+
if ( fname != 'item_meta['+ id +'][]' ) {
|
1506 |
+
// this is a repeatable field
|
1507 |
+
var nameParts = fname.replace('item_meta[', '').replace('[]', '').split('][');
|
1508 |
+
if ( nameParts.length == 3 ) {
|
1509 |
+
fileName = fileName +'-'+ nameParts[1];
|
1510 |
+
}
|
1511 |
+
}
|
1512 |
+
|
1513 |
+
obj.closest('.frm_form_field').find('.frm_uploaded_files:last').after('<input name="'+ fname +'" data-fid="'+ id +'"class="frm_transparent frm_multiple_file" multiple="multiple" type="file" />');
|
1514 |
+
}
|
1515 |
+
|
1516 |
+
function removeDiv(){
|
1517 |
+
/*jshint validthis:true */
|
1518 |
+
fadeOut(jQuery(this).parent('.frm_uploaded_files'));
|
1519 |
+
}
|
1520 |
+
|
1521 |
+
function clearFile(){
|
1522 |
+
/*jshint validthis:true */
|
1523 |
+
jQuery(this).parent('.frm_file_names').replaceWith('');
|
1524 |
+
return false;
|
1525 |
+
}
|
1526 |
+
|
1527 |
+
/* Repeating Fields */
|
1528 |
+
function removeRow(){
|
1529 |
+
/*jshint validthis:true */
|
1530 |
+
var id = 'frm_section_'+ jQuery(this).data('parent') +'-'+ jQuery(this).data('key');
|
1531 |
+
var thisRow = jQuery(document.getElementById(id));
|
1532 |
+
var fields = thisRow.find('input, select, textarea');
|
1533 |
+
|
1534 |
+
thisRow.fadeOut('slow', function(){
|
1535 |
+
thisRow.remove();
|
1536 |
+
|
1537 |
+
fields.each(function(){
|
1538 |
+
/* update calculations when a row is removed */
|
1539 |
+
if ( this.type != 'file' ) {
|
1540 |
+
var fieldID = this.name.replace('item_meta[', '').split(']')[2].replace('[', '');
|
1541 |
+
doCalculation(fieldID);
|
1542 |
+
}
|
1543 |
+
});
|
1544 |
+
});
|
1545 |
+
|
1546 |
+
return false;
|
1547 |
+
}
|
1548 |
+
|
1549 |
+
function addRow(){
|
1550 |
+
/*jshint validthis:true */
|
1551 |
+
var id = jQuery(this).data('parent');
|
1552 |
+
var i = 0;
|
1553 |
+
if ( jQuery('.frm_repeat_'+id).length > 0 ) {
|
1554 |
+
i = 1 + parseInt(jQuery('.frm_repeat_'+ id +':last').attr('id').replace('frm_section_'+ id +'-', ''));
|
1555 |
+
if ( typeof i == 'undefined' ) {
|
1556 |
+
i = 1;
|
1557 |
+
}
|
1558 |
+
}
|
1559 |
+
|
1560 |
+
jQuery.ajax({
|
1561 |
+
type:'POST',url:frm_js.ajax_url,
|
1562 |
+
dataType: 'json',
|
1563 |
+
data:{action:'frm_add_form_row', field_id:id, i:i, nonce:frm_js.nonce},
|
1564 |
+
success:function(r){
|
1565 |
+
var html = r.html;
|
1566 |
+
var item = jQuery(html).hide().fadeIn('slow');
|
1567 |
+
jQuery('.frm_repeat_'+ id +':last').after(item);
|
1568 |
+
|
1569 |
+
var checked = ['other'];
|
1570 |
+
var fieldID;
|
1571 |
+
var reset = 'reset';
|
1572 |
+
addingRow = item.attr('id');
|
1573 |
+
|
1574 |
+
// hide fields with conditional logic
|
1575 |
+
jQuery(html).find('input, select, textarea').each(function(){
|
1576 |
+
if ( this.type != 'file' ) {
|
1577 |
+
fieldID = this.name.replace('item_meta[', '').split(']')[2].replace('[', '');
|
1578 |
+
if ( jQuery.inArray(fieldID, checked ) == -1 ) {
|
1579 |
+
checked.push(fieldID);
|
1580 |
+
checkDependentField('und', fieldID, null, jQuery(this), reset);
|
1581 |
+
doCalculation(fieldID);
|
1582 |
+
reset = 'persist';
|
1583 |
+
}
|
1584 |
+
}
|
1585 |
+
});
|
1586 |
+
addingRow = '';
|
1587 |
+
|
1588 |
+
// check logic on fields outside of this section
|
1589 |
+
var checkLen = r.logic.check.length;
|
1590 |
+
for ( var f = 0, l = checkLen; f < l; f++ ) {
|
1591 |
+
if ( jQuery.inArray(r.logic.check[f], checked ) == -1 ) {
|
1592 |
+
if(jQuery(html).find('.frm_field_'+r.logic.check[f]+'_container').length < 1){
|
1593 |
+
checkDependentField('und', r.logic.check[f], null, null, reset);
|
1594 |
+
reset = 'persist';
|
1595 |
+
}
|
1596 |
+
}
|
1597 |
+
}
|
1598 |
+
|
1599 |
+
var star = jQuery(html).find('.star');
|
1600 |
+
if ( star.length > 0 ) {
|
1601 |
+
// trigger star fields
|
1602 |
+
jQuery('.star').rating();
|
1603 |
+
}
|
1604 |
+
|
1605 |
+
var autocomplete = jQuery(html).find('.frm_chzn');
|
1606 |
+
if ( autocomplete.length > 0 && jQuery().chosen ) {
|
1607 |
+
// trigger autocomplete
|
1608 |
+
jQuery('.frm_chzn').chosen({allow_single_deselect:true});
|
1609 |
+
}
|
1610 |
+
|
1611 |
+
if(typeof(frmThemeOverride_frmAddRow) == 'function'){
|
1612 |
+
frmThemeOverride_frmAddRow(id, r);
|
1613 |
+
}
|
1614 |
+
}
|
1615 |
+
});
|
1616 |
+
|
1617 |
+
|
1618 |
+
return false;
|
1619 |
+
}
|
1620 |
+
|
1621 |
+
/* General Helpers */
|
1622 |
+
function fadeOut($remove){
|
1623 |
+
$remove.fadeOut('slow', function(){
|
1624 |
+
$remove.remove();
|
1625 |
+
});
|
1626 |
+
}
|
1627 |
+
|
1628 |
+
function toggleDiv(){
|
1629 |
+
/*jshint validthis:true */
|
1630 |
+
var div=jQuery(this).data('frmtoggle');
|
1631 |
+
if(jQuery(div).is(':visible')){
|
1632 |
+
jQuery(div).slideUp('fast');
|
1633 |
+
}else{
|
1634 |
+
jQuery(div).slideDown('fast');
|
1635 |
+
}
|
1636 |
+
return false;
|
1637 |
+
}
|
1638 |
+
|
1639 |
+
function empty($obj) {
|
1640 |
+
if ( $obj !== null ) {
|
1641 |
+
while ( $obj.firstChild ) {
|
1642 |
+
$obj.removeChild($obj.firstChild);
|
1643 |
+
}
|
1644 |
+
}
|
1645 |
+
}
|
1646 |
+
|
1647 |
+
function objectSearch( array, value ) {
|
1648 |
+
for( var prop in array ) {
|
1649 |
+
if( array.hasOwnProperty( prop ) ) {
|
1650 |
+
if( array[ prop ] === value ) {
|
1651 |
+
return prop;
|
1652 |
+
}
|
1653 |
+
}
|
1654 |
+
}
|
1655 |
+
return null;
|
1656 |
+
}
|
1657 |
+
|
1658 |
+
function isNotEmptyArray( value ) {
|
1659 |
+
return jQuery.isArray( value ) && ( value.length > 1 || value[0] !== '' );
|
1660 |
+
}
|
1661 |
+
|
1662 |
+
function isNumeric( obj ) {
|
1663 |
+
return !jQuery.isArray( obj ) && (obj - parseFloat( obj ) + 1) >= 0;
|
1664 |
+
}
|
1665 |
+
|
1666 |
+
/* Get checked values with IE8 fallback */
|
1667 |
+
function getCheckedVal(containerID, inputName) {
|
1668 |
+
var checkVals = [];
|
1669 |
+
if ( typeof document.querySelector == 'undefined') {
|
1670 |
+
var ieVals = jQuery('#'+ containerID +' input[type=checkbox]:checked, input[type=hidden][name^="'+ inputName +'"]');
|
1671 |
+
ieVals.each(function(){
|
1672 |
+
checkVals.push( this.value );
|
1673 |
+
});
|
1674 |
+
} else {
|
1675 |
+
var checkboxes = document.querySelectorAll('#'+ containerID +' input[type=checkbox], input[type=hidden][name^="'+ inputName +'"]');
|
1676 |
+
for ( var b = 0; b < checkboxes.length; b++ ) {
|
1677 |
+
if (( checkboxes[b].type == 'checkbox' && checkboxes[b].checked ) || checkboxes[b].type == 'hidden' ){
|
1678 |
+
checkVals.push( checkboxes[b].value );
|
1679 |
+
}
|
1680 |
+
}
|
1681 |
+
}
|
1682 |
+
|
1683 |
+
return checkVals;
|
1684 |
+
}
|
1685 |
+
|
1686 |
+
return{
|
1687 |
+
init: function(){
|
1688 |
+
jQuery(document).on('click', '.frm_trigger', toggleSection);
|
1689 |
+
var $blankField = jQuery('.frm_blank_field');
|
1690 |
+
if ( $blankField.length ) {
|
1691 |
+
$blankField.closest('.frm_toggle_container').prev('.frm_trigger').click();
|
1692 |
+
}
|
1693 |
+
|
1694 |
+
if ( jQuery.isFunction(jQuery.fn.placeholder) ) {
|
1695 |
+
jQuery('.frm-show-form input, .frm-show-form textarea').placeholder();
|
1696 |
+
} else {
|
1697 |
+
jQuery('.frm-show-form input[onblur], .frm-show-form textarea[onblur]').each(function(){
|
1698 |
+
if(jQuery(this).val() === '' ){
|
1699 |
+
jQuery(this).blur();
|
1700 |
+
}
|
1701 |
+
});
|
1702 |
+
}
|
1703 |
+
|
1704 |
+
jQuery(document).on('focus', '.frm_toggle_default', clearDefault);
|
1705 |
+
jQuery(document).on('blur', '.frm_toggle_default', replaceDefault);
|
1706 |
+
jQuery('.frm_toggle_default').blur();
|
1707 |
+
|
1708 |
+
jQuery(document.getElementById('frm_resend_email')).click(resendEmail);
|
1709 |
+
|
1710 |
+
jQuery(document).on('change', '.frm_multiple_file', nextUpload);
|
1711 |
+
jQuery(document).on('click', '.frm_clear_file_link', clearFile);
|
1712 |
+
jQuery(document).on('click', '.frm_remove_link', removeDiv);
|
1713 |
+
|
1714 |
+
jQuery(document).on('focusin', 'input[data-frmmask]', function(){
|
1715 |
+
jQuery(this).mask( jQuery(this).data('frmmask').toString() );
|
1716 |
+
});
|
1717 |
+
|
1718 |
+
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"]', maybeCheckDependent);
|
1719 |
+
|
1720 |
+
jQuery(document).on('click', '.frm-show-form input[type="submit"], .frm-show-form input[name="frm_prev_page"], .frm-show-form .frm_save_draft', setNextPage);
|
1721 |
+
|
1722 |
+
jQuery(document).on('change', '.frm_other_container input[type="checkbox"], .frm_other_container input[type="radio"], .frm_other_container select', showOtherText);
|
1723 |
+
|
1724 |
+
jQuery(document).on('change', 'input[type=file].frm_transparent', showFileUploadText);
|
1725 |
+
|
1726 |
+
jQuery(document).on('click', '.frm_remove_form_row', removeRow);
|
1727 |
+
jQuery(document).on('click', '.frm_add_form_row', addRow);
|
1728 |
+
|
1729 |
+
jQuery('a[data-frmtoggle]').click(toggleDiv);
|
1730 |
+
|
1731 |
+
// toggle collapsible entries shortcode
|
1732 |
+
jQuery('.frm_month_heading, .frm_year_heading').click( function(){
|
1733 |
+
var content = jQuery(this).children('.ui-icon-triangle-1-e, .ui-icon-triangle-1-s');
|
1734 |
+
if ( content.hasClass('ui-icon-triangle-1-e') ) {
|
1735 |
+
content.addClass('ui-icon-triangle-1-s').removeClass('ui-icon-triangle-1-e');
|
1736 |
+
jQuery(this).next('.frm_toggle_container').fadeIn('slow');
|
1737 |
+
} else {
|
1738 |
+
content.addClass('ui-icon-triangle-1-e').removeClass('ui-icon-triangle-1-s');
|
1739 |
+
jQuery(this).next('.frm_toggle_container').hide();
|
1740 |
+
}
|
1741 |
+
});
|
1742 |
+
},
|
1743 |
+
|
1744 |
+
submitForm: function(e){
|
1745 |
+
e.preventDefault();
|
1746 |
+
if(jQuery(this).find('.wp-editor-wrap').length && typeof(tinyMCE) != 'undefined'){
|
1747 |
+
tinyMCE.triggerSave();
|
1748 |
+
}
|
1749 |
+
|
1750 |
+
var object = this;
|
1751 |
+
action = jQuery(object).find('input[name="frm_action"]').val();
|
1752 |
+
jsErrors = [];
|
1753 |
+
frmFrontForm.getAjaxFormErrors( object );
|
1754 |
+
|
1755 |
+
if ( jsErrors.length === 0 ) {
|
1756 |
+
getFormErrors( object, action );
|
1757 |
+
} else {
|
1758 |
+
// Remove all previous errors
|
1759 |
+
jQuery('.form-field').removeClass('frm_blank_field');
|
1760 |
+
jQuery('.form-field .frm_error').replaceWith('');
|
1761 |
+
|
1762 |
+
var $fieldCont = null;
|
1763 |
+
for ( var key in jsErrors ) {
|
1764 |
+
$fieldCont = jQuery(object).find(jQuery(document.getElementById('frm_field_'+key+'_container')));
|
1765 |
+
if ( $fieldCont.length && $fieldCont.is(':visible') ) {
|
1766 |
+
$fieldCont.addClass('frm_blank_field');
|
1767 |
+
if ( typeof frmThemeOverride_frmPlaceError == 'function' ) {
|
1768 |
+
frmThemeOverride_frmPlaceError( key, jsErrors );
|
1769 |
+
} else {
|
1770 |
+
$fieldCont.append( '<div class="frm_error">'+ jsErrors[key] +'</div>' );
|
1771 |
+
}
|
1772 |
+
}
|
1773 |
+
}
|
1774 |
+
}
|
1775 |
+
},
|
1776 |
+
|
1777 |
+
getAjaxFormErrors: function( object ) {
|
1778 |
+
if ( typeof frmThemeOverride_jsErrors == 'function' ) {
|
1779 |
+
jsErrors = frmThemeOverride_jsErrors( action, object );
|
1780 |
+
} else {
|
1781 |
+
//jsErrors = validateForm( action, object );
|
1782 |
+
}
|
1783 |
+
},
|
1784 |
+
|
1785 |
+
checkFormErrors: function(object, action){
|
1786 |
+
getFormErrors( object, action );
|
1787 |
+
},
|
1788 |
+
|
1789 |
+
scrollToID: function(id){
|
1790 |
+
var frm_pos = jQuery(document.getElementById(id).offset());
|
1791 |
+
window.scrollTo(frm_pos.left, frm_pos.top);
|
1792 |
+
},
|
1793 |
+
|
1794 |
+
scrollMsg: function( id, object, animate ) {
|
1795 |
+
var newPos = '';
|
1796 |
+
if(typeof(object) == 'undefined'){
|
1797 |
+
newPos = jQuery(document.getElementById('frm_form_'+id+'_container')).offset().top;
|
1798 |
+
}else{
|
1799 |
+
newPos = jQuery(object).find(document.getElementById('frm_field_'+id+'_container')).offset().top;
|
1800 |
+
}
|
1801 |
+
|
1802 |
+
if(!newPos){
|
1803 |
+
return;
|
1804 |
+
}
|
1805 |
+
newPos = newPos-frm_js.offset;
|
1806 |
+
|
1807 |
+
var m=jQuery('html').css('margin-top');
|
1808 |
+
var b=jQuery('body').css('margin-top');
|
1809 |
+
if(m || b){
|
1810 |
+
newPos = newPos - parseInt(m) - parseInt(b);
|
1811 |
+
}
|
1812 |
+
|
1813 |
+
if ( newPos && window.innerHeight ) {
|
1814 |
+
var screenTop = document.documentElement.scrollTop || document.body.scrollTop;
|
1815 |
+
var screenBottom = screenTop + window.innerHeight;
|
1816 |
+
|
1817 |
+
if( newPos > screenBottom || newPos < screenTop ) {
|
1818 |
+
// Not in view
|
1819 |
+
if ( typeof animate === 'undefined' ) {
|
1820 |
+
jQuery(window).scrollTop(newPos);
|
1821 |
+
}else{
|
1822 |
+
jQuery('html,body').animate({scrollTop: newPos}, 500);
|
1823 |
+
}
|
1824 |
+
return false;
|
1825 |
+
}
|
1826 |
+
}
|
1827 |
+
},
|
1828 |
+
|
1829 |
+
hideCondFields: function(ids){
|
1830 |
+
ids = JSON.parse(ids);
|
1831 |
+
var len = ids.length;
|
1832 |
+
for ( var i = 0, l = len; i < l; i++ ) {
|
1833 |
+
var container = document.getElementById('frm_field_'+ ids[i] +'_container');
|
1834 |
+
if ( container !== null ) {
|
1835 |
+
container.style.display = 'none';
|
1836 |
+
} else {
|
1837 |
+
// repeating or embedded fields
|
1838 |
+
jQuery('.frm_field_'+ ids[i] +'_container').hide();
|
1839 |
+
}
|
1840 |
+
}
|
1841 |
+
},
|
1842 |
+
|
1843 |
+
checkDependent: function(ids){
|
1844 |
+
ids = JSON.parse(ids);
|
1845 |
+
var len = ids.length;
|
1846 |
+
var reset = 'reset';
|
1847 |
+
for ( var i = 0, l = len; i < l; i++ ) {
|
1848 |
+
checkDependentField('und', ids[i], null, null, reset);
|
1849 |
+
reset = 'persist';
|
1850 |
+
}
|
1851 |
+
},
|
1852 |
+
|
1853 |
+
loadGoogle: function(){
|
1854 |
+
if ( typeof google !== 'undefined' && google && google.load ) {
|
1855 |
+
var graphs = __FRMTABLES;
|
1856 |
+
var packages = Object.keys( graphs );
|
1857 |
+
//google.load('visualization', '1.0', {'packages':packages});
|
1858 |
+
for ( var i = 0; i < packages.length; i++ ) {
|
1859 |
+
prepareGraphTypes( graphs[ packages[i] ], packages[i] );
|
1860 |
+
}
|
1861 |
+
} else {
|
1862 |
+
setTimeout( frmFrontForm.loadGoogle, 30 );
|
1863 |
+
}
|
1864 |
+
},
|
1865 |
+
|
1866 |
+
/* Time fields */
|
1867 |
+
removeUsedTimes: function(obj, timeField){
|
1868 |
+
var e = jQuery(obj).parents('form:first').find('input[name="id"]');
|
1869 |
+
jQuery.ajax({
|
1870 |
+
type:'POST',
|
1871 |
+
url:frm_js.ajax_url,
|
1872 |
+
dataType:'json',
|
1873 |
+
data:{
|
1874 |
+
action:'frm_fields_ajax_time_options',
|
1875 |
+
time_field:timeField, date_field:obj.id,
|
1876 |
+
entry_id: (e ? e.val() : ''), date: jQuery(obj).val(),
|
1877 |
+
nonce:frm_js.nonce
|
1878 |
+
},
|
1879 |
+
success:function(opts){
|
1880 |
+
var $timeField = jQuery(document.getElementById(timeField));
|
1881 |
+
$timeField.find('option').removeAttr('disabled');
|
1882 |
+
if(opts && opts !== ''){
|
1883 |
+
for(var opt in opts){
|
1884 |
+
$timeField.find('option[value="'+opt+'"]').attr('disabled', 'disabled');
|
1885 |
+
}
|
1886 |
+
}
|
1887 |
+
}
|
1888 |
+
});
|
1889 |
+
},
|
1890 |
+
|
1891 |
+
escapeHtml: function(text){
|
1892 |
+
return text
|
1893 |
+
.replace(/&/g, '&')
|
1894 |
+
.replace(/</g, '<')
|
1895 |
+
.replace(/>/g, '>')
|
1896 |
+
.replace(/"/g, '"')
|
1897 |
+
.replace(/'/g, ''');
|
1898 |
+
},
|
1899 |
+
|
1900 |
+
invisible: function(classes) {
|
1901 |
+
jQuery(classes).css('visibility', 'hidden');
|
1902 |
+
},
|
1903 |
+
|
1904 |
+
visible: function(classes) {
|
1905 |
+
jQuery(classes).css('visibility', 'visible');
|
1906 |
+
}
|
1907 |
+
};
|
1908 |
+
}
|
1909 |
+
var frmFrontForm = frmFrontFormJS();
|
1910 |
+
|
1911 |
+
jQuery(document).ready(function($){
|
1912 |
+
frmFrontForm.init();
|
1913 |
+
});
|
1914 |
+
|
1915 |
+
function frmEditEntry(entry_id,prefix,post_id,form_id,cancel,hclass){
|
1916 |
+
var $edit = jQuery(document.getElementById('frm_edit_'+entry_id));
|
1917 |
+
var label = $edit.html();
|
1918 |
+
var $cont = jQuery(document.getElementById(prefix+entry_id));
|
1919 |
+
var orig = $cont.html();
|
1920 |
+
$cont.html('<span class="frm-loading-img" id="'+prefix+entry_id+'"></span><div class="frm_orig_content" style="display:none">'+orig+'</div>');
|
1921 |
+
jQuery.ajax({
|
1922 |
+
type:'POST',url:frm_js.ajax_url,dataType:'html',
|
1923 |
+
data:{action:'frm_entries_edit_entry_ajax', post_id:post_id, entry_id:entry_id, id:form_id, nonce:frm_js.nonce},
|
1924 |
+
success:function(html){
|
1925 |
+
$cont.children('.frm-loading-img').replaceWith(html);
|
1926 |
+
$edit.replaceWith('<span id="frm_edit_'+entry_id+'"><a onclick="frmCancelEdit('+entry_id+',\''+prefix+'\',\''+ frmFrontForm.escapeHtml(label) +'\','+post_id+','+form_id+',\''+hclass+'\')" class="'+hclass+'">'+cancel+'</a></span>');
|
1927 |
+
}
|
1928 |
+
});
|
1929 |
+
}
|
1930 |
+
|
1931 |
+
function frmCancelEdit(entry_id,prefix,label,post_id,form_id,hclass){
|
1932 |
+
var $edit = jQuery(document.getElementById('frm_edit_'+entry_id));
|
1933 |
+
var $link = $edit.find('a');
|
1934 |
+
var cancel = $link.html();
|
1935 |
+
|
1936 |
+
if(!$link.hasClass('frm_ajax_edited')){
|
1937 |
+
var $cont = jQuery(document.getElementById(prefix+entry_id));
|
1938 |
+
$cont.children('.frm_forms').replaceWith('');
|
1939 |
+
$cont.children('.frm_orig_content').fadeIn('slow').removeClass('frm_orig_content');
|
1940 |
+
}
|
1941 |
+
$edit.replaceWith('<a id="frm_edit_'+entry_id+'" class="frm_edit_link '+hclass+'" href="javascript:frmEditEntry('+entry_id+',\''+prefix+'\','+post_id+','+form_id+',\''+ frmFrontForm.escapeHtml(cancel) +'\',\''+hclass+'\')">'+label+'</a>');
|
1942 |
+
}
|
1943 |
+
|
1944 |
+
function frmUpdateField(entry_id,field_id,value,message,num){
|
1945 |
+
jQuery(document.getElementById('frm_update_field_'+entry_id+'_'+field_id)).html('<span class="frm-loading-img"></span>');
|
1946 |
+
jQuery.ajax({
|
1947 |
+
type:'POST',url:frm_js.ajax_url,
|
1948 |
+
data:{action:'frm_entries_update_field_ajax', entry_id:entry_id, field_id:field_id, value:value, nonce:frm_js.nonce},
|
1949 |
+
success:function(){
|
1950 |
+
if(message.replace(/^\s+|\s+$/g,'') === ''){
|
1951 |
+
jQuery(document.getElementById('frm_update_field_'+entry_id+'_'+field_id+'_'+num)).fadeOut('slow');
|
1952 |
+
}else{
|
1953 |
+
jQuery(document.getElementById('frm_update_field_'+entry_id+'_'+field_id+'_'+num)).replaceWith(message);
|
1954 |
+
}
|
1955 |
+
}
|
1956 |
+
});
|
1957 |
+
}
|
1958 |
+
|
1959 |
+
function frmDeleteEntry(entry_id,prefix){
|
1960 |
+
jQuery(document.getElementById('frm_delete_'+entry_id)).replaceWith('<span class="frm-loading-img" id="frm_delete_'+entry_id+'"></span>');
|
1961 |
+
jQuery.ajax({
|
1962 |
+
type:'POST',url:frm_js.ajax_url,
|
1963 |
+
data:{action:'frm_entries_destroy', entry:entry_id, nonce:frm_js.nonce},
|
1964 |
+
success:function(html){
|
1965 |
+
if(html.replace(/^\s+|\s+$/g,'') == 'success')
|
1966 |
+
jQuery(document.getElementById(prefix+entry_id)).fadeOut('slow');
|
1967 |
+
else
|
1968 |
+
jQuery(document.getElementById('frm_delete_'+entry_id)).replaceWith(html);
|
1969 |
+
|
1970 |
+
}
|
1971 |
+
});
|
1972 |
+
}
|
1973 |
+
|
1974 |
+
function frmOnSubmit(e){
|
1975 |
+
console.warn('DEPRECATED: function frmOnSubmit in v2.0 use frmFrontForm.submitForm');
|
1976 |
+
frmFrontForm.submitForm(e, this);
|
1977 |
+
}
|
1978 |
+
|
1979 |
+
function frm_resend_email(entry_id,form_id){
|
1980 |
+
console.warn('DEPRECATED: function frm_resend_email in v2.0');
|
1981 |
+
$link = jQuery(document.getElementById('frm_resend_email'));
|
1982 |
+
$link.append('<span class="spinner" style="display:inline"></span>');
|
1983 |
+
jQuery.ajax({
|
1984 |
+
type:'POST',url:frm_js.ajax_url,
|
1985 |
+
data:{action:'frm_entries_send_email', entry_id:entry_id, form_id:form_id, nonce:frm_js.nonce},
|
1986 |
+
success:function(msg){
|
1987 |
+
$link.replaceWith(msg);
|
1988 |
+
}
|
1989 |
+
});
|
1990 |
+
}
|
js/formidable.min.js
CHANGED
@@ -1,57 +1,59 @@
|
|
1 |
-
function frmFrontFormJS(){function l(a){var b=jQuery(this),c=b.attr("type");"submit"!==c&&a.preventDefault();a=b.parents("form:first");var d=b="",
|
2 |
jQuery(this).toggleClass("active").children(".ui-icon-triangle-1-e, .ui-icon-triangle-1-s").toggleClass("ui-icon-triangle-1-s ui-icon-triangle-1-e")}function p(){this.className=this.className.replace("frm_transparent","");this.parentNode.getElementsByTagName("a")[0].className.indexOf("frm_clear_file_link")}function v(){var a=this.type,b=!1,c=!1;if("select-one"===a)c=!0,"frm_other_trigger"===this.options[this.selectedIndex].className&&(b=!0);else if("select-multiple"===a)for(var c=!0,d=this.options,
|
3 |
-
b=!1,
|
4 |
-
"checkbox"===a&&(this.checked?jQuery(this).closest(".frm_checkbox").children(".frm_other_input").removeClass("frm_pos_none"):jQuery(this).closest(".frm_checkbox").children(".frm_other_input").addClass("frm_pos_none").val(""))}function w(a){var b;b=this.name.replace("item_meta[","").split("]");var c=b[0],d=!1;jQuery('input[name="item_meta['+c+'][form]"]').length&&(c=b[2].replace("[",""),d=!0);"other"===c&&(c=d?b[3].replace("[",""):b[1].replace("[",
|
5 |
-
b)return;c="persist"}q("und",b,null,jQuery(this),c);
|
6 |
-
|
7 |
-
b.HideField+"_container";b.hideBy="#";var
|
8 |
-
b.HideField+"]"))}else{u(b);
|
9 |
-
f.eq(0))}u(b);null===document.getElementById(b.hideContainerID)&&(b.hideBy=".");if(b.FieldName!==c||"undefined"===typeof d||"und"===d)if(("radio"===b.Type||"data-radio"===b.Type)&&"radio"===
|
10 |
-
|
11 |
-
(m[b.hideContainerID][a]=!0),
|
12 |
-
"data-radio"===b.Type?m[b.hideContainerID][a]="undefined"===typeof b.DataType?z(b.Condition,b.Value,d):{funcName:"getData",f:b,sel:d}:"data-checkbox"===b.Type||"data-select"===b.Type&&
|
13 |
-
m[b.hideContainerID][a]=z(b.Condition,b.Value,d);K(a,b,
|
14 |
-
var d=!1;c.each(function(){"SELECT"==this.tagName&&null!==document.getElementById(this.id+"_chosen")&&jQuery(this).trigger("chosen:updated");!1===d&&jQuery(this)
|
15 |
-
|
16 |
-
m[b.hideContainerID][a]){
|
17 |
-
c.match&&-1<jQuery.inArray(!1,m[c.hideContainerID]))
|
18 |
-
"!=":function(a,b){return a!=b},"<":function(a,b){return a>b},">":function(a,b){return a<b},LIKE:function(a,b){return b?-1!=b.indexOf(a):0},"not LIKE":function(a,b){return b?-1==b.indexOf(a):1}}[a](b,c)}function
|
19 |
-
url:frm_js.ajax_url,data:{action:"frm_fields_ajax_get_data",entry_id:b,field_id:a.LinkedField,current_field:a.HideField,hide_id:a.hideContainerID,nonce:frm_js.nonce},success:function(a){c?
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
"
|
26 |
-
|
27 |
-
|
28 |
-
"
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
"
|
34 |
-
|
35 |
-
a.
|
36 |
-
c.
|
37 |
-
a.
|
38 |
-
a.
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
"").
|
43 |
-
"
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
(
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
|
|
|
|
55 |
function frmEditEntry(l,n,p,v,w,q){var r=jQuery(document.getElementById("frm_edit_"+l)),u=r.html(),y=jQuery(document.getElementById(n+l)),A=y.html();y.html('<span class="frm-loading-img" id="'+n+l+'"></span><div class="frm_orig_content" style="display:none">'+A+"</div>");jQuery.ajax({type:"POST",url:frm_js.ajax_url,dataType:"html",data:{action:"frm_entries_edit_entry_ajax",post_id:p,entry_id:l,id:v,nonce:frm_js.nonce},success:function(A){y.children(".frm-loading-img").replaceWith(A);r.replaceWith('<span id="frm_edit_'+
|
56 |
l+'"><a onclick="frmCancelEdit('+l+",'"+n+"','"+frmFrontForm.escapeHtml(u)+"',"+p+","+v+",'"+q+'\')" class="'+q+'">'+w+"</a></span>")}})}
|
57 |
function frmCancelEdit(l,n,p,v,w,q){var r=jQuery(document.getElementById("frm_edit_"+l)),u=r.find("a"),y=u.html();u.hasClass("frm_ajax_edited")||(u=jQuery(document.getElementById(n+l)),u.children(".frm_forms").replaceWith(""),u.children(".frm_orig_content").fadeIn("slow").removeClass("frm_orig_content"));r.replaceWith('<a id="frm_edit_'+l+'" class="frm_edit_link '+q+'" href="javascript:frmEditEntry('+l+",'"+n+"',"+v+","+w+",'"+frmFrontForm.escapeHtml(y)+"','"+q+"')\">"+p+"</a>")}
|
1 |
+
function frmFrontFormJS(){function l(a){var b=jQuery(this),c=b.attr("type");"submit"!==c&&a.preventDefault();a=b.parents("form:first");var d=b="",f=this.name;if("frm_prev_page"===f||-1!==this.className.indexOf("frm_prev_page"))b=jQuery(a).find(".frm_next_page").attr("id").replace("frm_next_p_","");else if("frm_save_draft"===f||-1!==this.className.indexOf("frm_save_draft"))d=1;jQuery(".frm_next_page").val(b);jQuery(".frm_saving_draft").val(d);"submit"!==c&&a.trigger("submit")}function n(){jQuery(this).parent().children(".frm_toggle_container").slideToggle("fast");
|
2 |
jQuery(this).toggleClass("active").children(".ui-icon-triangle-1-e, .ui-icon-triangle-1-s").toggleClass("ui-icon-triangle-1-s ui-icon-triangle-1-e")}function p(){this.className=this.className.replace("frm_transparent","");this.parentNode.getElementsByTagName("a")[0].className.indexOf("frm_clear_file_link")}function v(){var a=this.type,b=!1,c=!1;if("select-one"===a)c=!0,"frm_other_trigger"===this.options[this.selectedIndex].className&&(b=!0);else if("select-multiple"===a)for(var c=!0,d=this.options,
|
3 |
+
b=!1,f=0;f<d.length;f++)if("frm_other_trigger"===d[f].className&&d[f].selected){b=!0;break}c?(a=jQuery(this).parent().children(".frm_other_input"),b?a[0].className=a[0].className.replace("frm_pos_none",""):(1>a[0].className.indexOf("frm_pos_none")&&(a[0].className+=" frm_pos_none"),a[0].value="")):"radio"===a?jQuery(this).is(":checked")&&(jQuery(this).closest(".frm_radio").children(".frm_other_input").removeClass("frm_pos_none"),jQuery(this).closest(".frm_radio").siblings().children(".frm_other_input").addClass("frm_pos_none").val("")):
|
4 |
+
"checkbox"===a&&(this.checked?jQuery(this).closest(".frm_checkbox").children(".frm_other_input").removeClass("frm_pos_none"):jQuery(this).closest(".frm_checkbox").children(".frm_other_input").addClass("frm_pos_none").val(""))}function w(a){var b;b="";b=this instanceof jQuery?this.attr("name"):this.name;b=b.replace("item_meta[","").split("]");var c=b[0],d=!1;jQuery('input[name="item_meta['+c+'][form]"]').length&&(c=b[2].replace("[",""),d=!0);"other"===c&&(c=d?b[3].replace("[",""):b[1].replace("[",
|
5 |
+
""));if((b=c)&&"undefined"!==typeof b){c="reset";if(a.frmTriggered){if(a.frmTriggered==b)return;c="persist"}q("und",b,null,jQuery(this),c);E(b,jQuery(this))}}function q(a,b,c,d,f){var e;if("undefined"===typeof __FRMRULES||"undefined"===typeof __FRMRULES[b])e=void 0;else{e=__FRMRULES[b];for(var h=[],g=0,k=e.length;g<k;g++){var l=e[g];if("undefined"!==typeof l)for(var F=0,n=l.Conditions.length;F<n;F++){var p=l.Conditions[F];p.HideField=l.Setting.FieldName;p.MatchType=l.MatchType;p.Show=l.Show;h.push(p)}}e=
|
6 |
+
h}if("undefined"!==typeof e){if("undefined"===typeof c||null===c)c="go";"persist"!==f&&(m=[],D=[]);f=d;h=!1;""===x&&"undefined"!==typeof f&&null!==f&&(1<f.length&&(f=f.eq(0)),h=f.closest(".frm_repeat_sec, .frm_repeat_inline, .frm_repeat_grid"),"undefined"!==typeof h?(x=h.attr("id"),h=!0):h=!1);f=h;h=e.length;for(g=0;g<h;g++)e[g].FieldName===b?r(g,e[g],b,a,c,d):r(g,e[g],b,a,c),g===h-1&&(V(c),f&&(x=""))}}function r(a,b,c,d,f,e){b.inputName="item_meta["+b.FieldName+"]";b.hiddenName="item_meta["+b.HideField+
|
7 |
+
"]";b.containerID="frm_field_"+b.FieldName+"_container";b.hideContainerID="frm_field_"+b.HideField+"_container";b.hideBy="#";var h=!1;if("undefined"!==typeof e&&null!==e){1<e.length&&(e=e.eq(0));if("undefined"===typeof e.attr("name"))return;b.inputName=e.attr("name").replace("[other]","").replace("[]","");var g=e.closest(".frm_repeat_sec, .frm_repeat_inline, .frm_repeat_grid");g.length&&(g=g.find(".frm_field_"+b.FieldName+"_container"),b.containerID=g.attr("id"),b.hideContainerID=b.containerID.replace(b.FieldName,
|
8 |
+
b.HideField),b.hiddenName=b.inputName.replace("["+b.FieldName+"]","["+b.HideField+"]"))}else{u(b);h=!0;e=jQuery('input[name^="'+b.inputName+'"], textarea[name^="'+b.inputName+'"], select[name^="'+b.inputName+'"]');if(1>e.length&&(g="."+b.containerID,""!==x&&(g="#"+x+" "+g),g=jQuery(g),g.length)){e=g.find("input, textarea, select");if(e.length)if(""===x){var k="";e.each(function(){var c=jQuery(this).closest(".frm_form_field").attr("id");c!=k&&r(a,b,b.FieldName,d,f,jQuery(this));k=c})}else r(a,b,c,
|
9 |
+
d,f,e);else m[b.hideContainerID][a]=!1,K(a,b,f);return}1<e.length&&(e=e.eq(0))}u(b);null===document.getElementById(b.hideContainerID)&&(b.hideBy=".");if(b.FieldName!==c||"undefined"===typeof d||"und"===d)if(("radio"===b.Type||"data-radio"===b.Type)&&"radio"===e.attr("type"))d=jQuery('input[name="'+b.inputName+'"]:checked').val(),"undefined"===typeof d&&(d="");else if("select"===b.Type||"time"===b.Type||"data-select"===b.Type||"checkbox"!==b.Type&&"data-checkbox"!==b.Type)d=e.val();if("undefined"===
|
10 |
+
typeof d){if(0===e.length)return;d=e.val()}if("undefined"===typeof d){if(!0===h&&(c=jQuery("."+b.containerID+" input, ."+b.containerID+" select, ."+b.containerID+" textarea"),c.length)){c.each(function(){r(a,b,b.FieldName,d,f,jQuery(this))});return}d=""}c=[];if("checkbox"===b.Type||"data-checkbox"===b.Type)c=W(b.containerID,b.inputName),d=c.length?c:"";m[b.hideContainerID][a]=""===d||1>d.length?!1:{funcName:"getDataOpts",f:b,sel:d};if("checkbox"===b.Type||"data-checkbox"===b.Type&&"undefined"===typeof b.LinkedField)if(c=
|
11 |
+
m[b.hideContainerID][a]=!1,""!==d)for("!="===b.Condition&&(m[b.hideContainerID][a]=!0),e=0;e<d.length;e++)c=z(b.Condition,b.Value,d[e]),"!="===b.Condition?!0===m[b.hideContainerID][a]&&!1===c&&(m[b.hideContainerID][a]=!1):!1===m[b.hideContainerID][a]&&c&&(m[b.hideContainerID][a]=!0);else c=z(b.Condition,b.Value,""),!1===m[b.hideContainerID][a]&&c&&(m[b.hideContainerID][a]=!0);else if("undefined"!==typeof b.LinkedField&&0===b.Type.indexOf("data-")){if("undefined"===typeof b.DataType||"data"===b.DataType)""===
|
12 |
+
d?y(b.hideContainerID,b.hideBy,b.HideField,"hide"):"data-radio"===b.Type?m[b.hideContainerID][a]="undefined"===typeof b.DataType?z(b.Condition,b.Value,d):{funcName:"getData",f:b,sel:d}:"data-checkbox"===b.Type||"data-select"===b.Type&&X(d)?(y(b.hideContainerID,b.hideBy,b.HideField,"show"),m[b.hideContainerID][a]=!0,L(b,d,1)):"data-select"===b.Type&&(m[b.hideContainerID][a]={funcName:"getData",f:b,sel:d})}else"undefined"===typeof b.Value&&0===b.Type.indexOf("data")?(b.Value=""===d?"1":d,m[b.hideContainerID][a]=
|
13 |
+
z(b.Condition,b.Value,d),b.Value=void 0):m[b.hideContainerID][a]=z(b.Condition,b.Value,d);K(a,b,f)}function u(a){"undefined"===typeof m[a.hideContainerID]&&(m[a.hideContainerID]=[])}function y(a,b,c,d){-1===jQuery.inArray(a,D)&&(D[c]=a,a="."===b?jQuery("."+a):jQuery(document.getElementById(a)),"hide"===d&&a.hide(),a.find(".frm_data_field_container").empty())}function A(a,b){a.hide();if(-1===jQuery.inArray(a.attr("id"),D)){D[b.HideField]=a.attr("id");var c=M(a);if(c.length){c.prop("checked",!1).prop("selectedIndex",
|
14 |
+
0);c.not(":checkbox, :radio, select").val("");var d=!1;c.each(function(){"SELECT"==this.tagName&&null!==document.getElementById(this.id+"_chosen")&&jQuery(this).trigger("chosen:updated");!1===d&&B(jQuery(this));d=!0})}}}function M(a){return a.find('select[name^="item_meta"], textarea[name^="item_meta"], input[name^="item_meta"]:not([type=hidden])')}function N(a,b){var c=M(a),d=c.length;if(d)for(var f=0;f<d;f++){var e=jQuery(c[f]),h=e.data("frmval");if("undefined"!==typeof h)if(!e.is(":checkbox, :radio"))e.val(h),
|
15 |
+
B(e);else if(e.val()==h||jQuery.isArray(h)&&-1!==jQuery.inArray(e.val(),h))e.prop("checked",!0),B(e)}"undefined"!==typeof __FRMCALC&&(d=__FRMCALC,f=d.fieldsWithCalc[b.HideField],"undefined"!==typeof f&&O(d,f,[],c));a.show()}function B(a,b){"undefined"===typeof b&&(b="dependent");a.trigger({type:"change",selfTriggered:!0,frmTriggered:b})}function K(a,b,c){if("all"===b.MatchType||!1===m[b.hideContainerID][a])G.push({result:m[b.hideContainerID][a],show:b.Show,match:b.MatchType,FieldName:b.FieldName,
|
16 |
+
HideField:b.HideField,hideContainerID:b.hideContainerID,hideBy:b.hideBy});else{var d="none";if("show"===b.Show){if(!0!==m[b.hideContainerID][a]){P(m[b.hideContainerID][a],b.FieldName,c);return}d=""}a="."===b.hideBy?jQuery("."+b.hideContainerID):jQuery(document.getElementById(b.hideContainerID));a.length&&("none"===d?A(a,b):N(a,b))}}function V(a){jQuery.each(G,function(b,c){delete G[b];if("undefined"!==typeof c&&"undefined"!==typeof c.result){var d=jQuery(c.hideBy+c.hideContainerID),f=c.show;if(d.length){if("any"===
|
17 |
+
c.match&&-1===jQuery.inArray(!0,m[c.hideContainerID])||"all"===c.match&&-1<jQuery.inArray(!1,m[c.hideContainerID]))f="show"===c.show?"hide":"show";"show"===f?(N(d,c),!1!==typeof c.result&&!0!==typeof c.result&&P(c.result,c.FieldName,a)):A(d,c)}}})}function z(a,b,c){"undefined"===typeof c&&(c="");jQuery.isArray(c)&&-1<jQuery.inArray(b,c)&&(c=b);-1!==String(b).search(/^\s*(\+|-)?((\d+(\.\d+)?)|(\.\d+))\s*$/)&&(b=parseFloat(b),c=parseFloat(c));return"-1"!=String(b).indexOf(""")&&z(a,b.replace(""",
|
18 |
+
'"'),c)?!0:{"==":function(a,b){return a==b},"!=":function(a,b){return a!=b},"<":function(a,b){return a>b},">":function(a,b){return a<b},LIKE:function(a,b){return b?-1!=b.indexOf(a):0},"not LIKE":function(a,b){return b?-1==b.indexOf(a):1}}[a](b,c)}function P(a,b,c){"getDataOpts"==a.funcName?Y(a.f,a.sel,b,c):"getData"==a.funcName&&L(a.f,a.sel,0)}function L(a,b,c){var d=document.getElementById(a.hideContainerID),f=jQuery(d).find(".frm_data_field_container");if(0===f.length)return!0;c||f.html('<span class="frm-loading-img"></span>');
|
19 |
+
jQuery.ajax({type:"POST",url:frm_js.ajax_url,data:{action:"frm_fields_ajax_get_data",entry_id:b,field_id:a.LinkedField,current_field:a.HideField,hide_id:a.hideContainerID,nonce:frm_js.nonce},success:function(a){c?f.append(a):f.html(a);var b=f.children("input"),g=b.val();d.style.display=""===a&&!c||""===g?"none":"";B(b);return!0}})}function Y(a,b,c,d){if(!("stop"==d&&-1<jQuery.inArray(a.HideField,H)&&a.parentField&&"hidden"==a.parentField.attr("type"))){var f=jQuery('input[name^="'+a.hiddenName+'"], select[name^="'+
|
20 |
+
a.hiddenName+'"]:not(":disabled"), textarea[name^="'+a.hiddenName+'"]'),e=[];f.each(function(){"radio"===this.type||"checkbox"===this.type?!0===this.checked&&e.push(jQuery(this).val()):e.push(jQuery(this).val())});if("select"!=a.DataType||"stop"!=d&&!jQuery("#"+a.hideContainerID+" .frm-loading-img").length||!(-1<jQuery.inArray(a.HideField,H))){0===e.length&&(e="");H.push(a.HideField);var h=document.getElementById(a.hideContainerID),g=jQuery(h).find(".frm_data_field_container");if(0===g.length&&f.length)return q(e,
|
21 |
+
a.HideField,"stop",f),!1;if(""!==a.Value&&!z(a.Condition,a.Value,b))return h.style.display="none",g.html(""),q("",a.HideField,"stop",f),!1;g.html('<span class="frm-loading-img" style="visibility:visible;display:inline;"></span>');var k=a.DataType;jQuery.ajax({type:"POST",url:frm_js.ajax_url,data:{action:"frm_fields_ajax_data_options",hide_field:c,entry_id:b,selected_field_id:a.LinkedField,field_id:a.HideField,hide_id:a.hideContainerID,nonce:frm_js.nonce},success:function(b){g.html(b);var c=g.find("select, input, textarea"),
|
22 |
+
d=1;"hidden"==c.attr("type")&&(d=c.val());""===b||""===d?(h.style.display="none",e=""):"all"!=a.MatchType&&(h.style.display="");""!==b&&""!==e&&(jQuery.isArray(e)||(b=[],b.push(e),e=b),jQuery.each(e,function(a,b){if("undefined"!==typeof b&&""!==b)if("checkbox"==k||"radio"==k)1<c.length?c.filter('[value="'+b+'"]').attr("checked","checked"):c.val()==b&&c.attr("checked","checked");else if("select"==k){var d=c.children('option[value="'+b+'"]');d.length?d.prop("selected",!0):e.splice(a,1)}else c.val(b)}));
|
23 |
+
c.hasClass("frm_chzn")&&jQuery().chosen&&jQuery(".frm_chzn").chosen({allow_single_deselect:!0});B(c)}})}}}function E(a,b){if("undefined"!==typeof __FRMCALC){var c=__FRMCALC,d=c.fields[a];if("undefined"!==typeof d)for(var d=d.total,f=[],e=0,h=d.length;e<h;e++){var g=document.getElementById("frm_field_"+c.calc[d[e]].field_id+"_container");null!==g&&0===g.offsetHeight||O(c,d[e],f,b)}}}function O(a,b,c,d){var f=a.calc[b],e=f.calc,h=jQuery(document.getElementById("field_"+b)),g={triggerField:d,inSection:!1,
|
24 |
+
thisFieldCall:'input[id^="field_'+b+'-"]'};1>h.length&&"undefined"!==typeof d&&(g.inSection=!0,g.thisFieldId=Z(a.fieldsWithCalc,b),h=Q(g));e=aa(f,e,a,c,g);a=f.calc_dec;e.indexOf(").toFixed(")&&(c=e.split(").toFixed("),R(c[1])&&(a=c[1],e=e.replace(").toFixed("+a,"")));e=parseFloat(eval(e));R(a)&&(e=e.toFixed(a));"undefined"===typeof e&&(e=0);h.val()!=e&&(h.val(e),B(h,b))}function aa(a,b,c,d,f){for(var e=0,h=a.fields.length;e<h;e++){var g={triggerField:f.triggerField,thisFieldId:a.fields[e],inSection:f.inSection,
|
25 |
+
valKey:f.inSection+""+a.fields[e],thisField:c.fields[a.fields[e]],thisFieldCall:"input"+c.fieldKeys[a.fields[e]]},k=c;"checkbox"==g.thisField.type||"select"==g.thisField.type?g.thisFieldCall=g.thisFieldCall+":checked,select"+k.fieldKeys[g.thisFieldId]+" option:selected,"+g.thisFieldCall+"[type=hidden]":"radio"==g.thisField.type||"scale"==g.thisField.type?g.thisFieldCall=g.thisFieldCall+":checked,"+g.thisFieldCall+"[type=hidden]":"textarea"==g.thisField.type&&(g.thisFieldCall=g.thisFieldCall+",textarea"+
|
26 |
+
k.fieldKeys[g.thisFieldId]);d=ba(g,c,d);if("undefined"===typeof d[g.valKey]||isNaN(d[g.valKey]))d[g.valKey]=0;k="["+g.thisFieldId+"]";k=k.replace(/([.*+?^=!:${}()|\[\]\/\\])/g,"\\$1");b=b.replace(new RegExp(k,"g"),d[g.valKey])}return b}function ba(a,b,c){if("undefined"!==typeof c[a.valKey]&&0!==c[a.valKey])return c;c[a.valKey]=0;var d;if(!1===a.inSection)d=jQuery(a.thisFieldCall);else if(d=Q(a),null===d||"undefined"===typeof d)d=jQuery(a.thisFieldCall);if(null===d||"undefined"===typeof d||1>d.length)return c;
|
27 |
+
d.each(function(){var d;d=a.thisField;var e=!1;if("hidden"==this.type)""!==I(this)&&(e=!0);else if("select"==d.type){var h=this.className;h&&-1<h.indexOf("frm_other_trigger")&&(e=!0)}else("checkbox"==d.type||"radio"==d.type)&&-1<this.id.indexOf("-other_")&&0>this.id.indexOf("-otext")&&(e=!0);e?(e=0,"select"==d.type?"hidden"==this.type?(d=!1,2<this.name.split("[").length&&(d=!0),d||(e=I(this))):e=jQuery(this).closest(".frm_other_container").find(".frm_other_input").val():"checkbox"!=d.type&&"radio"!=
|
28 |
+
d.type||"hidden"==this.type||(e=I(this)),d=e):d="checkbox"!==this.type&&"radio"!==this.type||!this.checked?jQuery(this).val():this.value;"undefined"===typeof d&&(d="");"date"==a.thisField.type&&(e=jQuery.datepicker.parseDate(b.date,d),null!==e&&(c[a.valKey]=Math.ceil(e/864E5)));""!==d&&0!==d&&(d=d.trim(),d=parseFloat(d.replace(/,/g,"").match(/-?[\d\.]+$/)));if("undefined"===typeof d||isNaN(d)||""===d)d=0;c[a.valKey]+=d});return c}function Q(a){if("undefined"===typeof a.triggerField)return null;var b=
|
29 |
+
a.triggerField.closest(".frm_repeat_sec, .frm_repeat_inline, .frm_repeat_grid");if(b.length){var c=".frm_field_"+a.thisFieldId+"_container ";a=a.thisFieldCall.split(",");for(var d="",f=0,e=a.length;f<e;f++)""!==d&&(d+=","),d=d+c+a[f].replace("[id=","[id^=");return b.find(d)}return null}function I(a){var b="";a=document.getElementById(a.id+"-otext");null!==a&&""!==a.value&&(b=a.value);return b}function S(a,b){jQuery(a).find('input[type="submit"], input[type="button"]').attr("disabled","disabled");
|
30 |
+
jQuery(a).find(".frm_ajax_loading").addClass("frm_loading_now");"undefined"==typeof b&&jQuery(a).find('input[name="frm_action"]').val();jQuery.ajax({type:"POST",url:frm_js.ajax_url,data:jQuery(a).serialize()+"&action=frm_entries_"+b+"&nonce="+frm_js.nonce,success:function(b){b=b.replace(/^\s+|\s+$/g,"");0===b.indexOf("{")&&(b=jQuery.parseJSON(b));if(""===b||!b||"0"===b||"object"!=typeof b&&0===b.indexOf("<!DOCTYPE")){var d=document.getElementById("frm_loading");null!==d&&(b=jQuery(a).find("input[type=file]").val(),
|
31 |
+
"undefined"!=typeof b&&""!==b&&setTimeout(function(){jQuery(d).fadeIn("slow")},2E3));b=jQuery(a).find(".g-recaptcha");b.length&&(1>jQuery(a).find(".frm_next_page").length||1>jQuery(a).find(".frm_next_page").val())&&b.closest(".frm_form_field").replaceWith('<input type="hidden" name="recaptcha_checked" value="'+frm_js.nonce+'">');a.submit()}else if("object"!=typeof b){jQuery(a).find(".frm_ajax_loading").removeClass("frm_loading_now");var f=jQuery(a).find('input[name="form_id"]').val();jQuery(a).closest("#frm_form_"+
|
32 |
+
f+"_container").replaceWith(b);frmFrontForm.scrollMsg(f);if("function"==typeof frmThemeOverride_frmAfterSubmit){var f=jQuery('input[name="frm_page_order_'+f+'"]').val(),e=jQuery(b).find('input[name="form_id"]').val();frmThemeOverride_frmAfterSubmit(e,f,b,a)}b=jQuery(a).find('input[name="id"]');b.length&&jQuery(document.getElementById("frm_edit_"+b.val())).find("a").addClass("frm_ajax_edited").click()}else{jQuery(a).find('input[type="submit"], input[type="button"]').removeAttr("disabled");jQuery(a).find(".frm_ajax_loading").removeClass("frm_loading_now");
|
33 |
+
f=!0;jQuery(".form-field").removeClass("frm_blank_field");jQuery(".form-field .frm_error").replaceWith("");var e="",h=!1,g=null,k;for(k in b)if(g=jQuery(a).find(jQuery(document.getElementById("frm_field_"+k+"_container"))),g.length){if(!g.is(":visible")){var l=g.closest(".frm_toggle_container");l.length&&l.prev(".frm_trigger").click()}g.is(":visible")&&(f=!1,""===e&&(frmFrontForm.scrollMsg(k,a,!0),e="#frm_field_"+k+"_container"),jQuery(a).find("#frm_field_"+k+"_container .g-recaptcha").length&&(h=
|
34 |
+
!0,grecaptcha.reset()),g.addClass("frm_blank_field"),"function"==typeof frmThemeOverride_frmPlaceError?frmThemeOverride_frmPlaceError(k,b):g.append('<div class="frm_error">'+b[k]+"</div>"))}else if("redirect"==k){window.location=b[k];return}!0!==h&&jQuery(a).find(".g-recaptcha").closest(".frm_form_field").replaceWith('<input type="hidden" name="recaptcha_checked" value="'+frm_js.nonce+'">');f&&a.submit()}},error:function(){jQuery(a).find('input[type="submit"], input[type="button"]').removeAttr("disabled");
|
35 |
+
a.submit()}})}function ca(){T(jQuery(this),"clear")}function da(){T(jQuery(this),"replace")}function T(a,b){var c=a.data("frmval").replace(/(\n|\r\n)/g,"\r");if(""===c||"undefined"==typeof c)return!1;var d=a.val().replace(/(\n|\r\n)/g,"\r");"replace"==b?""===d&&a.addClass("frm_default").val(c):d==c&&a.removeClass("frm_default").val("")}function ea(){var a=jQuery(this),b=a.data("eid"),c=a.data("fid");a.append('<span class="spinner" style="display:inline"></span>');jQuery.ajax({type:"POST",url:frm_js.ajax_url,
|
36 |
+
data:{action:"frm_entries_send_email",entry_id:b,form_id:c,nonce:frm_js.nonce},success:function(b){a.replaceWith(b)}});return!1}function fa(a,b){google.load("visualization","1.0",{packages:[b],callback:function(){if("table"==b){var c=new google.visualization.DataTable,d=!1;-1!==jQuery.inArray("id",a.options.fields)&&(d=!0,c.addColumn("number",frm_js.id));for(var f=a.fields.length,e="string",h=0,g=f;h<g;h++){var k=a.fields[h],e=U(k);c.addColumn(e,k.name)}h=!1;a.options.edit_link&&(h=!0,c.addColumn("string",
|
37 |
+
a.options.edit_link));g=!1;a.options.delete_link&&(g=!0,c.addColumn("string",a.options.delete_link));k=0;if(null!==a.entries){var l=a.entries.length;c.addRows(l);for(var m=0,n=0;n<l;n++){var k=0,p=a.entries[n];d&&(c.setCell(m,k,p.id),k++);for(var q=0,r=f;q<r;q++){var t=a.fields[q],e=U(t),t=p.metas[t.id];"number"!=e||null!==t&&""!==t?"boolean"==e&&(t=null===t||"false"==t||!1===t?!1:!0):t=0;c.setCell(m,k,t);k++}h&&("undefined"!==typeof p.editLink?c.setCell(m,k,'<a href="'+p.editLink+'">'+a.options.edit_link+
|
38 |
+
"</a>"):c.setCell(m,k,""),k++);g&&("undefined"!==typeof p.deleteLink?c.setCell(m,k,'<a href="'+p.deleteLink+'" class="frm_delete_link" onclick="return confirm('+a.options.confirm+')">'+a.options.delete_link+"</a>"):c.setCell(m,k,""));m++}}else for(c.addRows(1),h=k=0,g=f;h<g;h++)0<k?c.setCell(0,k,""):c.setCell(0,k,a.options.no_entries),k++;(new google.visualization.Table(document.getElementById("frm_google_table_"+a.options.form_id))).draw(c,a.graphOpts)}else ga(a)}})}function U(a){var b="string";
|
39 |
+
if("number"==a.type)b="number";else if("checkbox"==a.type||"select"==a.type){var c=a.options.length;"select"==a.type&&""===a.options[0]&&(c="post_status"==a.field_options.post_field?3:c-1);1==c&&(b="boolean")}return b}function ga(a){var b=new google.visualization.DataTable,c=!1,d=!1,f=a.rows.length;if(0<f)if("table"==a.type){c=!0;b.addRows(a.rows[f-1][0]+1);for(var e=0;e<f;e++)b.setCell(a.rows[e])}else if("undefined"!=typeof a.rows[0].tooltip)for(var d=c=!0,h=0;h<f;h++){e=a.rows[h].tooltip;delete a.rows[h].tooltip;
|
40 |
+
var g=Object.keys(a.rows[h]).map(function(b){return a.rows[h][b]});a.rows[h]=g;a.rows[h].push(e)}f=a.cols.length;if(c){if(0<f)for(c=0;c<f;c++)e=a.cols[c],b.addColumn(e.type,e.name);d&&(b.addColumn({type:"string",role:"tooltip"}),b.addRows(a.rows))}else{b=[[]];for(d=0;d<f;d++)b[0].push(a.cols[d].name);b=b.concat(a.rows);b=google.visualization.arrayToDataTable(b)}d=a.type.charAt(0).toUpperCase()+a.type.slice(1)+"Chart";(new google.visualization[d](document.getElementById("chart_"+a.graph_id))).draw(b,
|
41 |
+
a.options)}function ha(){var a=jQuery(this),b=a.data("fid");a.wrap('<div class="frm_file_names frm_uploaded_files">');for(var c=a.get(0).files,d=0;d<c.length;d++)0===d?a.after(c[d].name+' <a href="#" class="frm_clear_file_link">'+frm_js.remove+"</a>"):a.after(c[d].name+"<br/>");a.hide();c=a.attr("name");c!="item_meta["+b+"][]"&&c.replace("item_meta[","").replace("[]","").split("][");a.closest(".frm_form_field").find(".frm_uploaded_files:last").after('<input name="'+c+'" data-fid="'+b+'"class="frm_transparent frm_multiple_file" multiple="multiple" type="file" />')}
|
42 |
+
function ia(){ja(jQuery(this).parent(".frm_uploaded_files"))}function ka(){jQuery(this).parent(".frm_file_names").replaceWith("");return!1}function la(){var a="frm_section_"+jQuery(this).data("parent")+"-"+jQuery(this).data("key"),b=jQuery(document.getElementById(a)),c=b.find("input, select, textarea");b.fadeOut("slow",function(){b.remove();c.each(function(){if("file"!=this.type){var a=this.name.replace("item_meta[","").split("]")[2].replace("[","");E(a)}})});return!1}function ma(){var a=jQuery(this).data("parent"),
|
43 |
+
b=0;0<jQuery(".frm_repeat_"+a).length&&(b=1+parseInt(jQuery(".frm_repeat_"+a+":last").attr("id").replace("frm_section_"+a+"-","")),"undefined"==typeof b&&(b=1));jQuery.ajax({type:"POST",url:frm_js.ajax_url,dataType:"json",data:{action:"frm_add_form_row",field_id:a,i:b,nonce:frm_js.nonce},success:function(b){var d=b.html,f=jQuery(d).hide().fadeIn("slow");jQuery(".frm_repeat_"+a+":last").after(f);var e=["other"],h,g="reset";x=f.attr("id");jQuery(d).find("input, select, textarea").each(function(){"file"!=
|
44 |
+
this.type&&(h=this.name.replace("item_meta[","").split("]")[2].replace("[",""),-1==jQuery.inArray(h,e)&&(e.push(h),q("und",h,null,jQuery(this),g),E(h),g="persist"))});x="";for(var f=0,k=b.logic.check.length;f<k;f++)-1==jQuery.inArray(b.logic.check[f],e)&&1>jQuery(d).find(".frm_field_"+b.logic.check[f]+"_container").length&&(q("und",b.logic.check[f],null,null,g),g="persist");0<jQuery(d).find(".star").length&&jQuery(".star").rating();0<jQuery(d).find(".frm_chzn").length&&jQuery().chosen&&jQuery(".frm_chzn").chosen({allow_single_deselect:!0});
|
45 |
+
"function"==typeof frmThemeOverride_frmAddRow&&frmThemeOverride_frmAddRow(a,b)}});return!1}function ja(a){a.fadeOut("slow",function(){a.remove()})}function na(){var a=jQuery(this).data("frmtoggle");jQuery(a).is(":visible")?jQuery(a).slideUp("fast"):jQuery(a).slideDown("fast");return!1}function Z(a,b){for(var c in a)if(a.hasOwnProperty(c)&&a[c]===b)return c;return null}function X(a){return jQuery.isArray(a)&&(1<a.length||""!==a[0])}function R(a){return!jQuery.isArray(a)&&0<=a-parseFloat(a)+1}function W(a,
|
46 |
+
b){var c=[];if("undefined"==typeof document.querySelector)jQuery("#"+a+' input[type=checkbox]:checked, input[type=hidden][name^="'+b+'"]').each(function(){c.push(this.value)});else for(var d=document.querySelectorAll("#"+a+' input[type=checkbox], input[type=hidden][name^="'+b+'"]'),f=0;f<d.length;f++)("checkbox"==d[f].type&&d[f].checked||"hidden"==d[f].type)&&c.push(d[f].value);return c}var m=[],G=[],D=[],H=[],x="",J="",C=[];return{init:function(){jQuery(document).on("click",".frm_trigger",n);var a=
|
47 |
+
jQuery(".frm_blank_field");a.length&&a.closest(".frm_toggle_container").prev(".frm_trigger").click();jQuery.isFunction(jQuery.fn.placeholder)?jQuery(".frm-show-form input, .frm-show-form textarea").placeholder():jQuery(".frm-show-form input[onblur], .frm-show-form textarea[onblur]").each(function(){""===jQuery(this).val()&&jQuery(this).blur()});jQuery(document).on("focus",".frm_toggle_default",ca);jQuery(document).on("blur",".frm_toggle_default",da);jQuery(".frm_toggle_default").blur();jQuery(document.getElementById("frm_resend_email")).click(ea);
|
48 |
+
jQuery(document).on("change",".frm_multiple_file",ha);jQuery(document).on("click",".frm_clear_file_link",ka);jQuery(document).on("click",".frm_remove_link",ia);jQuery(document).on("focusin","input[data-frmmask]",function(){jQuery(this).mask(jQuery(this).data("frmmask").toString())});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"]',w);jQuery(document).on("click",'.frm-show-form input[type="submit"], .frm-show-form input[name="frm_prev_page"], .frm-show-form .frm_save_draft',
|
49 |
+
l);jQuery(document).on("change",'.frm_other_container input[type="checkbox"], .frm_other_container input[type="radio"], .frm_other_container select',v);jQuery(document).on("change","input[type=file].frm_transparent",p);jQuery(document).on("click",".frm_remove_form_row",la);jQuery(document).on("click",".frm_add_form_row",ma);jQuery("a[data-frmtoggle]").click(na);jQuery(".frm_month_heading, .frm_year_heading").click(function(){var a=jQuery(this).children(".ui-icon-triangle-1-e, .ui-icon-triangle-1-s");
|
50 |
+
a.hasClass("ui-icon-triangle-1-e")?(a.addClass("ui-icon-triangle-1-s").removeClass("ui-icon-triangle-1-e"),jQuery(this).next(".frm_toggle_container").fadeIn("slow")):(a.addClass("ui-icon-triangle-1-e").removeClass("ui-icon-triangle-1-s"),jQuery(this).next(".frm_toggle_container").hide())})},submitForm:function(a){a.preventDefault();jQuery(this).find(".wp-editor-wrap").length&&"undefined"!=typeof tinyMCE&&tinyMCE.triggerSave();J=jQuery(this).find('input[name="frm_action"]').val();C=[];frmFrontForm.getAjaxFormErrors(this);
|
51 |
+
if(0===C.length)S(this,J);else{jQuery(".form-field").removeClass("frm_blank_field");jQuery(".form-field .frm_error").replaceWith("");a=null;for(var b in C)a=jQuery(this).find(jQuery(document.getElementById("frm_field_"+b+"_container"))),a.length&&a.is(":visible")&&(a.addClass("frm_blank_field"),"function"==typeof frmThemeOverride_frmPlaceError?frmThemeOverride_frmPlaceError(b,C):a.append('<div class="frm_error">'+C[b]+"</div>"))}},getAjaxFormErrors:function(a){"function"==typeof frmThemeOverride_jsErrors&&
|
52 |
+
(C=frmThemeOverride_jsErrors(J,a))},checkFormErrors:function(a,b){S(a,b)},scrollToID:function(a){a=jQuery(document.getElementById(a).offset());window.scrollTo(a.left,a.top)},scrollMsg:function(a,b,c){var d="";if(d="undefined"==typeof b?jQuery(document.getElementById("frm_form_"+a+"_container")).offset().top:jQuery(b).find(document.getElementById("frm_field_"+a+"_container")).offset().top){d-=frm_js.offset;a=jQuery("html").css("margin-top");b=jQuery("body").css("margin-top");if(a||b)d=d-parseInt(a)-
|
53 |
+
parseInt(b);if(d&&window.innerHeight&&(a=document.documentElement.scrollTop||document.body.scrollTop,d>a+window.innerHeight||d<a))return"undefined"===typeof c?jQuery(window).scrollTop(d):jQuery("html,body").animate({scrollTop:d},500),!1}},hideCondFields:function(a){a=JSON.parse(a);for(var b=0,c=a.length;b<c;b++){var d=document.getElementById("frm_field_"+a[b]+"_container");null!==d?d.style.display="none":jQuery(".frm_field_"+a[b]+"_container").hide()}},checkDependent:function(a){a=JSON.parse(a);for(var b=
|
54 |
+
"reset",c=0,d=a.length;c<d;c++)q("und",a[c],null,null,b),b="persist"},loadGoogle:function(){if("undefined"!==typeof google&&google&&google.load)for(var a=__FRMTABLES,b=Object.keys(a),c=0;c<b.length;c++)for(var d=a[b[c]],f=b[c],e=0;e<d.length;e++)fa(d[e],f);else setTimeout(frmFrontForm.loadGoogle,30)},removeUsedTimes:function(a,b){var c=jQuery(a).parents("form:first").find('input[name="id"]');jQuery.ajax({type:"POST",url:frm_js.ajax_url,dataType:"json",data:{action:"frm_fields_ajax_time_options",time_field:b,
|
55 |
+
date_field:a.id,entry_id:c?c.val():"",date:jQuery(a).val(),nonce:frm_js.nonce},success:function(a){var c=jQuery(document.getElementById(b));c.find("option").removeAttr("disabled");if(a&&""!==a)for(var e in a)c.find('option[value="'+e+'"]').attr("disabled","disabled")}})},escapeHtml:function(a){return a.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")},invisible:function(a){jQuery(a).css("visibility","hidden")},visible:function(a){jQuery(a).css("visibility",
|
56 |
+
"visible")}}}var frmFrontForm=frmFrontFormJS();jQuery(document).ready(function(l){frmFrontForm.init()});
|
57 |
function frmEditEntry(l,n,p,v,w,q){var r=jQuery(document.getElementById("frm_edit_"+l)),u=r.html(),y=jQuery(document.getElementById(n+l)),A=y.html();y.html('<span class="frm-loading-img" id="'+n+l+'"></span><div class="frm_orig_content" style="display:none">'+A+"</div>");jQuery.ajax({type:"POST",url:frm_js.ajax_url,dataType:"html",data:{action:"frm_entries_edit_entry_ajax",post_id:p,entry_id:l,id:v,nonce:frm_js.nonce},success:function(A){y.children(".frm-loading-img").replaceWith(A);r.replaceWith('<span id="frm_edit_'+
|
58 |
l+'"><a onclick="frmCancelEdit('+l+",'"+n+"','"+frmFrontForm.escapeHtml(u)+"',"+p+","+v+",'"+q+'\')" class="'+q+'">'+w+"</a></span>")}})}
|
59 |
function frmCancelEdit(l,n,p,v,w,q){var r=jQuery(document.getElementById("frm_edit_"+l)),u=r.find("a"),y=u.html();u.hasClass("frm_ajax_edited")||(u=jQuery(document.getElementById(n+l)),u.children(".frm_forms").replaceWith(""),u.children(".frm_orig_content").fadeIn("slow").removeClass("frm_orig_content"));r.replaceWith('<a id="frm_edit_'+l+'" class="frm_edit_link '+q+'" href="javascript:frmEditEntry('+l+",'"+n+"',"+v+","+w+",'"+frmFrontForm.escapeHtml(y)+"','"+q+"')\">"+p+"</a>")}
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: http://formidablepro.com/donate
|
|
4 |
Tags: admin, AJAX, captcha, contact, contact form, database, email, feedback, form, forms, javascript, jquery, page, plugin, poll, Post, spam, survey, template, widget, wpmu, form builder
|
5 |
Requires at least: 3.6
|
6 |
Tested up to: 4.2
|
7 |
-
Stable tag: 2.0.
|
8 |
|
9 |
Beautiful forms in 60 seconds. The WordPress form builder that enables you to create forms with a simple drag-and-drop interface and in-place editing.
|
10 |
|
@@ -89,6 +89,17 @@ A. Try clearing your browser cache. As plugin modifications are made, frequent j
|
|
89 |
[See more FAQs](http://formidablepro.com/formidable-faqs/ "Formidable Form FAQs")
|
90 |
|
91 |
== Changelog ==
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
92 |
= 2.0.09 =
|
93 |
* Add frm_time_to_check duplicate entries filter
|
94 |
* Allow custom JavaScript validation
|
4 |
Tags: admin, AJAX, captcha, contact, contact form, database, email, feedback, form, forms, javascript, jquery, page, plugin, poll, Post, spam, survey, template, widget, wpmu, form builder
|
5 |
Requires at least: 3.6
|
6 |
Tested up to: 4.2
|
7 |
+
Stable tag: 2.0.10
|
8 |
|
9 |
Beautiful forms in 60 seconds. The WordPress form builder that enables you to create forms with a simple drag-and-drop interface and in-place editing.
|
10 |
|
89 |
[See more FAQs](http://formidablepro.com/formidable-faqs/ "Formidable Form FAQs")
|
90 |
|
91 |
== Changelog ==
|
92 |
+
= 2.0.10 =
|
93 |
+
* Add frm_action_triggers hook for adding custom triggers into the actions
|
94 |
+
* Add frm_{action name here}_action_options hook so any action can be altered
|
95 |
+
* Prevent extra form actions when a form is duplicated
|
96 |
+
* Load correct version of formidable.js based on wp-config debugging constant (Thanks @naomicbush for the contributions!)
|
97 |
+
* Revert get_sortable_columns changes for < WP 4.0 support
|
98 |
+
* **Pro Features:**
|
99 |
+
* Allow calculations inside repeating sections and embedded forms
|
100 |
+
* Set default values for conditional checkboxes and radio fields and inside conditional sections
|
101 |
+
* A few changes to the way section fields create divs
|
102 |
+
|
103 |
= 2.0.09 =
|
104 |
* Add frm_time_to_check duplicate entries filter
|
105 |
* Allow custom JavaScript validation
|