mirror of
https://github.com/go-gitea/gitea
synced 2024-09-27 14:54:05 +00:00
Remove jQuery .text()
This commit is contained in:
parent
b9f69b4a4d
commit
ff0c9a04a5
@ -321,7 +321,7 @@ rules:
|
|||||||
jquery/no-sizzle: [2]
|
jquery/no-sizzle: [2]
|
||||||
jquery/no-slide: [0]
|
jquery/no-slide: [0]
|
||||||
jquery/no-submit: [0]
|
jquery/no-submit: [0]
|
||||||
jquery/no-text: [0]
|
jquery/no-text: [2]
|
||||||
jquery/no-toggle: [2]
|
jquery/no-toggle: [2]
|
||||||
jquery/no-trigger: [0]
|
jquery/no-trigger: [0]
|
||||||
jquery/no-trim: [2]
|
jquery/no-trim: [2]
|
||||||
@ -474,7 +474,7 @@ rules:
|
|||||||
no-jquery/no-slide: [2]
|
no-jquery/no-slide: [2]
|
||||||
no-jquery/no-sub: [2]
|
no-jquery/no-sub: [2]
|
||||||
no-jquery/no-support: [2]
|
no-jquery/no-support: [2]
|
||||||
no-jquery/no-text: [0]
|
no-jquery/no-text: [2]
|
||||||
no-jquery/no-trigger: [0]
|
no-jquery/no-trigger: [0]
|
||||||
no-jquery/no-trim: [2]
|
no-jquery/no-trim: [2]
|
||||||
no-jquery/no-type: [2]
|
no-jquery/no-type: [2]
|
||||||
|
@ -303,10 +303,10 @@ export function initGlobalLinkActions() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const $dialog = $(`.delete.modal${filter}`);
|
const $dialog = $(`.delete.modal${filter}`);
|
||||||
$dialog.find('.name').text($this.data('name'));
|
$dialog.find('.name')[0].textContent = $this.data('name');
|
||||||
for (const [key, value] of Object.entries(dataArray)) {
|
for (const [key, value] of Object.entries(dataArray)) {
|
||||||
if (key && key.startsWith('data')) {
|
if (key && key.startsWith('data')) {
|
||||||
$dialog.find(`.${key}`).text(value);
|
$dialog.find(`.${key}`)[0].textContent = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -373,7 +373,7 @@ function initGlobalShowModal() {
|
|||||||
} else if ($attrTarget[0].matches('input, textarea')) {
|
} else if ($attrTarget[0].matches('input, textarea')) {
|
||||||
$attrTarget.val(attrib.value); // FIXME: add more supports like checkbox
|
$attrTarget.val(attrib.value); // FIXME: add more supports like checkbox
|
||||||
} else {
|
} else {
|
||||||
$attrTarget.text(attrib.value); // FIXME: it should be more strict here, only handle div/span/p
|
$attrTarget[0].textContent = attrib.value; // FIXME: it should be more strict here, only handle div/span/p
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,7 +92,7 @@ export function initImageDiff() {
|
|||||||
return loadElem(img, info.path);
|
return loadElem(img, info.path);
|
||||||
}));
|
}));
|
||||||
// only the first images is associated with $boundsInfo
|
// only the first images is associated with $boundsInfo
|
||||||
if (!success) info.$boundsInfo.text('(image error)');
|
if (!success) info.$boundsInfo[0].textContent = '(image error)';
|
||||||
if (info.mime === 'image/svg+xml') {
|
if (info.mime === 'image/svg+xml') {
|
||||||
const resp = await GET(info.path);
|
const resp = await GET(info.path);
|
||||||
const text = await resp.text();
|
const text = await resp.text();
|
||||||
|
@ -47,16 +47,13 @@ async function receiveUpdateCount(event) {
|
|||||||
|
|
||||||
export function initNotificationCount() {
|
export function initNotificationCount() {
|
||||||
const $notificationCount = $('.notification_count');
|
const $notificationCount = $('.notification_count');
|
||||||
|
if (!$notificationCount.length) return;
|
||||||
if (!$notificationCount.length) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
let usingPeriodicPoller = false;
|
let usingPeriodicPoller = false;
|
||||||
const startPeriodicPoller = (timeout, lastCount) => {
|
const startPeriodicPoller = (timeout, lastCount) => {
|
||||||
if (timeout <= 0 || !Number.isFinite(timeout)) return;
|
if (timeout <= 0 || !Number.isFinite(timeout)) return;
|
||||||
usingPeriodicPoller = true;
|
usingPeriodicPoller = true;
|
||||||
lastCount = lastCount ?? $notificationCount.text();
|
lastCount = lastCount ?? getCurrentCount();
|
||||||
setTimeout(async () => {
|
setTimeout(async () => {
|
||||||
await updateNotificationCountWithCallback(startPeriodicPoller, timeout, lastCount);
|
await updateNotificationCountWithCallback(startPeriodicPoller, timeout, lastCount);
|
||||||
}, timeout);
|
}, timeout);
|
||||||
@ -120,8 +117,12 @@ export function initNotificationCount() {
|
|||||||
startPeriodicPoller(notificationSettings.MinTimeout);
|
startPeriodicPoller(notificationSettings.MinTimeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getCurrentCount() {
|
||||||
|
return document.querySelector('.notification_count').textContent;
|
||||||
|
}
|
||||||
|
|
||||||
async function updateNotificationCountWithCallback(callback, timeout, lastCount) {
|
async function updateNotificationCountWithCallback(callback, timeout, lastCount) {
|
||||||
const currentCount = $('.notification_count').text();
|
const currentCount = getCurrentCount();
|
||||||
if (lastCount !== currentCount) {
|
if (lastCount !== currentCount) {
|
||||||
callback(notificationSettings.MinTimeout, currentCount);
|
callback(notificationSettings.MinTimeout, currentCount);
|
||||||
return;
|
return;
|
||||||
|
@ -70,7 +70,7 @@ export function initRepoEditor() {
|
|||||||
hideElem('.quick-pull-branch-name');
|
hideElem('.quick-pull-branch-name');
|
||||||
document.querySelector('.quick-pull-branch-name input').required = false;
|
document.querySelector('.quick-pull-branch-name input').required = false;
|
||||||
}
|
}
|
||||||
$('#commit-button').text(this.getAttribute('button_text'));
|
$('#commit-button')[0].textContent = this.getAttribute('button_text');
|
||||||
});
|
});
|
||||||
|
|
||||||
const joinTreePath = ($fileNameEl) => {
|
const joinTreePath = ($fileNameEl) => {
|
||||||
@ -78,9 +78,9 @@ export function initRepoEditor() {
|
|||||||
$('.breadcrumb span.section').each(function () {
|
$('.breadcrumb span.section').each(function () {
|
||||||
const $element = $(this);
|
const $element = $(this);
|
||||||
if ($element.find('a').length) {
|
if ($element.find('a').length) {
|
||||||
parts.push($element.find('a').text());
|
parts.push($element.find('a')[0].textContent);
|
||||||
} else {
|
} else {
|
||||||
parts.push($element.text());
|
parts.push($element[0].textContent);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if ($fileNameEl.val()) parts.push($fileNameEl.val());
|
if ($fileNameEl.val()) parts.push($fileNameEl.val());
|
||||||
@ -116,7 +116,7 @@ export function initRepoEditor() {
|
|||||||
if (e.code === 'Backspace' && getCursorPosition($(this)) === 0 && $section.length > 0) {
|
if (e.code === 'Backspace' && getCursorPosition($(this)) === 0 && $section.length > 0) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
const $divider = $('.breadcrumb .breadcrumb-divider');
|
const $divider = $('.breadcrumb .breadcrumb-divider');
|
||||||
const value = $section.last().find('a').text();
|
const value = $section.last().find('a')[0].textContent;
|
||||||
$(this).val(value + $(this).val());
|
$(this).val(value + $(this).val());
|
||||||
this.setSelectionRange(value.length, value.length);
|
this.setSelectionRange(value.length, value.length);
|
||||||
$section.last().remove();
|
$section.last().remove();
|
||||||
|
@ -183,7 +183,7 @@ export function initRepoIssueCommentEdit() {
|
|||||||
$(document).on('click', '.quote-reply', async function (event) {
|
$(document).on('click', '.quote-reply', async function (event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
const target = $(this).data('target');
|
const target = $(this).data('target');
|
||||||
const quote = $(`#${target}`).text().replace(/\n/g, '\n> ');
|
const quote = $(`#${target}`)[0].textContent.replace(/\n/g, '\n> ');
|
||||||
const content = `> ${quote}\n\n`;
|
const content = `> ${quote}\n\n`;
|
||||||
let editor;
|
let editor;
|
||||||
if ($(this).hasClass('quote-reply-diff')) {
|
if ($(this).hasClass('quote-reply-diff')) {
|
||||||
|
@ -281,7 +281,7 @@ export function initRepoPullRequestUpdate() {
|
|||||||
if (url) {
|
if (url) {
|
||||||
const buttonText = pullUpdateButton.querySelector('.button-text');
|
const buttonText = pullUpdateButton.querySelector('.button-text');
|
||||||
if (buttonText) {
|
if (buttonText) {
|
||||||
buttonText.textContent = $choice.text();
|
buttonText.textContent = $choice[0].textContent;
|
||||||
}
|
}
|
||||||
pullUpdateButton.setAttribute('data-do', url);
|
pullUpdateButton.setAttribute('data-do', url);
|
||||||
}
|
}
|
||||||
@ -566,7 +566,7 @@ export function initRepoIssueReferenceIssue() {
|
|||||||
// Reference issue
|
// Reference issue
|
||||||
$(document).on('click', '.reference-issue', function (event) {
|
$(document).on('click', '.reference-issue', function (event) {
|
||||||
const $this = $(this);
|
const $this = $(this);
|
||||||
const content = $(`#${$this.data('target')}`).text();
|
const content = $(`#${$this.data('target')}`)[0].textContent;
|
||||||
const poster = $this.data('poster-username');
|
const poster = $this.data('poster-username');
|
||||||
const reference = toAbsoluteUrl($this.data('reference'));
|
const reference = toAbsoluteUrl($this.data('reference'));
|
||||||
const $modal = $($this.data('modal'));
|
const $modal = $($this.data('modal'));
|
||||||
@ -603,8 +603,7 @@ export function initRepoIssueWipToggle() {
|
|||||||
|
|
||||||
async function pullrequest_targetbranch_change(update_url) {
|
async function pullrequest_targetbranch_change(update_url) {
|
||||||
const targetBranch = $('#pull-target-branch').data('branch');
|
const targetBranch = $('#pull-target-branch').data('branch');
|
||||||
const $branchTarget = $('#branch_target');
|
if (targetBranch === $('#branch_target')[0].textContent) {
|
||||||
if (targetBranch === $branchTarget.text()) {
|
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -640,8 +639,9 @@ export function initRepoIssueTitleEdit() {
|
|||||||
$('#cancel-edit-title').on('click', editTitleToggle);
|
$('#cancel-edit-title').on('click', editTitleToggle);
|
||||||
$('#save-edit-title').on('click', editTitleToggle).on('click', async function () {
|
$('#save-edit-title').on('click', editTitleToggle).on('click', async function () {
|
||||||
const pullrequest_target_update_url = this.getAttribute('data-target-update-url');
|
const pullrequest_target_update_url = this.getAttribute('data-target-update-url');
|
||||||
if (!$editInput.val().length || $editInput.val() === $issueTitle.text()) {
|
const titleText = $issueTitle[0].textContent;
|
||||||
$editInput.val($issueTitle.text());
|
if (!$editInput.val().length || $editInput.val() === titleText) {
|
||||||
|
$editInput.val(titleText);
|
||||||
await pullrequest_targetbranch_change(pullrequest_target_update_url);
|
await pullrequest_targetbranch_change(pullrequest_target_update_url);
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
@ -650,7 +650,7 @@ export function initRepoIssueTitleEdit() {
|
|||||||
const response = await POST(this.getAttribute('data-update-url'), {data: params});
|
const response = await POST(this.getAttribute('data-update-url'), {data: params});
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
$editInput.val(data.title);
|
$editInput.val(data.title);
|
||||||
$issueTitle.text(data.title);
|
$issueTitle[0].textContent = data.title;
|
||||||
if (pullrequest_target_update_url) {
|
if (pullrequest_target_update_url) {
|
||||||
await pullrequest_targetbranch_change(pullrequest_target_update_url); // it will reload the window
|
await pullrequest_targetbranch_change(pullrequest_target_update_url); // it will reload the window
|
||||||
} else {
|
} else {
|
||||||
|
@ -64,7 +64,7 @@ export function initRepoCommentForm() {
|
|||||||
const editMode = $('#editing_mode').val();
|
const editMode = $('#editing_mode').val();
|
||||||
$($(this).data('id-selector')).val(selectedValue);
|
$($(this).data('id-selector')).val(selectedValue);
|
||||||
if ($isNewIssue) {
|
if ($isNewIssue) {
|
||||||
$selectBranch.find('.ui .branch-name').text($(this).data('name'));
|
$selectBranch.find('.ui .branch-name')[0].textContent = $(this).data('name');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,7 +79,7 @@ export function initRepoCommentForm() {
|
|||||||
console.error(error);
|
console.error(error);
|
||||||
}
|
}
|
||||||
} else if (editMode === '') {
|
} else if (editMode === '') {
|
||||||
$selectBranch.find('.ui .branch-name').text(selectedValue);
|
$selectBranch.find('.ui .branch-name')[0].textContent = selectedValue;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
$selectBranch.find('.reference.column').on('click', function () {
|
$selectBranch.find('.reference.column').on('click', function () {
|
||||||
@ -275,7 +275,7 @@ export function initRepoCommentForm() {
|
|||||||
$list.find('.selected').html(`
|
$list.find('.selected').html(`
|
||||||
<a class="item muted sidebar-item-link" href=${$(this).data('href')}>
|
<a class="item muted sidebar-item-link" href=${$(this).data('href')}>
|
||||||
${icon}
|
${icon}
|
||||||
${htmlEscape($(this).text())}
|
${htmlEscape(this.textContent)}
|
||||||
</a>
|
</a>
|
||||||
`);
|
`);
|
||||||
|
|
||||||
|
@ -22,12 +22,12 @@ export function initRepoSettingsCollaboration() {
|
|||||||
data.append('mode', value);
|
data.append('mode', value);
|
||||||
await POST(el.getAttribute('data-url'), {data});
|
await POST(el.getAttribute('data-url'), {data});
|
||||||
} catch {
|
} catch {
|
||||||
$text.text('(error)'); // prevent from misleading users when error occurs
|
$text[0].textContent = '(error)'; // prevent from misleading users when error occurs
|
||||||
el.setAttribute('data-last-value', lastValue);
|
el.setAttribute('data-last-value', lastValue);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onChange(_value, text, _$choice) {
|
onChange(_value, text, _$choice) {
|
||||||
$text.text(text); // update the text when using keyboard navigating
|
$text[0].textContent = text; // update the text when using keyboard navigating
|
||||||
},
|
},
|
||||||
onHide() {
|
onHide() {
|
||||||
// set to the really selected value, defer to next tick to make sure `action` has finished its work because the calling order might be onHide -> action
|
// set to the really selected value, defer to next tick to make sure `action` has finished its work because the calling order might be onHide -> action
|
||||||
@ -36,7 +36,7 @@ export function initRepoSettingsCollaboration() {
|
|||||||
if ($item) {
|
if ($item) {
|
||||||
$dropdown.dropdown('set selected', el.getAttribute('data-last-value'));
|
$dropdown.dropdown('set selected', el.getAttribute('data-last-value'));
|
||||||
} else {
|
} else {
|
||||||
$text.text('(none)'); // prevent from misleading users when the access mode is undefined
|
$text[0].textContent = '(none)'; // prevent from misleading users when the access mode is undefined
|
||||||
}
|
}
|
||||||
}, 0);
|
}, 0);
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user