MediaWiki:Common.js: Difference between revisions
Appearance
No edit summary |
No edit summary |
||
| Line 2: | Line 2: | ||
mw.hook( 'wikipage.content' ).add( function ( $content ) { | mw.hook( 'wikipage.content' ).add( function ( $content ) { | ||
$content.find( '.commentary-toggle' ).on( 'click', function () { | $content.find( '.commentary-toggle' ).on( 'click', function () { | ||
var | var verseId = $( this ).attr( 'data-verse' ); | ||
var $ | var $block = $( '#' + CSS.escape( verseId ) ); | ||
var $bodies = $block.find( '.commentary-body' ); | |||
var isHidden = $bodies.first().hasClass( 'commentary-hidden' ); | |||
$bodies.toggleClass( 'commentary-hidden', !isHidden ); | |||
$( this ).toggleClass( 'commentary-toggle-active', isHidden ); | |||
} ); | } ); | ||
} ); | } ); | ||
Revision as of 17:02, 24 March 2026
/* Any JavaScript here will be loaded for all users on every page load. */
mw.hook( 'wikipage.content' ).add( function ( $content ) {
$content.find( '.commentary-toggle' ).on( 'click', function () {
var verseId = $( this ).attr( 'data-verse' );
var $block = $( '#' + CSS.escape( verseId ) );
var $bodies = $block.find( '.commentary-body' );
var isHidden = $bodies.first().hasClass( 'commentary-hidden' );
$bodies.toggleClass( 'commentary-hidden', !isHidden );
$( this ).toggleClass( 'commentary-toggle-active', isHidden );
} );
} );