Skip to content

Commit

Permalink
Init popup for new code comment
Browse files Browse the repository at this point in the history
- 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
- Resolves go-gitea#20068
  • Loading branch information
Gusted committed Jul 5, 2022
1 parent c174bdc commit 33d5528
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
23 changes: 14 additions & 9 deletions web_src/js/features/common-global.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
// Show exact time
$('.time-since').each(function () {
Expand Down Expand Up @@ -121,15 +135,6 @@ export function initGlobalCommon() {

$('.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({
onShow() {
if ($('.top.menu .menu.transition').hasClass('visible')) {
Expand Down
2 changes: 2 additions & 0 deletions web_src/js/features/repo-diff.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {initCompReactionSelector} from './comp/ReactionSelector.js';
import {initRepoIssueContentHistory} from './repo-issue-content.js';
import {validateTextareaNonEmpty} from './comp/EasyMDE.js';
import {initViewedCheckboxListenerFor, countAndUpdateViewedFiles} from './pull-view-file.js';
import {initPopup} from './common-global.js';

const {csrfToken} = window.config;

Expand Down Expand Up @@ -52,6 +53,7 @@ export function initRepoDiffConversationForm() {
const newConversationHolder = $(await $.post(form.attr('action'), form.serialize()));
const {path, side, idx} = newConversationHolder.data();

initPopup(newConversationHolder.find('.tooltip'));
form.closest('.conversation-holder').replaceWith(newConversationHolder);
if (form.closest('tr').data('line-type') === 'same') {
$(`[data-path="${path}"] a.add-code-comment[data-idx="${idx}"]`).addClass('invisible');
Expand Down
2 changes: 2 additions & 0 deletions web_src/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ import {
initGlobalFormDirtyLeaveConfirm,
initGlobalLinkActions,
initHeadNavbarContentToggle,
initGlobalPopups,
} from './features/common-global.js';
import {initRepoTopicBar} from './features/repo-home.js';
import {initAdminEmails} from './features/admin-emails.js';
Expand Down Expand Up @@ -99,6 +100,7 @@ initVueEnv();
$(document).ready(() => {
initGlobalCommon();

initGlobalPopups();
initGlobalButtonClickOnEnter();
initGlobalButtons();
initGlobalCopyToClipboardListener();
Expand Down

0 comments on commit 33d5528

Please sign in to comment.