11import { createTippy } from '../modules/tippy.ts' ;
22import { toggleElem } from '../utils/dom.ts' ;
33import { registerGlobalEventFunc , registerGlobalInitFunc } from '../modules/observer.ts' ;
4- import $ from 'jquery' ;
54
65export 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 ( / 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 ;
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 ( / 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