File tree Expand file tree Collapse file tree 2 files changed +14
-7
lines changed Expand file tree Collapse file tree 2 files changed +14
-7
lines changed Original file line number Diff line number Diff line change 11$ ( document ) . ready ( start ) ;
22
3+ var isCommit = false ;
4+
35$ ( window ) . scroll ( ( ) => {
6+ if ( isCommit ) return ;
47 if ( $ ( '.is-stuck' ) . length ) {
58 $ ( '.gct-file-tree' ) . addClass ( 'gct-file-tree-fixed' ) ;
69 } else {
@@ -14,21 +17,25 @@ function start() {
1417 if ( location . origin + location . pathname != oldLocation ) {
1518 oldLocation = location . origin + location . pathname ;
1619
17- urlRegex = / ( h t t p | h t t p s ) : \/ \/ ( w w w \. ) ? g i t h u b \. c o m \/ [ - a - z A - Z 0 - 9 ] * \/ [ - a - z A - Z 0 - 9 ] * \/ p u l l \/ [ 0 - 9 ] * \/ ( f i l e s | c o m m i t s ) / ;
18- if ( location . href . match ( urlRegex ) ) { // show only on PR files page
20+ urlPullRegex = / ( h t t p | h t t p s ) : \/ \/ ( w w w \. ) ? g i t h u b \. c o m \/ [ - a - z A - Z 0 - 9 ] * \/ [ - a - z A - Z 0 - 9 ] * \/ p u l l \/ [ 0 - 9 ] * \/ ( f i l e s | c o m m i t s ) / ;
21+ urlCommitRegex = / ( h t t p | h t t p s ) : \/ \/ ( w w w \. ) ? g i t h u b \. c o m \/ [ - a - z A - Z 0 - 9 ] * \/ [ - a - z A - Z 0 - 9 ] * \/ c o m m i t / ;
22+
23+ isCommit = location . href . match ( urlCommitRegex ) ;
24+
25+ if ( location . href . match ( urlPullRegex ) || location . href . match ( urlCommitRegex ) ) { // show only on PR files page
1926 initialSetup ( ) ;
2027 }
2128 }
2229 } , 500 ) ;
2330}
2431
2532function initialSetup ( ) {
26- if ( $ ( '.js-diff-progressive-spinner' ) . length ) {
33+ if ( $ ( '.js-diff-progressive-spinner' ) . length || ! $ ( '#files' ) . length ) {
2734 setTimeout ( initialSetup , 100 ) ;
2835 return ;
2936 }
3037
31- injectCss ( ) ; // style.js
38+ injectCss ( isCommit ? 0 : 178 , isCommit ? 20 : 0 ) ; // style.js
3239 injectHTML ( ) ;
3340
3441 areDiffBlocksCollapsed ( ) ? $ ( '#collapseAll' ) . hide ( ) : $ ( '#expandAll' ) . hide ( ) ;
Original file line number Diff line number Diff line change 1- function injectCss ( ) {
1+ function injectCss ( offsetTop , offsetLeft ) {
22 $ ( '#gct-style' ) . remove ( ) ;
33 $ ( `<style type='text/css' id="gct-style">
44 #files {
@@ -17,9 +17,9 @@ function injectCss() {
1717
1818 .gct-file-tree {
1919 position: absolute;
20- top: ${ $ ( '#files' ) . offset ( ) . top - 178 } px;
20+ top: ${ $ ( '#files' ) . offset ( ) . top - offsetTop } px;
2121 background-color: #fff;
22- left: 0 ;
22+ left: ${ offsetLeft } px ;
2323 z-index: 28;
2424 width: 280px;
2525 border: 1px solid #ddd;
You can’t perform that action at this time.
0 commit comments