1window.jQuery(document).ready(function () { 2 var $ = window.jQuery; 3 4 function isValidEmail(email) { 5 return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email); 6 } 7 8 $('.cupo-user_profile-address-edit_button').on('click', function (e) { 9 e.preventDefault(); 10 e.stopPropagation(); 11 12 $('.user_profile-address-edit .cupo-modal-loader').hide(); 13 $('.cupo-modal-user_profile-address-edit .cupo-modal-success-message').hide(); 14 $('.cupo-modal-user_profile-address-edit .cupo-modal-error-message').hide(); 15 $('.cupo-modal-user_profile-address-edit .cupo-popup-heading').html('Adresse bearbeiten'); 16 $('.cupo-modal-user_profile-address-edit .cupo-modal-success-message > span').html('Ihre Adresse wurde erfolgreich geändert.'); 17 $('.cupo-modal-user_profile-address-edit').addClass('active'); 18 }); 19 20 $('.cupo-user_profile-address-add_button').on('click', function (e) { 21 e.preventDefault(); 22 e.stopPropagation(); 23 24 $('.user_profile-address-edit .cupo-modal-loader').hide(); 25 $('.cupo-modal-user_profile-address-edit .cupo-modal-success-message').hide(); 26 $('.cupo-modal-user_profile-address-edit .cupo-modal-error-message').hide(); 27 $('.cupo-modal-user_profile-address-edit .cupo-popup-heading').html('Adresse hinzufügen'); 28 $('.cupo-modal-user_profile-address-edit .cupo-modal-success-message > span').html('Ihre Adresse wurde erfolgreich hinzugefügt.'); 29 $('.cupo-modal-user_profile-address-edit').addClass('active'); 30 }); 31 32 $('.cupo-user_profile-payment-edit_button, .kupo-payment-detail .kupo-profile-box-content-add, .kupo-payment-detail .kupo-header-add, .kupo-payment-detail .kupo-header-edit').on('click', function (e) { 33 e.preventDefault(); 34 e.stopPropagation(); 35 36 $('.cupo-modal-user_profile-edit_payment .cupo-modal-loader').hide(); 37 $('.cupo-modal-user_profile-edit_payment .cupo-modal-success-message').hide(); 38 $('.cupo-modal-user_profile-edit_payment .cupo-modal-error-message').hide(); 39 $('.cupo-modal-user_profile-edit_payment').addClass('active'); 40 }); 41 42 $('.cupo-edit-payment-cancel_button').on('click', function (e) { 43 e.preventDefault(); 44 e.stopPropagation(); 45 46 $('.cupo-modal-user_profile-edit_payment').removeClass('active').addClass('inactive'); 47 }); 48 49 $('.cupo-edit_account-holder_info_button').on('click', function (e) { 50 e.preventDefault(); 51 e.stopPropagation(); 52 53 $('.cupo-modal-user_profile-account_holder_info').addClass('active'); 54 }); 55 56 $('.cupo-user_profile-actions-delete_address_button').on('click', function (e) { 57 e.preventDefault(); 58 e.stopPropagation(); 59 60 $('.cupo-modal-user_profile-delete-address').addClass('active'); 61 }); 62 63 $('.cupo-user_profile-actions-delete_account_button').on('click', function(e) { 64 e.preventDefault(); 65 e.stopPropagation(); 66 67 $('.cupo-modal-user_profile-delete-account').addClass('active'); 68 }); 69 70 $('.cupo-user_profile-personal_data-edit_button').on('click', function (e) { 71 e.preventDefault(); 72 e.stopPropagation(); 73 74 $('.cupo-modal-user_profile-personal_data-edit').addClass('active'); 75 }); 76 77 $('.cupo-modal-user_profile-personal_data-edit .cupo-modal-close').on('click', function (e) { 78 e.preventDefault(); 79 80 $('.cupo-modal-user_profile-personal_data-edit').trigger('reset'); 81 $('.cupo-modal.cupo-modal-user_profile-personal_data-edit').removeClass('active'); 82 }); 83 84 $('.cupo-user_profile-actions-edit_password_button').on('click', function (e) { 85 e.preventDefault(); 86 e.stopPropagation(); 87 88 $('.cupo-modal-user_profile-edit_password .cupo-modal-loader').hide(); 89 $('.cupo-modal-user_profile-edit_password .cupo-modal-success-message').hide(); 90 $('.cupo-modal-user_profile-edit_password .cupo-modal-error-message').hide(); 91 $('.cupo-modal-user_profile-edit_password .cupo_icon_red').show(); 92 $('.cupo-modal-user_profile-edit_password .cupo_icon_green').hide(); 93 94 $('.cupo-edit_password-visible_password_button').hide() 95 .closest('.cupo-edit_password-form_control') 96 .find('.cupo-edit_password-hidden_password_button').show() 97 .end() 98 .find('.cupo-edit_password-password_input').val('').prop('type', 'password'); 99 100 $('.cupo-modal-user_profile-edit_password').addClass('active'); 101 }); 102 103 $('.cupo-user_profile-edit_password_form input[data-equal-id]').bind('input', function () { 104 var toConfirm = $(this); 105 var toEqual = $('#' + toConfirm.data('equalId')); 106 107 if (toConfirm.val() === toEqual.val()) { 108 this.setCustomValidity(''); 109 return; 110 } 111 112 this.setCustomValidity('Die beiden Passwörter müssen übereinstimmen.'); 113 }); 114 115 $('.cupo-edit_password-visible_password_button').on('click', function () { 116 $(this).hide() 117 .closest('.cupo-edit_password-form_control') 118 .find('.cupo-edit_password-hidden_password_button').show() 119 .end() 120 .find('.cupo-edit_password-password_input').prop('type', 'password'); 121 }); 122 123 $('.cupo-edit_password-hidden_password_button').on('click', function () { 124 $(this).hide() 125 .closest('.cupo-edit_password-form_control') 126 .find('.cupo-edit_password-visible_password_button').show() 127 .end() 128 .find('.cupo-edit_password-password_input').prop('type', 'text'); 129 }); 130 131 $('#cupo-edit_password-new-password, #cupo-edit_password-repeat-password').bind('input', function () { 132 if ($('#cupo-edit_password-old-password').val() === $(this).val()) { 133 this.setCustomValidity('Das neue Passwort darf nicht einem Ihrer vergangenen Passwörter entsprechen.'); 134 return; 135 } 136 137 if (!/^(?=.*[0-9])(?=.*[A-ZÃÃÃ])(?=.*[a-zöäüÃ])(?=.*[?!$%&\/=*+~,.;:<>\-_])[a-zA-Z0-9äöüÃÃÃÃ?!$%&\/=*+~,.;:<>\-_]{8,}$/.test($(this).val())) { 138 this.setCustomValidity('Das Passwort muss der Passwortrichtlinie entsprechen.'); 139 return; 140 } 141 142 this.setCustomValidity(''); 143 }); 144 145 $('#cupo-edit_password-new-password').on('keyup', function () { 146 $('#cupo-edit_password-repeat-password').trigger('input'); 147 }); 148 149 $('#cupo-edit_password-new-password').on('input', function() { 150 var password = $(this).val(); 151 152 if (/[A-Z]+/.test(password)) { 153 $('.password-rule-uppercase_chars .cupo_icon_green').show(); 154 $('.password-rule-uppercase_chars .cupo_icon_red').hide(); 155 } else { 156 $('.password-rule-uppercase_chars .cupo_icon_red').show(); 157 $('.password-rule-uppercase_chars .cupo_icon_green').hide(); 158 } 159 160 if (/[a-z]+/.test(password)) { 161 $('.password-rule-lowercase_chars .cupo_icon_green').show(); 162 $('.password-rule-lowercase_chars .cupo_icon_red').hide(); 163 } else { 164 $('.password-rule-lowercase_chars .cupo_icon_red').show(); 165 $('.password-rule-lowercase_chars .cupo_icon_green').hide(); 166 } 167 168 if (/[0-9]+/.test(password)) { 169 $('.password-rule-numbers .cupo_icon_green').show(); 170 $('.password-rule-numbers .cupo_icon_red').hide(); 171 } else { 172 $('.password-rule-numbers .cupo_icon_red').show(); 173 $('.password-rule-numbers .cupo_icon_green').hide(); 174 } 175 176 if (/[?!$%&\/=*+~,.;:<>\-_]+/.test(password)) { 177 $('.password-rule-special_chars .cupo_icon_green').show(); 178 $('.password-rule-special_chars .cupo_icon_red').hide(); 179 } else { 180 $('.password-rule-special_chars .cupo_icon_red').show(); 181 $('.password-rule-special_chars .cupo_icon_green').hide(); 182 } 183 184 if (password.length >= 8) { 185 $('.password-rule-min_length .cupo_icon_green').show(); 186 $('.password-rule-min_length .cupo_icon_red').hide(); 187 } else { 188 $('.password-rule-min_length .cupo_icon_red').show(); 189 $('.password-rule-min_length .cupo_icon_green').hide(); 190 } 191 }); 192 193 $('form.cupo-user_profile-edit_address_form').on('submit', function (e) { 194 e.preventDefault(); 195 e.stopPropagation(); 196 197 var street = $('#cupo-edit_address-form_control_street').val(); 198 var zipCode = $('#cupo-edit_address-form_control_zipCode').val(); 199 var city = $('#cupo_personal_setting_form_city').val(); 200 var countryId = $('#cupo-edit_address-form_control_country_name').val(); 201 202 if ( 203 typeof street !== 'string' || street.trim().length === 0 204 || typeof zipCode !== 'string' || zipCode.trim().length === 0 205 || typeof city !== 'string' || city.trim().length === 0 206 || typeof countryId !== 'string' || countryId.trim().length === 0 207 ) { 208 return; 209 } 210 211 $('.cupo-modal-user_profile-address-edit .cupo-modal-loader').css('display', 'flex'); 212 213 $.ajax({ 214 type: 'POST', 215 url: cupo_user_profile_script.ajax_url, 216 data: { 217 'action': 'cupoAddressEdit', 218 'data': { 219 street: street, 220 zip_code: zipCode, 221 city: city, 222 country_id: countryId 223 } 224 }, 225 success: function (data) { 226 data = typeof data === 'string' ? JSON.parse(data) : data; 227 228 $('.cupo-modal-user_profile-address-edit .cupo-modal-loader').hide(); 229 230 if (data && data.status === 'success') { 231 $('.cupo-modal-user_profile-address-edit .cupo-modal-success-message').css('display', 'flex'); 232 } else { 233 $('.cupo-modal-user_profile-address-edit .cupo-modal-error-message').css('display', 'flex'); 234 } 235 }, 236 error: function () { 237 $('.cupo-modal-user_profile-address-edit .cupo-modal-loader').hide(); 238 $('.cupo-modal-user_profile-address-edit .cupo-modal-error-message').css('display', 'flex'); 239 } 240 }); 241 }); 242 243 $('form.cupo-user_profile-edit_password_form').on('submit', function (e) { 244 e.preventDefault(); 245 e.stopPropagation(); 246 247 var currentPassword = $('#cupo-edit_password-old-password').val(); 248 var newPassword = $('#cupo-edit_password-new-password').val(); 249 var repeatPassword = $('#cupo-edit_password-repeat-password').val(); 250 251 if ( 252 typeof currentPassword !== 'string' || currentPassword.trim().length === 0 253 || typeof newPassword !== 'string' || newPassword.trim().length === 0 254 || typeof repeatPassword !== 'string' || repeatPassword.trim().length === 0 255 ) { 256 return; 257 } 258 259 $('.cupo-modal-user_profile-edit_password .cupo-modal-loader').css('display', 'flex'); 260 261 $.ajax({ 262 type: 'POST', 263 url: cupo_user_profile_script.ajax_url, 264 data: { 265 'action': 'cupoChangePassword', 266 'data': { 267 current_password: currentPassword, 268 new_password: newPassword, 269 repeat_password: repeatPassword 270 } 271 }, 272 success: function (data) { 273 data = typeof data === 'string' ? JSON.parse(data) : data; 274 275 $('.cupo-modal-user_profile-edit_password .cupo-modal-loader').hide(); 276 277 if (data && data.status === 'success') { 278 $('.cupo-modal-user_profile-edit_password .cupo-modal-success-message').css('display', 'flex'); 279 } else { 280 $('.cupo-modal-user_profile-edit_password .cupo-modal-error-message').css('display', 'flex'); 281 } 282 }, 283 error: function () { 284 $('.cupo-modal-user_profile-edit_password .cupo-modal-loader').hide(); 285 $('.cupo-modal-user_profile-edit_password .cupo-modal-error-message').css('display', 'flex'); 286 } 287 }); 288 }); 289 290 $('form.cupo-user_profile-edit_payment_form').on('submit', function (e) { 291 e.preventDefault(); 292 e.stopPropagation(); 293 294 var iban = $('#cupo-edit_payment-form_control_iban').val(); 295 var bic = $('#cupo-edit_payment-form_control_bic').val(); 296 var holder = $('#cupo-edit_payment-form_control_holder').val(); 297 298 if ( 299 typeof iban !== 'string' || iban.trim().length === 0 300 || typeof bic !== 'string' || bic.trim().length === 0 301 || typeof holder !== 'string' || holder.trim().length === 0 302 ) { 303 return; 304 } 305 306 $('.cupo-modal-user_profile-edit_payment .cupo-modal-loader').css('display', 'flex'); 307 308 $.ajax({ 309 type: 'POST', 310 url: cupo_user_profile_script.ajax_url, 311 data: { 312 'action': 'cupoEditPaymentData', 313 'data': {iban, bic, holder} 314 }, 315 success: function (data) { 316 data = typeof data === 'string' ? JSON.parse(data) : data; 317 318 $('.cupo-modal-user_profile-edit_payment .cupo-modal-loader').hide(); 319 320 if (data && data.status === 'success') { 321 $('.cupo-modal-user_profile-edit_payment .cupo-modal-success-message').css('display', 'flex'); 322 } else { 323 $('.cupo-modal-user_profile-edit_payment .cupo-modal-error-message').css('display', 'flex'); 324 } 325 }, 326 error: function () { 327 $('.cupo-modal-user_profile-edit_payment .cupo-modal-loader').hide(); 328 $('.cupo-modal-user_profile-edit_payment .cupo-modal-error-message').css('display', 'flex'); 329 } 330 }); 331 }); 332 333 $('.kupo-profile-contact-edit_button').on('click', function (e) { 334 e.preventDefault(); 335 e.stopPropagation(); 336 337 var modal = '.cupo-modal-user_profile-edit_contact.edit-contact-' + $(this).data('value'); 338 339 $(modal).find('.cupo-modal-loader').hide(); 340 $(modal).find('.cupo-modal-success-message > span').html('Die Kontaktdaten wurden erfolgreich geändert.'); 341 $(modal).find('.cupo-modal-success-message').hide(); 342 $(modal).find('.cupo-modal-error-message > span').html('Es ist ein technischer Fehler aufgetreten. Bitte versuchen Sie es später erneut.'); 343 $(modal).find('.cupo-modal-error-message').hide(); 344 $(modal).find('.cupo-popup-heading').html('Kontakt ändern'); 345 $(modal).addClass('active'); 346 }); 347 348 function openEditAccountMailModal(e) { 349 var modal = $('.cupo-modal-user_profile-edit_account_mail'); 350 var passwordInput = modal.find('#cupo-edit_account_mail-password'); 351 352 $('form.cupo-edit_account_mail-form').trigger('reset'); 353 $(passwordInput).prop('type', 'password'); 354 $(modal).find('.cupo-modal-input-error-message').remove(); 355 356 $(modal).find('.cupo_icon.cupo-edit_account_mail-visible_password_button').on('click', function() { 357 $(passwordInput).prop('type', 'password'); 358 $(this).hide(); 359 $(modal).find('.cupo_icon.cupo-edit_account_mail-hidden_password_button').show(); 360 }); 361 362 $(modal).find('.cupo_icon.cupo-edit_account_mail-hidden_password_button').on('click', function() { 363 $(passwordInput).prop('type', 'text'); 364 $(modal).find('.cupo_icon.cupo-edit_account_mail-visible_password_button').show(); 365 $(this).hide(); 366 }); 367 368 $(modal).addClass('active'); 369 } 370 371 $('.kupo-user_profile-actions-button.kupo-user_profile-actions-edit_email_button').on('click', function(e) { 372 openEditAccountMailModal(e); 373 }); 374 375 function confirmEditAccountMailModal(e) { 376 e.preventDefault(); 377 e.stopPropagation(); 378 379 var modal = $(e.target).closest('.cupo-modal-user_profile-edit_account_mail'); 380 var modalLoader = modal.find('.cupo-modal-loader'); 381 var successMessage = modal.find('.cupo-modal-success-message'); 382 var errorMessage = modal.find('.cupo-modal-error-message'); 383 var mailInput = modal.find('#cupo-edit_account_mail-mail'); 384 var confirmMailInput = modal.find('#cupo-edit_account_mail-confirm-mail'); 385 var passwordInput = modal.find('#cupo-edit_account_mail-password'); 386 var currentEmailAddress = $('.kupo-user-mail'); 387 388 var showEditAccountMailValidationMessage = function (inputElement, message) { 389 modal.find('.cupo-modal-input-error-message').remove(); 390 inputElement.closest('.cupo-input-wrapper').prepend('<span class="cupo-modal-input-error-message">' + message + '</span>'); 391 } 392 393 if (typeof mailInput.val() !== 'string' || mailInput.val().trim().length === 0 || !isValidEmail(mailInput.val())) { 394 showEditAccountMailValidationMessage(mailInput, 'Bitte geben Sie eine gültige E-Mail-Adresse ein.'); 395 return; 396 } 397 398 if (typeof confirmMailInput.val() !== 'string' || confirmMailInput.val().trim().length === 0 || !isValidEmail(mailInput.val())) { 399 showEditAccountMailValidationMessage(confirmMailInput, 'Bitte geben Sie eine gültige E-Mail-Adresse ein.'); 400 return; 401 } 402 403 if (confirmMailInput.val() !== mailInput.val()) { 404 showEditAccountMailValidationMessage(confirmMailInput, 'Die E-Mail-Adressen müssen übereinstimmen.'); 405 return; 406 } 407 408 if (currentEmailAddress.text() === mailInput.val()) { 409 showEditAccountMailValidationMessage(mailInput, 'Diese E-Mail-Adresse wird bereits für den Log-In verwendet.'); 410 return; 411 } 412 413 if ( 414 typeof passwordInput.val() !== 'string' 415 || passwordInput.val().trim().length === 0 416 || !/^(?=.*[0-9])(?=.*[A-ZÃÃÃ])(?=.*[a-zöäüÃ])(?=.*[?!$%&\/=*+~,.;:<>\-_])[a-zA-Z0-9äöüÃÃÃÃ?!$%&\/=*+~,.;:<>\-_]{8,}$/.test(passwordInput.val()) 417 ) { 418 showEditAccountMailValidationMessage(passwordInput, 'Bitte geben Sie ein gültiges Passwort ein!'); 419 return; 420 } 421 422 $(modal).find('.cupo-modal-input-error-message').remove(); 423 modalLoader.css('display', 'flex'); 424 425 $.ajax({ 426 type: 'POST', 427 url: cupo_user_profile_script.ajax_url, 428 data: { 429 action: 'cupoLoginEmailEdit', 430 data: { 431 email: mailInput.val(), 432 confirm_email: confirmMailInput.val(), 433 password: passwordInput.val() 434 } 435 }, 436 success: function (data) { 437 modalLoader.hide(); 438 439 var parsedData = typeof data === 'string' ? JSON.parse(data) : data; 440 441 if (parsedData && parsedData.status === 'success') { 442 successMessage.css('displ
442ay', 'flex'); 443 } else { 444 errorMessage.css('display', 'flex'); 445 } 446 }, 447 error: function () { 448 modalLoader.hide(); 449 errorMessage.css('display', 'flex'); 450 } 451 }); 452 } 453 454 $('.cupo-modal-user_profile-edit_account_mail .cupo-modal-confirm_button').on('click', function (e) { 455 confirmEditAccountMailModal(e); 456 }); 457 458 function confirmContactModal(e, modalClassName) { 459 e.preventDefault(); 460 e.stopPropagation(); 461 462 var modal = $(e.target).closest(modalClassName); 463 var modalLoader = modal.find('.cupo-modal-loader'); 464 var successMessage = modal.find('.cupo-modal-success-message'); 465 var errorMessage = modal.find('.cupo-modal-error-message'); 466 467 var contactIdInput = modal.find('input[name="id"]'); 468 var contactTypeInput = modal.find('input[name="contact_type"], select[name="contact_type"]'); 469 var emailInput = modal.find('input[name="email"]'); 470 var prefixSelect = modal.find('select[name="prefix"]'); 471 var numberInput = modal.find('input[name="number"]'); 472 var contactType = contactTypeInput.val(); 473 474 var showEditContactValidationMessage = function (inputElement, message) { 475 modal.find('.cupo-modal-input-error-message').remove(); 476 inputElement.closest('.cupo-input-wrapper').append('<span class="cupo-modal-input-error-message">' + message + '</span>'); 477 } 478 479 var showEditContactErrorMessage = function (message) { 480 errorMessage.find('span').html(message); 481 errorMessage.css('display', 'flex'); 482 }; 483 484 if (!contactType) { 485 showEditContactErrorMessage('Bitte wählen Sie eine Kontaktart!'); 486 return; 487 } 488 489 var businessMatch = /B$/; 490 var payload = { 491 category: businessMatch.test(contactType) ? 'business' : 'private', 492 contactType: contactType.replace(businessMatch, ''), 493 }; 494 495 if (contactIdInput && contactIdInput.length > 0) { 496 payload['id'] = contactIdInput.val(); 497 } 498 499 // ensure tailing B is gone 500 contactType = payload.contactType; 501 502 switch (contactType) { 503 case '1': 504 var email = emailInput.val().trim(); 505 506 if (!email || !isValidEmail(email)) { 507 showEditContactValidationMessage(emailInput, 'Bitte geben Sie eine gültige E-Mail-Adresse ein!'); 508 return; 509 } 510 511 payload['email'] = email; 512 break; 513 514 case '3': 515 case '5': 516 case '6': 517 var prefix = prefixSelect.val().trim(); 518 var phoneNumber = numberInput.val().trim(); 519 520 if (!prefix) { 521 showEditContactValidationMessage(prefixSelect, 'Bitte geben Sie die Ländervorwahl ein!'); 522 return; 523 } 524 525 if (!phoneNumber) { 526 showEditContactValidationMessage(numberInput, 'Bitte geben Sie die Nummer ein!'); 527 return; 528 } else if (!/^\d[\d\s-]*$/.test(phoneNumber)) { 529 showEditContactValidationMessage(numberInput, 'Ungültige Nummer.'); 530 return; 531 } 532 533 payload['prefix'] = prefix; 534 payload['number'] = phoneNumber; 535 break; 536 } 537 538 modalLoader.css('display', 'flex'); 539 540 $.ajax({ 541 type: 'POST', 542 url: cupo_user_profile_script.ajax_url, 543 data: { action: 'cupoAddOrEditContact', data: payload }, 544 success: function (data) { 545 modalLoader.hide(); 546 547 var parsedData = typeof data === 'string' ? JSON.parse(data) : data; 548 549 if (parsedData && parsedData.status === 'success') { 550 successMessage.css('display', 'flex'); 551 } else { 552 errorMessage.css('display', 'flex'); 553 } 554 }, 555 error: function () { 556 modalLoader.hide(); 557 errorMessage.css('display', 'flex'); 558 } 559 }); 560 } 561 562 $('.cupo-user_profile-edit_contact_form .cupo-modal-confirm_button').on('click', function (e) { 563 confirmContactModal(e, '.cupo-modal-user_profile-edit_contact'); 564 }); 565 566 $('.cupo-user_profile-add_contact_form .cupo-modal-confirm_button').on('click', function (e) { 567 confirmContactModal(e, '.cupo-modal-user_profile-add_contact'); 568 }); 569 570 $('.kupo-profile-contact-delete_button').on('click', function (e) { 571 e.preventDefault(); 572 e.stopPropagation(); 573 574 var modal = '.cupo-modal-user_profile-delete_contact.delete-contact-' + $(this).data('value'); 575 576 $(modal).find('.cupo-modal-loader').hide(); 577 $(modal).find('.cupo-modal-success-message > span').html('Ihr Kontakt wurde erfolgreich gelöscht.'); 578 $(modal).find('.cupo-modal-success-message').hide(); 579 $(modal).find('.cupo-modal-error-message > span').html('Es ist ein technischer Fehler aufgetreten. Bitte versuchen Sie es später erneut.'); 580 $(modal).find('.cupo-modal-error-message').hide(); 581 $(modal).find('.cupo-popup-heading').html('Kontakt löschen'); 582 $(modal).addClass('active'); 583 }); 584 585 $('.cupo-user_profile-delete_contact_form .cupo-modal-confirm_button').on('click', function (e) { 586 e.preventDefault(); 587 e.stopPropagation(); 588 589 var modal = $(this).closest('.cupo-modal-user_profile-delete_contact'); 590 var modalLoader = modal.find('.cupo-modal-loader'); 591 var successMessage = modal.find('.cupo-modal-success-message'); 592 var errorMessage = modal.find('.cupo-modal-error-message'); 593 var contactID = modal.find('#cupo-delete_contact').val(); 594 595 if (typeof contactID !== 'string' || contactID.trim().length === 0) { 596 errorMessage.css('display', 'flex'); 597 return; 598 } 599 600 modalLoader.css('display', 'flex'); 601 602 $.ajax({ 603 type: 'POST', 604 url: cupo_user_profile_script.ajax_url, 605 data: { 606 action: 'cupoDeleteContact', 607 data: { contactId: contactID } 608 }, 609 success: function (data) { 610 modalLoader.hide(); 611 612 var parsedData = typeof data === 'string' ? JSON.parse(data) : data; 613 614 if (parsedData && parsedData.status === 'success') { 615 successMessage.css('display', 'flex'); 616 } else { 617 errorMessage.css('display', 'flex'); 618 } 619 }, 620 error: function () { 621 modalLoader.hide(); 622 errorMessage.css('display', 'flex'); 623 } 624 }); 625 }); 626 627 $('.cupo-user_profile-contact-add_button').on('click', function (e) { 628 e.preventDefault(); 629 e.stopPropagation(); 630 631 var modal = '.cupo-modal-user_profile-add_contact'; 632 633 toggleAddContactForm(); 634 635 $(modal).find('.cupo-modal-loader').hide(); 636 $(modal).find('.cupo-modal-success-message > span').html('Ihr Kontakt wurde erfolgreich hinzugefügt.'); 637 $(modal).find('.cupo-modal-success-message').hide(); 638 $(modal).find('.cupo-modal-error-message > span').html('Es ist ein technischer Fehler aufgetreten. Bitte versuchen Sie es später erneut.'); 639 $(modal).find('.cupo-modal-error-message').hide(); 640 $(modal).find('.cupo-popup-heading').html('Kontakt hinzufügen'); 641 $(modal).addClass('active'); 642 }); 643 644 function toggleAddContactForm() { 645 if ($('#kupo-add_contact_form-contact_type').length === 0) { 646 return; 647 } 648 649 var modal = $('.cupo-modal-user_profile-add_contact'); 650 var formEmail = modal.find('.cupo_row_add_contact_form_email'); 651 var formPhone = modal.find('.cupo_row_add_contact_form_phone'); 652 var contactType = $('#kupo-add_contact_form-contact_type').val().trim(); 653 654 formEmail.hide(); 655 formPhone.hide(); 656 657 if (contactType === '1') { 658 formEmail.css('display', 'flex'); 659 } else if ( 660 contactType === '3' 661 || contactType === '5' 662 || contactType === '6' 663 || contactType === '3B' 664 || contactType === '5B' 665 || contactType === '6B' 666 ) { 667 formPhone.css('display', 'flex'); 668 } 669 } 670 671 $('#kupo-add_contact_form-contact_type').on('change', function (e) { 672 e.preventDefault(); 673 e.stopPropagation(); 674 toggleAddContactForm(); 675 }); 676 677 toggleAddContactForm(); 678});
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.