MediaWiki:Common.js: Difference between revisions
Content added Content deleted
Emmateapot (talk | contribs) mNo edit summary |
Emmateapot (talk | contribs) No edit summary Tag: Reverted |
||
Line 12: | Line 12: | ||
$('#catlinks').children().not('#mw-normal-catlinks').hide(); |
$('#catlinks').children().not('#mw-normal-catlinks').hide(); |
||
} |
} |
||
/* Adding Spoilers extension JS because the spoilers extension - https://github.com/Telshin/Spoilers - doesn't seem to natively support MobileFrontend */ |
|||
( function ( mw, $ ) { |
|||
'use strict'; |
|||
mw.Spoilers = function () { |
|||
var $spoilerButton = $( '.spoilers-button' ); |
|||
$spoilerButton.each( function () { |
|||
var $parent = $( this ).parent(); |
|||
$parent.children( '.spoilers-button' ).text( $parent.data( 'showtext' ) || mw.msg( 'spoilers_show_default' ) ); |
|||
$parent.data( 'shown', false ); |
|||
} ); |
|||
$spoilerButton.click( function () { |
|||
var $parent = $( this ).parent(), |
|||
shown = $parent.data( 'shown' ), |
|||
showMsg = $parent.data( 'showtext' ) || mw.msg( 'spoilers_show_default' ), |
|||
hideMsg = $parent.data( 'hidetext' ) || mw.msg( 'spoilers_hide_default' ); |
|||
$parent.data( 'shown', !shown ); |
|||
$parent.children( '.spoilers-button' ).text( shown ? showMsg : hideMsg ); |
|||
$parent.children( '.spoilers-body' ).slideToggle(); |
|||
} ); |
|||
}; |
|||
$( function () { |
|||
mw.Spoilers(); |
|||
} ); |
|||
}( mediaWiki, jQuery ) ); |
Revision as of 00:23, 24 February 2022
/* Any JavaScript here will be loaded for all users on every page load. */
if (mw.config.get('skin') == 'timeless') {
$('#catlinks-sidebar').find(".mw-portlet-body").find("ul").wrap('<details class=\'catlinks-details\'></details>')
.closest('details')
.prepend('<summary class=\'catlinks-details-summary\'>Show full category list</summary>');
$('#mw-normal-catlinks').find("ul").wrap('<details class=\'catlinks-details\'></details>')
.closest('details')
.prepend('<summary class=\'catlinks-details-summary\'>Show full category list</summary>');
$('#catlinks').children().not('#mw-normal-catlinks').hide();
}
/* Adding Spoilers extension JS because the spoilers extension - https://github.com/Telshin/Spoilers - doesn't seem to natively support MobileFrontend */
( function ( mw, $ ) {
'use strict';
mw.Spoilers = function () {
var $spoilerButton = $( '.spoilers-button' );
$spoilerButton.each( function () {
var $parent = $( this ).parent();
$parent.children( '.spoilers-button' ).text( $parent.data( 'showtext' ) || mw.msg( 'spoilers_show_default' ) );
$parent.data( 'shown', false );
} );
$spoilerButton.click( function () {
var $parent = $( this ).parent(),
shown = $parent.data( 'shown' ),
showMsg = $parent.data( 'showtext' ) || mw.msg( 'spoilers_show_default' ),
hideMsg = $parent.data( 'hidetext' ) || mw.msg( 'spoilers_hide_default' );
$parent.data( 'shown', !shown );
$parent.children( '.spoilers-button' ).text( shown ? showMsg : hideMsg );
$parent.children( '.spoilers-body' ).slideToggle();
} );
};
$( function () {
mw.Spoilers();
} );
}( mediaWiki, jQuery ) );