Skip to content

Commit e5774b5

Browse files
committed
clean code
1 parent 4916e7f commit e5774b5

File tree

2 files changed

+3
-14
lines changed

2 files changed

+3
-14
lines changed

templates/repo/view_file.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@
108108
{{range $idx, $code := .FileContent}}
109109
{{$line := Eval $idx "+" 1}}
110110
<tr>
111-
<td id="L{{$line}}" class="lines-num"><span data-line-number="{{$line}}"></span></td>
111+
<td class="lines-num"><span id="L{{$line}}" data-line-number="{{$line}}"></span></td>
112112
{{if $.EscapeStatus.Escaped}}
113113
<td class="lines-escape">{{if (index $.LineEscapeStatus $idx).Escaped}}<button class="toggle-escape-button btn interact-bg" title="{{if (index $.LineEscapeStatus $idx).HasInvisible}}{{ctx.Locale.Tr "repo.invisible_runes_line"}} {{end}}{{if (index $.LineEscapeStatus $idx).HasAmbiguous}}{{ctx.Locale.Tr "repo.ambiguous_runes_line"}}{{end}}"></button>{{end}}</td>
114114
{{end}}

web_src/js/features/repo-code.ts

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ function changeHash(hash: string) {
1414
// it selects the code lines defined by range: `L1-L3` (3 lines) or `L2` (singe line)
1515
function selectRange(range: string): Element {
1616
for (const el of document.querySelectorAll('.code-view tr.active')) el.classList.remove('active');
17-
const elLineNums = document.querySelectorAll(`.code-view td.lines-num[id^="L"]`);
17+
const elLineNums = document.querySelectorAll(`.code-view td.lines-num span[id^="L"]`);
1818

1919
const refInNewIssue = document.querySelector('a.ref-in-new-issue');
2020
const copyPermalink = document.querySelector('a.copy-line-permalink');
@@ -107,17 +107,6 @@ function showLineButton() {
107107
}, {once: true});
108108
},
109109
});
110-
111-
// Handle menu button click manually
112-
btn.addEventListener('click', (e) => {
113-
e.stopPropagation();
114-
const tippyInstance = btn._tippy;
115-
if (tippyInstance?.state.isShown) {
116-
tippyInstance.hide();
117-
} else if (tippyInstance) {
118-
tippyInstance.show();
119-
}
120-
});
121110
}
122111

123112
export function initRepoCodeView() {
@@ -129,7 +118,7 @@ export function initRepoCodeView() {
129118

130119
// "file code view" and "blame" pages need this "line number button" feature
131120
let selRangeStart: string;
132-
addDelegatedEventListener(document, 'click', '.code-view .lines-num', (el: HTMLElement, e: KeyboardEvent) => {
121+
addDelegatedEventListener(document, 'click', '.code-view .lines-num span', (el: HTMLElement, e: KeyboardEvent) => {
133122
if (!selRangeStart || !e.shiftKey) {
134123
selRangeStart = el.getAttribute('id');
135124
selectRange(selRangeStart);

0 commit comments

Comments
 (0)