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
btnClass: 'btn-confirm',
[4500] Fix | Delete
keys: [ 'enter' ],
[4501] Fix | Delete
},
[4502] Fix | Delete
},
[4503] Fix | Delete
} );
[4504] Fix | Delete
},
[4505] Fix | Delete
[4506] Fix | Delete
/**
[4507] Fix | Delete
* Make field choices sortable.
[4508] Fix | Delete
* Currently used for select, radio, and checkboxes field types.
[4509] Fix | Delete
*
[4510] Fix | Delete
* @since 1.0.0
[4511] Fix | Delete
*
[4512] Fix | Delete
* @param {string} type Type.
[4513] Fix | Delete
* @param {string|undefined} selector Selector.
[4514] Fix | Delete
*/
[4515] Fix | Delete
fieldChoiceSortable( type, selector ) {
[4516] Fix | Delete
selector = typeof selector !== 'undefined' ? selector : '.wpforms-field-option-' + type + ' .wpforms-field-option-row-choices ul';
[4517] Fix | Delete
[4518] Fix | Delete
$( selector ).sortable( {
[4519] Fix | Delete
items: 'li',
[4520] Fix | Delete
axis: 'y',
[4521] Fix | Delete
delay: 100,
[4522] Fix | Delete
opacity: 0.6,
[4523] Fix | Delete
handle: '.move',
[4524] Fix | Delete
stop( e, ui ) {
[4525] Fix | Delete
const id = ui.item.parent().data( 'field-id' );
[4526] Fix | Delete
app.fieldChoiceUpdate( type, id );
[4527] Fix | Delete
$builder.trigger( 'wpformsFieldChoiceMove', ui );
[4528] Fix | Delete
},
[4529] Fix | Delete
update( e, ui ) { // eslint-disable-line no-unused-vars
[4530] Fix | Delete
},
[4531] Fix | Delete
} );
[4532] Fix | Delete
},
[4533] Fix | Delete
[4534] Fix | Delete
/**
[4535] Fix | Delete
* Generate Choice label. Used in field preview template.
[4536] Fix | Delete
*
[4537] Fix | Delete
* @since 1.6.2
[4538] Fix | Delete
*
[4539] Fix | Delete
* @param {Object} data Template data.
[4540] Fix | Delete
* @param {number} choiceID Choice ID.
[4541] Fix | Delete
*
[4542] Fix | Delete
* @return {string} Label.
[4543] Fix | Delete
*/
[4544] Fix | Delete
fieldChoiceLabel( data, choiceID ) { // eslint-disable-line complexity
[4545] Fix | Delete
const isPaymentChoice = [ 'payment-multiple', 'payment-checkbox' ].includes( data.settings.type ),
[4546] Fix | Delete
isIconImageChoice = data.settings.choices_icons || data.settings.choices_images,
[4547] Fix | Delete
isEmptyLabel = typeof data.settings.choices[ choiceID ].label === 'undefined' || data.settings.choices[ choiceID ].label.length === 0;
[4548] Fix | Delete
[4549] Fix | Delete
// Do not set a placeholder for an empty label in Icon and Image choices except for payment fields.
[4550] Fix | Delete
if ( isEmptyLabel && ! isPaymentChoice && isIconImageChoice ) {
[4551] Fix | Delete
return '';
[4552] Fix | Delete
}
[4553] Fix | Delete
[4554] Fix | Delete
const placeholder = isPaymentChoice ? wpforms_builder.payment_choice_empty_label_tpl : wpforms_builder.choice_empty_label_tpl;
[4555] Fix | Delete
let label = ! isEmptyLabel
[4556] Fix | Delete
? wpf.sanitizeHTML( data.settings.choices[ choiceID ].label, wpforms_builder.allowed_label_html_tags )
[4557] Fix | Delete
: placeholder.replace( '{number}', choiceID );
[4558] Fix | Delete
[4559] Fix | Delete
if ( data.settings.show_price_after_labels ) {
[4560] Fix | Delete
label += ' - ' + wpf.amountFormatCurrency( data.settings.choices[ choiceID ].value );
[4561] Fix | Delete
}
[4562] Fix | Delete
[4563] Fix | Delete
return label;
[4564] Fix | Delete
},
[4565] Fix | Delete
[4566] Fix | Delete
/**
[4567] Fix | Delete
* Update field choices in the preview area for the Fields panel.
[4568] Fix | Delete
*
[4569] Fix | Delete
* Currently used for select, radio, and checkboxes field types.
[4570] Fix | Delete
*
[4571] Fix | Delete
* @param {string} type Field type.
[4572] Fix | Delete
* @param {string|number} id Field ID.
[4573] Fix | Delete
* @param {number} count Number of choices to show, -1 if not set.
[4574] Fix | Delete
*
[4575] Fix | Delete
* @since 1.0.0
[4576] Fix | Delete
*/
[4577] Fix | Delete
fieldChoiceUpdate: ( type, id, count = -1 ) => { // eslint-disable-line complexity, max-lines-per-function
[4578] Fix | Delete
const isDynamicChoices = app.dropdownField.helpers.isDynamicChoices( id );
[4579] Fix | Delete
[4580] Fix | Delete
if ( app.replaceChoicesWithTemplate( type, id, isDynamicChoices ) ) {
[4581] Fix | Delete
return;
[4582] Fix | Delete
}
[4583] Fix | Delete
[4584] Fix | Delete
if ( count === -1 ) {
[4585] Fix | Delete
count = app.settings.choicesLimitLong;
[4586] Fix | Delete
}
[4587] Fix | Delete
[4588] Fix | Delete
// Dropdown payment choices are of select type.
[4589] Fix | Delete
if ( 'payment-select' === type ) {
[4590] Fix | Delete
type = 'select';
[4591] Fix | Delete
}
[4592] Fix | Delete
[4593] Fix | Delete
const $primary = $( '#wpforms-field-' + id + ' .primary-input' );
[4594] Fix | Delete
[4595] Fix | Delete
let newChoice = '';
[4596] Fix | Delete
[4597] Fix | Delete
if ( 'select' === type ) {
[4598] Fix | Delete
if ( ! isDynamicChoices ) {
[4599] Fix | Delete
newChoice = '<option value="{label}">{label}</option>';
[4600] Fix | Delete
$primary.find( 'option' ).not( '.placeholder' ).remove();
[4601] Fix | Delete
}
[4602] Fix | Delete
} else if ( 'radio' === type || 'checkbox' === type || 'gdpr-checkbox' === type ) {
[4603] Fix | Delete
type = 'gdpr-checkbox' === type ? 'checkbox' : type;
[4604] Fix | Delete
$primary.find( 'li' ).remove();
[4605] Fix | Delete
newChoice = '<li><input type="' + type + '" disabled>{label}</li>';
[4606] Fix | Delete
}
[4607] Fix | Delete
[4608] Fix | Delete
// Building an inner content for Primary field.
[4609] Fix | Delete
const $choicesList = $( '#wpforms-field-option-row-' + id + '-choices .choices-list' ),
[4610] Fix | Delete
$choicesToRender = $choicesList.find( 'li' ).slice( 0, count ),
[4611] Fix | Delete
hasDefaults = !! $choicesList.find( 'input.default:checked' ).length,
[4612] Fix | Delete
modernSelectChoices = [],
[4613] Fix | Delete
showPriceAfterLabels = $( '#wpforms-field-option-' + id + '-show_price_after_labels' ).prop( 'checked' ),
[4614] Fix | Delete
isModernSelect = app.dropdownField.helpers.isModernSelect( $primary );
[4615] Fix | Delete
[4616] Fix | Delete
$choicesToRender.get().forEach( function( item ) {// eslint-disable-line complexity
[4617] Fix | Delete
const $this = $( item ),
[4618] Fix | Delete
value = $this.find( 'input.value' ).val(),
[4619] Fix | Delete
choiceID = $this.data( 'key' );
[4620] Fix | Delete
[4621] Fix | Delete
let label = wpf.sanitizeHTML( $this.find( 'input.label' ).val().trim(), wpforms_builder.allowed_label_html_tags ),
[4622] Fix | Delete
$choice;
[4623] Fix | Delete
[4624] Fix | Delete
label = label !== '' ? label : wpforms_builder.choice_empty_label_tpl.replace( '{number}', choiceID );
[4625] Fix | Delete
label += ( showPriceAfterLabels && value ) ? ' - ' + wpf.amountFormatCurrency( value ) : '';
[4626] Fix | Delete
[4627] Fix | Delete
// Append a new choice.
[4628] Fix | Delete
if ( ! isModernSelect ) {
[4629] Fix | Delete
if ( ! isDynamicChoices ) {
[4630] Fix | Delete
$choice = $( newChoice.replace( /{label}/g, label ) );
[4631] Fix | Delete
$primary.append( $choice );
[4632] Fix | Delete
}
[4633] Fix | Delete
} else {
[4634] Fix | Delete
modernSelectChoices.push(
[4635] Fix | Delete
{
[4636] Fix | Delete
value: label,
[4637] Fix | Delete
label,
[4638] Fix | Delete
}
[4639] Fix | Delete
);
[4640] Fix | Delete
}
[4641] Fix | Delete
[4642] Fix | Delete
const selected = $this.find( 'input.default' ).is( ':checked' );
[4643] Fix | Delete
[4644] Fix | Delete
if ( true === selected ) {
[4645] Fix | Delete
switch ( type ) {
[4646] Fix | Delete
case 'select':
[4647] Fix | Delete
[4648] Fix | Delete
if ( ! isModernSelect ) {
[4649] Fix | Delete
app.setClassicSelectedChoice( $choice );
[4650] Fix | Delete
} else {
[4651] Fix | Delete
modernSelectChoices[ modernSelectChoices.length - 1 ].selected = true;
[4652] Fix | Delete
}
[4653] Fix | Delete
break;
[4654] Fix | Delete
case 'radio':
[4655] Fix | Delete
case 'checkbox':
[4656] Fix | Delete
$choice.find( 'input' ).prop( 'checked', 'true' );
[4657] Fix | Delete
break;
[4658] Fix | Delete
}
[4659] Fix | Delete
}
[4660] Fix | Delete
} );
[4661] Fix | Delete
[4662] Fix | Delete
if ( isModernSelect ) {
[4663] Fix | Delete
const placeholderClass = $primary.prop( 'multiple' ) ? 'input.choices__input' : '.choices__inner .choices__placeholder',
[4664] Fix | Delete
choicesjsInstance = app.dropdownField.helpers.getInstance( $primary );
[4665] Fix | Delete
[4666] Fix | Delete
if ( ! isDynamicChoices ) {
[4667] Fix | Delete
choicesjsInstance.removeActiveItems();
[4668] Fix | Delete
}
[4669] Fix | Delete
[4670] Fix | Delete
choicesjsInstance.setChoices( modernSelectChoices, 'value', 'label', true );
[4671] Fix | Delete
[4672] Fix | Delete
// Re-initialize modern dropdown to properly determine and update placeholder.
[4673] Fix | Delete
app.dropdownField.helpers.update( id, isDynamicChoices );
[4674] Fix | Delete
[4675] Fix | Delete
// Hide/show a placeholder for Modern select if it has or not default choices.
[4676] Fix | Delete
$primary
[4677] Fix | Delete
.closest( '.choices' )
[4678] Fix | Delete
.find( placeholderClass )
[4679] Fix | Delete
.toggleClass( 'wpforms-hidden', hasDefaults );
[4680] Fix | Delete
}
[4681] Fix | Delete
},
[4682] Fix | Delete
[4683] Fix | Delete
/**
[4684] Fix | Delete
* Generate Choice label. Used in field preview template.
[4685] Fix | Delete
*
[4686] Fix | Delete
* @since 1.8.6
[4687] Fix | Delete
*
[4688] Fix | Delete
* @param {string} type Field type.
[4689] Fix | Delete
* @param {number} id Field ID.
[4690] Fix | Delete
* @param {boolean} isDynamicChoices Whether the field has dynamic choices.
[4691] Fix | Delete
*
[4692] Fix | Delete
* @return {boolean} True if the template was used.
[4693] Fix | Delete
*/
[4694] Fix | Delete
replaceChoicesWithTemplate: ( type, id, isDynamicChoices ) => { // eslint-disable-line complexity
[4695] Fix | Delete
// Radio, Checkbox, and Payment Multiple/Checkbox use _ template.
[4696] Fix | Delete
if ( 'radio' !== type && 'checkbox' !== type && 'payment-multiple' !== type && 'payment-checkbox' !== type ) {
[4697] Fix | Delete
return false;
[4698] Fix | Delete
}
[4699] Fix | Delete
[4700] Fix | Delete
const order = wpf.getChoicesOrder( id ),
[4701] Fix | Delete
tmpl = wp.template( 'wpforms-field-preview-checkbox-radio-payment-multiple' );
[4702] Fix | Delete
[4703] Fix | Delete
const fieldSettings = wpf.getField( id ),
[4704] Fix | Delete
slicedChoices = {},
[4705] Fix | Delete
slicedOrder = order.slice( 0, app.settings.choicesLimit ),
[4706] Fix | Delete
data = {
[4707] Fix | Delete
settings: fieldSettings,
[4708] Fix | Delete
order: slicedOrder,
[4709] Fix | Delete
type: 'radio',
[4710] Fix | Delete
};
[4711] Fix | Delete
[4712] Fix | Delete
// If Icon Choices is on, get the valid color.
[4713] Fix | Delete
if ( fieldSettings.choices_icons ) {
[4714] Fix | Delete
// eslint-disable-next-line camelcase
[4715] Fix | Delete
data.settings.choices_icons_color = app.getValidColorPickerValue( $( '#wpforms-field-option-' + id + '-choices_icons_color' ) );
[4716] Fix | Delete
}
[4717] Fix | Delete
[4718] Fix | Delete
// Slice choices for preview.
[4719] Fix | Delete
slicedOrder.forEach( function( entry ) {
[4720] Fix | Delete
slicedChoices[ entry ] = fieldSettings.choices[ entry ];
[4721] Fix | Delete
} );
[4722] Fix | Delete
[4723] Fix | Delete
fieldSettings.choices = slicedChoices;
[4724] Fix | Delete
[4725] Fix | Delete
if ( 'checkbox' === type || 'payment-checkbox' === type ) {
[4726] Fix | Delete
data.type = 'checkbox';
[4727] Fix | Delete
}
[4728] Fix | Delete
[4729] Fix | Delete
if ( ! isDynamicChoices ) {
[4730] Fix | Delete
$( '#wpforms-field-' + id ).find( 'ul.primary-input' ).replaceWith( tmpl( data ) );
[4731] Fix | Delete
}
[4732] Fix | Delete
[4733] Fix | Delete
// Toggle limit choices alert message.
[4734] Fix | Delete
app.firstNChoicesAlert( id, order.length );
[4735] Fix | Delete
[4736] Fix | Delete
return true;
[4737] Fix | Delete
},
[4738] Fix | Delete
[4739] Fix | Delete
/**
[4740] Fix | Delete
* Set classic selected choice.
[4741] Fix | Delete
*
[4742] Fix | Delete
* @since 1.8.2.3
[4743] Fix | Delete
*
[4744] Fix | Delete
* @param {jQuery|undefined} $choice Choice option.
[4745] Fix | Delete
*/
[4746] Fix | Delete
setClassicSelectedChoice( $choice ) {
[4747] Fix | Delete
if ( $choice === undefined ) {
[4748] Fix | Delete
return;
[4749] Fix | Delete
}
[4750] Fix | Delete
[4751] Fix | Delete
$choice.prop( 'selected', 'true' );
[4752] Fix | Delete
},
[4753] Fix | Delete
[4754] Fix | Delete
/**
[4755] Fix | Delete
* Field choice bulk add toggling.
[4756] Fix | Delete
*
[4757] Fix | Delete
* @since 1.3.7
[4758] Fix | Delete
*
[4759] Fix | Delete
* @param {Object} el jQuery object.
[4760] Fix | Delete
*/
[4761] Fix | Delete
fieldChoiceBulkAddToggle( el ) {
[4762] Fix | Delete
const $this = $( el ),
[4763] Fix | Delete
$label = $this.closest( 'label' );
[4764] Fix | Delete
[4765] Fix | Delete
if ( $this.hasClass( 'bulk-add-showing' ) ) {
[4766] Fix | Delete
// "Import details" is showing, so hide/remove it.
[4767] Fix | Delete
const $selector = $label.next( '.bulk-add-display' );
[4768] Fix | Delete
[4769] Fix | Delete
$selector.slideUp( 400, function() {
[4770] Fix | Delete
$selector.remove();
[4771] Fix | Delete
} );
[4772] Fix | Delete
[4773] Fix | Delete
$this.find( 'span' ).text( wpforms_builder.bulk_add_show );
[4774] Fix | Delete
} else {
[4775] Fix | Delete
let importOptions = '<div class="bulk-add-display unfoldable-cont">';
[4776] Fix | Delete
[4777] Fix | Delete
importOptions += '<p class="heading wpforms-clear">' + wpforms_builder.bulk_add_heading + ' <a href="#" class="toggle-bulk-add-presets">' + wpforms_builder.bulk_add_presets_show + '</a></p>';
[4778] Fix | Delete
importOptions += '<ul>';
[4779] Fix | Delete
[4780] Fix | Delete
for ( const key in wpforms_preset_choices ) {
[4781] Fix | Delete
importOptions += '<li><a href="#" data-preset="' + key + '" class="bulk-add-preset-insert">' + wpforms_preset_choices[ key ].name + '</a></li>';
[4782] Fix | Delete
}
[4783] Fix | Delete
[4784] Fix | Delete
importOptions += '</ul>';
[4785] Fix | Delete
importOptions += '<textarea placeholder="' + wpforms_builder.bulk_add_placeholder + '"></textarea>';
[4786] Fix | Delete
importOptions += '<button class="bulk-add-insert wpforms-btn wpforms-btn-sm wpforms-btn-blue">' + wpforms_builder.bulk_add_button + '</button>';
[4787] Fix | Delete
importOptions += '</div>';
[4788] Fix | Delete
[4789] Fix | Delete
$label.after( importOptions );
[4790] Fix | Delete
$label.next( '.bulk-add-display' ).slideDown( 400, function() {
[4791] Fix | Delete
$( this ).find( 'textarea' ).trigger( 'focus' );
[4792] Fix | Delete
} );
[4793] Fix | Delete
$this.find( 'span' ).text( wpforms_builder.bulk_add_hide );
[4794] Fix | Delete
}
[4795] Fix | Delete
[4796] Fix | Delete
$this.toggleClass( 'bulk-add-showing' );
[4797] Fix | Delete
},
[4798] Fix | Delete
[4799] Fix | Delete
/**
[4800] Fix | Delete
* Field choice bulk insert the new choices.
[4801] Fix | Delete
*
[4802] Fix | Delete
* @since 1.3.7
[4803] Fix | Delete
*
[4804] Fix | Delete
* @param {Object} el DOM element.
[4805] Fix | Delete
*/
[4806] Fix | Delete
fieldChoiceBulkAddInsert( el ) {
[4807] Fix | Delete
const $this = $( el ),
[4808] Fix | Delete
$container = $this.closest( '.wpforms-field-option-row' ),
[4809] Fix | Delete
$textarea = $container.find( 'textarea' ),
[4810] Fix | Delete
$list = $container.find( '.choices-list' ),
[4811] Fix | Delete
$choice = $list.find( 'li:first-of-type' ).clone().wrap( '<div>' ).parent();
[4812] Fix | Delete
let choice = '';
[4813] Fix | Delete
const fieldID = $container.data( 'field-id' ),
[4814] Fix | Delete
type = $list.data( 'field-type' );
[4815] Fix | Delete
let nextID = Number( $list.attr( 'data-next-id' ) );
[4816] Fix | Delete
const newValues = $textarea.val().split( '\n' );
[4817] Fix | Delete
let newChoices = '';
[4818] Fix | Delete
[4819] Fix | Delete
$this.prop( 'disabled', true ).html( $this.html() + ' ' + s.spinner );
[4820] Fix | Delete
$choice.find( 'input.value,input.label' ).attr( 'value', '' );
[4821] Fix | Delete
$choice.find( 'input.default' ).attr( 'checked', false );
[4822] Fix | Delete
$choice.find( 'input.source-icon' ).attr( 'value', wpforms_builder.icon_choices.default_icon );
[4823] Fix | Delete
$choice.find( 'input.source-icon-style' ).attr( 'value', wpforms_builder.icon_choices.default_icon_style );
[4824] Fix | Delete
$choice.find( '.ic-fa-preview' ).removeClass().addClass( `ic-fa-preview ic-fa-${ wpforms_builder.icon_choices.default_icon_style } ic-fa-${ wpforms_builder.icon_choices.default_icon }` );
[4825] Fix | Delete
$choice.find( '.ic-fa-preview + span' ).text( wpforms_builder.icon_choices.default_icon );
[4826] Fix | Delete
choice = $choice.html();
[4827] Fix | Delete
[4828] Fix | Delete
for ( const key in newValues ) {
[4829] Fix | Delete
if ( ! newValues.hasOwnProperty( key ) ) {
[4830] Fix | Delete
continue;
[4831] Fix | Delete
}
[4832] Fix | Delete
[4833] Fix | Delete
const value = wpf.sanitizeHTML( newValues[ key ] ).trim().replace( /"/g, '&quot;' );
[4834] Fix | Delete
let newChoice = choice;
[4835] Fix | Delete
[4836] Fix | Delete
newChoice = newChoice.replace( /\[choices\]\[(\d+)\]/g, '[choices][' + nextID + ']' );
[4837] Fix | Delete
newChoice = newChoice.replace( /data-key="(\d+)"/g, 'data-key="' + nextID + '"' );
[4838] Fix | Delete
newChoice = newChoice.replace( /value="" class="label"/g, 'value="' + value + '" class="label"' );
[4839] Fix | Delete
[4840] Fix | Delete
// For some reason, IE has its own attribute order.
[4841] Fix | Delete
newChoice = newChoice.replace( /class="label" type="text" value=""/g, 'class="label" type="text" value="' + value + '"' );
[4842] Fix | Delete
newChoices += newChoice;
[4843] Fix | Delete
nextID++;
[4844] Fix | Delete
}
[4845] Fix | Delete
[4846] Fix | Delete
$list.attr( 'data-next-id', nextID ).append( newChoices );
[4847] Fix | Delete
[4848] Fix | Delete
app.fieldChoiceUpdate( type, fieldID, nextID );
[4849] Fix | Delete
$builder.trigger( 'wpformsFieldChoiceAdd' );
[4850] Fix | Delete
app.fieldChoiceBulkAddToggle( $container.find( '.toggle-bulk-add-display' ) );
[4851] Fix | Delete
},
[4852] Fix | Delete
[4853] Fix | Delete
/**
[4854] Fix | Delete
* Toggle fields tabs (Add Fields, Field Options.
[4855] Fix | Delete
*
[4856] Fix | Delete
* @since 1.0.0
[4857] Fix | Delete
*
[4858] Fix | Delete
* @param {number|string} id Field Id or `add-fields` or `field-options`.
[4859] Fix | Delete
*
[4860] Fix | Delete
* @return {false|void} False if event is prevented.
[4861] Fix | Delete
*/
[4862] Fix | Delete
fieldTabToggle( id ) {
[4863] Fix | Delete
const event = WPFormsUtils.triggerEvent( $builder, 'wpformsFieldTabToggle', [ id ] );
[4864] Fix | Delete
[4865] Fix | Delete
// Allow callbacks on `wpformsFieldTabToggle` to cancel tab toggle by triggering `event.preventDefault()`.
[4866] Fix | Delete
if ( event.isDefaultPrevented() ) {
[4867] Fix | Delete
return false;
[4868] Fix | Delete
}
[4869] Fix | Delete
[4870] Fix | Delete
$( '.wpforms-tab a' ).removeClass( 'active' );
[4871] Fix | Delete
$( '.wpforms-field, .wpforms-title-desc' ).removeClass( 'active' );
[4872] Fix | Delete
[4873] Fix | Delete
if ( id === 'add-fields' ) {
[4874] Fix | Delete
$( '#add-fields a' ).addClass( 'active' );
[4875] Fix | Delete
$( '.wpforms-field-options' ).hide();
[4876] Fix | Delete
$( '.wpforms-add-fields' ).show();
[4877] Fix | Delete
} else {
[4878] Fix | Delete
$( '#field-options a' ).addClass( 'active' );
[4879] Fix | Delete
[4880] Fix | Delete
if ( id === 'field-options' ) {
[4881] Fix | Delete
const $field = $( '.wpforms-field' ).first();
[4882] Fix | Delete
[4883] Fix | Delete
$field.addClass( 'active' );
[4884] Fix | Delete
id = $field.data( 'field-id' );
[4885] Fix | Delete
} else {
[4886] Fix | Delete
$( '#wpforms-field-' + id ).addClass( 'active' );
[4887] Fix | Delete
}
[4888] Fix | Delete
[4889] Fix | Delete
$( '.wpforms-field-option' ).hide();
[4890] Fix | Delete
$( '#wpforms-field-option-' + id ).show();
[4891] Fix | Delete
$( '.wpforms-add-fields' ).hide();
[4892] Fix | Delete
$( '.wpforms-field-options' ).show();
[4893] Fix | Delete
[4894] Fix | Delete
$builder.trigger( 'wpformsFieldOptionTabToggle', [ id ] );
[4895] Fix | Delete
}
[4896] Fix | Delete
},
[4897] Fix | Delete
[4898] Fix | Delete
/**
[4899] Fix | Delete
* Watches fields being added and listens for a pagebreak field.
[4900] Fix | Delete
*
[4901] Fix | Delete
* If a pagebreak field is added, and it's the first one, then we
[4902] Fix | Delete
* automatically add the top and bottom pagebreak elements to the
[4903] Fix | Delete
* builder.
[4904] Fix | Delete
*
[4905] Fix | Delete
* @param {Object} event Current DOM event.
[4906] Fix | Delete
* @param {number} id Field ID.
[4907] Fix | Delete
* @param {string} type Field type.
[4908] Fix | Delete
*
[4909] Fix | Delete
* @since 1.2.1
[4910] Fix | Delete
*/
[4911] Fix | Delete
fieldPagebreakAdd( event, id, type ) {
[4912] Fix | Delete
/* eslint-disable camelcase */
[4913] Fix | Delete
[4914] Fix | Delete
if ( 'pagebreak' !== type ) {
[4915] Fix | Delete
return;
[4916] Fix | Delete
}
[4917] Fix | Delete
[4918] Fix | Delete
let options;
[4919] Fix | Delete
[4920] Fix | Delete
if ( ! s.pagebreakTop ) {
[4921] Fix | Delete
s.pagebreakTop = true;
[4922] Fix | Delete
options = {
[4923] Fix | Delete
position: 'top',
[4924] Fix | Delete
scroll: false,
[4925] Fix | Delete
defaults: {
[4926] Fix | Delete
position: 'top',
[4927] Fix | Delete
nav_align: 'left',
[4928] Fix | Delete
},
[4929] Fix | Delete
};
[4930] Fix | Delete
[4931] Fix | Delete
app.fieldAdd( 'pagebreak', options ).done( function( res ) {
[4932] Fix | Delete
s.pagebreakTop = res.data.field.id;
[4933] Fix | Delete
[4934] Fix | Delete
const $preview = $( '#wpforms-field-' + res.data.field.id ),
[4935] Fix | Delete
$options = $( '#wpforms-field-option-' + res.data.field.id );
[4936] Fix | Delete
[4937] Fix | Delete
$options.find( '.wpforms-field-option-group' ).addClass( 'wpforms-pagebreak-top' );
[4938] Fix | Delete
$preview.addClass( 'wpforms-field-stick wpforms-pagebreak-top' );
[4939] Fix | Delete
} );
[4940] Fix | Delete
} else if ( ! s.pagebreakBottom ) {
[4941] Fix | Delete
s.pagebreakBottom = true;
[4942] Fix | Delete
options = {
[4943] Fix | Delete
position: 'bottom',
[4944] Fix | Delete
scroll: false,
[4945] Fix | Delete
defaults: {
[4946] Fix | Delete
position: 'bottom',
[4947] Fix | Delete
},
[4948] Fix | Delete
};
[4949] Fix | Delete
app.fieldAdd( 'pagebreak', options ).done( function( res ) {
[4950] Fix | Delete
s.pagebreakBottom = res.data.field.id;
[4951] Fix | Delete
[4952] Fix | Delete
const $preview = $( '#wpforms-field-' + res.data.field.id ),
[4953] Fix | Delete
$options = $( '#wpforms-field-option-' + res.data.field.id );
[4954] Fix | Delete
[4955] Fix | Delete
$options.find( '.wpforms-field-option-group' ).addClass( 'wpforms-pagebreak-bottom' );
[4956] Fix | Delete
$preview.addClass( 'wpforms-field-stick wpforms-pagebreak-bottom' );
[4957] Fix | Delete
} );
[4958] Fix | Delete
}
[4959] Fix | Delete
},
[4960] Fix | Delete
[4961] Fix | Delete
/**
[4962] Fix | Delete
* Watches fields being deleted and listens for a pagebreak field.
[4963] Fix | Delete
*
[4964] Fix | Delete
* If a pagebreak field is added, and it's the first one, then we
[4965] Fix | Delete
* automatically add the top and bottom pagebreak elements to the
[4966] Fix | Delete
* builder.
[4967] Fix | Delete
*
[4968] Fix | Delete
* @param {Object} event Current DOM event.
[4969] Fix | Delete
* @param {number} id Field ID.
[4970] Fix | Delete
* @param {string} type Field type.
[4971] Fix | Delete
*
[4972] Fix | Delete
* @since 1.2.1
[4973] Fix | Delete
*/
[4974] Fix | Delete
fieldPagebreakDelete( event, id, type ) {
[4975] Fix | Delete
if ( 'pagebreak' !== type ) {
[4976] Fix | Delete
return;
[4977] Fix | Delete
}
[4978] Fix | Delete
[4979] Fix | Delete
const pagebreaksRemaining = $( '#wpforms-panel-fields .wpforms-field-pagebreak' ).not( '.wpforms-pagebreak-top, .wpforms-pagebreak-bottom' ).length;
[4980] Fix | Delete
[4981] Fix | Delete
if ( pagebreaksRemaining ) {
[4982] Fix | Delete
return;
[4983] Fix | Delete
}
[4984] Fix | Delete
[4985] Fix | Delete
// All pagebreaks, excluding top/bottom, are gone.
[4986] Fix | Delete
// So we need to remove the top and bottom pagebreak.
[4987] Fix | Delete
const $preview = $( '#wpforms-panel-fields .wpforms-preview-wrap' ),
[4988] Fix | Delete
$top = $preview.find( '.wpforms-pagebreak-top' ),
[4989] Fix | Delete
topID = $top.data( 'field-id' ),
[4990] Fix | Delete
$bottom = $preview.find( '.wpforms-pagebreak-bottom' ),
[4991] Fix | Delete
bottomID = $bottom.data( 'field-id' );
[4992] Fix | Delete
[4993] Fix | Delete
$top.remove();
[4994] Fix | Delete
$( '#wpforms-field-option-' + topID ).remove();
[4995] Fix | Delete
s.pagebreakTop = false;
[4996] Fix | Delete
$bottom.remove();
[4997] Fix | Delete
$( '#wpforms-field-option-' + bottomID ).remove();
[4998] Fix | Delete
s.pagebreakBottom = false;
[4999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function