|
138 | 138 | });
|
139 | 139 | }
|
140 | 140 | });
|
| 141 | + |
| 142 | + if (deg != 0) { |
| 143 | + $('[data-attach-id="' + attach_id + '"]').find('.save-image').css({ |
| 144 | + 'background-color': '#22f822', |
| 145 | + 'background-image': 'unset' |
| 146 | + }); |
| 147 | + } else { |
| 148 | + $('[data-attach-id="' + attach_id + '"]').find('.save-image').removeAttr( 'style' ); |
| 149 | + } |
141 | 150 | },
|
142 | 151 |
|
143 | 152 | /**
|
|
262 | 271 | imcger.imgUpload.updateAttId(response.oldAttachId, response.newAttachId);
|
263 | 272 | imcger.imgUpload.image.imgOrientationValue[index] = 0;
|
264 | 273 | imcger.imgUpload.image.updateImgFileSize(response.newAttachId, response.fileSize);
|
| 274 | + $('[data-attach-id="' + response.newAttachId + '"]').find('.save-image').removeAttr( 'style' ); |
265 | 275 |
|
266 | 276 | // Display a message when a warning occurs
|
267 | 277 | if (response.message) {
|
|
425 | 435 | $textarea.val(text);
|
426 | 436 | };
|
427 | 437 |
|
| 438 | + /** |
| 439 | + * Open a confirmbox when preview or save post |
| 440 | + * and rotated images have not been saved |
| 441 | + */ |
| 442 | + $('.submit-buttons').on('click', '.button1', function(e) { |
| 443 | + imcger.imgUpload.submitType = $(e.target).attr('name'); |
| 444 | + let attach_id = 0, |
| 445 | + imgHTMLList = '<ul>'; |
| 446 | + |
| 447 | + // Are all images saved? |
| 448 | + $.each(imcger.imgUpload.image.imgOrientationValue, function(index, value) { |
| 449 | + |
| 450 | + if (value != 0) { |
| 451 | + attach_id = imcger.imgUpload.image.imgOrientationIndex[index]; |
| 452 | + |
| 453 | + imgHTMLList += '<li>' + $('#img-' + attach_id).attr('title'); |
| 454 | + } |
| 455 | + }); |
| 456 | + imgHTMLList += '</ul>'; |
| 457 | + |
| 458 | + // If one or more images not save open confirmbox |
| 459 | + if (attach_id) { |
| 460 | + let confirmMsgText = '<h3 class="alert_title">{{ IMGUPLOAD_TITLE }}</h3><div class="alert_text"><p>{{ lang("IUL_CONFIRMBOX_TEXT1")|e("js") }}</p>' + imgHTMLList + '<p>{{ lang("IUL_CONFIRMBOX_TEXT2")|e("js") }}</p><input type="button" name="confirm" value="{{ lang("YES")|e("js") }}" class="button2"> <input type="button" name="cancel" value="{{ lang("NO")|e("js") }}" class="button2"></div>'; |
| 461 | + |
| 462 | + e.preventDefault(); |
| 463 | + phpbb.confirm(confirmMsgText, imcger.imgUpload.confirmSavePost, true); |
| 464 | + } |
| 465 | + }); |
| 466 | + |
| 467 | + /** |
| 468 | + * Callback function for confirmbox |
| 469 | + * |
| 470 | + * @param {bool} answerYes |
| 471 | + */ |
| 472 | + imcger.imgUpload.confirmSavePost = function(answerYes) { |
| 473 | + |
| 474 | + if (answerYes) { |
| 475 | + $('.submit-buttons').off('click', '.button1'); |
| 476 | + $('.submit-buttons [name="' + imcger.imgUpload.submitType + '"').trigger('click'); |
| 477 | + } |
| 478 | + } |
| 479 | + |
428 | 480 | /**
|
429 | 481 | * Update the relevant elements and hidden data for
|
430 | 482 | * an attachment when page load.
|
|
497 | 549 | imgHeight = maxImgHeight / e.target.width * e.target.height;
|
498 | 550 | }
|
499 | 551 |
|
500 |
| - $(this).css('margin-top', ((maxImgHeight - parseInt(imgHeight)) / 2)); |
| 552 | + $(e.target).css('margin-top', ((maxImgHeight - parseInt(imgHeight)) / 2)); |
501 | 553 | });
|
502 | 554 | }
|
503 | 555 | });
|
|
584 | 636 | imgHeight = maxImgHeight / e.target.width * e.target.height;
|
585 | 637 | }
|
586 | 638 |
|
587 |
| - $(this).css('margin-top', ((maxImgHeight - parseInt(imgHeight)) / 2)); |
| 639 | + $(e.target).css('margin-top', ((maxImgHeight - parseInt(imgHeight)) / 2)); |
588 | 640 | });
|
589 | 641 |
|
590 | 642 | // Update row with the image file size
|
|
0 commit comments