@@ -504,24 +504,16 @@ const renderPopup = function() {
504
504
// Use tooltip for ARIA purpose.
505
505
506
506
const renderTooltips = function ( selector ) {
507
- for ( const entry of tooltipTargetSelectors ) {
508
- if ( selector !== undefined && entry [ 0 ] !== selector ) { continue ; }
507
+ for ( const [ key , details ] of tooltipTargetSelectors ) {
508
+ if ( selector !== undefined && key !== selector ) { continue ; }
509
+ const elem = uDom . nodeFromSelector ( key ) ;
510
+ if ( elem . hasAttribute ( 'title' ) === false ) { continue ; }
509
511
const text = vAPI . i18n (
510
- entry [ 1 ] . i18n +
511
- ( uDom . nodeFromSelector ( entry [ 1 ] . state ) === null ? '1' : '2' )
512
+ details . i18n +
513
+ ( uDom . nodeFromSelector ( details . state ) === null ? '1' : '2' )
512
514
) ;
513
- const elem = uDom . nodeFromSelector ( entry [ 0 ] ) ;
514
515
elem . setAttribute ( 'aria-label' , text ) ;
515
- const tip = elem . querySelector ( '.tip' ) ;
516
- if ( tip !== null ) {
517
- tip . textContent = text ;
518
- } else {
519
- elem . setAttribute ( 'data-tip' , text ) ;
520
- }
521
- if ( tip === null && selector !== undefined ) {
522
- uDom . nodeFromId ( 'tooltip' ) . textContent =
523
- elem . getAttribute ( 'data-tip' ) ;
524
- }
516
+ elem . setAttribute ( 'title' , text ) ;
525
517
}
526
518
} ;
527
519
@@ -533,6 +525,13 @@ const tooltipTargetSelectors = new Map([
533
525
i18n : 'popupPowerSwitchInfo' ,
534
526
}
535
527
] ,
528
+ [
529
+ '#no-popups' ,
530
+ {
531
+ state : '#no-popups.on' ,
532
+ i18n : 'popupTipNoPopups'
533
+ }
534
+ ] ,
536
535
[
537
536
'#no-large-media' ,
538
537
{
@@ -585,13 +584,17 @@ let renderOnce = function() {
585
584
586
585
// https://github.com/uBlockOrigin/uBlock-issues/issues/22
587
586
if ( popupData . advancedUserEnabled !== true ) {
588
- uDom ( '#firewall [data-i18n-tip ][data-src]' ) . removeAttr ( 'data-tip ' ) ;
587
+ uDom ( '#firewall [title ][data-src]' ) . removeAttr ( 'title ' ) ;
589
588
}
590
589
591
- body . classList . toggle (
592
- 'no-tooltips' ,
593
- popupData . tooltipsDisabled === true
594
- ) ;
590
+ if ( popupData . uiPopupConfig !== undefined ) {
591
+ document . body . setAttribute ( 'data-ui' , popupData . uiPopupConfig ) ;
592
+ }
593
+
594
+ body . classList . toggle ( 'no-tooltips' , popupData . tooltipsDisabled === true ) ;
595
+ if ( popupData . tooltipsDisabled === true ) {
596
+ uDom ( '[title]' ) . removeAttr ( 'title' ) ;
597
+ }
595
598
} ;
596
599
597
600
/******************************************************************************/
@@ -986,7 +989,7 @@ const toggleHostnameSwitch = async function(ev) {
986
989
return ;
987
990
}
988
991
target . classList . toggle ( 'on' ) ;
989
- renderTooltips ( '#' + switchName ) ;
992
+ renderTooltips ( `# ${ switchName } ` ) ;
990
993
991
994
const response = await messaging . send ( 'popupPanel' , {
992
995
what : 'toggleHostnameSwitch' ,
0 commit comments