Skip to content

Commit 1789023

Browse files
author
Thomas Sayen
committed
Removed jquery
1 parent 2b578b1 commit 1789023

File tree

2 files changed

+24
-20
lines changed

2 files changed

+24
-20
lines changed

web_src/js/features/repo-commit.ts

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import {createTippy} from '../modules/tippy.ts';
22
import {toggleElem} from '../utils/dom.ts';
33
import {registerGlobalEventFunc, registerGlobalInitFunc} from '../modules/observer.ts';
4-
import $ from 'jquery';
54

65
export function initRepoEllipsisButton() {
76
registerGlobalEventFunc('click', 'onRepoEllipsisButtonClick', async (el: HTMLInputElement, e: Event) => {
@@ -26,24 +25,28 @@ export function initCommitStatuses() {
2625
});
2726
}
2827

29-
window.addEventListener('DOMContentLoaded', () => {
30-
($('input[name=history-enable-follow-renames]')[0] as HTMLInputElement).checked = location.toString().includes('history_follow_rename=true');
31-
});
28+
export function initCommitFileHistoryFollowRename() {
29+
const checkbox : HTMLInputElement | null = document.querySelector('input[name=history-enable-follow-renames]');
3230

33-
$('input[name=history-enable-follow-renames]').on('change', function() {
34-
const checked = ($(this)[0] as HTMLInputElement).matches(':checked');
35-
let url = location.toString();
36-
37-
url = url.replaceAll(/history_follow_rename=(true|false)&*/g, '');
38-
if (url.endsWith('?')) {
39-
url = url.slice(0, -1);
40-
}
41-
if (url.includes('?')) {
42-
url += '&';
43-
} else {
44-
url += '?';
31+
if (!checkbox) {
32+
return;
4533
}
34+
checkbox.checked = location.toString().includes('history_follow_rename=true');
35+
36+
checkbox.addEventListener('change', () => {
37+
let url = location.toString();
4638

47-
url += `history_follow_rename=${checked}`;
48-
window.location.href = url;
49-
});
39+
url = url.replaceAll(/history_follow_rename=(true|false)&*/g, '');
40+
if (url.endsWith('?')) {
41+
url = url.slice(0, -1);
42+
}
43+
if (url.includes('?')) {
44+
url += '&';
45+
} else {
46+
url += '?';
47+
}
48+
49+
url += `history_follow_rename=${checkbox.checked}`;
50+
window.location.href = url;
51+
});
52+
}

web_src/js/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import {initMarkupContent} from './markup/content.ts';
2222
import {initPdfViewer} from './render/pdf.ts';
2323
import {initUserAuthOauth2, initUserCheckAppUrl} from './features/user-auth.ts';
2424
import {initRepoPullRequestAllowMaintainerEdit, initRepoPullRequestReview, initRepoIssueSidebarDependency, initRepoIssueFilterItemLabel} from './features/repo-issue.ts';
25-
import {initRepoEllipsisButton, initCommitStatuses} from './features/repo-commit.ts';
25+
import {initRepoEllipsisButton, initCommitStatuses, initCommitFileHistoryFollowRename} from './features/repo-commit.ts';
2626
import {initRepoTopicBar} from './features/repo-home.ts';
2727
import {initAdminCommon} from './features/admin/common.ts';
2828
import {initRepoCodeView} from './features/repo-code.ts';
@@ -151,6 +151,7 @@ onDomReady(() => {
151151
initRepoRecentCommits,
152152

153153
initCommitStatuses,
154+
initCommitFileHistoryFollowRename,
154155
initCaptcha,
155156

156157
initUserCheckAppUrl,

0 commit comments

Comments
 (0)