mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/MinervaNeue
synced 2024-11-15 02:13:49 +00:00
bcdfd66fa6
Depends-on: I88af8585e8fc75f77ebef867d267199aeb2c6592 Change-Id: I859c9d763e77bb06b5109d419fb581258f3bd665
49 lines
1.2 KiB
JavaScript
49 lines
1.2 KiB
JavaScript
var watchstar = mw.loader.require( 'mediawiki.page.watch.ajax' ).watchstar;
|
|
|
|
( function () {
|
|
|
|
var WATCHED_CLASS = [ 'watched', 'mw-ui-icon-wikimedia-unStar-progressive' ],
|
|
TEMP_WATCHED_CLASS = [ 'temp-watched', 'mw-ui-icon-wikimedia-halfStar-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
|
|
*/
|
|
function init( $icon ) {
|
|
var $watchlink = $icon.find( 'a' );
|
|
watchstar( $watchlink, mw.config.get( 'wgRelevantPageName' ), toggleClasses );
|
|
}
|
|
|
|
/**
|
|
*
|
|
* @param {jQuery.Object} $link
|
|
* @param {boolean} isWatched
|
|
* @param {string} expiry
|
|
*/
|
|
function toggleClasses( $link, isWatched, expiry ) {
|
|
$link.removeClass(
|
|
[].concat( WATCHED_CLASS, TEMP_WATCHED_CLASS, UNWATCHED_CLASS )
|
|
).addClass( function () {
|
|
var classes = UNWATCHED_CLASS;
|
|
if ( isWatched ) {
|
|
if ( expiry !== null && expiry !== undefined && expiry !== 'infinity' ) {
|
|
classes = TEMP_WATCHED_CLASS;
|
|
} else {
|
|
classes = WATCHED_CLASS;
|
|
}
|
|
}
|
|
return classes;
|
|
} );
|
|
}
|
|
|
|
module.exports = {
|
|
init: init,
|
|
test: {
|
|
toggleClasses: toggleClasses
|
|
}
|
|
};
|
|
|
|
}() );
|