mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/Vector.git
synced 2024-12-12 16:05:17 +00:00
87dd101a69
* Upgrade @wikimedia/types-wikimedia to allow us to drop several @ts-ignores * Merges eslint rules now that ES6 is default everywhere * Runs autofix command * Fixes various prefer-const errors Change-Id: Iee5bcb93f10a76d80dbeec813f6387c13438263e
29 lines
895 B
JavaScript
29 lines
895 B
JavaScript
module.exports = function () {
|
|
mw.hook( 'wikipage.watchlistChange' ).add(
|
|
function ( /** @type {boolean} */ isWatched, /** @type {string} */ expiry ) {
|
|
const 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' );
|
|
}
|
|
}
|
|
);
|
|
};
|