Difference between revisions of "MediaWiki:Common.js"
From Awesome Baozam
Line 4: | Line 4: | ||
mw.hook( 'wikipage.content' ).add( function ( $content ) { | mw.hook( 'wikipage.content' ).add( function ( $content ) { | ||
$content.find('.details' ).each( function() { | $content.find('.details' ).each( function() { | ||
− | var d = $('<div>').addClass('reallist').html( $(this).html() | + | var d = $('<div>').addClass('reallist').html( $(this).html() ); |
$(this).html("").append( '<h2 class=toctitle>Details <span class="toctoggle">[ <a href=#></a> ]</span></h4>' ).append( d ); | $(this).html("").append( '<h2 class=toctitle>Details <span class="toctoggle">[ <a href=#></a> ]</span></h4>' ).append( d ); | ||
$(this).find( '.toctitle a' ).click( function(e) { | $(this).find( '.toctitle a' ).click( function(e) { | ||
Line 10: | Line 10: | ||
$(this).toggleClass('off').text( $(this).hasClass('off') ? mw.msg( 'showtoc' ) : mw.msg( 'hidetoc' ) ); | $(this).toggleClass('off').text( $(this).hasClass('off') ? mw.msg( 'showtoc' ) : mw.msg( 'hidetoc' ) ); | ||
$(this).parents('.details').find('.reallist')[$(this).hasClass('off') ? 'slideDown' : 'slideUp']( 'fast' ); | $(this).parents('.details').find('.reallist')[$(this).hasClass('off') ? 'slideDown' : 'slideUp']( 'fast' ); | ||
− | } ); | + | } ).click(); |
} ); | } ); | ||
} ); | } ); | ||
}( mediaWiki, jQuery ) ); | }( mediaWiki, jQuery ) ); |
Revision as of 11:41, 6 July 2016
( function ( mw, $ ) { 'use strict'; mw.msg( 'showtoc' ); mw.msg( 'hidetoc' ); 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=#></a> ]</span></h4>' ).append( d ); $(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') ? 'slideDown' : 'slideUp']( 'fast' ); } ).click(); } ); } ); }( mediaWiki, jQuery ) );