Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93

Warning: Undefined array key "page_file_edit_line" in /home/sportsfever/public_html/filemanger/edit_text_line.php on line 32
/home/sportsfe.../httpdocs/clone/wp-conte.../plugins/wpforms-.../assets/js/admin/builder
File: admin-builder.js
app.fieldChoiceBulkAddToggle( this );
[2000] Fix | Delete
} );
[2001] Fix | Delete
[2002] Fix | Delete
$builder.on( 'click', '.toggle-bulk-add-presets', function( e ) {
[2003] Fix | Delete
e.preventDefault();
[2004] Fix | Delete
[2005] Fix | Delete
const $presetList = $( this ).closest( '.bulk-add-display' ).find( 'ul' );
[2006] Fix | Delete
[2007] Fix | Delete
if ( $presetList.css( 'display' ) === 'block' ) {
[2008] Fix | Delete
$( this ).text( wpforms_builder.bulk_add_presets_show );
[2009] Fix | Delete
} else {
[2010] Fix | Delete
$( this ).text( wpforms_builder.bulk_add_presets_hide );
[2011] Fix | Delete
}
[2012] Fix | Delete
[2013] Fix | Delete
$presetList.stop().slideToggle();
[2014] Fix | Delete
} );
[2015] Fix | Delete
[2016] Fix | Delete
$builder.on( 'click', '.bulk-add-preset-insert', function( e ) {
[2017] Fix | Delete
e.preventDefault();
[2018] Fix | Delete
[2019] Fix | Delete
const $this = $( this ),
[2020] Fix | Delete
preset = $this.data( 'preset' ),
[2021] Fix | Delete
$container = $this.closest( '.bulk-add-display' ),
[2022] Fix | Delete
$presetList = $container.find( 'ul' ),
[2023] Fix | Delete
$presetToggle = $container.find( '.toggle-bulk-add-presets' ),
[2024] Fix | Delete
$textarea = $container.find( 'textarea' );
[2025] Fix | Delete
[2026] Fix | Delete
$textarea.val( '' );
[2027] Fix | Delete
$textarea.insertAtCaret( wpforms_preset_choices[ preset ].choices.join( '\n' ) );
[2028] Fix | Delete
$presetToggle.text( wpforms_builder.bulk_add_presets_show );
[2029] Fix | Delete
$presetList.slideUp();
[2030] Fix | Delete
} );
[2031] Fix | Delete
[2032] Fix | Delete
$builder.on( 'click', '.bulk-add-insert', function( e ) {
[2033] Fix | Delete
e.preventDefault();
[2034] Fix | Delete
app.fieldChoiceBulkAddInsert( this );
[2035] Fix | Delete
} );
[2036] Fix | Delete
[2037] Fix | Delete
// Field Options group tabs.
[2038] Fix | Delete
$builder.on( 'click', '.wpforms-field-option-group-toggle:not(.education-modal)', function( e ) {
[2039] Fix | Delete
const event = WPFormsUtils.triggerEvent( $builder, 'wpformsFieldOptionGroupToggle' );
[2040] Fix | Delete
[2041] Fix | Delete
// Allow callbacks on `wpformsFieldOptionGroupToggle` to cancel tab toggle by triggering `event.preventDefault()`.
[2042] Fix | Delete
if ( event.isDefaultPrevented() ) {
[2043] Fix | Delete
return false;
[2044] Fix | Delete
}
[2045] Fix | Delete
[2046] Fix | Delete
e.preventDefault();
[2047] Fix | Delete
[2048] Fix | Delete
const $group = $( this ).closest( '.wpforms-field-option-group' );
[2049] Fix | Delete
[2050] Fix | Delete
$group.siblings( '.wpforms-field-option-group' ).removeClass( 'active' );
[2051] Fix | Delete
$group.addClass( 'active' );
[2052] Fix | Delete
} );
[2053] Fix | Delete
[2054] Fix | Delete
// Display toggle for an Address field hide address line 2 option.
[2055] Fix | Delete
$builder.on( 'change', '.wpforms-field-option-address input.wpforms-subfield-hide', function( e ) { // eslint-disable-line no-unused-vars
[2056] Fix | Delete
const $optionRow = $( this ).closest( '.wpforms-field-option-row' ),
[2057] Fix | Delete
id = $optionRow.data( 'field-id' ),
[2058] Fix | Delete
subfield = $optionRow.data( 'subfield' );
[2059] Fix | Delete
[2060] Fix | Delete
$( '#wpforms-field-' + id ).find( '.wpforms-' + subfield ).toggleClass( 'wpforms-hide' );
[2061] Fix | Delete
} );
[2062] Fix | Delete
[2063] Fix | Delete
// Real-time updates for the "Label" field option.
[2064] Fix | Delete
$builder.on( 'input', '.wpforms-field-option-row-label input, .wpforms-field-option-row-name input', function( e ) { // eslint-disable-line no-unused-vars
[2065] Fix | Delete
const $this = $( this ),
[2066] Fix | Delete
id = $this.parent().data( 'field-id' ),
[2067] Fix | Delete
$preview = $( '#wpforms-field-' + id ),
[2068] Fix | Delete
type = $preview.data( 'field-type' );
[2069] Fix | Delete
[2070] Fix | Delete
let value = $this.val(),
[2071] Fix | Delete
showEmptyLabel = value.length === 0;
[2072] Fix | Delete
[2073] Fix | Delete
// Do not modify the label of the HTML field.
[2074] Fix | Delete
if ( type === 'html' ) {
[2075] Fix | Delete
showEmptyLabel = false;
[2076] Fix | Delete
}
[2077] Fix | Delete
[2078] Fix | Delete
if ( showEmptyLabel ) {
[2079] Fix | Delete
value = wpforms_builder.empty_label;
[2080] Fix | Delete
}
[2081] Fix | Delete
[2082] Fix | Delete
$preview.toggleClass( 'label_empty', showEmptyLabel ).find( '> .label-title .text' ).text( value );
[2083] Fix | Delete
} );
[2084] Fix | Delete
[2085] Fix | Delete
// Real-time updates for "Description" field option
[2086] Fix | Delete
$builder.on( 'input', '.wpforms-field-option-row-description textarea', function() {
[2087] Fix | Delete
const $this = $( this ),
[2088] Fix | Delete
value = wpf.sanitizeHTML( $this.val() ),
[2089] Fix | Delete
id = $this.parent().data( 'field-id' ),
[2090] Fix | Delete
// IIF description is not following other fields structure and needs to be selected separately.
[2091] Fix | Delete
$desc = $( `#wpforms-field-${ id } > .description, #wpforms-field-${ id } .wpforms-field-internal-information-row-description` );
[2092] Fix | Delete
[2093] Fix | Delete
app.updateDescription( $desc, value );
[2094] Fix | Delete
[2095] Fix | Delete
$this.trigger( 'wpformsDescriptionFieldUpdated', { id, descField: $desc, value } );
[2096] Fix | Delete
} );
[2097] Fix | Delete
[2098] Fix | Delete
// Real-time updates for "Required" field option
[2099] Fix | Delete
$builder.on( 'change', '.wpforms-field-option-row-required input', function( e ) { // eslint-disable-line no-unused-vars
[2100] Fix | Delete
const id = $( this ).closest( '.wpforms-field-option-row' ).data( 'field-id' );
[2101] Fix | Delete
[2102] Fix | Delete
$( '#wpforms-field-' + id ).toggleClass( 'required' );
[2103] Fix | Delete
} );
[2104] Fix | Delete
[2105] Fix | Delete
// Real-time updates for "Summary" field option
[2106] Fix | Delete
$builder.on( 'change', '.wpforms-field-option-row-summary input', function() {
[2107] Fix | Delete
const $this = $( this ),
[2108] Fix | Delete
id = $this.closest( '.wpforms-field-option-row' ).data( 'field-id' );
[2109] Fix | Delete
[2110] Fix | Delete
$( `#wpforms-field-${ id }` ).toggleClass( 'wpforms-summary-enabled' );
[2111] Fix | Delete
$this.closest( '.wpforms-field-option-group-inner' ).find( '.wpforms-total-summary-alert' ).toggleClass( 'wpforms-hidden' );
[2112] Fix | Delete
} );
[2113] Fix | Delete
[2114] Fix | Delete
// Real-time updates for "Confirmation" field option
[2115] Fix | Delete
$builder.on( 'change', '.wpforms-field-option-row-confirmation input', function() {
[2116] Fix | Delete
const id = $( this ).closest( '.wpforms-field-option-row' ).data( 'field-id' );
[2117] Fix | Delete
[2118] Fix | Delete
$( '#wpforms-field-' + id ).find( '.wpforms-confirm' ).toggleClass( 'wpforms-confirm-enabled wpforms-confirm-disabled' );
[2119] Fix | Delete
$( '#wpforms-field-option-' + id ).toggleClass( 'wpforms-confirm-enabled wpforms-confirm-disabled' );
[2120] Fix | Delete
} );
[2121] Fix | Delete
[2122] Fix | Delete
// Real-time updates for "Filter" field option
[2123] Fix | Delete
$builder.on( 'change', '.wpforms-field-option-row-filter_type select', function() {
[2124] Fix | Delete
const id = $( this ).parent().data( 'field-id' ),
[2125] Fix | Delete
$toggledField = $( '#wpforms-field-option-' + id );
[2126] Fix | Delete
[2127] Fix | Delete
if ( $( this ).val() ) {
[2128] Fix | Delete
$toggledField.removeClass( 'wpforms-filter-allowlist' );
[2129] Fix | Delete
$toggledField.removeClass( 'wpforms-filter-denylist' );
[2130] Fix | Delete
$toggledField.addClass( 'wpforms-filter-' + $( this ).val() );
[2131] Fix | Delete
} else {
[2132] Fix | Delete
$toggledField.removeClass( 'wpforms-filter-allowlist' );
[2133] Fix | Delete
$toggledField.removeClass( 'wpforms-filter-denylist' );
[2134] Fix | Delete
}
[2135] Fix | Delete
} );
[2136] Fix | Delete
[2137] Fix | Delete
$builder.on( 'focusout', '.wpforms-field-option-row-allowlist textarea,.wpforms-field-option-row-denylist textarea', function() {
[2138] Fix | Delete
const $currentField = $( this );
[2139] Fix | Delete
[2140] Fix | Delete
let $current = 'allow';
[2141] Fix | Delete
[2142] Fix | Delete
if ( $currentField.val() === '' ) {
[2143] Fix | Delete
return;
[2144] Fix | Delete
}
[2145] Fix | Delete
[2146] Fix | Delete
const $allowField = $( '.wpforms-field-option-row-allowlist textarea' ),
[2147] Fix | Delete
$denyField = $( '.wpforms-field-option-row-denylist textarea' );
[2148] Fix | Delete
[2149] Fix | Delete
if ( $currentField.is( $denyField ) ) {
[2150] Fix | Delete
$current = 'deny';
[2151] Fix | Delete
}
[2152] Fix | Delete
[2153] Fix | Delete
$.get(
[2154] Fix | Delete
wpforms_builder.ajax_url,
[2155] Fix | Delete
{
[2156] Fix | Delete
nonce: wpforms_builder.nonce,
[2157] Fix | Delete
content: JSON.stringify(
[2158] Fix | Delete
{
[2159] Fix | Delete
allow: $allowField.val(),
[2160] Fix | Delete
deny: $denyField.val(),
[2161] Fix | Delete
current: $current,
[2162] Fix | Delete
}
[2163] Fix | Delete
),
[2164] Fix | Delete
action: 'wpforms_sanitize_restricted_rules',
[2165] Fix | Delete
},
[2166] Fix | Delete
function( res ) {
[2167] Fix | Delete
if ( res.success ) {
[2168] Fix | Delete
$currentField.val( res.data.currentField );
[2169] Fix | Delete
const intersect = res.data.intersect;
[2170] Fix | Delete
if ( intersect.length !== 0 ) {
[2171] Fix | Delete
const content = '<p>' + wpforms_builder.allow_deny_lists_intersect + '</p>' +
[2172] Fix | Delete
'<p class="bold">' + intersect + '</p>';
[2173] Fix | Delete
$.alert( {
[2174] Fix | Delete
title: wpforms_builder.heads_up,
[2175] Fix | Delete
content,
[2176] Fix | Delete
icon: 'fa fa-exclamation-circle',
[2177] Fix | Delete
type: 'red',
[2178] Fix | Delete
buttons: {
[2179] Fix | Delete
confirm: {
[2180] Fix | Delete
text: wpforms_builder.ok,
[2181] Fix | Delete
btnClass: 'btn-confirm',
[2182] Fix | Delete
keys: [ 'enter' ],
[2183] Fix | Delete
},
[2184] Fix | Delete
},
[2185] Fix | Delete
} );
[2186] Fix | Delete
}
[2187] Fix | Delete
}
[2188] Fix | Delete
}
[2189] Fix | Delete
);
[2190] Fix | Delete
} );
[2191] Fix | Delete
[2192] Fix | Delete
// On any click check if we had focusout event.
[2193] Fix | Delete
$builder.on( 'click', function() {
[2194] Fix | Delete
app.focusOutEvent();
[2195] Fix | Delete
} );
[2196] Fix | Delete
[2197] Fix | Delete
// Save focusout target.
[2198] Fix | Delete
$builder.on( 'focusout', elements.defaultEmailSelector, function() {
[2199] Fix | Delete
elements.$focusOutTarget = $( this );
[2200] Fix | Delete
} );
[2201] Fix | Delete
[2202] Fix | Delete
// Real-time updates for "Size" field option
[2203] Fix | Delete
$builder.on( 'change', '.wpforms-field-option-row-size select', function( e ) { // eslint-disable-line no-unused-vars
[2204] Fix | Delete
const $this = $( this ),
[2205] Fix | Delete
value = $this.val(),
[2206] Fix | Delete
id = $this.parent().data( 'field-id' );
[2207] Fix | Delete
[2208] Fix | Delete
$( '#wpforms-field-' + id ).removeClass( 'size-small size-medium size-large' ).addClass( 'size-' + value );
[2209] Fix | Delete
} );
[2210] Fix | Delete
[2211] Fix | Delete
// Real-time updates for "Placeholder" field option.
[2212] Fix | Delete
$builder.on( 'input', '.wpforms-field-option-row-placeholder input', function() { // eslint-disable-line complexity
[2213] Fix | Delete
const $this = $( this ),
[2214] Fix | Delete
id = $this.parent().data( 'field-id' ),
[2215] Fix | Delete
$preview = $( '#wpforms-field-' + id ),
[2216] Fix | Delete
$primary = $preview.find( '.primary-input' );
[2217] Fix | Delete
[2218] Fix | Delete
let value = wpf.sanitizeHTML( $this.val() );
[2219] Fix | Delete
[2220] Fix | Delete
// Single Item Field - if placeholder is cleared, set it to "price" placeholder.
[2221] Fix | Delete
if ( $preview.data( 'field-type' ) === 'payment-single' && value === '' ) {
[2222] Fix | Delete
value = $( '#wpforms-field-option-' + id + '-price' ).prop( 'placeholder' );
[2223] Fix | Delete
}
[2224] Fix | Delete
[2225] Fix | Delete
// Set the placeholder value for `input` fields.
[2226] Fix | Delete
if ( ! $primary.is( 'select' ) ) {
[2227] Fix | Delete
$primary.prop( 'placeholder', value );
[2228] Fix | Delete
return;
[2229] Fix | Delete
}
[2230] Fix | Delete
[2231] Fix | Delete
// Modern select style.
[2232] Fix | Delete
if ( app.dropdownField.helpers.isModernSelect( $primary ) ) {
[2233] Fix | Delete
const choiceInstance = app.dropdownField.helpers.getInstance( $primary );
[2234] Fix | Delete
[2235] Fix | Delete
// Additional case for multiple select.
[2236] Fix | Delete
if ( $primary.prop( 'multiple' ) ) {
[2237] Fix | Delete
$( choiceInstance.input.element ).prop( 'placeholder', value );
[2238] Fix | Delete
} else {
[2239] Fix | Delete
choiceInstance.setChoiceByValue( '' );
[2240] Fix | Delete
$primary.closest( '.choices' ).find( '.choices__inner .choices__placeholder' ).text( value );
[2241] Fix | Delete
[2242] Fix | Delete
const isDynamicChoices = $( '#wpforms-field-option-' + id + '-dynamic_choices' ).val();
[2243] Fix | Delete
[2244] Fix | Delete
// We need to re-initialize modern dropdown to properly determine and update placeholder.
[2245] Fix | Delete
app.dropdownField.helpers.update( id, isDynamicChoices );
[2246] Fix | Delete
}
[2247] Fix | Delete
[2248] Fix | Delete
return;
[2249] Fix | Delete
}
[2250] Fix | Delete
[2251] Fix | Delete
const $placeholder = $primary.find( '.placeholder' );
[2252] Fix | Delete
[2253] Fix | Delete
// Classic select style.
[2254] Fix | Delete
if ( ! value.length && $placeholder.length ) {
[2255] Fix | Delete
$placeholder.remove();
[2256] Fix | Delete
} else {
[2257] Fix | Delete
if ( $placeholder.length ) {
[2258] Fix | Delete
$placeholder.text( value );
[2259] Fix | Delete
} else {
[2260] Fix | Delete
$primary.prepend( '<option value="" class="placeholder">' + value + '</option>' );
[2261] Fix | Delete
}
[2262] Fix | Delete
[2263] Fix | Delete
$primary.find( '.placeholder' ).prop( 'selected', ! $primary.prop( 'multiple' ) );
[2264] Fix | Delete
}
[2265] Fix | Delete
} );
[2266] Fix | Delete
[2267] Fix | Delete
// Real-time updates for "Confirmation Placeholder" field option
[2268] Fix | Delete
$builder.on( 'input', '.wpforms-field-option-row-confirmation_placeholder input', function( e ) { // eslint-disable-line no-unused-vars
[2269] Fix | Delete
const $this = $( this ),
[2270] Fix | Delete
value = $this.val(),
[2271] Fix | Delete
id = $this.parent().data( 'field-id' );
[2272] Fix | Delete
[2273] Fix | Delete
$( '#wpforms-field-' + id ).find( '.secondary-input' ).attr( 'placeholder', value );
[2274] Fix | Delete
} );
[2275] Fix | Delete
[2276] Fix | Delete
// Real-time updates for Date/Time, and Name "Placeholder" field options
[2277] Fix | Delete
$builder.on( 'input', '.wpforms-field-option .format-selected input.placeholder', function() {
[2278] Fix | Delete
const $this = $( this );
[2279] Fix | Delete
const value = $this.val();
[2280] Fix | Delete
const $fieldOptionRow = $this.closest( '.wpforms-field-option-row' );
[2281] Fix | Delete
const id = $fieldOptionRow.data( 'field-id' );
[2282] Fix | Delete
const subfield = $fieldOptionRow.data( 'subfield' );
[2283] Fix | Delete
[2284] Fix | Delete
$( '#wpforms-field-' + id ).find( '.wpforms-' + subfield + ' input' ).attr( 'placeholder', value );
[2285] Fix | Delete
} );
[2286] Fix | Delete
[2287] Fix | Delete
// Real-time updates for Address field "Placeholder" field options.
[2288] Fix | Delete
$builder.on( 'input', '.wpforms-field-option-address input.placeholder', function() {
[2289] Fix | Delete
const $this = $( this );
[2290] Fix | Delete
const $fieldOptionRow = $this.closest( '.wpforms-field-option-row' );
[2291] Fix | Delete
const id = $fieldOptionRow.data( 'field-id' );
[2292] Fix | Delete
const subfield = $fieldOptionRow.data( 'subfield' );
[2293] Fix | Delete
const $fieldPreviews = $( '#wpforms-field-' + id + ' .wpforms-' + subfield ).find( 'input, select' );
[2294] Fix | Delete
const $default = $fieldOptionRow.find( '#wpforms-field-option-' + id + '-' + subfield + '_default' );
[2295] Fix | Delete
const defaultValue = $default.val();
[2296] Fix | Delete
const defaultText = $default.find( 'option:selected' ).text();
[2297] Fix | Delete
[2298] Fix | Delete
const placeholderValue = $this.val();
[2299] Fix | Delete
[2300] Fix | Delete
$fieldPreviews.each( function() {
[2301] Fix | Delete
const $fieldPreview = $( this );
[2302] Fix | Delete
[2303] Fix | Delete
if ( $fieldPreview.is( 'select' ) ) {
[2304] Fix | Delete
const $option = $fieldPreview.find( '.placeholder' );
[2305] Fix | Delete
const value = defaultValue === '' && placeholderValue !== '' ? placeholderValue : defaultText;
[2306] Fix | Delete
[2307] Fix | Delete
$option.text( value );
[2308] Fix | Delete
[2309] Fix | Delete
return;
[2310] Fix | Delete
}
[2311] Fix | Delete
[2312] Fix | Delete
$fieldPreview.attr( 'placeholder', placeholderValue );
[2313] Fix | Delete
} );
[2314] Fix | Delete
} );
[2315] Fix | Delete
[2316] Fix | Delete
// Real-time updates for "Default" field option.
[2317] Fix | Delete
$builder.on( 'input', '.wpforms-field-option-row-default_value input', function() {
[2318] Fix | Delete
const $this = $( this );
[2319] Fix | Delete
const value = wpf.sanitizeHTML( $this.val() );
[2320] Fix | Delete
const id = $this.closest( '.wpforms-field-option-row' ).data( 'field-id' );
[2321] Fix | Delete
const $preview = $( '#wpforms-field-' + id + ' .primary-input' );
[2322] Fix | Delete
[2323] Fix | Delete
$preview.val( value );
[2324] Fix | Delete
} );
[2325] Fix | Delete
[2326] Fix | Delete
// Real-time updates for "Default" field option of the Name and Address fields.
[2327] Fix | Delete
$builder.on( 'input', '.wpforms-field-options-column input.default', function() {
[2328] Fix | Delete
const $this = $( this );
[2329] Fix | Delete
const value = wpf.sanitizeHTML( $this.val() );
[2330] Fix | Delete
const $fieldOptionRow = $this.closest( '.wpforms-field-option-row' );
[2331] Fix | Delete
const id = $fieldOptionRow.data( 'field-id' );
[2332] Fix | Delete
const subfield = $fieldOptionRow.data( 'subfield' );
[2333] Fix | Delete
const $fieldPreview = $( '#wpforms-field-' + id + ' .wpforms-' + subfield + ' input' );
[2334] Fix | Delete
[2335] Fix | Delete
$fieldPreview.val( value );
[2336] Fix | Delete
} );
[2337] Fix | Delete
[2338] Fix | Delete
// Real-time updates for "Default" select field option of the Address field.
[2339] Fix | Delete
$builder.on( 'change', '.wpforms-field-option-address select.default', function() {
[2340] Fix | Delete
const $this = $( this );
[2341] Fix | Delete
const value = $this.val();
[2342] Fix | Delete
const textValue = $this.find( 'option:selected' ).text();
[2343] Fix | Delete
const $fieldOptionRow = $this.closest( '.wpforms-field-option-row' );
[2344] Fix | Delete
const id = $fieldOptionRow.data( 'field-id' );
[2345] Fix | Delete
const subfield = $fieldOptionRow.data( 'subfield' );
[2346] Fix | Delete
const scheme = $( '#wpforms-field-option-' + id + '-scheme' ).val();
[2347] Fix | Delete
const $placeholder = $fieldOptionRow.find( '#wpforms-field-option-' + id + '-' + subfield + '_placeholder' );
[2348] Fix | Delete
const placeholderValue = $placeholder.val();
[2349] Fix | Delete
const $fieldPreview = $( '#wpforms-field-' + id + ' .wpforms-address-scheme-' + scheme + ' .wpforms-' + subfield + ' .placeholder' );
[2350] Fix | Delete
[2351] Fix | Delete
value === '' && placeholderValue.trim().length > 0
[2352] Fix | Delete
? $fieldPreview.text( placeholderValue )
[2353] Fix | Delete
: $fieldPreview.text( textValue );
[2354] Fix | Delete
} );
[2355] Fix | Delete
[2356] Fix | Delete
// Real-time updates for "Confirmation Placeholder" field option
[2357] Fix | Delete
$builder.on( 'input', '.wpforms-field-option-row-confirmation_placeholder input', function( e ) { // eslint-disable-line no-unused-vars
[2358] Fix | Delete
const $this = $( this ),
[2359] Fix | Delete
value = $this.val(),
[2360] Fix | Delete
id = $this.parent().data( 'field-id' );
[2361] Fix | Delete
[2362] Fix | Delete
$( '#wpforms-field-' + id ).find( '.secondary-input' ).attr( 'placeholder', value );
[2363] Fix | Delete
} );
[2364] Fix | Delete
[2365] Fix | Delete
// Real-time updates for "Hide Label" field option.
[2366] Fix | Delete
$builder.on( 'change', '.wpforms-field-option-row-label_hide input', function( e ) { // eslint-disable-line no-unused-vars
[2367] Fix | Delete
const id = $( this ).closest( '.wpforms-field-option-row' ).data( 'field-id' );
[2368] Fix | Delete
[2369] Fix | Delete
$( '#wpforms-field-' + id ).toggleClass( 'label_hide' );
[2370] Fix | Delete
} );
[2371] Fix | Delete
[2372] Fix | Delete
// Real-time updates for a Sub Label visibility field option.
[2373] Fix | Delete
$builder.on( 'change', '.wpforms-field-option-row-sublabel_hide input', function( e ) { // eslint-disable-line no-unused-vars
[2374] Fix | Delete
const id = $( this ).closest( '.wpforms-field-option-row' ).data( 'field-id' );
[2375] Fix | Delete
[2376] Fix | Delete
$( '#wpforms-field-' + id ).toggleClass( 'sublabel_hide' );
[2377] Fix | Delete
} );
[2378] Fix | Delete
[2379] Fix | Delete
// Real-time updates for a Quantity visibility field option.
[2380] Fix | Delete
$builder.on( 'change', '.wpforms-field-option-row-enable_quantity input', function() {
[2381] Fix | Delete
const id = $( this ).closest( '.wpforms-field-option-row' ).data( 'field-id' ),
[2382] Fix | Delete
$preview = $( `#wpforms-field-${ id }` );
[2383] Fix | Delete
[2384] Fix | Delete
$( `#wpforms-field-option-row-${ id }-quantity` ).toggleClass( 'wpforms-hidden' );
[2385] Fix | Delete
$preview.find( '.quantity-input' ).toggleClass( 'wpforms-hidden' );
[2386] Fix | Delete
$preview.toggleClass( 'payment-quantity-enabled' );
[2387] Fix | Delete
} );
[2388] Fix | Delete
[2389] Fix | Delete
// Real-time updates for Quantity preview minimum value.
[2390] Fix | Delete
$builder.on( 'input', '.wpforms-field-option-row-quantity input', function() {
[2391] Fix | Delete
const $this = $( this );
[2392] Fix | Delete
[2393] Fix | Delete
// Allow only a positive integer value less than 9999.
[2394] Fix | Delete
$this.val( Math.min( Math.abs( Math.round( $this.val() ) ), 9999 ) );
[2395] Fix | Delete
[2396] Fix | Delete
const $optionRow = $this.closest( '.wpforms-field-option-row' ),
[2397] Fix | Delete
id = $optionRow.data( 'field-id' ),
[2398] Fix | Delete
isMinInput = $this.hasClass( 'min-quantity-input' ),
[2399] Fix | Delete
$minInput = $optionRow.find( '.min-quantity-input' ),
[2400] Fix | Delete
$maxInput = $optionRow.find( '.max-quantity-input' );
[2401] Fix | Delete
[2402] Fix | Delete
if ( isMinInput ) {
[2403] Fix | Delete
$( '#wpforms-field-' + id ).find( '.quantity-input option' ).text( $this.val() );
[2404] Fix | Delete
}
[2405] Fix | Delete
[2406] Fix | Delete
$minInput.toggleClass( 'wpforms-error', parseInt( $minInput.val(), 10 ) > parseInt( $maxInput.val(), 10 ) );
[2407] Fix | Delete
} );
[2408] Fix | Delete
[2409] Fix | Delete
// Real-time updates for Date/Time, Name and Single Item "Format" option.
[2410] Fix | Delete
$builder.on( 'change', '.wpforms-field-option-row-format select', function() {
[2411] Fix | Delete
const $this = $( this ),
[2412] Fix | Delete
value = $this.val(),
[2413] Fix | Delete
id = $this.parent().data( 'field-id' ),
[2414] Fix | Delete
$sublabelToggle = $( '#wpforms-field-option-row-' + id + '-sublabel_hide' ),
[2415] Fix | Delete
$preview = $( '#wpforms-field-' + id );
[2416] Fix | Delete
[2417] Fix | Delete
$preview.find( '.format-selected' ).removeClass().addClass( 'format-selected format-selected-' + value );
[2418] Fix | Delete
$( '#wpforms-field-option-' + id ).find( '.format-selected' ).removeClass().addClass( 'format-selected format-selected-' + value );
[2419] Fix | Delete
[2420] Fix | Delete
// Show toggle for "Hide Sub labels" only when the field consists of more than one subfield.
[2421] Fix | Delete
if ( [ 'date-time', 'first-last', 'first-middle-last' ].includes( value ) ) {
[2422] Fix | Delete
$sublabelToggle.removeClass( 'wpforms-hidden' );
[2423] Fix | Delete
} else {
[2424] Fix | Delete
$sublabelToggle.addClass( 'wpforms-hidden' );
[2425] Fix | Delete
}
[2426] Fix | Delete
[2427] Fix | Delete
// Hide the label field if it's not a single item.
[2428] Fix | Delete
$( `#wpforms-field-option-row-${ id }-price_label` ).toggleClass( 'wpforms-hidden', value !== 'single' );
[2429] Fix | Delete
[2430] Fix | Delete
// Toggle options based on Single Item "Format".
[2431] Fix | Delete
if ( [ 'single', 'user', 'hidden' ].includes( value ) ) {
[2432] Fix | Delete
const isUserDefined = value === 'user',
[2433] Fix | Delete
isSingle = value === 'single',
[2434] Fix | Delete
isHidden = value === 'hidden',
[2435] Fix | Delete
isQuantityEnabled = $( '#wpforms-field-option-' + id + '-enable_quantity' ).is( ':checked' ),
[2436] Fix | Delete
$minPriceOption = $( '#wpforms-field-option-' + id + '-min_price' ),
[2437] Fix | Delete
minPrice = wpf.amountSanitize( $minPriceOption.val() ),
[2438] Fix | Delete
isValidMinPrice = minPrice >= $minPriceOption.data( 'minimum-price' ),
[2439] Fix | Delete
$minPriceOptionRow = $( '#wpforms-field-option-row-' + id + '-min_price' );
[2440] Fix | Delete
[2441] Fix | Delete
// Toggle Placeholder option.
[2442] Fix | Delete
$( '#wpforms-field-option-row-' + id + '-placeholder' ).toggleClass( 'wpforms-hidden', ! isUserDefined );
[2443] Fix | Delete
[2444] Fix | Delete
// Toggle Quantity options.
[2445] Fix | Delete
$( '#wpforms-field-option-row-' + id + '-enable_quantity' ).toggleClass( 'wpforms-hidden', ! isSingle );
[2446] Fix | Delete
$( '#wpforms-field-option-row-' + id + '-quantities_alert' ).toggleClass( 'wpforms-hidden', ! isSingle );
[2447] Fix | Delete
$( '#wpforms-field-option-row-' + id + '-quantity' ).toggleClass( 'wpforms-hidden', ! isSingle || ! isQuantityEnabled );
[2448] Fix | Delete
$preview.find( '.quantity-input' ).toggleClass( 'wpforms-hidden', ! isSingle || ! isQuantityEnabled );
[2449] Fix | Delete
[2450] Fix | Delete
// Toggle Minimum Price options.
[2451] Fix | Delete
$minPriceOptionRow.toggleClass( 'wpforms-hidden', ! isUserDefined );
[2452] Fix | Delete
$minPriceOptionRow.find( '.wpforms-item-minimum-price-alert' ).toggleClass( 'wpforms-hidden', isValidMinPrice );
[2453] Fix | Delete
$preview.find( '.item-min-price' ).toggleClass( 'wpforms-hidden', isUserDefined && minPrice <= 0 );
[2454] Fix | Delete
$preview.toggleClass( 'min-price-warning', ! isValidMinPrice );
[2455] Fix | Delete
$preview.find( '.fa-exclamation-triangle' ).toggleClass( 'wpforms-hidden', isValidMinPrice );
[2456] Fix | Delete
[2457] Fix | Delete
// Toggle the label
[2458] Fix | Delete
$( `#wpforms-field-${ id } .item-price-single` ).toggleClass( 'wpforms-hidden', ! isSingle );
[2459] Fix | Delete
$( `#wpforms-field-${ id } .item-price-hidden` ).toggleClass( 'wpforms-hidden', ! isHidden );
[2460] Fix | Delete
}
[2461] Fix | Delete
} );
[2462] Fix | Delete
[2463] Fix | Delete
// Real-time updates specific for Address "Scheme" option
[2464] Fix | Delete
$builder.on( 'change', '.wpforms-field-option-row-scheme select', function( e ) { // eslint-disable-line no-unused-vars
[2465] Fix | Delete
const $this = $( this );
[2466] Fix | Delete
const value = $this.val();
[2467] Fix | Delete
const fieldId = $this.parent().data( 'field-id' );
[2468] Fix | Delete
[2469] Fix | Delete
const $fieldPreview = $( `#wpforms-field-${ fieldId }` );
[2470] Fix | Delete
const $stateOption = $( `#wpforms-field-option-row-${ fieldId }-state` );
[2471] Fix | Delete
const $countryOption = $( `#wpforms-field-option-row-${ fieldId }-country` );
[2472] Fix | Delete
[2473] Fix | Delete
// Switch the scheme in a Preview panel.
[2474] Fix | Delete
$fieldPreview.find( '.wpforms-address-scheme' ).addClass( 'wpforms-hide' );
[2475] Fix | Delete
$fieldPreview.find( `.wpforms-address-scheme-${ value }` ).removeClass( 'wpforms-hide' );
[2476] Fix | Delete
[2477] Fix | Delete
// Show an or hide country option depending on the scheme.
[2478] Fix | Delete
const $countryPreviewField = $fieldPreview.find( `.wpforms-address-scheme-${ value } .wpforms-country select, .wpforms-address-scheme-${ value } .wpforms-country input` );
[2479] Fix | Delete
[2480] Fix | Delete
$countryPreviewField.length === 0
[2481] Fix | Delete
? $countryOption.addClass( 'wpforms-hidden' )
[2482] Fix | Delete
: $countryOption.removeClass( 'wpforms-hidden' );
[2483] Fix | Delete
[2484] Fix | Delete
// Inputs/selects for a currently selected scheme and the one that we're changing to.
[2485] Fix | Delete
const $currentState = $stateOption.find( '.default .default' ).not( '.wpforms-hidden-strict' );
[2486] Fix | Delete
const $newState = $stateOption.find( `.default [data-scheme="${ value }"]` );
[2487] Fix | Delete
const $currentCountry = $countryOption.find( '.default .default' ).not( '.wpforms-hidden-strict' );
[2488] Fix | Delete
const $newCountry = $countryOption.find( `.default [data-scheme="${ value }"]` );
[2489] Fix | Delete
[2490] Fix | Delete
// Switch the state field type in options to match the scheme.
[2491] Fix | Delete
$newState.attr( {
[2492] Fix | Delete
id: $currentState.attr( 'id' ),
[2493] Fix | Delete
name: $currentState.attr( 'name' ),
[2494] Fix | Delete
} ).removeClass( 'wpforms-hidden-strict' );
[2495] Fix | Delete
$currentState.attr( { id: '', name: '' } ).addClass( 'wpforms-hidden-strict' );
[2496] Fix | Delete
$newCountry.attr( {
[2497] Fix | Delete
id: $currentCountry.attr( 'id' ),
[2498] Fix | Delete
name: $currentCountry.attr( 'name' ),
[2499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function