Interested Article - Gadget-common-special-watchlist.js


- 2020-07-05
- 1

После сохранения или недавних изменений очистите кэш браузера .
/* Не удаляйте проверку на название спецстраницы */
mw.loader.using( 'mediawiki.storage', () => {
if ( mw.config.get( 'wgCanonicalSpecialPageName' ) !== 'Watchlist' ) {
return;
}
$( '.watchlist-msg' ).each( function() {
if ( !this.id ) return;
var hideId = 'ruwiki-wlhide-' + this.id;
if ( mw.storage.get( hideId ) ) {
this.classList.add( 'watchlist-msg-hidden' );
} else {
var toggle = document.createElement( 'a' );
toggle.className = 'watchlist-msg-close';
toggle.setAttribute( 'href', '#' );
toggle.setAttribute( 'role', 'button' );
toggle.setAttribute( 'aria-label', 'Скрыть на неделю' );
toggle.setAttribute( 'title', 'Скрыть сообщение на неделю или до появления новых событий' );
$( toggle )
.on( 'click', function ( e ) {
e.preventDefault();
// 7 * 24 * 60 * 60 (7 дней)
mw.storage.set( hideId, 1, 604800 );
var $parent = $( this ).parent();
$parent.addClass( 'watchlist-msg-hidden' );
$parent.parent().focus();
} )
.on( 'keydown', function ( e ) {
if ( [ 'Space', 'Enter' ].includes( e.code ) ) {
e.preventDefault();
$( this ).click();
}
} );
this.insertBefore( toggle, this.firstChild );
this.classList.add( 'watchlist-msg-hideable' );
$( this ).parent().attr( 'tabindex', '-1' );
}
} );
mw.hook( 'structuredChangeFilters.ui.initialized' ).add(function () {
$( '.watchlist-wrapper' ).prependTo( $( '.mw-rcfilters-ui-watchlistTopSectionWidget-editWatchlistButton' ) );
$( '.mw-rcfilters-ui-watchlistTopSectionWidget-editWatchlistButton' )
.removeClass( 'mw-rcfilters-ui-watchlistTopSectionWidget-editWatchlistButton' )
.find( '.oo-ui-buttonWidget' )
.wrap( '<div>' )
.parent()
.addClass( 'mw-rcfilters-ui-watchlistTopSectionWidget-editWatchlistButton' )
.appendTo( '.mw-rcfilters-ui-watchlistTopSectionWidget-watchlistDetails' );
} );
} );

- 2020-07-05
- 1