मेडियाविकि:Gadget-switcher.js
टिप्पणी: संरक्षणक बाद, अहाँक परिवर्तन देखबा लेल अपन ब्राउजरक उपस्मृतिक हटबए पडत। फायरफक्स/ सफारी: सिफ्टके दाबि रिलोड, वा Ctrl-F5 वा Ctrl-R (म्याकपर ⌘-R) गुगल क्रोम: Ctrl-Shift-R दाबी(म्याकपर ⌘-Shift-R) इन्टरनेट एक्सप्लोरर: Refresh क्लिक करि Ctrl दाबि, वा Ctrl-F5 दाबी ओपेरा: Menu → Settings पर जाए (म्याकपर Opera → Preferences) आ ओकर बाद Privacy & security → Clear browsing data → Cached images and files
।
'use strict';
$( function () {
$.each( document.querySelectorAll( '.switcher-container' ), function ( i ) {
var activeElement,
switchers = [], container = this, radioName = 'switcher-' + i;
$.each( this.children, function () {
var $radio, switcher = this,
$labelContainer = $( switcher.querySelector('.switcher-label') ),
$labelText = $labelContainer.contents();
if ( !$labelText.length ) {
return;
}
switchers.push( switcher );
$radio = $( '<input type="radio">' ).attr( 'name', radioName ).click( function () {
$( activeElement ).hide();
$( switcher ).show();
activeElement = switcher;
} );
if ( !activeElement ) {
// Mark the first one as selected
activeElement = switcher;
$radio.prop( 'checked', true );
} else if ( $labelContainer.attr( 'data-switcher-default' ) !== undefined ) {
// Custom default
$radio.click();
} else {
// Hide non-default
$( switcher ).hide();
}
$( '<label style="display:block"></label>' ).append( $radio, $labelText ).appendTo( container );
$labelContainer.remove();
} );
if ( switchers.length > 1 ) {
$( '<label style="display:block">सभ देखी</label>' ).prepend(
$( '<input type="radio">' ).attr( 'name', radioName ).click( function () {
$( switchers ).show();
activeElement = switchers;
} )
).appendTo( container );
}
if ( switchers.length === 1 ) {
$radio.remove();
}
} );
} );