MediaWiki:Mobile.js: Difference between revisions
Content added Content deleted
Emmateapot (talk | contribs) (Adding Spoilers extension JS because the spoilers extension - https://github.com/Telshin/Spoilers - doesn't seem to natively support MobileFrontend) Tag: Reverted |
Emmateapot (talk | contribs) (Replaced content with "→All JavaScript here will be loaded for users of the mobile site: mw.loader.using('mobile.site.styles')") Tags: Replaced Manual revert |
||
Line 1: | Line 1: | ||
/* All JavaScript here will be loaded for users of the mobile site */ |
/* All JavaScript here will be loaded for users of the mobile site */ |
||
mw.loader.using('mobile.site.styles') |
mw.loader.using('mobile.site.styles') |
||
/* 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 ) ); |