MediaWiki:Common.js/NavigationTabs.js
Chú ý: Sau khi lưu trang, có thể bạn sẽ phải xóa bộ nhớ đệm của trình duyệt để xem các thay đổi.
- Firefox / Safari: Nhấn giữ phím Shift trong khi nhấn Tải lại (Reload), hoặc nhấn tổ hợp Ctrl-F5 hay Ctrl-R (⌘R trên Mac)
- Google Chrome: Nhấn tổ hợp Ctrl-Shift-R (⇧⌘R trên Mac)
- Internet Explorer / Edge: Nhấn giữ phím Ctrl trong khi nhấn Làm tươi (Refresh), hoặc nhấn tổ hợp Ctrl-F5
- Opera: Nhấn tổ hợp Ctrl-F5.
// Navigate Tabs. Allows for lots of information to be displayed on a page in a more compact form.
// Maintained by [[User:Darklama]]
function Navigate_Tabs()
{
function clicked_tab( e )
{
var $target = $( e.target ), id = e.target.hash;
if ( !$target.is( 'a' ) || !id ) {
return true;
}
$target = $(this).siblings( id );
if ( !$target.hasClass( 'contents' ) || !$target.parent().hasClass( 'navtabs' ) ) {
return true;
}
e.preventDefault();
$target.parent().children( '.tabs' ).find( 'a' ).each( function() {
if ( this.hash !== id ) {
$(this).parent().addClass( 'inactive' ).removeClass( 'selected' );
} else {
$(this).parent().addClass( 'selected' ).removeClass( 'inactive' );
}
} );
$target.parent().children( '.contents' ).hide();
$target.show();
}
mw.util.$content.find('.navtabs').each( function() {
var $this = $(this), $p = $this.children( 'p' ), $tabs, $any;
// remove any surrounding paragraph first
$p.has( '.tabs' ).before( $p.children( '.tabs' ) ).remove();
// deal with clicks, and show default
$tabs = $this.children( '.tabs' ).click( clicked_tab );
$any = $tabs.children( '.selected' ).find('a[href^="#"]').click();
if ( !$any.length ) {
$tabs.children(':first-child').find('a[href^="#"]').click();
}
} );
}
$(document).ready(Navigate_Tabs);