Init popup for new code comment (#20234) (#20235)

- Backport #20234
 
  - Initialize the popup for the tooltip inside the new code comment.
  - This works and is good enough to have this issue fixed for 1.17
 
Fix #20068
This commit is contained in:
Gusted 2022-07-05 14:29:04 +02:00 committed by GitHub
parent 35fd55c7df
commit f42fc3b287
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 9 deletions

View file

@ -75,6 +75,20 @@ export function initGlobalButtonClickOnEnter() {
}); });
} }
export function initPopup(target) {
const $el = $(target);
const attr = $el.attr('data-variation');
const attrs = attr ? attr.split(' ') : [];
const variations = new Set([...attrs, 'inverted', 'tiny']);
$el.attr('data-variation', [...variations].join(' ')).popup();
}
export function initGlobalPopups() {
$('.tooltip').each((_, el) => {
initPopup(el);
});
}
export function initGlobalCommon() { export function initGlobalCommon() {
// Show exact time // Show exact time
$('.time-since').each(function () { $('.time-since').each(function () {
@ -121,15 +135,6 @@ export function initGlobalCommon() {
$('.ui.checkbox').checkbox(); $('.ui.checkbox').checkbox();
// init popups
$('.tooltip').each((_, el) => {
const $el = $(el);
const attr = $el.attr('data-variation');
const attrs = attr ? attr.split(' ') : [];
const variations = new Set([...attrs, 'inverted', 'tiny']);
$el.attr('data-variation', [...variations].join(' ')).popup();
});
$('.top.menu .tooltip').popup({ $('.top.menu .tooltip').popup({
onShow() { onShow() {
if ($('.top.menu .menu.transition').hasClass('visible')) { if ($('.top.menu .menu.transition').hasClass('visible')) {

View file

@ -3,6 +3,7 @@ import {initCompReactionSelector} from './comp/ReactionSelector.js';
import {initRepoIssueContentHistory} from './repo-issue-content.js'; import {initRepoIssueContentHistory} from './repo-issue-content.js';
import {validateTextareaNonEmpty} from './comp/EasyMDE.js'; import {validateTextareaNonEmpty} from './comp/EasyMDE.js';
import {initViewedCheckboxListenerFor, countAndUpdateViewedFiles} from './pull-view-file.js'; import {initViewedCheckboxListenerFor, countAndUpdateViewedFiles} from './pull-view-file.js';
import {initPopup} from './common-global.js';
const {csrfToken} = window.config; const {csrfToken} = window.config;
@ -52,6 +53,7 @@ export function initRepoDiffConversationForm() {
const newConversationHolder = $(await $.post(form.attr('action'), form.serialize())); const newConversationHolder = $(await $.post(form.attr('action'), form.serialize()));
const {path, side, idx} = newConversationHolder.data(); const {path, side, idx} = newConversationHolder.data();
initPopup(newConversationHolder.find('.tooltip'));
form.closest('.conversation-holder').replaceWith(newConversationHolder); form.closest('.conversation-holder').replaceWith(newConversationHolder);
if (form.closest('tr').data('line-type') === 'same') { if (form.closest('tr').data('line-type') === 'same') {
$(`[data-path="${path}"] a.add-code-comment[data-idx="${idx}"]`).addClass('invisible'); $(`[data-path="${path}"] a.add-code-comment[data-idx="${idx}"]`).addClass('invisible');

View file

@ -55,6 +55,7 @@ import {
initGlobalEnterQuickSubmit, initGlobalEnterQuickSubmit,
initGlobalFormDirtyLeaveConfirm, initGlobalFormDirtyLeaveConfirm,
initGlobalLinkActions, initGlobalLinkActions,
initGlobalPopups,
initHeadNavbarContentToggle, initHeadNavbarContentToggle,
} from './features/common-global.js'; } from './features/common-global.js';
import {initRepoTopicBar} from './features/repo-home.js'; import {initRepoTopicBar} from './features/repo-home.js';
@ -99,6 +100,7 @@ initVueEnv();
$(document).ready(() => { $(document).ready(() => {
initGlobalCommon(); initGlobalCommon();
initGlobalPopups();
initGlobalButtonClickOnEnter(); initGlobalButtonClickOnEnter();
initGlobalButtons(); initGlobalButtons();
initGlobalCopyToClipboardListener(); initGlobalCopyToClipboardListener();