Replace jQuery UI's tooltip from ajax messages

Signed-off-by: Maurício Meneghini Fauth <mauricio@mfauth.net>
This commit is contained in:
Maurício Meneghini Fauth 2025-01-23 13:54:27 -03:00
parent db3e882700
commit f2dd364582
No known key found for this signature in database
GPG Key ID: 6A16FD38AFC89CC8
2 changed files with 8 additions and 31 deletions

View File

@ -1,5 +1,4 @@
import $ from 'jquery';
import tooltip from './tooltip.ts';
import highlightSql from './sql-highlight.ts';
/**
@ -115,9 +114,7 @@ const ajaxShowMessage = function (message = null, timeout = null, type = null) {
$retval
.delay(newTimeOut)
.fadeOut('medium', function () {
if ($(this).is(':data(tooltip)')) {
$(this).uiTooltip('destroy');
}
window.bootstrap.Tooltip.getInstance(this)?.dispose();
// Remove the notification
$(this).remove();
@ -132,7 +129,8 @@ const ajaxShowMessage = function (message = null, timeout = null, type = null) {
* Add a tooltip to the notification to let the user know that they
* can dismiss the ajax notification by clicking on it.
*/
tooltip($retval, 'span', window.Messages.strDismiss);
window.bootstrap.Tooltip.getOrCreateInstance($retval.get(0), { title: window.Messages.strDismiss })
.setContent({ '.tooltip-inner': window.Messages.strDismiss });
}
// Hide spinner if this is not a loading message
@ -152,15 +150,13 @@ const ajaxShowMessage = function (message = null, timeout = null, type = null) {
*/
const ajaxRemoveMessage = function ($thisMessageBox: JQuery | boolean): void {
if ($thisMessageBox !== undefined && typeof $thisMessageBox !== 'boolean' && $thisMessageBox instanceof $) {
window.bootstrap.Tooltip.getInstance($thisMessageBox.get(0))?.dispose();
$thisMessageBox
.stop(true, true)
.fadeOut('medium');
if ($thisMessageBox.is(':data(tooltip)')) {
$thisMessageBox.uiTooltip('destroy');
} else {
$thisMessageBox.remove();
}
$thisMessageBox.remove();
}
};

View File

@ -1507,22 +1507,6 @@ export function dismissNotifications () {
}
});
/**
* The below two functions hide the "Dismiss notification" tooltip when a user
* is hovering a link or button that is inside an ajax message
*/
$(document).on('mouseover', 'span.ajax_notification a, span.ajax_notification button, span.ajax_notification input', function () {
if ($(this).parents('span.ajax_notification').is(':data(tooltip)')) {
$(this).parents('span.ajax_notification').uiTooltip('disable');
}
});
$(document).on('mouseout', 'span.ajax_notification a, span.ajax_notification button, span.ajax_notification input', function () {
if ($(this).parents('span.ajax_notification').is(':data(tooltip)')) {
$(this).parents('span.ajax_notification').uiTooltip('enable');
}
});
$(document).on('click', 'a.copyQueryBtn', function (event) {
event.preventDefault();
var copyStatus = copyToClipboard($(this).attr('data-text'));
@ -1536,11 +1520,8 @@ export function dismissNotifications () {
message = $(this).hasClass('copyQueryBtn') ? window.Messages.strCopyToClipboard : window.Messages.strEditQuery;
}
tooltip(
$('.ajax_notification'),
'span',
message
);
window.bootstrap.Tooltip.getOrCreateInstance('.ajax_notification', { title: message })
.setContent({ '.tooltip-inner': message });
});
$(document).on('mouseup', '.ajax_notification a', function (event) {