mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/MinervaNeue
synced 2024-12-01 09:16:34 +00:00
0fc40f71c5
MobileFrontend extension is currently tracking watched/temp-watch css classes and applying animations to the "watch" event. This patch starts adding temp-watched accordingly now that the expiry is part of the event's data. Note: this patch does not fix the lack of animation when transitioning from half-star to empty-star or on page-load when the page is temporarily watched but it fixes the awkward angle the half-star icon was left in when transitioning from a full-star to a half-star Bug: T262862 Change-Id: I1c8cb9c33cda76b87b6a9f15e408d88edbf61d93
48 lines
1.1 KiB
JavaScript
48 lines
1.1 KiB
JavaScript
( 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 ) {
|
|
$icon.on( 'watchpage.mw', function ( _ev, action, expiry ) {
|
|
toggleClasses( $( this ).find( 'a' ), action, expiry );
|
|
} );
|
|
}
|
|
|
|
/**
|
|
*
|
|
* @param {jQuery.Object} $elem
|
|
* @param {string} action
|
|
* @param {string} expiry
|
|
*/
|
|
function toggleClasses( $elem, action, expiry ) {
|
|
$elem.removeClass(
|
|
[].concat( WATCHED_CLASS, TEMP_WATCHED_CLASS, UNWATCHED_CLASS )
|
|
).addClass( function () {
|
|
var classes = UNWATCHED_CLASS;
|
|
if ( action === 'watch' ) {
|
|
if ( expiry !== null && expiry !== undefined ) {
|
|
classes = TEMP_WATCHED_CLASS;
|
|
} else {
|
|
classes = WATCHED_CLASS;
|
|
}
|
|
}
|
|
return classes;
|
|
} );
|
|
}
|
|
|
|
module.exports = {
|
|
init: init,
|
|
test: {
|
|
toggleClasses: toggleClasses
|
|
}
|
|
};
|
|
|
|
}() );
|