mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/Vector.git
synced 2024-12-01 18:57:04 +00:00
d8bcb73647
Depends-on: Ibd762c810e1d89047e39ce3af792b43689bf11e3 Bug: T335909 Change-Id: I5b42780416b466cc3fc33d29220aef2979ac3239
31 lines
899 B
JavaScript
31 lines
899 B
JavaScript
module.exports = function () {
|
|
mw.hook( 'wikipage.watchlistChange' ).add(
|
|
function ( /** @type {boolean} */ isWatched, /** @type {string} */ expiry ) {
|
|
const watchIcon = document.querySelectorAll( '#ca-watch .mw-ui-icon, #ca-unwatch .mw-ui-icon' )[ 0 ];
|
|
if ( !watchIcon ) {
|
|
return;
|
|
}
|
|
|
|
watchIcon.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' ) {
|
|
watchIcon.classList.add( 'mw-ui-icon-wikimedia-unStar' );
|
|
} else {
|
|
watchIcon.classList.add( 'mw-ui-icon-wikimedia-halfStar' );
|
|
}
|
|
} else {
|
|
watchIcon.classList.add( 'mw-ui-icon-wikimedia-star' );
|
|
}
|
|
}
|
|
);
|
|
};
|