From 7f8783555baf5fa95f67e522ac6ce8cb50fa326d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Sat, 13 Nov 2021 20:16:24 -0500 Subject: [PATCH] Revert "perf: remove createUserTooltips" This reverts commit facc10e40f8789058214d0677806e65b0cc7c37d. --- public/src/app.js | 20 ++++++++++++++++++-- public/src/client/account/posts.js | 1 + public/src/client/account/topics.js | 1 + public/src/client/categories.js | 2 ++ public/src/client/category.js | 1 + public/src/client/topic/posts.js | 3 +++ public/src/modules/chat.js | 1 + public/src/modules/topicList.js | 1 + 8 files changed, 28 insertions(+), 2 deletions(-) diff --git a/public/src/app.js b/public/src/app.js index e92eb5c8ca..6154c8b323 100644 --- a/public/src/app.js +++ b/public/src/app.js @@ -209,8 +209,18 @@ app.flags = {}; .addClass('active'); } - app.createUserTooltips = function () { - console.warn('[removed] app.creatUserTooltips is removed'); + app.createUserTooltips = function (els, placement) { + if (isTouchDevice) { + return; + } + els = els || $('body'); + els.find('.avatar,img[title].teaser-pic,img[title].user-img,div.user-icon,span.user-icon').each(function () { + $(this).tooltip({ + placement: placement || $(this).attr('title-placement') || 'top', + title: $(this).attr('title'), + container: '#content', + }); + }); }; app.createStatusTooltips = function () { @@ -224,9 +234,15 @@ app.flags = {}; app.processPage = function () { highlightNavigationLink(); + $('.timeago').timeago(); + utils.makeNumbersHumanReadable($('.human-readable-number')); + utils.addCommasToNumbers($('.formatted-number')); + + app.createUserTooltips($('#content')); + app.createStatusTooltips(); }; diff --git a/public/src/client/account/posts.js b/public/src/client/account/posts.js index a0c0a3e92f..27442e21a5 100644 --- a/public/src/client/account/posts.js +++ b/public/src/client/account/posts.js @@ -45,6 +45,7 @@ define('forum/account/posts', ['forum/account/header', 'forum/infinitescroll', ' $('[component="posts"]').append(html); html.find('img:not(.not-responsive)').addClass('img-responsive'); html.find('.timeago').timeago(); + app.createUserTooltips(); utils.makeNumbersHumanReadable(html.find('.human-readable-number')); hooks.fire('action:posts.loaded', { posts: posts }); callback(); diff --git a/public/src/client/account/topics.js b/public/src/client/account/topics.js index 565bb9b170..cba3358275 100644 --- a/public/src/client/account/topics.js +++ b/public/src/client/account/topics.js @@ -46,6 +46,7 @@ define('forum/account/topics', [ app.parseAndTranslate(template, 'topics', { topics: topics }, function (html) { $('[component="category"]').append(html); html.find('.timeago').timeago(); + app.createUserTooltips(); utils.makeNumbersHumanReadable(html.find('.human-readable-number')); hooks.fire('action:topics.loaded', { topics: topics }); callback(); diff --git a/public/src/client/categories.js b/public/src/client/categories.js index 1881941c00..44025e8b8c 100644 --- a/public/src/client/categories.js +++ b/public/src/client/categories.js @@ -55,6 +55,8 @@ define('forum/categories', ['components', 'categorySelector', 'hooks'], function } html.fadeIn(); + + app.createUserTooltips(); html.find('.timeago').timeago(); if (category.find('[component="category/posts"]').length > parseInt(numRecentReplies, 10)) { diff --git a/public/src/client/category.js b/public/src/client/category.js index 5e0fccbcbb..da8a6296cf 100644 --- a/public/src/client/category.js +++ b/public/src/client/category.js @@ -104,6 +104,7 @@ define('forum/category', [ html.find('.timeago').timeago(); $('[component="category/subcategory/container"]').append(html); utils.makeNumbersHumanReadable(html.find('.human-readable-number')); + app.createUserTooltips(html); ajaxify.data.nextSubCategoryStart += ajaxify.data.subCategoriesPerPage; ajaxify.data.subCategoriesLeft -= data.length; btn.toggleClass('hidden', ajaxify.data.subCategoriesLeft <= 0) diff --git a/public/src/client/topic/posts.js b/public/src/client/topic/posts.js index 9e3f63a657..b84953e915 100644 --- a/public/src/client/topic/posts.js +++ b/public/src/client/topic/posts.js @@ -370,6 +370,9 @@ define('forum/topic/posts', [ Posts.onNewPostsAddedToDom = function (posts) { Posts.onTopicPageLoad(posts); + + app.createUserTooltips(posts); + utils.addCommasToNumbers(posts.find('.formatted-number')); utils.makeNumbersHumanReadable(posts.find('.human-readable-number')); posts.find('.timeago').timeago(); diff --git a/public/src/modules/chat.js b/public/src/modules/chat.js index 1300b78c22..d57386040a 100644 --- a/public/src/modules/chat.js +++ b/public/src/modules/chat.js @@ -96,6 +96,7 @@ define('chat', [ app.parseAndTranslate('partials/chats/dropdown', { rooms: rooms }, function (html) { chatsListEl.find('*').not('.navigation-link').remove(); chatsListEl.prepend(html); + app.createUserTooltips(chatsListEl, 'right'); chatsListEl.off('click').on('click', '[data-roomid]', function (ev) { if ($(ev.target).parents('.user-link').length) { return; diff --git a/public/src/modules/topicList.js b/public/src/modules/topicList.js index db65c20522..1ce4016364 100644 --- a/public/src/modules/topicList.js +++ b/public/src/modules/topicList.js @@ -262,6 +262,7 @@ define('topicList', [ } html.find('.timeago').timeago(); + app.createUserTooltips(html); utils.makeNumbersHumanReadable(html.find('.human-readable-number')); hooks.fire('action:topics.loaded', { topics: topics, template: templateName }); callback();