"मेडियाविकि:Gadget-switcher.js" के अवतरणसभमे अन्तर

मैथिली विकिपिडियासँ, एक मुक्त विश्वकोश
Content deleted Content added
अनुवाद
Update per enwiki
 
पङ्क्त्ति १: पङ्क्त्ति १:
'use strict';
( function ( $ ) {
$( function () {
'use strict';
$( function () {
$.each( document.querySelectorAll( '.switcher-container' ), function ( i ) {
var activeElement,
$( '.switcher-container' ).each( function ( i ) {
switchers = [], container = this, radioName = 'switcher-' + i;
var activeElement, $showRadio, $showAllRadio;
$.each( this.children, function () {
var elements = [], container = this;
var radioName = 'switcher-' + i;
var $radio, switcher = this,
$labelContainer = $( switcher.querySelector('.switcher-label') ),
$( this ).children().each( function () {
$labelText = $labelContainer.contents();
var self = this;
if ( !$labelText.length ) {
var $labelContainer = $( this ).find( '.switcher-label' );
return;
var $labelText = $labelContainer.contents();
}
if ( !$labelText.length ) {
switchers.push( switcher );
return;
$radio = $( '<input type="radio">' ).attr( 'name', radioName ).click( function () {
}
elements.push( this );
$( activeElement ).hide();
$( switcher ).show();
$showRadio = $( '<input type="radio" />' ).attr( 'name', radioName ).click( function () {
$( activeElement ).hide();
activeElement = switcher;
$( self ).show();
activeElement = self;
} );
$( '<label style="display:block"></label>' ).append( $showRadio ).append( $labelText ).appendTo( container );
if ( !activeElement ) {
activeElement = this;
$showRadio.prop( 'checked', true );
} else if ( $labelContainer.is( '[data-switcher-default]' ) ) {
$showRadio.click();
} else {
$( this ).hide();
}
$labelContainer.remove();
} );
} );
if ( elements.length > 1 ) {
if ( !activeElement ) {
// Mark the first one as selected
$showAllRadio = $( '<input type="radio" />' ).attr( 'name', radioName ).click( function () {
activeElement = switcher;
$( elements ).show();
$radio.prop( 'checked', true );
activeElement = elements;
} else if ( $labelContainer.attr( 'data-switcher-default' ) !== undefined ) {
} );
// Custom default
$( '<label style="display:block">सभ देखी</label>' ).prepend( $showAllRadio ).appendTo( container );
$radio.click();
} else if ( elements.length === 1 ) {
} else {
$showRadio.remove();
// 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();
}
} );
} );
} )( jQuery );
} );

१३:०७, २० जनवरी २०२० कऽ समकालिक अवतरण

'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();
		}
	} );
} );