1
1
import { createTippy } from '../modules/tippy.ts' ;
2
2
import { toggleElem } from '../utils/dom.ts' ;
3
3
import { registerGlobalEventFunc , registerGlobalInitFunc } from '../modules/observer.ts' ;
4
- import $ from 'jquery' ;
5
4
6
5
export function initRepoEllipsisButton ( ) {
7
6
registerGlobalEventFunc ( 'click' , 'onRepoEllipsisButtonClick' , async ( el : HTMLInputElement , e : Event ) => {
@@ -26,24 +25,28 @@ export function initCommitStatuses() {
26
25
} ) ;
27
26
}
28
27
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]' ) ;
32
30
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 ( / h i s t o r y _ f o l l o w _ r e n a m e = ( t r u e | f a l s e ) & * / 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 ;
45
33
}
34
+ checkbox . checked = location . toString ( ) . includes ( 'history_follow_rename=true' ) ;
35
+
36
+ checkbox . addEventListener ( 'change' , ( ) => {
37
+ let url = location . toString ( ) ;
46
38
47
- url += `history_follow_rename=${ checked } ` ;
48
- window . location . href = url ;
49
- } ) ;
39
+ url = url . replaceAll ( / h i s t o r y _ f o l l o w _ r e n a m e = ( t r u e | f a l s e ) & * / 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
+ }
0 commit comments