MediaWiki:Gadget-switcher.js
Eʼtibor bering: Oʻzgartirishlaringizni koʻrish uchun, yangi moslamalaringizning saqlashdan keyin, brauzer keshini tozalash kerak:
Mozilla / Firefox: Ctrl+Shift+R, IE: Ctrl+F5, Safari: Cmd+Shift+R, Konqueror: F5, Opera: Tools → Preferences orqali keshni tozalang.
'use strict';
$( function () {
$.each( document.querySelectorAll( '.switcher-container' ), function ( i, container ) {
var selected, $radio;
var switchers = []
var radioName = 'switcher-' + i;
$.each( container.children, function ( j, switcher ) {
var label = switcher.querySelector( '.switcher-label' );
if ( !label || !label.childNodes.length ) {
return;
}
switchers.push( switcher );
$radio = $( '<input>' ).prop({ type: 'radio', name: radioName }).on( 'click', function () {
$( selected ).hide();
$( switcher ).show();
selected = switcher;
} );
if ( !selected ) {
//
selected = switcher;
$radio.prop( 'checked', true );
} else if ( label.getAttribute( 'data-switcher-default' ) !== null ) {
//
$radio.click();
} else {
//
$( switcher ).hide();
}
$( '<label style="display:block"></label>' ).append( $radio, label.childNodes ).appendTo( container );
$( label ).remove();
} );
if ( switchers.length > 1 ) {
$( '<label style="display:block">Hammasini koʻrsat</label>' ).prepend(
$( '<input>' ).prop({ type: 'radio', name: radioName }).on( 'click', function () {
$( switchers ).show();
selected = switchers;
} )
).appendTo( container );
}
if ( switchers.length === 1 ) {
$radio.remove();
}
} );
} );