mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/MinervaNeue
synced 2024-11-16 18:58:45 +00:00
b7b4e4b01f
Legacy icons shouldn't have the minerva-icon class as this is meant to be reserved for Icon template (Codex icons) Bug: T342908 Change-Id: I63556fe42c8650bc5f0d6e5a0c5328b3f29d75f3
53 lines
1.3 KiB
JavaScript
53 lines
1.3 KiB
JavaScript
var watchstar = mw.loader.require( 'mediawiki.page.watch.ajax' ).watchstar;
|
|
|
|
( function () {
|
|
|
|
var
|
|
WATCHED_ICON_CLASS = 'mw-ui-icon-wikimedia-unStar-progressive',
|
|
TEMP_WATCHED_ICON_CLASS = 'mw-ui-icon-wikimedia-halfStar-progressive',
|
|
UNWATCHED_ICON_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 ) {
|
|
var $icon = $link.find( '.minerva-icon, .mw-ui-icon' );
|
|
$icon.removeClass( [ WATCHED_ICON_CLASS, UNWATCHED_ICON_CLASS, TEMP_WATCHED_ICON_CLASS ] )
|
|
.addClass( function () {
|
|
var classes = UNWATCHED_ICON_CLASS;
|
|
if ( isWatched ) {
|
|
if ( expiry !== null && expiry !== undefined && expiry !== 'infinity' ) {
|
|
classes = TEMP_WATCHED_ICON_CLASS;
|
|
} else {
|
|
classes = WATCHED_ICON_CLASS;
|
|
}
|
|
}
|
|
return classes;
|
|
} );
|
|
}
|
|
|
|
module.exports = {
|
|
init: init,
|
|
test: {
|
|
toggleClasses,
|
|
TEMP_WATCHED_ICON_CLASS,
|
|
WATCHED_ICON_CLASS,
|
|
UNWATCHED_ICON_CLASS
|
|
}
|
|
};
|
|
|
|
}() );
|