Skip to content

Commit

Permalink
Merge pull request #1292 from GedeonTS/fix-duplicated-close-btn
Browse files Browse the repository at this point in the history
[FIX]: Fixed the duplicate close button for inline messages and ensured it works properly for non-inline messages
  • Loading branch information
Shadow243 authored Nov 25, 2024
2 parents 595382f + 9ed6b03 commit 727801e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
6 changes: 4 additions & 2 deletions modules/imap/site.js
Original file line number Diff line number Diff line change
Expand Up @@ -780,8 +780,10 @@ var imap_setup_message_view_page = function(uid, details, list_path, callback) {
.append(msgResponse.msg_text)
.append(msgResponse.msg_parts);
document.title = $('.header_subject th').text();
$('.header_subject th').append('<i class="bi bi-x-lg close_inline_msg"></i>');
$('.close_inline_msg').on("click", function() { msg_inline_close(); });
if ($('.header_subject th').find('i.bi.bi-x-lg.close_inline_msg').length === 0) {
$('.header_subject th').append('<i class="bi bi-x-lg close_inline_msg"></i>');
$('.close_inline_msg').on("click", function() { msg_inline_close(); });
}

$('.reply_link, .reply_all_link, .forward_link').each(function() {
$(this).data("href", $(this).attr("href")).removeAttr("href");
Expand Down
24 changes: 16 additions & 8 deletions modules/inline_message/site.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,19 @@ var get_inline_msg_details = function(link) {
};

var msg_inline_close = function() {
if (inline_msg_style() == 'right') {
$('.msg_text').remove();
$('.message_table').css('width', '100%');
}
else {
if ($('.inline_msg').length) {
if (inline_msg_style() == 'right') {
$('.refresh_link').trigger('click');
$('.msg_text').remove();
$('.message_table').css('width', '100%');
} else {
$('.refresh_link').trigger('click');
$('.inline_msg').remove();
$('tr').removeClass('hl');
}
} else {
window.history.back();
}
$('tr').removeClass('hl');
};

var update_imap_links = function(uid, details) {
Expand All @@ -123,8 +128,11 @@ var capture_subject_click = function() {
var uid = msg_details[0];
var list_path = msg_details[1];
var inline_msg_loaded_callback = function() {
$('.header_subject th').append('<i class="bi bi-x-lg close_inline_msg"></i>');
$('.close_inline_msg').on("click", function() { msg_inline_close(); });
if ($('.header_subject th').find('i.bi.bi-x-lg.close_inline_msg').length === 0) {
$('.header_subject th').append('<i class="bi bi-x-lg close_inline_msg"></i>');
$('.close_inline_msg').on("click", function() { msg_inline_close(); });
$('.msg_part_link').on("click", function() { return get_message_content($(this).data('messagePart'), uid, list_path, details, inline_msg_loaded_callback); });
}
update_imap_links(uid, details);
};

Expand Down

0 comments on commit 727801e

Please sign in to comment.