"मेडियाविकि:Gadget-switcher.js" के अवतरणसभमे अन्तर
Content deleted Content added
Biplab Anand (वार्ता | योगदान) अनुवाद |
Biplab Anand (वार्ता | योगदान) अ Update per enwiki |
||
पङ्क्त्ति १: | पङ्क्त्ति १: | ||
⚫ | |||
( function ( |
$( function () { |
||
⚫ | |||
$( function () { |
$.each( document.querySelectorAll( '.switcher-container' ), function ( i ) { |
||
⚫ | |||
$( '.switcher-container' ).each( function ( i ) { |
|||
switchers = [], container = this, radioName = 'switcher-' + i; |
|||
var activeElement, $showRadio, $showAllRadio; |
|||
⚫ | |||
var elements = [], container = this; |
|||
var |
var $radio, switcher = this, |
||
⚫ | |||
⚫ | |||
⚫ | |||
var self = this; |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
switchers.push( switcher ); |
|||
⚫ | |||
⚫ | |||
⚫ | |||
$( activeElement ).hide(); |
|||
⚫ | |||
⚫ | |||
activeElement = switcher; |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
} ); |
} ); |
||
if ( |
if ( !activeElement ) { |
||
// Mark the first one as selected |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
activeElement = elements; |
|||
⚫ | |||
} ); |
|||
// Custom default |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
// Hide non-default |
|||
⚫ | |||
} |
} |
||
⚫ | |||
⚫ | |||
} ); |
} ); |
||
if ( switchers.length > 1 ) { |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
).appendTo( container ); |
|||
⚫ | |||
⚫ | |||
⚫ | |||
} |
|||
} ); |
} ); |
||
} |
} ); |
१३:०७, २० जनवरी २०२० कऽ समकालिक अवतरण
'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();
}
} );
} );