|
25 | 25 | */
|
26 | 26 | imcger.imgUpload = {};
|
27 | 27 |
|
| 28 | + /** |
| 29 | + * Remove new click event in 3.3.12 |
| 30 | + * It doesn't work with imgUpload, |
| 31 | + * the event function is built into imgUpload own event. |
| 32 | + */ |
| 33 | + $('[data-prevent-flood] input[type=submit]').off('click'); |
| 34 | + |
28 | 35 | /**
|
29 | 36 | * Update row with new attachment id
|
30 | 37 | * when save image after rotate
|
|
449 | 456 | * and rotated images have not been saved
|
450 | 457 | */
|
451 | 458 | $('.submit-buttons').on('click', '.button1', function(e) {
|
452 |
| - imcger.imgUpload.submitType = $(e.target).attr('name'); |
| 459 | + imcger.imgUpload.submitButton = $(this); // Store the button element |
| 460 | + |
453 | 461 | let attach_id = 0,
|
454 | 462 | imgHTMLList = '<ul>';
|
455 | 463 |
|
| 464 | + // Always add the disabled class for visual feedback |
| 465 | + imcger.imgUpload.submitButton.addClass('disabled'); |
| 466 | + |
456 | 467 | // Are all images saved?
|
457 | 468 | $.each(imcger.imgUpload.image.imgOrientationValue, function(index, value) {
|
458 | 469 |
|
|
470 | 481 |
|
471 | 482 | e.preventDefault();
|
472 | 483 | phpbb.confirm(confirmMsgText, imcger.imgUpload.confirmSavePost, true);
|
| 484 | + |
| 485 | + // Re-enable when the confirmbox is closed by clicking on the wrapper |
| 486 | + $('#darken').on('click', function(e) {imcger.imgUpload.submitButton.removeClass('disabled');}); |
| 487 | + |
| 488 | + } else { |
| 489 | + const $form = imcger.imgUpload.submitButton.closest('form'); |
| 490 | + |
| 491 | + // Submit form if it hasn't been submitted yet |
| 492 | + if (!$form.prop('data-form-submitted')) { |
| 493 | + $form.prop('data-form-submitted', true); |
| 494 | + |
| 495 | + return; |
| 496 | + } |
| 497 | + |
| 498 | + // Prevent default submission for subsequent clicks within 5 seconds |
| 499 | + e.preventDefault(); |
| 500 | + |
| 501 | + setTimeout(() => { |
| 502 | + $form.prop('removeProp', 'data-form-submitted'); |
| 503 | + imcger.imgUpload.submitButton.removeClass('disabled'); // Re-enable after 5 seconds |
| 504 | + }, 5000); |
473 | 505 | }
|
474 | 506 | });
|
475 | 507 |
|
|
488 | 520 | }
|
489 | 521 |
|
490 | 522 | $('.submit-buttons').off('click', '.button1');
|
491 |
| - $('.submit-buttons [name="' + imcger.imgUpload.submitType + '"').trigger('click'); |
| 523 | + imcger.imgUpload.submitButton.trigger('click'); |
| 524 | + |
| 525 | + const $form = imcger.imgUpload.submitButton.closest('form'); |
| 526 | + |
| 527 | + // Submit form if it hasn't been submitted yet |
| 528 | + if (!$form.prop('data-form-submitted')) { |
| 529 | + $form.prop('data-form-submitted', true); |
| 530 | + |
| 531 | + return; |
| 532 | + } |
| 533 | + |
| 534 | + // Prevent default submission for subsequent clicks within 5 seconds |
| 535 | + e.preventDefault(); |
| 536 | + |
| 537 | + setTimeout(() => { |
| 538 | + $form.prop('removeProp', 'data-form-submitted'); |
| 539 | + imcger.imgUpload.submitButton.removeClass('disabled'); // Re-enable after 5 seconds |
| 540 | + }, 5000); |
| 541 | + } else { |
| 542 | + imcger.imgUpload.submitButton.removeClass('disabled'); // Re-enable |
492 | 543 | }
|
493 | 544 | }
|
494 | 545 |
|
|
0 commit comments