1function mec_rsvp_module_init($){ 2 3 if( 0 == $('.mec_rsvp_form').length ){ 4 5 return; 6 } 7 var primary_box, rsvp_id, nonce, answer_id, event_date, total_attendees, creator_email; 8 9 function mec_get_body_form_step_1(el, replace_vars = false) { 10 11 var primary_box = $(el).parents('.mec-custom-form-box'); 12 var form = $(el).parents('.mec_rsvp_form'); 13 var data = { 14 action: 'mec-rsvp-get-body-form-step1', 15 event_id: $('input[name="event_id"]').val(), 16 event_date: $(el).val(), 17 nonce: $('#_mec_nonce_s1').val(), 18 }; 19 20 $(form).css('opacity', '0.7'); 21 $('.mec-loading-1', primary_box).show(); 22 $('.mec-rsvp-step-1-box .mec-body-form', primary_box).hide(); 23 $.post( 24 mec_rsvp.ajaxurl, 25 data, 26 function (r) { 27 28 if (r.success == true) { 29 $('.mec-rsvp-step-1-box .mec-body-form', primary_box).html(r.html); 30 } else { 31 if (r.error_message_html) { 32 $('.mec-rsvp-message-box', form).html(r.error_message_html); 33 } 34 } 35 $('.mec-loading-1', primary_box).hide(); 36 $(form).css('opacity', '1'); 37 $('.mec-rsvp-step-1-box .mec-body-form', primary_box).show(); 38 39 mec_custom_form_init(); 40 41 if (true === replace_vars) { 42 43 $('h4', primary_box).html('Edit RSVP - ' + rsvp_id); 44 $('select[name="rsvp[event_date]"]', form).prop('disabled', true); 45 $('select[name="rsvp[event_date]"]', form).hide(); 46 $('[name="rsvp[attendees_count]"]', form).val(total_attendees); 47 $('[name="rsvp[email]"]', form).val(creator_email); 48 49 $('#mec-rsvp-rsvp_' + answer_id, form).trigger('click'); 50 $('#rsvp_email', form).parent().hide(); 51 52 if ($('input[name="rsvp[rsvp_id]"]', form).length > 0) { 53 54 $('input[name="rsvp[rsvp_id]"]', form).val(rsvp_id); 55 $('input[name="rsvp[rsvp_nonce]"]', form).val(nonce); 56 $('input[name="rsvp[event_date]"]', form).val(event_date); 57 } else { 58 59 $(form).append('<input type="hidden" name="rsvp[rsvp_id]" value="' + rsvp_id + '" />'); 60 $(form).append('<input type="hidden" name="rsvp[rsvp_nonce]" value="' + nonce + '" />'); 61 $(form).append('<input type="hidden" name="rsvp[event_date]" class="mec-rsvp-event-days" value="' + event_date + '" />'); 62 } 63 } 64 65 /** Init reCaptcha */ 66 var recaptcha_check = jQuery('#mec-rsvp-g-recaptcha').length; 67 if (recaptcha_check != 0) { 68 jQuery('#mec-rsvp-g-recaptcha').html(''); 69 grecaptcha.render("mec-rsvp-g-recaptcha", { 70 sitekey: mecdata.recapcha_key 71 }); 72 } 73 } 74 ); 75 } 76 77 function mec_scroll_to_rsvp_form(btn) { 78 79 var custom_form = $(btn).parents('.mec-custom-form-box'); 80 $('html, body').animate({ 81 scrollTop: $(custom_form).offset().top - 20, 82 scrollLeft: $(custom_form).offset().left - 20, 83 }); 84 } 85 86 function mec_rsvp_form_init(is_edit_form = false) { 87 88 if (is_edit_form) { 89 90 var body = $('.mec-rsvp-modification'); 91 } else { 92 93 var body = $(document); 94 } 95 96 $('.mec-rsvp-event-days', body).on('change', function () { 97 mec_get_body_form_step_1($(this)); 98 }); 99 100 $('.mec-move-to-step-2', body).on('click', function (e) { 101 var btn = $(this); 102 var primary_box = $(e.currentTarget).parents('.mec-custom-form-box'); 103 var form = $(e.currentTarget).parents('.mec_rsvp_form'); 104 var fdata = $(form).serializeArray(); 105 var data = { 106 'action': $('[name="rsvp_action"]', form).val(), 107 }; 108 109 $.each(fdata, function (i, v) { 110 data[v['name']] = v['value']; 111 }); 112 113 $('.mec-rsvp-message-box').html(); 114 $(form).css('opacity', '0.7'); 115 $(btn).addClass('loading'); 116 $.post(
117 mec_rsvp.ajaxurl, 118 data, 119 function (r) { 120 121 if (r.success == true) { 122 $('.mec-rsvp-step-2-box', primary_box).html(r.html); 123 $('.mec-rsvp-step-2-box', primary_box).removeClass('hidden'); 124 $('.mec-rsvp-step-1-box', primary_box).addClass('hidden'); 125 126 var input_email_selector = 'input[type=email][name="rsvp[attendees][0][mec_email]"]'; 127 var email = $(input_email_selector, primary_box).val(); 128 $(input_email_selector, primary_box).prop('disabled', true); 129 130 var hidden_input_selector = 'input[type=hidden][name="rsvp[attendees][0][mec_email]"]'; 131 if ($(hidden_input_selector, primary_box).length == 0) { 132 133 $(input_email_selector, primary_box).parent().append('<input type="hidden" name="rsvp[attendees][0][mec_email]" value="' + email + '">'); 134 } 135 136 if ($('[name="rsvp[first_for_all]"]', primary_box).is(':checked')) { 137 138 $('[name="rsvp[attendees][0][first_name]"]').on('change', function () { 139 140 $('input[name$="[first_name]"][name!="rsvp[attendees][0][first_name]"]', primary_box).val($(this).val()); 141 }); 142 143 $('[name="rsvp[attendees][0][last_name]"]').on('change', function () { 144 145 $('input[name$="[last_name]"][name!="rsvp[attendees][0][last_name]"]', primary_box).val($(this).val()); 146 }); 147 } 148 149 if ($('[name="rsvp[rsvp_id]"]', primary_box).length == 0 || $('[name="rsvp[first_for_all]"]', primary_box).is(':checked')) { 150 151 $('input[name$="[mec_email]"]', primary_box).val(email); 152 } 153 $('[name="rsvp[email]"]', primary_box).val(email); 154 $(hidden_input_selector, primary_box).val(email); 155 } else { 156 if (r.error_message_html) { 157 $('.mec-rsvp-message-box', form).html(r.error_message_html); 158 } 159 } 160 $(btn).removeClass('loading'); 161 $(form).css('opacity', '1'); 162 mec_custom_form_init(); 163 mec_scroll_to_rsvp_form(e.currentTarget); 164 } 165 ); 166 167 return false; 168 }); 169 } 170 171 mec_rsvp_form_init(); 172 173 function mec_custom_form_init() { 174 $('.mec-move-to-step-1').on('click', function (e) { 175 var primary_box = $(e.currentTarget).parents('.mec-custom-form-box'); 176 177 $(primary_box).find(' > div').addClass('hidden'); 178 $(primary_box).find('.mec-rsvp-step-1-box').removeClass('hidden'); 179 mec_scroll_to_rsvp_form(e.currentTarget); 180 181 /** Refresh reCaptcha */ 182 if ( typeof grecaptcha !== "undefined") { 183 grecaptcha.reset(); 184 } 185 186 return false; 187 }); 188 189 $('input , select , textarea').on('change', function () { 190 if ($(this).val().length == 0) { 191 if (true == $(this).prop('required')) { 192 193 $(this).addClass('mec-error'); 194 } 195 } else { 196 $(this).removeClass('mec-error'); 197 } 198 }); 199 200 $('.mec-custom-form-box .mec-submit').on('click', function (e) { 201 202 $('.mec_rsvp_form .mec-field-radio .input-radio-checkbox').removeClass('mec-error'); 203 204 var btn = $(this); 205 var form = $(this).parents('form').get(0); 206 var primary_box = $(e.currentTarget).parents('.mec-custom-form-box'); 207 var result_box = $('.mec-rsvp-result-box', primary_box); 208 var data = { 209 'action': $('[name="mec-action-2"]', primary_box).val(), 210 }; 211 212 var can_submit = true; 213 var fdata; 214 $.each($('.mec_rsvp_form', primary_box), function (f, form) { 215 216 fdata = $(form).serializeArray(); 217 $.each(fdata, function (i, v) { 218 data[v['name']] = v['value']; 219 220 var el = $('[name="' + v['name'] + '"]', primary_box); 221 if (true == $(el).prop('required') && true != $(el).prop('disabled')) { 222 if (v['value'].length === 0) { 223 224 $(el).addClass('mec-error'); 225 can_submit = false; 226 } 227 } 228 }); 229 }); 230 231 let i = 1; 232 $('.mec_rsvp_form .agreement-fields').each(function() { 233 if($(this).hasClass('required')){ 234 var status_first_for_all = $('input[name="rsvp[first_for_all]"]').is(":checked"); 235 if (status_first_for_all){ 236 if(i===1){ 237 var status = $(this).is(":checked"); 238 if (!status) { 239 $(this).addClass('mec-error'); 240 can_submit = false; 241 } 242 } 243 }else{ 244 var status = $(this).is(":checked"); 245 if (!status) { 246 $(this).addClass('mec-error'); 247 can_submit = false; 248 } 249 } 250 i++; 251 } 252 }); 253 254 i = 1; 255 $('.mec_rsvp_form .input-radio-checkbox').each(function() { 256 if($(this).is(':required')){ 257 var status_first_for_all = $('input[name="rsvp[first_for_all]"]').is(":checked"); 258 if (status_first_for_all){ 259 if(i===1){ 260 var name = $(this).attr("name"); 261 var checked = [...document.getElementsByName(name)].some(c=>c.checked) 262 if (!checked) { 263 $(this).addClass('mec-error'); 264 can_submit = false; 265 } 266 } 267 }else{ 268 var name = $(this).attr("name"); 269 var checked = [...document.getElementsByName(name)].some(c=>c.checked) 270 if (!checked) { 271 $(this).addClass('mec-error'); 272 can_submit = false; 273 } 274 } 275 i++; 276 } 277 }); 278 279 280 if (!can_submit) { 281 282 alert(mec_rsvp.error_form_data); 283 return false; 284 } 285 286 $(primary_box).css('opacity', '0.7'); 287 $(btn).addClass('loading'); 288 289 if ($(result_box).find('.mec-rsvp-message-box').length > 1) { 290 291 $(result_box).find('.mec-rsvp-message-box').html(); 292 } else { 293 294 $(result_box).append('<div class="mec-rsvp-message-box"></div>'); 295 } 296 297 $(btn).prop('disabled', true); 298 $.post(
299 mec_rsvp.ajaxurl, 300 data, 301 function (r) { 302 if (r.success == true) { 303 304 $(primary_box).find(' > div').addClass('hidden'); 305 $(result_box).removeClass('hidden'); 306 307 $(result_box).html(r.html); 308 } else { 309 if (r.error_message_html) { 310 $('.mec-rsvp-message-box', form).html(r.error_message_html); 311 } 312 } 313 314 $(btn).removeClass('loading'); 315 $(primary_box).css('opacity', '1'); 316 mec_scroll_to_rsvp_form(e.currentTarget); 317 $(btn).prop('disabled', false); 318 } 319 ); 320 321 return false; 322 }); 323 324 function mec_rsvp_attendees_first_for_all(el) { 325 var form = $(el).parents('.mec_rsvp_form'); 326 if (form.length > 1) { 327 form = form[0]; 328 } 329 if ($(el).is(':checked')) { 330 $('.mec-attendees-detail-inputs', form).addClass('hidden'); 331 } else { 332 $('.mec-attendees-detail-inputs', form).removeClass('hidden'); 333 } 334 } 335 336 $('.mec_rsvp_first_for_all').on('change', function (e) { 337 mec_rsvp_attendees_first_for_all(this); 338 }); 339 $('.rsvp-first-for-all-label').on('click', function (e) { 340 console.log('webnus') 341 var form = $(this).parents('.mec_rsvp_form'); 342 var input = $(this).parents('.mec-fill-attendees').find(".mec_rsvp_first_for_all"); 343 console.log(input) 344 console.log(form) 345 if (form.length > 1) { 346 form = form[0]; 347 } 348 if (!input.is(":checked")) { 349 input.prop("checked", true); 350 $('.mec-attendees-detail-inputs', form).addClass('hidden'); 351 } 352 else { 353 input.prop("checked", false); 354 $('.mec-attendees-detail-inputs', form).removeClass('hidden'); 355 } 356 //mec_rsvp_attendees_first_for_all(this); 357 }); 358 359 $.each($('.mec_rsvp_first_for_all'), function (i, v) { 360 mec_rsvp_attendees_first_for_all(v); 361 }); 362 363 function mec_load_more_attendees_init() { 364 365 $('.mec-load-attendees').on('click', function (e) { 366 367 var btn = $(this); 368 var form = $(this).parents('form').get(0); 369 var primary_box = $(e.currentTarget).parents('.mec-custom-form-box'); 370 var result_box = $('.mec-rsvp-result-box', primary_box); 371 372 var data = { 373 action: "mec-get-more-attendees", 374 event_id: $(this).data('event_id'), 375 answer: $(this).data('answer'), 376 event_date: $(this).data('event_date'), 377 offset: $(this).data('offset'), 378 }; 379 380 $(primary_box).css('opacity', '0.7'); 381 $(btn).addClass('mec-load-more-loading'); 382 383 $.post( 384 mec_rsvp.ajaxurl, 385 data, 386 function (r) { 387 388 var tab = $('#mec-rsvp-answer-rsvp_' + data.answer + '-details'); 389 var new_attendees = $(r).filter('.mec-attendees').html(); 390 if ('undefined' !== typeof new_attendees) { 391 392 $('.mec-attendees', tab).append(new_attendees); 393 } 394 395 var load_more = $(r).filter('.mec-load-more-wrap').html(); 396 if ('undefined' !== typeof load_more) { 397 398 $('.mec-load-more-wrap', tab).html(load_more); 399 mec_load_more_attendees_init(); 400 } else { 401 402 $('.mec-load-more-wrap', tab).remove(); 403 } 404 405 $(btn).removeClass('mec-load-more-loading'); 406 $(primary_box).css('opacity', '1'); 407 } 408 ); 409 410 return false; 411 }); 412 } 413 414 mec_load_more_attendees_init(); 415 416 $('.mec-rsvp-answers-details-links input').on('change', function (e) { 417 418 $(e.currentTarget).parents('.mec-rsvp-answers-details-links').find('div').removeClass('active'); 419 $(e.currentTarget).parents('.mec-rsvp-answer').find('.mec-rsvp-answers-details-tabs div').removeClass('active'); 420 if ($(e.currentTarget).is(':checked')) { 421 422 $(e.currentTarget).parents('div').addClass('active'); 423 var target_id = $(e.currentTarget).data('target-id'); 424 $(e.currentTarget).parents('.mec-rsvp-answer').find('.mec-rsvp-answers-details-tabs #' + target_id).addClass('active'); 425 } 426 return true; 427 }); 428 } 429 430 mec_get_body_form_step_1($('.mec-rsvp-event-days')); 431 mec_custom_form_init(); 432 433 /** RSVP edit form start */ 434 $('.mec-show-rsvp-modification').on('click', function (e) { 435 436 $(this).hide(); 437 $(this).parent().find('.mec-rsvp-search-form').toggle(); 438 });
439 440 $("#mec-rsvp-search-by-email").on('click', function () { 441 442 var primary_box = $(this).parents('.mec-rsvp-modification'); 443 var form = $(this).parents('.mec-rsvp-search-form'); 444 var data = { 445 action: $('[name="action"]').val(), 446 event_id: $('[name="event_id"]').val(), 447 email: $('[name="mec-rsvp-search-form[email]"]').val(), 448 nonce: $('#mec-rsvp-search-form-nonce').val(), 449 verification_code: $('input[name="mec-rsvp-verification-code"]').val(), 450 }; 451 452 $('.mec-loading-1', form).show(); 453 $('.mec-rsvps', primary_box).show(); 454 $.post( 455 mec_rsvp.ajaxurl, 456 data, 457 function (r) { 458 459 $('.mec-loading-1', form).hide(); 460 if (r.success == true) { 461 $('.mec-rsvps', primary_box).html(r.html); 462 } else if ('need_verification' == r.success) { 463 $('.mec-email-confirmation', form).removeClass('hidden'); 464 465 return; 466 } else { 467 if (r.error_message_html) { 468 $('.mec-rsvp-message-box', primary_box).html(r.error_message_html); 469 470 return; 471 } 472 } 473 $('.mec-loading-1', form).hide(); 474 $('.mec-rsvps', primary_box).show(); 475 $(form).hide(); 476 477 mec_rsvp_form_init(true); 478 mec_edit_rsvp_init(); 479 } 480 ); 481 }); 482 483 function mec_edit_rsvp_init() { 484 485 $(".mec-edit-rsvp").on('click', function (e) { 486 487 var primary_box = $(this).parents('.mec-rsvp-modification'); 488 rsvp_id = $(this).data('rsvp_id'); 489 nonce = $(this).data('nonce'); 490 answer_id = $(this).data('answer_id'); 491 event_date = $(this).data('event_date'); 492 total_attendees = $(this).data('total_attendees'); 493 creator_email = $(this).data('creator_email'); 494 495 var data = { 496 action: 'mec-get-rsvp-form-for-edit', 497 event_id: $('[name="event_id"]').val(), 498 }; 499 500 $('.mec-loading-1', primary_box).show(); 501 $('.mec-edit-form-rsvp', primary_box).hide(); 502 $('.mec-rsvps', primary_box).hide(); 503 $.post( 504 mec_rsvp.ajaxurl, 505 data, 506 function (r) { 507 508 if (r.success == true) { 509 $('.mec-edit-form-rsvp', primary_box).html(r.html); 510 mec_get_body_form_step_1($('.mec-edit-form-rsvp .mec-rsvp-event-days ', primary_box), true); 511 512 var form = $(primary_box).find('.mec-rsvp-step-1-box .mec_rsvp_form'); 513 514 } else { 515 if (r.error_message_html) { 516 $('.mec-rsvp-message-box', primary_box).html(r.error_message_html); 517 } 518 } 519 $('.mec-loading-1', primary_box).hide(); 520 $('.mec-edit-form-rsvp', primary_box).show(); 521 $('.mec-rsvps').hide(); 522 523 mec_rsvp_form_init(true); 524 } 525 ); 526 527 return false; 528 }); 529 } 530 /** RSVP edit form end */ 531} 532 533jQuery(document).ready(function ($) { 534 mec_rsvp_module_init($); 535});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.