mediawiki-skins-MinervaNeue/resources/skins.minerva.scripts/watchstar.js
jdlrobson bf8d325388 Use core watchstar code
Apply the mediawiki core watchstar to the
Minerva skin. Note, watchstars in search and other locations will
continue to be provided by the MobileFrontend library (see
follow up patch I7b748dc87089389400b0035c62a3b9a00c2e43f9)

Bug: T234970
Change-Id: I11bbe976412b50dba76a55f37887e4c9235d0be1
2019-10-15 15:33:25 -07:00

17 lines
527 B
JavaScript

var WATCHED_CLASS = 'mw-ui-icon-wikimedia-unStar-progressive',
UNWATCHED_CLASS = 'mw-ui-icon-wikimedia-star-base20';
/**
* Tweaks the global watchstar handler in core to use the correct classes for Minerva.
* @param {jQuery.Object} $icon
*/
module.exports = function init( $icon ) {
$icon.on( 'watchpage.mw', function ( _ev, action ) {
$( this ).find( 'a' ).removeClass(
[ WATCHED_CLASS, 'watched', UNWATCHED_CLASS ]
).addClass(
action === 'watch' ? [ WATCHED_CLASS, 'watched' ] : UNWATCHED_CLASS
);
} );
};