mediawiki-skins-Vector/resources/skins.vector.js/watchstar.js
Jon Robson 3e40a753b1 Drop unnecessary watchstar icon classes on toggle
These interfere with the toggle on certain pages
see T317710#8389485

Bug: T322673
Change-Id: I3e40cc0c5701a3c055ced1c74e9cac1b369586a3
2022-11-14 13:54:16 -08:00

29 lines
893 B
JavaScript

module.exports = function () {
mw.hook( 'wikipage.watchlistChange' ).add(
function ( /** @type {boolean} */ isWatched, /** @type {string} */ expiry ) {
var watchElement = document.querySelectorAll( '#ca-watch a, #ca-unwatch a' )[ 0 ];
if ( !watchElement ) {
return;
}
watchElement.classList.remove(
// Vector attaches two icon classes to the element.
// Remove the mw-ui-icon one rather than managing both.
'mw-ui-icon-star',
'mw-ui-icon-unStar',
'mw-ui-icon-wikimedia-unStar',
'mw-ui-icon-wikimedia-star',
'mw-ui-icon-wikimedia-halfStar'
);
if ( isWatched ) {
if ( expiry === 'infinity' ) {
watchElement.classList.add( 'mw-ui-icon-wikimedia-unStar' );
} else {
watchElement.classList.add( 'mw-ui-icon-wikimedia-halfStar' );
}
} else {
watchElement.classList.add( 'mw-ui-icon-wikimedia-star' );
}
}
);
};