미디어위키:Gadget-switcher.js

참고: 설정을 저장한 후에 바뀐 점을 확인하기 위해서는 브라우저의 캐시를 새로 고쳐야 합니다. 구글 크롬, 파이어폭스, 마이크로소프트 엣지, 사파리: ⇧ Shift 키를 누른 채 "새로 고침" 버튼을 클릭하십시오. 더 자세한 정보를 보려면 위키백과:캐시 무시하기 항목을 참고하십시오.

'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 ) { 				// Mark the first one as selected 				selected = switcher; 				$radio.prop( 'checked', true ); 			} else if ( label.getAttribute( 'data-switcher-default' ) !== null ) { 				// Custom default 				$radio.click(); 			} else { 				// Hide non-default 				$( switcher ).hide(); 			} 			$( '<label style="display:block"></label>' ).append( $radio, label.childNodes ).appendTo( container ); 			$( label ).remove(); 		} ); 		if ( switchers.length > 1 ) { 			$( '<label style="display:block">모두 보기</label>' ).prepend( 				$( '<input>' ).prop({ type: 'radio', name: radioName }).on( 'click', function () { 					$( switchers ).show(); 					selected = switchers; 				} ) 			).appendTo( container ); 		} 		if ( switchers.length === 1 ) { 			$radio.remove(); 		} 	} ); } );