2022-09-15 00:31:29 +00:00
|
|
|
/**
|
|
|
|
* Upgrades Echo for icon consistency.
|
|
|
|
* Undos work inside Echo to replace our button.
|
|
|
|
*/
|
|
|
|
function init() {
|
|
|
|
if ( document.querySelectorAll( '#pt-notifications-alert a, #pt-notifications-notice a' ).length !== 2 ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
mw.hook( 'ext.echo.NotificationBadgeWidget.onInitialize' ).add( function ( badge ) {
|
2023-04-12 22:37:36 +00:00
|
|
|
const element = badge.$element[ 0 ];
|
|
|
|
element.classList.add( 'mw-list-item' );
|
2023-04-27 20:39:40 +00:00
|
|
|
const anchor = /** @type {HTMLElement} */ ( element.querySelector( 'a' ) );
|
|
|
|
anchor.classList.add(
|
|
|
|
'cdx-button',
|
|
|
|
'cdx-button--weight-quiet',
|
|
|
|
'cdx-button--icon-only',
|
|
|
|
'cdx-button--fake-button',
|
|
|
|
'cdx-button--fake-button--enabled'
|
|
|
|
);
|
|
|
|
// Icon classes shouldn't go on the same element as button classes
|
|
|
|
// However this cant be avoided due to Echo button's implementation
|
|
|
|
// which directly sets the contents of the anchor element every update
|
|
|
|
// which would clear out any icon children that we define
|
2023-04-12 22:37:36 +00:00
|
|
|
if ( element.id === 'pt-notifications-alert' ) {
|
2023-04-27 20:39:40 +00:00
|
|
|
anchor.classList.add( 'vector-icon', 'mw-ui-icon-wikimedia-bell' );
|
2022-09-15 00:31:29 +00:00
|
|
|
}
|
2023-04-12 22:37:36 +00:00
|
|
|
if ( element.id === 'pt-notifications-notice' ) {
|
2023-04-27 20:39:40 +00:00
|
|
|
anchor.classList.add( 'vector-icon', 'mw-ui-icon-wikimedia-tray' );
|
2022-09-15 00:31:29 +00:00
|
|
|
}
|
2023-04-27 20:39:40 +00:00
|
|
|
anchor.classList.remove( 'oo-ui-icon-bell', 'oo-ui-icon-tray' );
|
2022-09-15 00:31:29 +00:00
|
|
|
} );
|
|
|
|
}
|
2023-04-27 20:39:40 +00:00
|
|
|
|
2022-09-15 00:31:29 +00:00
|
|
|
module.exports = init;
|