File tree Expand file tree Collapse file tree 4 files changed +35
-6
lines changed Expand file tree Collapse file tree 4 files changed +35
-6
lines changed Original file line number Diff line number Diff line change 164
164
<input type="checkbox" name="{{$file.GetDiffFileName}}" autocomplete="off"{{if $file.IsViewed}} checked{{end}}> {{ctx.Locale.Tr "repo.pulls.has_viewed_file"}}
165
165
</label>
166
166
{{end}}
167
- <div class="ui dropdown basic ">
167
+ <div class="ui tiny js-btn-diff-file-menu ">
168
168
{{svg "octicon-kebab-horizontal" 18 "icon tw-mx-2"}}
169
- <div class="ui menu ">
169
+ <div class="tippy-target ">
170
170
{{if not (or $file.IsIncomplete $file.IsBin $file.IsSubmodule)}}
171
- <button class="unescape-button item">{{ctx.Locale.Tr "repo.unescape_control_characters"}}</button >
172
- <button class="escape-button tw-hidden item">{{ctx.Locale.Tr "repo.escape_control_characters"}}</button >
171
+ <a class="unescape-button item">{{ctx.Locale.Tr "repo.unescape_control_characters"}}</a >
172
+ <a class="escape-button tw-hidden item">{{ctx.Locale.Tr "repo.escape_control_characters"}}</a >
173
173
{{end}}
174
174
{{if and (not $file.IsSubmodule) (not $.PageIsWiki)}}
175
175
{{if $file.IsDeleted}}
Original file line number Diff line number Diff line change 1
1
import $ from 'jquery' ;
2
+ import { createTippy } from '../modules/tippy.ts' ;
2
3
import { initCompReactionSelector } from './comp/ReactionSelector.ts' ;
3
4
import { initRepoIssueContentHistory } from './repo-issue-content.ts' ;
4
5
import { initDiffFileTree , initDiffFileList } from './repo-diff-filetree.ts' ;
@@ -225,3 +226,23 @@ export function initRepoDiffView() {
225
226
initViewedCheckboxListenerFor ( ) ;
226
227
initExpandAndCollapseFilesButton ( ) ;
227
228
}
229
+
230
+ export function initRepoDiffFileMenu ( ) {
231
+ let tippyIndex = 0 ;
232
+ $ ( '.js-btn-diff-file-menu' ) . each ( function ( ) {
233
+ tippyIndex ++ ;
234
+ this . setAttribute ( 'data-diff-file-menu-tippy-target-id' , tippyIndex ) ;
235
+ const $menu = $ ( this ) . find ( '.tippy-target' ) ;
236
+ if ( $menu . length < 1 ) return ;
237
+ $menu [ 0 ] . setAttribute ( 'data-diff-file-menu-tippy-id' , tippyIndex ) ;
238
+ createTippy ( this , {
239
+ content : $menu [ 0 ] ,
240
+ role : 'menu' ,
241
+ theme : 'menu' ,
242
+ trigger : 'click' ,
243
+ placement : 'bottom' ,
244
+ interactive : true ,
245
+ hideOnClick : true ,
246
+ } ) ;
247
+ } ) ;
248
+ }
Original file line number Diff line number Diff line change @@ -7,8 +7,15 @@ export function initUnicodeEscapeButton() {
7
7
8
8
e . preventDefault ( ) ;
9
9
10
- const fileContent = btn . closest ( '.file-content, .non-diff-file-content' ) ;
10
+ let fileContent = btn . closest ( '.file-content, .non-diff-file-content' ) ;
11
+ if ( ! fileContent ) {
12
+ const tippyTarget = btn . closest ( '.tippy-target' ) ;
13
+ if ( tippyTarget ) {
14
+ fileContent = document . querySelectorAll ( `[data-diff-file-menu-tippy-target-id="${ tippyTarget . getAttribute ( 'data-diff-file-menu-tippy-id' ) } "]` ) [ 0 ] . closest ( '.file-content, .non-diff-file-content' ) ;
15
+ }
16
+ }
11
17
const fileView = fileContent ?. querySelectorAll ( '.file-code, .file-view' ) ;
18
+ if ( ! fileView ) return ;
12
19
if ( btn . matches ( '.escape-button' ) ) {
13
20
for ( const el of fileView ) el . classList . add ( 'unicode-escaped' ) ;
14
21
hideElem ( btn ) ;
Original file line number Diff line number Diff line change @@ -42,7 +42,7 @@ import {initSshKeyFormParser} from './features/sshkey-helper.ts';
42
42
import { initUserSettings } from './features/user-settings.ts' ;
43
43
import { initRepoActivityTopAuthorsChart , initRepoArchiveLinks } from './features/repo-common.ts' ;
44
44
import { initRepoMigrationStatusChecker } from './features/repo-migrate.ts' ;
45
- import { initRepoDiffView } from './features/repo-diff.ts' ;
45
+ import { initRepoDiffView , initRepoDiffFileMenu } from './features/repo-diff.ts' ;
46
46
import { initOrgTeamSearchRepoBox , initOrgTeamSettings } from './features/org-team.ts' ;
47
47
import { initUserAuthWebAuthn , initUserAuthWebAuthnRegister } from './features/user-auth-webauthn.ts' ;
48
48
import { initRepoRelease , initRepoReleaseNew } from './features/repo-release.ts' ;
@@ -212,6 +212,7 @@ onDomReady(() => {
212
212
initUserAuthWebAuthnRegister ,
213
213
initUserSettings ,
214
214
initRepoDiffView ,
215
+ initRepoDiffFileMenu ,
215
216
initPdfViewer ,
216
217
initScopedAccessTokenCategories ,
217
218
initColorPickers ,
You can’t perform that action at this time.
0 commit comments