fix: dynamic tooltips

This commit is contained in:
Barış Soner Uşaklı
2022-09-27 22:27:40 -04:00
parent 75eea53c4b
commit 092bdd9f22
2 changed files with 16 additions and 8 deletions

View File

@@ -10,7 +10,8 @@ define('forum/topic/threadTools', [
'hooks',
'bootbox',
'alerts',
], function (components, translator, handleBack, posts, api, hooks, bootbox, alerts) {
'bootstrap',
], function (components, translator, handleBack, posts, api, hooks, bootbox, alerts, bootstrap) {
const ThreadTools = {};
ThreadTools.init = function (tid, topicContainer) {
@@ -365,11 +366,12 @@ define('forum/topic/threadTools', [
unfollow: '[[topic:not-watching]]',
ignore: '[[topic:ignoring]]',
};
// TODO: doesnt work on bs5
translator.translate(titles[state], function (translatedTitle) {
$('[component="topic/watch"]')
.attr('title', translatedTitle)
.tooltip();
const tooltip = bootstrap.Tooltip.getInstance('[component="topic/watch"]');
if (tooltip) {
tooltip.setContent({ '.tooltip-inner': translatedTitle });
}
});
let menu = components.get('topic/following/menu');

View File

@@ -2,8 +2,8 @@
define('forum/topic/votes', [
'components', 'translator', 'api', 'hooks', 'bootbox', 'alerts',
], function (components, translator, api, hooks, bootbox, alerts) {
'components', 'translator', 'api', 'hooks', 'bootbox', 'alerts', 'bootstrap',
], function (components, translator, api, hooks, bootbox, alerts, bootstrap) {
const Votes = {};
Votes.addVoteHandler = function () {
@@ -32,7 +32,13 @@ define('forum/topic/votes', [
function createTooltip(el, data) {
function doCreateTooltip(title) {
el.attr('title', title).tooltip('fixTitle').tooltip('show');
const tooltip = bootstrap.Tooltip.getInstance(el);
if (tooltip) {
tooltip.setContent({ '.tooltip-inner': title });
} else {
el.attr('title', title);
(new bootstrap.Tooltip(el)).show();
}
el.parent().find('.tooltip').css('display', '');
}
let usernames = data.usernames