@@ -38,6 +38,8 @@ import componentCSS from './recommender-view.css?inline';
38
38
import iconHIndex from '../../images/icon-hindex-c.svg?raw' ;
39
39
import iconFile from '../../images/icon-file-c.svg?raw' ;
40
40
import iconCiteTimes from '../../images/icon-cite-times-c.svg?raw' ;
41
+ import iconExternal from '../../images/icon-external-link.svg?raw' ;
42
+ import iconClick from '../../images/icon-click.svg?raw' ;
41
43
42
44
const DEV_MODE = true ;
43
45
const MAX_RECOMMENDER_NUM = 500 ;
@@ -84,6 +86,8 @@ interface SliderRange {
84
86
initialValue : number ;
85
87
}
86
88
89
+ let descriptionTooltipTimer : number | null = null ;
90
+
87
91
/**
88
92
* Recommender view element.
89
93
*/
@@ -181,12 +185,18 @@ export class RecRecRecommenderView extends LitElement {
181
185
@query ( '#paper-overlay' )
182
186
paperOverlayElement : HTMLElement | undefined ;
183
187
188
+ @query ( '#description-overlay' )
189
+ descriptionOverlayElement : HTMLElement | undefined ;
190
+
184
191
@state ( )
185
192
overlayPaperCounts : [ string , number ] [ ] ;
186
193
187
194
@state ( )
188
195
overlayPaperCountsType : 'citeTimes' | 'paperCount' = 'citeTimes' ;
189
196
197
+ @state ( )
198
+ overlayDescriptionType : 'citeTimes' | 'paperCount' | 'hIndex' = 'citeTimes' ;
199
+
190
200
curClickedCiteTimeAuthorID : string | null = null ;
191
201
overlayCleanup = ( ) => { } ;
192
202
@@ -514,7 +524,7 @@ export class RecRecRecommenderView extends LitElement {
514
524
let maxHIndex = - Infinity ;
515
525
516
526
for ( const [ i , chunk ] of authorIDChunks . entries ( ) ) {
517
- console . log ( `Chunk: ${ i } ` ) ;
527
+ // console.log(`Chunk: ${i}`);
518
528
const startTime = performance . now ( ) ;
519
529
520
530
let retry = 3 ;
@@ -759,6 +769,9 @@ export class RecRecRecommenderView extends LitElement {
759
769
return ;
760
770
}
761
771
772
+ // Hide the description tooltip
773
+ this . citeTimeButtonMouseLeft ( e ) ;
774
+
762
775
if ( this . curClickedCiteTimeAuthorID === recommender . authorID ) {
763
776
// This overlay is already shown. We hide it if the user clicks the button (again)
764
777
this . paperOverlayElement . classList . add ( 'hidden' ) ;
@@ -801,6 +814,57 @@ export class RecRecRecommenderView extends LitElement {
801
814
this . paperOverlayElement . classList . remove ( 'hidden' ) ;
802
815
}
803
816
817
+ citeTimeButtonMouseEntered (
818
+ e : MouseEvent ,
819
+ type : 'paperCount' | 'citeTimes' | 'hIndex'
820
+ ) {
821
+ e . stopPropagation ( ) ;
822
+ e . preventDefault ( ) ;
823
+
824
+ if ( ! this . descriptionOverlayElement ) {
825
+ console . error ( 'descriptionOverlayElement are not initialized yet.' ) ;
826
+ return ;
827
+ }
828
+
829
+ const anchor = e . currentTarget as HTMLElement ;
830
+
831
+ if ( descriptionTooltipTimer ) {
832
+ clearTimeout ( descriptionTooltipTimer ) ;
833
+ }
834
+
835
+ descriptionTooltipTimer = setTimeout ( async ( ) => {
836
+ this . overlayDescriptionType = type ;
837
+ await this . updateComplete ;
838
+
839
+ updatePopperOverlay (
840
+ this . descriptionOverlayElement ! ,
841
+ anchor ,
842
+ 'top' ,
843
+ true ,
844
+ 10 ,
845
+ 300
846
+ ) ;
847
+
848
+ this . descriptionOverlayElement ! . classList . remove ( 'hidden' ) ;
849
+ } , 500 ) ;
850
+ }
851
+
852
+ citeTimeButtonMouseLeft ( e : MouseEvent ) {
853
+ e . stopPropagation ( ) ;
854
+ e . preventDefault ( ) ;
855
+
856
+ if ( ! this . descriptionOverlayElement ) {
857
+ console . error ( 'descriptionOverlayElement are not initialized yet.' ) ;
858
+ return ;
859
+ }
860
+
861
+ if ( descriptionTooltipTimer ) {
862
+ clearTimeout ( descriptionTooltipTimer ) ;
863
+ }
864
+
865
+ this . descriptionOverlayElement . classList . add ( 'hidden' ) ;
866
+ }
867
+
804
868
citeTimeBlurred ( ) {
805
869
if ( ! this . paperOverlayElement ) {
806
870
console . error ( 'paperOverlayElement are not initialized yet.' ) ;
@@ -914,6 +978,11 @@ export class RecRecRecommenderView extends LitElement {
914
978
tabindex = "0"
915
979
@click = ${ ( e : MouseEvent ) =>
916
980
this . citeTimeButtonClicked ( e , recommender , 'paperCount' ) }
981
+ @mouseenter = ${ ( e : MouseEvent ) =>
982
+ this . citeTimeButtonMouseEntered ( e , 'paperCount' ) }
983
+ @mouseleave = ${ ( e : MouseEvent ) => {
984
+ this . citeTimeButtonMouseLeft ( e ) ;
985
+ } }
917
986
@touchstart = ${ ( e : TouchEvent ) => {
918
987
e . stopPropagation ( ) ;
919
988
} }
@@ -928,6 +997,11 @@ export class RecRecRecommenderView extends LitElement {
928
997
tabindex = "0"
929
998
@click = ${ ( e : MouseEvent ) =>
930
999
this . citeTimeButtonClicked ( e , recommender , 'citeTimes' ) }
1000
+ @mouseenter = ${ ( e : MouseEvent ) =>
1001
+ this . citeTimeButtonMouseEntered ( e , 'citeTimes' ) }
1002
+ @mouseleave = ${ ( e : MouseEvent ) => {
1003
+ this . citeTimeButtonMouseLeft ( e ) ;
1004
+ } }
931
1005
@touchstart = ${ ( e : TouchEvent ) => {
932
1006
e . stopPropagation ( ) ;
933
1007
} }
@@ -940,6 +1014,11 @@ export class RecRecRecommenderView extends LitElement {
940
1014
<a
941
1015
class= "info-block info-icon"
942
1016
href = "${ recommender . url ! } "
1017
+ @mouseenter = ${ ( e : MouseEvent ) =>
1018
+ this . citeTimeButtonMouseEntered ( e , 'hIndex' ) }
1019
+ @mouseleave = ${ ( e : MouseEvent ) => {
1020
+ this . citeTimeButtonMouseLeft ( e ) ;
1021
+ } }
943
1022
target= "_blank"
944
1023
>
945
1024
<span class= "svg-icon" > ${ unsafeHTML ( iconHIndex ) } </ span>
@@ -1104,6 +1183,28 @@ export class RecRecRecommenderView extends LitElement {
1104
1183
</ div>
1105
1184
` ;
1106
1185
1186
+ // Compile the description overlay
1187
+ let description = 'Papers by this recommender citing my work' ;
1188
+ let descriptionIcon = html `<span class= "svg-icon"
1189
+ > ${ unsafeHTML ( iconClick ) } </ span
1190
+ > ` ;
1191
+
1192
+ if ( this . overlayDescriptionType === 'citeTimes' ) {
1193
+ description = 'Total citations by this recommender' ;
1194
+ } else if ( this . overlayDescriptionType === 'hIndex' ) {
1195
+ description = 'H-Index' ;
1196
+ descriptionIcon = html `<span class= "svg-icon external-icon"
1197
+ > ${ unsafeHTML ( iconExternal ) } </ span
1198
+ > ` ;
1199
+ }
1200
+
1201
+ const descriptionOverlay = html `
1202
+ <div class= "description" >
1203
+ <span> ${ description } </ span>
1204
+ ${ descriptionIcon }
1205
+ </ div>
1206
+ ` ;
1207
+
1107
1208
return html `
1108
1209
<div class= "recommender-view" >
1109
1210
${ progressRing } ${ MOBILE_MODE ? controlPopBar : controlSideBar }
@@ -1149,6 +1250,15 @@ export class RecRecRecommenderView extends LitElement {
1149
1250
</ div>
1150
1251
<div class= "popper-arrow" > </ div>
1151
1252
</ div>
1253
+
1254
+ <div
1255
+ id= "description-overlay"
1256
+ class = "popper- to oltip hidden"
1257
+ role= "to oltip"
1258
+ >
1259
+ <div class= "popper-content" > ${ descriptionOverlay } </ div>
1260
+ <div class= "popper-arrow" > </ div>
1261
+ </ div>
1152
1262
</ div>
1153
1263
` ;
1154
1264
}
0 commit comments