Difference between revisions of "MediaWiki:Common.js"
From Awesome Baozam
(13 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
( function ( mw, $ ) { | ( function ( mw, $ ) { | ||
'use strict'; | 'use strict'; | ||
− | |||
− | |||
mw.hook( 'wikipage.content' ).add( function ( $content ) { | mw.hook( 'wikipage.content' ).add( function ( $content ) { | ||
$content.find('.details' ).each( function() { | $content.find('.details' ).each( function() { | ||
− | $(this).slideUp( 'fast' ); | + | var d = $('<div>').addClass('reallist').html( $(this).html() ); |
+ | $(this).html("").append( '<h2 class=toctitle>Details <span class="toctoggle">[ <a href=# class=off>show</a> ]</span></h4>' ).append( d ); | ||
+ | d.slideUp( 'fast' ); | ||
+ | $(this).find( '.toctitle a' ).click( function(e) { | ||
+ | e.preventDefault(); | ||
+ | $(this).toggleClass('off').text( $(this).hasClass('off') ? mw.msg( 'showtoc' ) : mw.msg( 'hidetoc' ) ); | ||
+ | $(this).parents('.details').find('.reallist')[$(this).hasClass('off') ? 'slideUp' : 'slideDown']( 'fast' ); | ||
+ | } ); | ||
} ); | } ); | ||
} ); | } ); | ||
}( mediaWiki, jQuery ) ); | }( mediaWiki, jQuery ) ); |
Latest revision as of 11:56, 6 July 2016
( function ( mw, $ ) { 'use strict'; mw.hook( 'wikipage.content' ).add( function ( $content ) { $content.find('.details' ).each( function() { var d = $('<div>').addClass('reallist').html( $(this).html() ); $(this).html("").append( '<h2 class=toctitle>Details <span class="toctoggle">[ <a href=# class=off>show</a> ]</span></h4>' ).append( d ); d.slideUp( 'fast' ); $(this).find( '.toctitle a' ).click( function(e) { e.preventDefault(); $(this).toggleClass('off').text( $(this).hasClass('off') ? mw.msg( 'showtoc' ) : mw.msg( 'hidetoc' ) ); $(this).parents('.details').find('.reallist')[$(this).hasClass('off') ? 'slideUp' : 'slideDown']( 'fast' ); } ); } ); } ); }( mediaWiki, jQuery ) );