3
3
* Add to Calendar Button
4
4
* ++++++++++++++++++++++
5
5
*
6
- * Version: 2.6.18
6
+ * Version: 2.6.19
7
7
* Creator: Jens Kuerschner (https://jekuer.com)
8
8
* Project: https://github.com/add2cal/add-to-calendar-button
9
9
* License: Elastic License 2.0 (ELv2) (https://github.com/add2cal/add-to-calendar-button/blob/main/LICENSE.txt)
@@ -291,19 +291,19 @@ async function atcb_generate_rsvp_form(host, data, hostEl, keyboardTrigger = fal
291
291
rsvpContent += '<div class="pro-field"><label for="' + data . identifier + '-rsvp-amount">' + atcb_translate_hook ( 'form.amount' , data ) + ' (' + atcb_translate_hook ( 'form.max' , data ) + ' ' + maxAmount + ')<span>*</span></label>' ;
292
292
rsvpContent += '<input type="number" name="' + staticID + '-amount" min="1" max="' + maxAmount + '" id="' + data . identifier + '-rsvp-amount" ' + ( data . disabled && 'disabled' ) + ' aria-label="' + atcb_translate_hook ( 'form.amount' , data ) + '" value="1" /></div>' ;
293
293
}
294
+ const attendee = ( function ( ) {
295
+ if ( data . attendee && data . attendee !== '' ) {
296
+ const attendeeParts = data . attendee . split ( '|' ) ;
297
+ if ( attendeeParts . length > 1 ) {
298
+ return attendeeParts [ 1 ] ;
299
+ }
300
+ return attendeeParts [ 0 ] ;
301
+ }
302
+ return null ;
303
+ } ) ( ) ;
294
304
const customEmailField = rsvpData . fields ?. find ( ( field ) => field . name === 'email' ) ;
295
305
if ( ! customEmailField ) {
296
- const attendee = ( function ( ) {
297
- if ( data . attendee && data . attendee !== '' ) {
298
- const attendeeParts = data . attendee . split ( '|' ) ;
299
- if ( attendeeParts . length > 1 ) {
300
- return attendeeParts [ 1 ] ;
301
- }
302
- return attendeeParts [ 0 ] ;
303
- }
304
- return '' ;
305
- } ) ( ) ;
306
- if ( attendee !== '' ) {
306
+ if ( attendee ) {
307
307
hiddenContent += '<input type="hidden" name="email" id="' + data . identifier + '-rsvp-email" value="' + attendee + '" />' ;
308
308
} else {
309
309
rsvpContent += '<div class="pro-field"><label for="' + data . identifier + '-rsvp-email">' + atcb_translate_hook ( 'form.email' , data ) + '<span>*</span></label>' ;
@@ -312,7 +312,7 @@ async function atcb_generate_rsvp_form(host, data, hostEl, keyboardTrigger = fal
312
312
} else {
313
313
rsvpData . fields = rsvpData . fields . map ( ( field ) => {
314
314
if ( field . name === 'email' ) {
315
- return { ...field , required : true } ;
315
+ return { ...field , required : true , type : 'email' , default : attendee !== '' && attendee || field . default } ;
316
316
}
317
317
return field ;
318
318
} ) ;
@@ -669,7 +669,7 @@ function atcb_build_form(fields, identifier = '', disabled = false) {
669
669
function atcb_create_field_html ( type , name , fieldLabel , fieldId , required = false , fieldValue , defaultVal = null , fieldPlaceholder = '' , disabled = false ) {
670
670
let fieldHtml = '' ;
671
671
// add label
672
- if ( ( type === 'text' || type === 'number' ) && fieldLabel !== '' ) {
672
+ if ( ( type === 'text' || type === 'email' || type === ' number') && fieldLabel !== '' ) {
673
673
fieldHtml += '<label for="' + fieldId + '">' + fieldLabel + ( required ? '<span>*</span>' : '' ) + '</label>' ;
674
674
}
675
675
// add input
0 commit comments