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/frontend
File: wpforms.js
if ( typeof $.fn.timepicker === 'undefined' ) {
[1000] Fix | Delete
return;
[1001] Fix | Delete
}
[1002] Fix | Delete
[1003] Fix | Delete
$context = $context?.length ? $context : $( document );
[1004] Fix | Delete
[1005] Fix | Delete
$context.find( '.wpforms-timepicker' ).each( function() { // eslint-disable-line complexity
[1006] Fix | Delete
const element = $( this ),
[1007] Fix | Delete
form = element.closest( '.wpforms-form' ),
[1008] Fix | Delete
formID = form.data( 'formid' ),
[1009] Fix | Delete
fieldID = element.closest( '.wpforms-field' ).data( 'field-id' );
[1010] Fix | Delete
[1011] Fix | Delete
let properties;
[1012] Fix | Delete
[1013] Fix | Delete
if (
[1014] Fix | Delete
typeof window[ 'wpforms_' + formID + '_' + fieldID ] !== 'undefined' &&
[1015] Fix | Delete
window[ 'wpforms_' + formID + '_' + fieldID ].hasOwnProperty( 'timepicker' )
[1016] Fix | Delete
) {
[1017] Fix | Delete
properties = window[ 'wpforms_' + formID + '_' + fieldID ].timepicker;
[1018] Fix | Delete
} else if (
[1019] Fix | Delete
typeof window[ 'wpforms_' + formID ] !== 'undefined' &&
[1020] Fix | Delete
window[ 'wpforms_' + formID ].hasOwnProperty( 'timepicker' )
[1021] Fix | Delete
) {
[1022] Fix | Delete
properties = window[ 'wpforms_' + formID ].timepicker;
[1023] Fix | Delete
} else if ( typeof wpforms_timepicker !== 'undefined' ) {
[1024] Fix | Delete
properties = wpforms_timepicker;
[1025] Fix | Delete
} else {
[1026] Fix | Delete
properties = {
[1027] Fix | Delete
scrollDefault: 'now',
[1028] Fix | Delete
forceRoundTime: true,
[1029] Fix | Delete
};
[1030] Fix | Delete
}
[1031] Fix | Delete
[1032] Fix | Delete
// Retrieve the value from the input element.
[1033] Fix | Delete
const inputValue = element.val();
[1034] Fix | Delete
[1035] Fix | Delete
element.timepicker( properties );
[1036] Fix | Delete
[1037] Fix | Delete
// Check if a value is available.
[1038] Fix | Delete
if ( inputValue ) {
[1039] Fix | Delete
// Set the input element's value to the retrieved value.
[1040] Fix | Delete
element.val( inputValue );
[1041] Fix | Delete
[1042] Fix | Delete
// Trigger the 'changeTime' event to update the timepicker after programmatically setting the value.
[1043] Fix | Delete
element.trigger( 'changeTime' );
[1044] Fix | Delete
}
[1045] Fix | Delete
} );
[1046] Fix | Delete
},
[1047] Fix | Delete
[1048] Fix | Delete
/**
[1049] Fix | Delete
* Load jQuery input masks.
[1050] Fix | Delete
*
[1051] Fix | Delete
* @since 1.2.3
[1052] Fix | Delete
* @since 1.8.9 Added the `$context` parameter.
[1053] Fix | Delete
*
[1054] Fix | Delete
* @param {jQuery} $context Container to search for datepicker elements.
[1055] Fix | Delete
*/
[1056] Fix | Delete
loadInputMask( $context ) {
[1057] Fix | Delete
// Only load if jQuery input mask library exists.
[1058] Fix | Delete
if ( typeof $.fn.inputmask === 'undefined' ) {
[1059] Fix | Delete
return;
[1060] Fix | Delete
}
[1061] Fix | Delete
[1062] Fix | Delete
$context = $context?.length ? $context : $( document );
[1063] Fix | Delete
[1064] Fix | Delete
// This setting has no effect when switching to the "RTL" mode.
[1065] Fix | Delete
$context.find( '.wpforms-masked-input' ).inputmask( { rightAlign: false } );
[1066] Fix | Delete
},
[1067] Fix | Delete
[1068] Fix | Delete
/**
[1069] Fix | Delete
* Fix the Phone field snippets.
[1070] Fix | Delete
*
[1071] Fix | Delete
* @since 1.8.7.1
[1072] Fix | Delete
*
[1073] Fix | Delete
* @param {jQuery} $field Phone field element.
[1074] Fix | Delete
*/
[1075] Fix | Delete
fixPhoneFieldSnippets( $field ) {
[1076] Fix | Delete
$field.siblings( 'input[type="hidden"]' ).each( function() {
[1077] Fix | Delete
if ( ! $( this ).attr( 'name' ).includes( 'function' ) ) {
[1078] Fix | Delete
return;
[1079] Fix | Delete
}
[1080] Fix | Delete
[1081] Fix | Delete
const data = $field.data( 'plugin_intlTelInput' );
[1082] Fix | Delete
const options = data.d || data.options;
[1083] Fix | Delete
[1084] Fix | Delete
if ( ! options ) {
[1085] Fix | Delete
return;
[1086] Fix | Delete
}
[1087] Fix | Delete
[1088] Fix | Delete
$field.intlTelInput( 'destroy' );
[1089] Fix | Delete
options.initialCountry = options.initialCountry.toLowerCase();
[1090] Fix | Delete
options.onlyCountries = options.onlyCountries.map( ( v ) => v.toLowerCase() );
[1091] Fix | Delete
options.preferredCountries = options.preferredCountries.map( ( v ) => v.toLowerCase() );
[1092] Fix | Delete
$field.intlTelInput( options );
[1093] Fix | Delete
$field.siblings( 'input[type="hidden"]' ).each( function() {
[1094] Fix | Delete
const $hiddenInput = $( this );
[1095] Fix | Delete
$hiddenInput.attr( 'name', $hiddenInput.attr( 'name' ).replace( 'wpf-temp-', '' ) );
[1096] Fix | Delete
} );
[1097] Fix | Delete
} );
[1098] Fix | Delete
},
[1099] Fix | Delete
[1100] Fix | Delete
/**
[1101] Fix | Delete
* Load Smartphone field.
[1102] Fix | Delete
*
[1103] Fix | Delete
* @since 1.5.2
[1104] Fix | Delete
* @since 1.8.9 Added the `$context` parameter.
[1105] Fix | Delete
*
[1106] Fix | Delete
* @param {jQuery} $context Context to search for smartphone elements.
[1107] Fix | Delete
*/
[1108] Fix | Delete
loadSmartPhoneField( $context ) { // eslint-disable-line complexity
[1109] Fix | Delete
if ( typeof $.fn.intlTelInput === 'undefined' ) {
[1110] Fix | Delete
// Only load if a library exists.
[1111] Fix | Delete
return;
[1112] Fix | Delete
}
[1113] Fix | Delete
[1114] Fix | Delete
const inputOptions = {
[1115] Fix | Delete
countrySearch: false,
[1116] Fix | Delete
fixDropdownWidth: false,
[1117] Fix | Delete
preferredCountries: [ 'us', 'gb' ],
[1118] Fix | Delete
};
[1119] Fix | Delete
let countryCode;
[1120] Fix | Delete
[1121] Fix | Delete
// Determine the country by IP if no GDPR restrictions enabled.
[1122] Fix | Delete
if ( ! wpforms_settings.gdpr ) {
[1123] Fix | Delete
inputOptions.geoIpLookup = app.currentIpToCountry;
[1124] Fix | Delete
}
[1125] Fix | Delete
[1126] Fix | Delete
// Try to kick in an alternative solution if GDPR restrictions are enabled.
[1127] Fix | Delete
if ( wpforms_settings.gdpr ) {
[1128] Fix | Delete
const lang = this.getFirstBrowserLanguage();
[1129] Fix | Delete
[1130] Fix | Delete
countryCode = lang.indexOf( '-' ) > -1 ? lang.split( '-' ).pop() : '';
[1131] Fix | Delete
}
[1132] Fix | Delete
[1133] Fix | Delete
// Make sure the library recognizes browser country code to avoid console error.
[1134] Fix | Delete
if ( countryCode ) {
[1135] Fix | Delete
let countryData = window.intlTelInputGlobals.getCountryData();
[1136] Fix | Delete
[1137] Fix | Delete
countryData = countryData.filter( function( country ) {
[1138] Fix | Delete
return country.iso2 === countryCode.toLowerCase();
[1139] Fix | Delete
} );
[1140] Fix | Delete
countryCode = countryData.length ? countryCode : '';
[1141] Fix | Delete
}
[1142] Fix | Delete
[1143] Fix | Delete
// Set default country.
[1144] Fix | Delete
inputOptions.initialCountry = wpforms_settings.gdpr && countryCode ? countryCode.toLowerCase() : 'auto';
[1145] Fix | Delete
[1146] Fix | Delete
$context = $context?.length ? $context : $( document );
[1147] Fix | Delete
[1148] Fix | Delete
$context.find( '.wpforms-smart-phone-field' ).each( function( i, el ) {
[1149] Fix | Delete
const $el = $( el );
[1150] Fix | Delete
[1151] Fix | Delete
// Prevent initialization if the popup is hidden.
[1152] Fix | Delete
if ( $el.parents( '.elementor-location-popup' ).is( ':hidden' ) ) {
[1153] Fix | Delete
return false;
[1154] Fix | Delete
}
[1155] Fix | Delete
[1156] Fix | Delete
// Hidden input allows to include country code into submitted data.
[1157] Fix | Delete
inputOptions.hiddenInput = function( telInputName ) {
[1158] Fix | Delete
return {
[1159] Fix | Delete
phone: telInputName,
[1160] Fix | Delete
};
[1161] Fix | Delete
};
[1162] Fix | Delete
inputOptions.utilsScript = wpforms_settings.wpforms_plugin_url + 'assets/pro/lib/intl-tel-input/jquery.intl-tel-input-utils.min.js';
[1163] Fix | Delete
[1164] Fix | Delete
$el.intlTelInput( inputOptions );
[1165] Fix | Delete
[1166] Fix | Delete
// For proper validation, we should preserve the name attribute of the input field.
[1167] Fix | Delete
// But we need to modify the original input name not to interfere with a hidden input.
[1168] Fix | Delete
$el.attr( 'name', 'wpf-temp-' + $el.attr( 'name' ) );
[1169] Fix | Delete
[1170] Fix | Delete
// Add special class to remove name attribute before submitting.
[1171] Fix | Delete
// So, only the hidden input value will be submitted.
[1172] Fix | Delete
$el.addClass( 'wpforms-input-temp-name' );
[1173] Fix | Delete
[1174] Fix | Delete
// Instantly update a hidden form input with correct data.
[1175] Fix | Delete
// Previously "blur" only was used, which is broken in case Enter was used to submit the form.
[1176] Fix | Delete
$el.on( 'blur input', function() {
[1177] Fix | Delete
if ( $el.intlTelInput( 'isValidNumber' ) || ! app.empty( window.WPFormsEditEntry ) ) {
[1178] Fix | Delete
$el.siblings( 'input[type="hidden"]' ).val( $el.intlTelInput( 'getNumber' ) );
[1179] Fix | Delete
}
[1180] Fix | Delete
} );
[1181] Fix | Delete
} );
[1182] Fix | Delete
},
[1183] Fix | Delete
[1184] Fix | Delete
/**
[1185] Fix | Delete
* Bind Smartphone field event.
[1186] Fix | Delete
*
[1187] Fix | Delete
* @since 1.8.9
[1188] Fix | Delete
*/
[1189] Fix | Delete
bindSmartPhoneField() {
[1190] Fix | Delete
// Update hidden input of the `Smart` phone field to be sure the latest value will be submitted.
[1191] Fix | Delete
$( '.wpforms-form' ).on( 'wpformsBeforeFormSubmit', function() {
[1192] Fix | Delete
$( this ).find( '.wpforms-smart-phone-field' ).trigger( 'input' );
[1193] Fix | Delete
} );
[1194] Fix | Delete
},
[1195] Fix | Delete
[1196] Fix | Delete
/**
[1197] Fix | Delete
* Payments: Do various payment-related tasks on a load.
[1198] Fix | Delete
*
[1199] Fix | Delete
* @since 1.2.6
[1200] Fix | Delete
*/
[1201] Fix | Delete
loadPayments() {
[1202] Fix | Delete
// Update Total field(s) with the latest calculation.
[1203] Fix | Delete
$( '.wpforms-payment-total' ).each( function( index, el ) {
[1204] Fix | Delete
app.amountTotal( this );
[1205] Fix | Delete
} );
[1206] Fix | Delete
[1207] Fix | Delete
// Credit card validation.
[1208] Fix | Delete
if ( typeof $.fn.payment !== 'undefined' ) {
[1209] Fix | Delete
$( '.wpforms-field-credit-card-cardnumber' ).payment( 'formatCardNumber' );
[1210] Fix | Delete
$( '.wpforms-field-credit-card-cardcvc' ).payment( 'formatCardCVC' );
[1211] Fix | Delete
}
[1212] Fix | Delete
},
[1213] Fix | Delete
[1214] Fix | Delete
/**
[1215] Fix | Delete
* Load mailcheck.
[1216] Fix | Delete
*
[1217] Fix | Delete
* @since 1.5.3
[1218] Fix | Delete
*/
[1219] Fix | Delete
loadMailcheck() { // eslint-disable-line max-lines-per-function
[1220] Fix | Delete
// Skip loading if `wpforms_mailcheck_enabled` filter return false.
[1221] Fix | Delete
if ( ! wpforms_settings.mailcheck_enabled ) {
[1222] Fix | Delete
return;
[1223] Fix | Delete
}
[1224] Fix | Delete
[1225] Fix | Delete
// Only load if a library exists.
[1226] Fix | Delete
if ( typeof $.fn.mailcheck === 'undefined' ) {
[1227] Fix | Delete
return;
[1228] Fix | Delete
}
[1229] Fix | Delete
[1230] Fix | Delete
if ( wpforms_settings.mailcheck_domains.length > 0 ) {
[1231] Fix | Delete
Mailcheck.defaultDomains = Mailcheck.defaultDomains.concat( wpforms_settings.mailcheck_domains );
[1232] Fix | Delete
}
[1233] Fix | Delete
if ( wpforms_settings.mailcheck_toplevel_domains.length > 0 ) {
[1234] Fix | Delete
Mailcheck.defaultTopLevelDomains = Mailcheck.defaultTopLevelDomains.concat( wpforms_settings.mailcheck_toplevel_domains );
[1235] Fix | Delete
}
[1236] Fix | Delete
[1237] Fix | Delete
// Mailcheck suggestion.
[1238] Fix | Delete
$( document ).on( 'blur', '.wpforms-field-email input', function() {
[1239] Fix | Delete
const $input = $( this ),
[1240] Fix | Delete
id = $input.attr( 'id' );
[1241] Fix | Delete
[1242] Fix | Delete
$input.mailcheck( {
[1243] Fix | Delete
suggested( $el, suggestion ) {
[1244] Fix | Delete
// decodeURI() will throw an error if the percent sign is not followed by two hexadecimal digits.
[1245] Fix | Delete
suggestion.full = suggestion.full.replace( /%(?![0-9][0-9a-fA-F]+)/g, '%25' );
[1246] Fix | Delete
suggestion.address = suggestion.address.replace( /%(?![0-9][0-9a-fA-F]+)/g, '%25' );
[1247] Fix | Delete
suggestion.domain = suggestion.domain.replace( /%(?![0-9][0-9a-fA-F]+)/g, '%25' );
[1248] Fix | Delete
[1249] Fix | Delete
if ( suggestion.address.match( /^xn--/ ) ) {
[1250] Fix | Delete
suggestion.full = punycode.toUnicode( decodeURI( suggestion.full ) );
[1251] Fix | Delete
[1252] Fix | Delete
const parts = suggestion.full.split( '@' );
[1253] Fix | Delete
[1254] Fix | Delete
suggestion.address = parts[ 0 ];
[1255] Fix | Delete
suggestion.domain = parts[ 1 ];
[1256] Fix | Delete
}
[1257] Fix | Delete
[1258] Fix | Delete
if ( suggestion.domain.match( /^xn--/ ) ) {
[1259] Fix | Delete
suggestion.domain = punycode.toUnicode( decodeURI( suggestion.domain ) );
[1260] Fix | Delete
}
[1261] Fix | Delete
[1262] Fix | Delete
const address = decodeURI( suggestion.address ).replaceAll( /[<>'"()/\\|:;=@%&\s]/ig, '' ).substr( 0, 64 ),
[1263] Fix | Delete
domain = decodeURI( suggestion.domain ).replaceAll( /[<>'"()/\\|:;=@%&+_\s]/ig, '' );
[1264] Fix | Delete
[1265] Fix | Delete
suggestion = '<a href="#" class="mailcheck-suggestion" data-id="' + id + '" title="' + wpforms_settings.val_email_suggestion_title + '">' + address + '@' + domain + '</a>';
[1266] Fix | Delete
suggestion = wpforms_settings.val_email_suggestion.replace( '{suggestion}', suggestion );
[1267] Fix | Delete
[1268] Fix | Delete
$el.closest( '.wpforms-field' ).find( '#' + id + '_suggestion' ).remove();
[1269] Fix | Delete
$el.parent().append( '<label class="wpforms-error mailcheck-error" id="' + id + '_suggestion">' + suggestion + '</label>' );
[1270] Fix | Delete
},
[1271] Fix | Delete
empty() {
[1272] Fix | Delete
$( '#' + id + '_suggestion' ).remove();
[1273] Fix | Delete
},
[1274] Fix | Delete
} );
[1275] Fix | Delete
} );
[1276] Fix | Delete
[1277] Fix | Delete
// Apply a Mailcheck suggestion.
[1278] Fix | Delete
$( document ).on( 'click', '.wpforms-field-email .mailcheck-suggestion', function( e ) {
[1279] Fix | Delete
const $suggestion = $( this ),
[1280] Fix | Delete
$field = $suggestion.closest( '.wpforms-field' ),
[1281] Fix | Delete
id = $suggestion.data( 'id' );
[1282] Fix | Delete
[1283] Fix | Delete
e.preventDefault();
[1284] Fix | Delete
$field.find( '#' + id ).val( $suggestion.text() );
[1285] Fix | Delete
$suggestion.parent().remove();
[1286] Fix | Delete
} );
[1287] Fix | Delete
},
[1288] Fix | Delete
[1289] Fix | Delete
/**
[1290] Fix | Delete
* Load Choices.js library for all Modern style Dropdown fields (<select>).
[1291] Fix | Delete
*
[1292] Fix | Delete
* @since 1.6.1
[1293] Fix | Delete
* @since 1.8.9 Added the `$context` parameter.
[1294] Fix | Delete
*
[1295] Fix | Delete
* @param {jQuery} $context Container to search for ChoicesJS elements.
[1296] Fix | Delete
*/
[1297] Fix | Delete
loadChoicesJS( $context ) { // eslint-disable-line max-lines-per-function
[1298] Fix | Delete
// Loads if function exists.
[1299] Fix | Delete
if ( typeof window.Choices !== 'function' ) {
[1300] Fix | Delete
return;
[1301] Fix | Delete
}
[1302] Fix | Delete
[1303] Fix | Delete
$context = $context?.length ? $context : $( document );
[1304] Fix | Delete
[1305] Fix | Delete
// eslint-disable-next-line max-lines-per-function
[1306] Fix | Delete
$context.find( '.wpforms-field-select-style-modern .choicesjs-select, .wpforms-field-payment-select .choicesjs-select' ).each( function( idx, el ) {
[1307] Fix | Delete
if ( $( el ).data( 'choicesjs' ) ) {
[1308] Fix | Delete
return;
[1309] Fix | Delete
}
[1310] Fix | Delete
[1311] Fix | Delete
const args = window.wpforms_choicesjs_config || {},
[1312] Fix | Delete
searchEnabled = $( el ).data( 'search-enabled' ),
[1313] Fix | Delete
removeItems = $( el ).data( 'remove-items-enabled' );
[1314] Fix | Delete
[1315] Fix | Delete
args.searchEnabled = 'undefined' !== typeof searchEnabled ? searchEnabled : true;
[1316] Fix | Delete
args.removeItems = 'undefined' !== typeof removeItems ? removeItems : true;
[1317] Fix | Delete
args.removeItemButton = args.removeItems;
[1318] Fix | Delete
args.searchEnabled = 'undefined' !== typeof searchEnabled ? searchEnabled : true;
[1319] Fix | Delete
args.allowHTML = false; // TODO: Remove after next Choices.js release.
[1320] Fix | Delete
[1321] Fix | Delete
args.callbackOnInit = function() {
[1322] Fix | Delete
const self = this,
[1323] Fix | Delete
$element = $( self.passedElement.element ),
[1324] Fix | Delete
$input = $( self.input.element ),
[1325] Fix | Delete
sizeClass = $element.data( 'size-class' );
[1326] Fix | Delete
[1327] Fix | Delete
// Remove hidden attribute and hide `<select>` like a screen-reader text.
[1328] Fix | Delete
// It's important for field validation.
[1329] Fix | Delete
$element
[1330] Fix | Delete
.removeAttr( 'hidden' )
[1331] Fix | Delete
.addClass( self.config.classNames.input + '--hidden' );
[1332] Fix | Delete
[1333] Fix | Delete
// Add CSS-class for size.
[1334] Fix | Delete
if ( sizeClass ) {
[1335] Fix | Delete
$( self.containerOuter.element ).addClass( sizeClass );
[1336] Fix | Delete
}
[1337] Fix | Delete
[1338] Fix | Delete
/**
[1339] Fix | Delete
* If a multiple select has selected choices - hide a placeholder text.
[1340] Fix | Delete
* In case if select is empty - we return placeholder text.
[1341] Fix | Delete
*/
[1342] Fix | Delete
if ( $element.prop( 'multiple' ) ) {
[1343] Fix | Delete
// On init event.
[1344] Fix | Delete
$input.data( 'placeholder', $input.attr( 'placeholder' ) ).css( 'width', 'auto' );
[1345] Fix | Delete
[1346] Fix | Delete
if ( self.getValue( true ).length ) {
[1347] Fix | Delete
$input.removeAttr( 'placeholder' );
[1348] Fix | Delete
}
[1349] Fix | Delete
}
[1350] Fix | Delete
[1351] Fix | Delete
// On change event.
[1352] Fix | Delete
$element.on( 'change', function() {
[1353] Fix | Delete
// Listen if multiple select has choices.
[1354] Fix | Delete
if ( $element.prop( 'multiple' ) ) {
[1355] Fix | Delete
// eslint-disable-next-line no-unused-expressions
[1356] Fix | Delete
self.getValue( true ).length
[1357] Fix | Delete
? $input.removeAttr( 'placeholder' )
[1358] Fix | Delete
: $input.attr( 'placeholder', $input.data( 'placeholder' ) ).css( 'width', 'auto' );
[1359] Fix | Delete
}
[1360] Fix | Delete
[1361] Fix | Delete
const validator = $element.closest( 'form' ).data( 'validator' );
[1362] Fix | Delete
[1363] Fix | Delete
if ( ! validator ) {
[1364] Fix | Delete
return;
[1365] Fix | Delete
}
[1366] Fix | Delete
[1367] Fix | Delete
validator.element( $element );
[1368] Fix | Delete
} );
[1369] Fix | Delete
};
[1370] Fix | Delete
[1371] Fix | Delete
args.callbackOnCreateTemplates = function() {
[1372] Fix | Delete
const self = this,
[1373] Fix | Delete
$element = $( self.passedElement.element );
[1374] Fix | Delete
[1375] Fix | Delete
return {
[1376] Fix | Delete
// Change default template for option.
[1377] Fix | Delete
option( item ) {
[1378] Fix | Delete
const opt = Choices.defaults.templates.option.call( this, item );
[1379] Fix | Delete
[1380] Fix | Delete
// Add a `.placeholder` class for placeholder option - it needs for WPForm CL.
[1381] Fix | Delete
if ( 'undefined' !== typeof item.placeholder && true === item.placeholder ) {
[1382] Fix | Delete
opt.classList.add( 'placeholder' );
[1383] Fix | Delete
}
[1384] Fix | Delete
[1385] Fix | Delete
// Add a `data-amount` attribute for payment dropdown.
[1386] Fix | Delete
// It will be a copy from a Choices.js `data-custom-properties` attribute.
[1387] Fix | Delete
if ( $element.hasClass( 'wpforms-payment-price' ) && 'undefined' !== typeof item.customProperties && null !== item.customProperties ) {
[1388] Fix | Delete
opt.dataset.amount = item.customProperties;
[1389] Fix | Delete
}
[1390] Fix | Delete
[1391] Fix | Delete
return opt;
[1392] Fix | Delete
},
[1393] Fix | Delete
};
[1394] Fix | Delete
};
[1395] Fix | Delete
[1396] Fix | Delete
// Save choicesjs instance for future access.
[1397] Fix | Delete
$( el ).data( 'choicesjs', new Choices( el, args ) );
[1398] Fix | Delete
} );
[1399] Fix | Delete
},
[1400] Fix | Delete
[1401] Fix | Delete
/**
[1402] Fix | Delete
* Bind ChoicesJS' events.
[1403] Fix | Delete
*
[1404] Fix | Delete
* @since 1.8.9
[1405] Fix | Delete
*/
[1406] Fix | Delete
bindChoicesJS() {
[1407] Fix | Delete
// Add the ability to close the drop-down menu on the frontend.
[1408] Fix | Delete
$( document ).on( 'click', '.choices', function( e ) {
[1409] Fix | Delete
const $choices = $( this ),
[1410] Fix | Delete
choicesObj = $choices.find( 'select' ).data( 'choicesjs' );
[1411] Fix | Delete
[1412] Fix | Delete
if (
[1413] Fix | Delete
choicesObj &&
[1414] Fix | Delete
$choices.hasClass( 'is-open' ) &&
[1415] Fix | Delete
(
[1416] Fix | Delete
e.target.classList.contains( 'choices__inner' ) ||
[1417] Fix | Delete
e.target.classList.contains( 'choices__arrow' )
[1418] Fix | Delete
)
[1419] Fix | Delete
) {
[1420] Fix | Delete
choicesObj.hideDropdown();
[1421] Fix | Delete
}
[1422] Fix | Delete
} );
[1423] Fix | Delete
},
[1424] Fix | Delete
[1425] Fix | Delete
//--------------------------------------------------------------------//
[1426] Fix | Delete
// Binds.
[1427] Fix | Delete
//--------------------------------------------------------------------//
[1428] Fix | Delete
[1429] Fix | Delete
/**
[1430] Fix | Delete
* Element bindings.
[1431] Fix | Delete
*
[1432] Fix | Delete
* @since 1.2.3
[1433] Fix | Delete
*/
[1434] Fix | Delete
bindUIActions() { // eslint-disable-line max-lines-per-function
[1435] Fix | Delete
const $document = $( document );
[1436] Fix | Delete
[1437] Fix | Delete
// Pagebreak navigation.
[1438] Fix | Delete
$document.on( 'click', '.wpforms-page-button', function( event ) {
[1439] Fix | Delete
event.preventDefault();
[1440] Fix | Delete
app.pagebreakNav( this );
[1441] Fix | Delete
} );
[1442] Fix | Delete
[1443] Fix | Delete
// Payments: Update Total field(s) when latest calculation.
[1444] Fix | Delete
$document.on( 'change input', '.wpforms-payment-price', function() {
[1445] Fix | Delete
app.amountTotal( this, true );
[1446] Fix | Delete
} );
[1447] Fix | Delete
[1448] Fix | Delete
// Payments: Update Total field(s) when changing quantity.
[1449] Fix | Delete
$document.on( 'change input', 'select.wpforms-payment-quantity', function() {
[1450] Fix | Delete
app.amountTotal( this, true );
[1451] Fix | Delete
app.updateOrderSummaryItemQuantity( $( this ) );
[1452] Fix | Delete
} );
[1453] Fix | Delete
[1454] Fix | Delete
// Payments: Restrict user input payment fields.
[1455] Fix | Delete
$document.on( 'input', '.wpforms-payment-user-input', function() {
[1456] Fix | Delete
const $this = $( this ),
[1457] Fix | Delete
amount = $this.val();
[1458] Fix | Delete
$this.val( amount.replace( /[^0-9.,]/g, '' ) );
[1459] Fix | Delete
} );
[1460] Fix | Delete
[1461] Fix | Delete
// Payments: Sanitize/format user input amounts.
[1462] Fix | Delete
$document.on( 'focusout', '.wpforms-payment-user-input', function() {
[1463] Fix | Delete
const $this = $( this ),
[1464] Fix | Delete
amount = $this.val();
[1465] Fix | Delete
[1466] Fix | Delete
if ( ! amount ) {
[1467] Fix | Delete
return amount;
[1468] Fix | Delete
}
[1469] Fix | Delete
[1470] Fix | Delete
const sanitized = app.amountSanitize( amount ),
[1471] Fix | Delete
formatted = app.amountFormat( sanitized );
[1472] Fix | Delete
[1473] Fix | Delete
$this.val( formatted );
[1474] Fix | Delete
} );
[1475] Fix | Delete
[1476] Fix | Delete
// Payments: Update Total field(s) when conditionals are processed.
[1477] Fix | Delete
$document.on( 'wpformsProcessConditionals', function( e, el ) {
[1478] Fix | Delete
app.amountTotal( el, true );
[1479] Fix | Delete
} );
[1480] Fix | Delete
[1481] Fix | Delete
// Order Summary: Update field when conditionals are processed.
[1482] Fix | Delete
$document.on( 'wpformsProcessConditionalsField', function( e, formID, fieldID ) {
[1483] Fix | Delete
app.updateOrderSummaryItems( $( `#wpforms-form-${ formID }` ), $( `#wpforms-${ formID }-field_${ fieldID }` ), '' );
[1484] Fix | Delete
} );
[1485] Fix | Delete
[1486] Fix | Delete
// Rating field: hover effect.
[1487] Fix | Delete
$document.on( 'mouseenter', '.wpforms-field-rating-item', function() {
[1488] Fix | Delete
$( this ).parent().find( '.wpforms-field-rating-item' ).removeClass( 'selected hover' );
[1489] Fix | Delete
$( this ).prevAll().addBack().addClass( 'hover' );
[1490] Fix | Delete
} ).on( 'mouseleave', '.wpforms-field-rating-item', function() {
[1491] Fix | Delete
$( this ).parent().find( '.wpforms-field-rating-item' ).removeClass( 'selected hover' );
[1492] Fix | Delete
$( this ).parent().find( 'input:checked' ).parent().prevAll().addBack().addClass( 'selected' );
[1493] Fix | Delete
} );
[1494] Fix | Delete
[1495] Fix | Delete
// Rating field: toggle selected state.
[1496] Fix | Delete
$( document ).on( 'change', '.wpforms-field-rating-item input', function() {
[1497] Fix | Delete
const $this = $( this ),
[1498] Fix | Delete
$wrap = $this.closest( '.wpforms-field-rating-items' ),
[1499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function