미디어위키:Common.js: 두 판 사이의 차이

편집 요약 없음
태그: 되돌려진 기여
편집 요약 없음
 
(같은 사용자의 중간 판 58개는 보이지 않습니다)
1번째 줄: 1번째 줄:
/**
/* MediaWiki:Common.js */
* 이 스크립트는 위키백과 전체에 적용됩니다. 고칠 때는 주의해주세요.
mw.hook('wikipage.content').add(function ($content) {
* [[위키백과:위키프로젝트 시스템]] 참고
*
* 스크립트를 넣을 때는 충분한 설명, 출처를 넣어주세요! 이후 관리가 어려워집니다.
**/


document.addEventListener("DOMContentLoaded", function () {
    var initialized = {};
     document.querySelectorAll(".mw-customtoggle").forEach(toggle => {
 
        toggle.addEventListener("click", function (event) {
     $content.find('[class*="mw-customtoggle-"]').each(function () {
            event.preventDefault();
        var classList = (this.className || '').split(/\s+/);
            let table = document.getElementById(this.getAttribute("data-target"));
 
            let content = table.querySelector("tbody");
        classList.forEach(function (cls) {
           
             if (cls.indexOf('mw-customtoggle-') !== 0) {
             if (table.classList.contains("mw-collapsed")) {
                 return;
                 table.classList.remove("mw-collapsed");
            }
                content.style.overflow = "hidden";
 
                content.style.transform = "scaleY(0)";
            var suffix = cls.substring('mw-customtoggle-'.length);
                content.style.opacity = "0";
 
                content.style.transition = "transform 0.3s ease-out, opacity 0.2s ease-out";
            if (initialized[suffix]) {
               
                return;
                setTimeout(() => {
            }
                    content.style.transform = "scaleY(1)";
 
                    content.style.opacity = "1";
            initialized[suffix] = true;
                 }, 10);
 
             } else {
            var targetId = 'mw-customcollapsible-' + suffix;
                content.style.transform = "scaleY(1)";
 
                 content.style.opacity = "1";
            /*
                content.style.transition = "transform 0.3s ease-in, opacity 0.2s ease-in";
            * 중복 ID가 있을 수 있으므로
               
            * #id 대신 attribute selector 사용
                setTimeout(() => {
            */
                     content.style.transform = "scaleY(0)";
            var $targets = $content.find('[id="' + targetId + '"]');
                     content.style.opacity = "0";
 
                     table.classList.add("mw-collapsed");
            if (!$targets.length) {
                 }, 10);
                 return;
             }
 
 
            /*
            * =====================================================
            * 특수형
            *
            * 아나운서 표처럼:
            *
            * [상단 버튼 wrapper]
            * [실제 내용 패널]
            *
            * 두 요소가 같은 ID를 공유하고,
            * 실제 패널 안에 wikitable이 있는 구조
            * =====================================================
            */
            var $specialPanel = $targets.filter(function () {
                 return $(this).find('table.wikitable').length > 0;
            });
 
            if ($targets.length > 1 && $specialPanel.length) {
                initStackedCollapsible(
                     $content,
                     cls,
                     $targets
                );
 
                 return;
             }
             }
            /*
            * =====================================================
            * 일반 MediaWiki collapsible
            * =====================================================
            */
            initNormalCollapsible(
                $content,
                cls,
                $targets.first()
            );
         });
         });
     });
     });
});




mw.loader.using( ['mediawiki.util', 'mediawiki.notify', 'jquery.client'], function () {
/* Begin of mw.loader.using callback */


/**
    /*
* Map addPortletLink to mw.util
    * =============================================================
*
    * 일반 펼치기 · 접기
* @deprecated: Use mw.util.addPortletLink instead.
    * =============================================================
*/
    */
mw.log.deprecate( window, 'addPortletLink', mw.util.addPortletLink,
    function initNormalCollapsible($content, cls, $target) {
'Use mw.util.addPortletLink instead' );
 
        var $toggles = $content.find('.' + cls);
/**
 
* Extract a URL parameter from the current URL
        /*
*
        * 일반 MediaWiki 구조:
* @deprecated: Use mw.util.getParamValue with proper escaping
        *
*/
        * .mw-collapsible
mw.log.deprecate( window, 'getURLParamValue', mw.util.getParamValue, 'Use mw.util.getParamValue instead' );
        *   └ .mw-collapsible-content
        *
/**
        * content가 있으면 content만 애니메이션
* Test if an element has a certain class
        */
*
        var $contentTarget = $target.children('.mw-collapsible-content');
* @deprecated:  Use $(element).hasClass() instead.
 
*/
        if (!$contentTarget.length) {
mw.log.deprecate( window, 'hasClass', function ( element, className ) {
            $contentTarget = $target.find('.mw-collapsible-content').first();
    return $( element ).hasClass( className );
        }
}, 'Use jQuery.hasClass() instead' );
 
        var $animTarget = $contentTarget.length
/**
            ? $contentTarget
* @source www.mediawiki.org/wiki/Snippets/Load_JS_and_CSS_by_URL
            : $target;
* @rev 5
 
*/
 
// CSS
        /*
var extraCSS = mw.util.getParamValue( 'withCSS' );
        * 현재 상태를 기준으로 초기 aria 설정
if ( extraCSS ) {
        */
if ( extraCSS.match( /^MediaWiki:[^&<>=%#]*\.css$/ ) ) {
        var initiallyOpen = $animTarget.is(':visible');
importStylesheet( extraCSS );
 
} else {
        $toggles.attr(
mw.notify( 'Only pages from the MediaWiki namespace are allowed.', { title: 'Invalid withCSS value' } );
            'aria-expanded',
}
            initiallyOpen ? 'true' : 'false'
}
        );
 
// JS
 
var extraJS = mw.util.getParamValue( 'withJS' );
        $toggles
if ( extraJS ) {
            .off('click.smoothSlide')
if ( extraJS.match( /^MediaWiki:[^&<>=%#]*\.js$/ ) ) {
            .on('click.smoothSlide', function (e) {
importScript( extraJS );
 
} else {
                e.preventDefault();
mw.notify( 'Only pages from the MediaWiki namespace are allowed.', { title: 'Invalid withJS value' } );
                e.stopImmediatePropagation();
}
 
}


/**
                /*
* Import more specific scripts if necessary
                * 애니메이션 중 재클릭 방지
*/
                */
                if ($animTarget.is(':animated')) {
                    return false;
                }


if ( mw.config.get( 'wgNamespaceNumber' ) === 6 ) {
    /* file description page scripts */
    importScript( 'MediaWiki:Common.js/file.js' );
}


/* ([[위키백과:관리자 요청/2007년 5월#스크립트 추가 요청]]) */
                var opening = !$animTarget.is(':visible');
/** Collapsible tables *********************************************************
*
*  Description: Allows tables to be collapsed, showing only the header. See
*              [[:en:Wikipedia:NavFrame]].
*  Maintainers: [[:en:User:R. Koot]]
*/
var autoCollapse = 2;
var collapseCaption = '숨기기';
var expandCaption = '보이기';


window.collapseTable = function ( tableIndex ) {
    var Button = document.getElementById( 'collapseButton' + tableIndex );
    var Table = document.getElementById( 'collapsibleTable' + tableIndex );


    if ( !Table || !Button ) {
                /*
        return false;
                * -------------------------------------------------
    }
                * 펼치기
                * -------------------------------------------------
                */
                if (opening) {


    var Rows = Table.rows;
                    /*
    var i;
                    * MediaWiki collapsed 상태 제거
                    */
                    $target.removeClass('mw-collapsed');


    if ( Button.firstChild.data === collapseCaption ) {
        for ( i = 1; i < Rows.length; i++ ) {
            Rows[i].style.display = 'none';
        }
        Button.firstChild.data = expandCaption;
    } else {
        for ( i = 1; i < Rows.length; i++ ) {
            Rows[i].style.display = Rows[0].style.display;
        }
        Button.firstChild.data = collapseCaption;
    }
};


function createCollapseButtons() {
                    /*
    var tableIndex = 0;
                    * 내용만 펼침
    var NavigationBoxes = {};
                    */
    var Tables = document.getElementsByTagName( 'table' );
                    $animTarget
    var i;
                        .stop(true, true)
                        .hide()
                        .slideDown(250, function () {


    function handleButtonLink( index, e ) {
                            /*
        window.collapseTable( index );
                            * jQuery 애니메이션 inline style 정리
        e.preventDefault();
                            */
    }
                            $(this).css({
                                height: '',
                                overflow: '',
                                paddingTop: '',
                                paddingBottom: '',
                                marginTop: '',
                                marginBottom: ''
                            });
                        });


    for ( i = 0; i < Tables.length; i++ ) {
        if ( $( Tables[i] ).hasClass( 'collapsible' ) ) {


            /* only add button and increment count if there is a header row to work with */
                    $toggles.attr('aria-expanded', 'true');
            var HeaderRow = Tables[i].getElementsByTagName( 'tr' )[0];
                }
            if ( !HeaderRow ) continue;
            var Header = HeaderRow.getElementsByTagName( 'th' )[0];
            if ( !Header ) continue;


            NavigationBoxes[ tableIndex ] = Tables[i];
            Tables[i].setAttribute( 'id', 'collapsibleTable' + tableIndex );


            var Button    = document.createElement( 'span' );
                /*
            var ButtonLink = document.createElement( 'a' );
                * -------------------------------------------------
            var ButtonText = document.createTextNode( collapseCaption );
                * 접기
                * -------------------------------------------------
                */
                else {


            Button.className = 'collapseButton';  /* Styles are declared in Common.css */
                    $animTarget
                        .stop(true, true)
                        .slideUp(250, function () {


            ButtonLink.style.color = Header.style.color;
                            /*
            ButtonLink.setAttribute( 'id', 'collapseButton' + tableIndex );
                            * 애니메이션 종료 후 collapsed 복원
            ButtonLink.setAttribute( 'href', '#' );
                            */
            $( ButtonLink ).on( 'click', $.proxy( handleButtonLink, ButtonLink, tableIndex ) );
                            $target.addClass('mw-collapsed');
            ButtonLink.appendChild( ButtonText );


            Button.appendChild( document.createTextNode( '[' ) );
                            $(this).css({
            Button.appendChild( ButtonLink );
                                display: 'none',
            Button.appendChild( document.createTextNode( ']' ) );
                                height: '',
                                overflow: '',
                                paddingTop: '',
                                paddingBottom: '',
                                marginTop: '',
                                marginBottom: ''
                            });
                        });


            Header.insertBefore( Button, Header.firstChild );
            tableIndex++;
        }
    }


    for ( i = 0;  i < tableIndex; i++ ) {
                    $toggles.attr('aria-expanded', 'false');
        if ( $( NavigationBoxes[i] ).hasClass( 'collapsed' ) || ( tableIndex >= autoCollapse && $( NavigationBoxes[i] ).hasClass( 'autocollapse' ) ) ) {
            window.collapseTable( i );
        }
        else if ( $( NavigationBoxes[i] ).hasClass ( 'innercollapse' ) ) {
            var element = NavigationBoxes[i];
            while ((element = element.parentNode)) {
                if ( $( element ).hasClass( 'outercollapse' ) ) {
                    window.collapseTable ( i );
                    break;
                 }
                 }
             }
 
        }
 
                return false;
             });
     }
     }
}


mw.hook( 'wikipage.content' ).add( createCollapseButtons );


/* ([[위키백과:관리자 요청/2007년 5월#스크립트 추가 요청]]) */
/** Dynamic Navigation Bars (experimental) *************************************
*
*  Description: See [[:en:Wikipedia:NavFrame]].
*  Maintainers: UNMAINTAINED
*/
// set up the words in your language
/* set up the words in your language */
var NavigationBarHide = '[' + collapseCaption + ']';
var NavigationBarShow = '[' + expandCaption + ']';


/**
    /*
* Shows and hides content and picture (if available) of navigation bars
    * =============================================================
* Parameters:
    * 아나운서형 특수 펼치기 · 접기
*     indexNavigationBar: the index of navigation bar to be toggled
    * =============================================================
**/
    *
window.toggleNavigationBar = function ( indexNavigationBar, event ) {
    * DOM 예:
    var NavToggle = document.getElementById( 'NavToggle' + indexNavigationBar );
    *
    var NavFrame = document.getElementById( 'NavFrame' + indexNavigationBar );
    * [남성 버튼 wrapper]
    var NavChild;
    * [남성 실제 패널]
    * [여성 버튼 wrapper]
    * [여성 실제 패널]
    *
    * 패널을 이동시키지 않고
    * 원래 DOM 위치에서 펼친다.
    *
    * 중요한 점:
    *
    * wrapper와 panel을 둘 다 애니메이션하지 않는다.
    *
    * 버튼 wrapper는 즉시 교체하고,
    * 실제 패널 하나만 slide 애니메이션한다.
    *
    * 따라서 이중 움직임이나
    * 중간 겹침 현상이 최소화된다.
    * =============================================================
    */
    function initStackedCollapsible($content, cls, $targets) {
 
        /*
        * wikitable이 들어 있는 요소를 실제 패널로 사용
        */
        var $panel = $targets.filter(function () {
            return $(this).find('table.wikitable').length > 0;
        }).first();
 
        if (!$panel.length) {
            return;
        }
 


    if ( !NavFrame || !NavToggle ) {
        /*
        return false;
        * 실제 패널이 아닌 동일 ID 요소 중
    }
        * 해당 toggle을 포함하는 요소 = 상단 버튼 wrapper
        */
        var $topWrapper = $targets.not($panel).filter(function () {
            return $(this).find('.' + cls).length > 0;
        }).first();


    /* if shown now */
        if (!$topWrapper.length) {
    if ( NavToggle.firstChild.data === NavigationBarHide ) {
             return;
        for ( NavChild = NavFrame.firstChild; NavChild !== null; NavChild = NavChild.nextSibling ) {
             if ( $( NavChild ).hasClass( 'NavContent' ) || $( NavChild ).hasClass( 'NavPic' ) ) {
                NavChild.style.display = 'none';
            }
         }
         }
    NavToggle.firstChild.data = NavigationBarShow;


    /* if hidden now */
 
    } else if ( NavToggle.firstChild.data === NavigationBarShow ) {
        var $topToggle = $topWrapper.find('.' + cls).first();
         for ( NavChild = NavFrame.firstChild; NavChild !== null; NavChild = NavChild.nextSibling ) {
         var $panelToggle = $panel.find('.' + cls).first();
            if ( $( NavChild ).hasClass( 'NavContent' ) || $( NavChild ).hasClass( 'NavPic' ) ) {
 
                NavChild.style.display = 'block';
 
            }
        if (!$topToggle.length || !$panelToggle.length) {
            return;
         }
         }
        NavToggle.firstChild.data = NavigationBarHide;
    }


    event.preventDefault();
};


/* adds show/hide-button to navigation bars */
function createNavigationBarToggleButton() {
    var indexNavigationBar = 0;
    var NavFrame;
    var NavChild;
    /* iterate over all < div >-elements */
    var divs = document.getElementsByTagName( 'div' );
    for ( var i = 0; (NavFrame = divs[i]); i++ ) {
        /* if found a navigation bar */
        if ( $( NavFrame ).hasClass( 'NavFrame' ) ) {


             indexNavigationBar++;
        /*
             var NavToggle = document.createElement( 'a' );
        * =========================================================
             NavToggle.className = 'NavToggle';
        * 최초 상태
            NavToggle.setAttribute( 'id', 'NavToggle' + indexNavigationBar );
        * =========================================================
            NavToggle.setAttribute( 'href', '#' );
        */
             $( NavToggle ).on( 'click', $.proxy( window.toggleNavigationBar, window, indexNavigationBar ) );
        $panel
            .stop(true, true)
             .addClass('mw-collapsed')
            .hide()
             .css({
                height: '',
                overflow: '',
                paddingTop: '',
                paddingBottom: '',
                marginTop: '',
                marginBottom: ''
            });
 
 
        $topWrapper
            .stop(true, true)
             .show()
            .css({
                height: '',
                overflow: '',
                paddingTop: '',
                paddingBottom: '',
                marginTop: '',
                marginBottom: ''
            });
 
 
        $topToggle.attr('aria-expanded', 'false');
        $panelToggle.attr('aria-expanded', 'false');
 
 
 
        /*
        * =========================================================
        * 위쪽 버튼 클릭 → 펼치기
        * =========================================================
        */
        $topToggle
             .off('click.smoothSlide')
            .on('click.smoothSlide', function (e) {
 
                e.preventDefault();
                e.stopImmediatePropagation();
 


            var isCollapsed = $( NavFrame ).hasClass( 'collapsed' );
                /*
            /**
                * 애니메이션 중 재클릭 방지
            * Check if any children are already hidden.  This loop is here for backwards compatibility:
                */
            * the old way of making NavFrames start out collapsed was to manually add style="display:none"
                 if ($panel.is(':animated')) {
            * to all the NavPic/NavContent elements.  Since this was bad for accessibility (no way to make
                     return false;
            * the content visible without JavaScript support), the new recommended way is to add the class
            * "collapsed" to the NavFrame itself, just like with collapsible tables.
            */
            for ( NavChild = NavFrame.firstChild; NavChild != null && !isCollapsed; NavChild = NavChild.nextSibling ) {
                 if ( $( NavChild ).hasClass( 'NavPic' ) || $( NavChild ).hasClass( 'NavContent' ) ) {
                     if ( NavChild.style.display === 'none' ) {
                        isCollapsed = true;
                    }
                 }
                 }
            }
 
            if ( isCollapsed ) {
 
                 for ( NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling ) {
                 /*
                    if ( $( NavChild ).hasClass( 'NavPic' ) || $( NavChild ).hasClass( 'NavContent' ) ) {
                * 이미 열려 있으면 중단
                        NavChild.style.display = 'none';
                */
                    }
                if ($panel.is(':visible')) {
                    return false;
                 }
                 }
            }
            var NavToggleText = document.createTextNode( isCollapsed ? NavigationBarShow : NavigationBarHide );
            NavToggle.appendChild( NavToggleText );


            /* Find the NavHead and attach the toggle link (Must be this complicated because Moz's firstChild handling is borked) */
            for( var j = 0; j < NavFrame.childNodes.length; j++ ) {
                if ( $( NavFrame.childNodes[j] ).hasClass( 'NavHead' ) ) {
                    NavToggle.style.color = NavFrame.childNodes[j].style.color;
                    NavFrame.childNodes[j].appendChild( NavToggle );
                }
            }
            NavFrame.setAttribute( 'id', 'NavFrame' + indexNavigationBar );
        }
    }
}


mw.hook( 'wikipage.content' ).add( createNavigationBarToggleButton );
                /*
                * -------------------------------------------------
                * 상단 버튼 wrapper는 즉시 숨김
                *
                * wrapper 자체를 애니메이션하지 않으므로
                * 이중 움직임이 발생하지 않는다.
                * -------------------------------------------------
                */
                $topWrapper
                    .stop(true, true)
                    .hide();
 
 
                /*
                * MediaWiki collapsed 상태 제거
                */
                $panel.removeClass('mw-collapsed');
 
 
                /*
                * -------------------------------------------------
                * 실제 패널 하나만 부드럽게 펼침
                * -------------------------------------------------
                */
                $panel
                    .stop(true, true)
                    .hide()
                    .slideDown(260, function () {
 
                        /*
                        * animation 종료 후
                        * jQuery가 만든 inline style 정리
                        */
                        $(this).css({
                            height: '',
                            overflow: '',
                            paddingTop: '',
                            paddingBottom: '',
                            marginTop: '',
                            marginBottom: ''
                        });
                    });
 
 
                /*
                * ARIA
                */
                $topToggle.attr('aria-expanded', 'true');
                $panelToggle.attr('aria-expanded', 'true');


/***** 그림 정보 틀을 자동으로 불러옴 ********
* Adds a link to subpages of current page
* from commons.wikimedia.org
*  Maintainers: [[User:Yonidebest]], [[User:Dschwen]]
*  [[사용자:Kwj2772]]가 수정
*  JSconfig items: bool 'loadAutoInformationTemplate'
*                      (true=enabled (default), false=disabled)
* JSConfig를 사용하지 않도록 수정함. --[[사용자:Klutzy|klutzy]] ([[사용자토론:Klutzy|토론]]) 2009년 9월 27일 (일) 20:33 (KST)
****/
if (mw.config.get('wgCanonicalSpecialPageName') == 'Upload') {
  importScript('MediaWiki:Upload.js');
}


/* 인터랙티브 지도. 영어 위키백과에서 가져옴. -- [[사용자:ChongDae]] 2010년 3월 28일 (일) 02:08 (KST) */
/**
* WikiMiniAtlas
*
* Description: WikiMiniAtlas is a popup click and drag world map.
*              This script causes all of our coordinate links to display the WikiMiniAtlas popup button.
*              The script itself is located on meta because it is used by many projects.
*              See [[Meta:WikiMiniAtlas]] for more information.
* Maintainers: [[User:Dschwen]]
*/
( function () {
    var require_wikiminiatlas = false;
    var coord_filter = /geohack/;
    $( function () {
        $( 'a.external.text' ).each( function( key, link ) {
            if ( link.href && coord_filter.exec( link.href ) ) {
                require_wikiminiatlas = true;
                // break from loop
                 return false;
                 return false;
             }
             });
         } );
 
         if ( $( 'div.kmldata' ).length ) {
 
            require_wikiminiatlas = true;
 
        }
         /*
        if ( require_wikiminiatlas ) {
        * =========================================================
            mw.loader.load( '//meta.wikimedia.org/w/index.php?title=MediaWiki:Wikiminiatlas.js&action=raw&ctype=text/javascript' );
        * 패널 안쪽 버튼 클릭 → 접기
        }
        * =========================================================
    } );
        */
} )();
         $panelToggle
            .off('click.smoothSlide')
            .on('click.smoothSlide', function (e) {
 
                e.preventDefault();
                e.stopImmediatePropagation();
 
 
                /*
                * 애니메이션 중 재클릭 방지
                */
                if ($panel.is(':animated')) {
                    return false;
                }
 
 
                /*
                * -------------------------------------------------
                * 실제 패널 하나만 접음
                * -------------------------------------------------
                */
                $panel
                    .stop(true, true)
                    .slideUp(260, function () {


/**
                        /*
* Fix for Windows XP Unicode font rendering
                        * 패널을 완전히 닫은 뒤
*/
                        * collapsed 상태 복원
if ( navigator.appVersion.search(/windows nt 5/i) !== -1 ) {
                        */
    mw.util.addCSS( '.IPA { font-family: "Lucida Sans Unicode", "Arial Unicode MS"; } ' +
                        $(this)
                '.Unicode { font-family: "Arial Unicode MS", "Lucida Sans Unicode"; } ' );
                            .addClass('mw-collapsed')
}
                            .css({
                                display: 'none',
                                height: '',
                                overflow: '',
                                paddingTop: '',
                                paddingBottom: '',
                                marginTop: '',
                                marginBottom: ''
                            });


/**
* 편집 안내 ****************************************************
*
* 생존 인물에 대한 편집 안내. 영어 위키백과에서 가져옴 - ChongDae
* Maintainers: [[User:RockMFR]]
*/
function addEditIntro( name ) {
    $( '.mw-editsection, #ca-edit' ).find( 'a' ).each( function ( i, el ) {
        el.href = $( this ).attr( 'href' ) + '&editintro=' + name;
    } );
}


if ( mw.config.get( 'wgNamespaceNumber' ) === 0 ) {
                        /*
    $( function () {
                        * -------------------------------------------------
        var cats = mw.config.get('wgCategories');
                        * 원래 상단 버튼 즉시 복귀
        if ( !cats ) {
                        *
            return;
                        * 별도 애니메이션을 하지 않기 때문에
        }
                        * 닫힘 동작도 한 번의 움직임으로 보인다.
        if ( $.inArray( '살아있는 사람', cats ) !== -1 || $.inArray( '생사 불명', cats ) !== -1 ) {
                        * -------------------------------------------------
            addEditIntro( '틀:BLP_편집_안내' );
                        */
        }
                        $topWrapper
    } );
                            .stop(true, true)
}
                            .show()
                            .css({
                                height: '',
                                overflow: '',
                                paddingTop: '',
                                paddingBottom: '',
                                marginTop: '',
                                marginBottom: ''
                            });
                    });


mw.loader.load('//code.jquery.com/jquery-3.6.0.min.js');


$(document).ready(function() {
                /*
    var toggleBtns = $('.toggleBtn');
                * ARIA
    toggleBtns.each(function() {
                */
        var toggleId = $(this).attr("id");
                $topToggle.attr('aria-expanded', 'false');
        var contentId = toggleId.replace("toggle", "collapsible");
                $panelToggle.attr('aria-expanded', 'false');
        var content = $("#" + contentId);
        var toggleTextId = toggleId.replace("toggle", "toggleText");
        var toggleText = $("#" + toggleTextId);
       
        content.hide();
       
        $(this).click(function() {
            content.slideToggle(300);
            if (content.css("display") == "none") {
                toggleText.html("[ 펼치기 · 접기 ]");
            } else {
                toggleText.html("[ 펼치기 · 접기 ]");
            }
        });
    });
});


document.addEventListener("DOMContentLoaded", function () {
    document.querySelectorAll(".mw-collapsible-toggle").forEach(toggle => {
        toggle.addEventListener("click", function (event) {
            event.preventDefault();
            let table = this.closest(".mw-collapsible");
            let content = table.querySelector("tbody");
           
            if (table.classList.contains("mw-collapsed")) {
                content.style.overflow = "hidden";
                content.style.maxHeight = "0px";
                content.style.opacity = "0";
                content.style.transition = "max-height 0.5s ease-out, opacity 0.3s ease-out";
               
                setTimeout(() => {
                    table.classList.remove("mw-collapsed");
                    content.style.maxHeight = content.scrollHeight + "px";
                    content.style.opacity = "1";
                }, 10);
            } else {
                content.style.maxHeight = content.scrollHeight + "px";
                content.style.opacity = "1";
                content.style.transition = "max-height 0.5s ease-in, opacity 0.3s ease-in";
               
                setTimeout(() => {
                    content.style.maxHeight = "0px";
                    content.style.opacity = "0";
                    table.classList.add("mw-collapsed");
                }, 10);
            }
        });
    });
});


                return false;
            });
    }


/* End of mw.loader.using callback */
});
} );
/* DO NOT ADD CODE BELOW THIS LINE */

2026년 8월 20일 (목) 15:13 기준 최신판

/* MediaWiki:Common.js */
mw.hook('wikipage.content').add(function ($content) {

    var initialized = {};

    $content.find('[class*="mw-customtoggle-"]').each(function () {
        var classList = (this.className || '').split(/\s+/);

        classList.forEach(function (cls) {
            if (cls.indexOf('mw-customtoggle-') !== 0) {
                return;
            }

            var suffix = cls.substring('mw-customtoggle-'.length);

            if (initialized[suffix]) {
                return;
            }

            initialized[suffix] = true;

            var targetId = 'mw-customcollapsible-' + suffix;

            /*
             * 중복 ID가 있을 수 있으므로
             * #id 대신 attribute selector 사용
             */
            var $targets = $content.find('[id="' + targetId + '"]');

            if (!$targets.length) {
                return;
            }


            /*
             * =====================================================
             * 특수형
             *
             * 아나운서 표처럼:
             *
             * [상단 버튼 wrapper]
             * [실제 내용 패널]
             *
             * 두 요소가 같은 ID를 공유하고,
             * 실제 패널 안에 wikitable이 있는 구조
             * =====================================================
             */
            var $specialPanel = $targets.filter(function () {
                return $(this).find('table.wikitable').length > 0;
            });

            if ($targets.length > 1 && $specialPanel.length) {
                initStackedCollapsible(
                    $content,
                    cls,
                    $targets
                );

                return;
            }


            /*
             * =====================================================
             * 일반 MediaWiki collapsible
             * =====================================================
             */
            initNormalCollapsible(
                $content,
                cls,
                $targets.first()
            );
        });
    });



    /*
     * =============================================================
     * 일반 펼치기 · 접기
     * =============================================================
     */
    function initNormalCollapsible($content, cls, $target) {

        var $toggles = $content.find('.' + cls);

        /*
         * 일반 MediaWiki 구조:
         *
         * .mw-collapsible
         *   └ .mw-collapsible-content
         *
         * content가 있으면 content만 애니메이션
         */
        var $contentTarget = $target.children('.mw-collapsible-content');

        if (!$contentTarget.length) {
            $contentTarget = $target.find('.mw-collapsible-content').first();
        }

        var $animTarget = $contentTarget.length
            ? $contentTarget
            : $target;


        /*
         * 현재 상태를 기준으로 초기 aria 설정
         */
        var initiallyOpen = $animTarget.is(':visible');

        $toggles.attr(
            'aria-expanded',
            initiallyOpen ? 'true' : 'false'
        );


        $toggles
            .off('click.smoothSlide')
            .on('click.smoothSlide', function (e) {

                e.preventDefault();
                e.stopImmediatePropagation();


                /*
                 * 애니메이션 중 재클릭 방지
                 */
                if ($animTarget.is(':animated')) {
                    return false;
                }


                var opening = !$animTarget.is(':visible');


                /*
                 * -------------------------------------------------
                 * 펼치기
                 * -------------------------------------------------
                 */
                if (opening) {

                    /*
                     * MediaWiki collapsed 상태 제거
                     */
                    $target.removeClass('mw-collapsed');


                    /*
                     * 내용만 펼침
                     */
                    $animTarget
                        .stop(true, true)
                        .hide()
                        .slideDown(250, function () {

                            /*
                             * jQuery 애니메이션 inline style 정리
                             */
                            $(this).css({
                                height: '',
                                overflow: '',
                                paddingTop: '',
                                paddingBottom: '',
                                marginTop: '',
                                marginBottom: ''
                            });
                        });


                    $toggles.attr('aria-expanded', 'true');
                }


                /*
                 * -------------------------------------------------
                 * 접기
                 * -------------------------------------------------
                 */
                else {

                    $animTarget
                        .stop(true, true)
                        .slideUp(250, function () {

                            /*
                             * 애니메이션 종료 후 collapsed 복원
                             */
                            $target.addClass('mw-collapsed');

                            $(this).css({
                                display: 'none',
                                height: '',
                                overflow: '',
                                paddingTop: '',
                                paddingBottom: '',
                                marginTop: '',
                                marginBottom: ''
                            });
                        });


                    $toggles.attr('aria-expanded', 'false');
                }


                return false;
            });
    }



    /*
     * =============================================================
     * 아나운서형 특수 펼치기 · 접기
     * =============================================================
     *
     * DOM 예:
     *
     * [남성 버튼 wrapper]
     * [남성 실제 패널]
     * [여성 버튼 wrapper]
     * [여성 실제 패널]
     *
     * 패널을 이동시키지 않고
     * 원래 DOM 위치에서 펼친다.
     *
     * 중요한 점:
     *
     * wrapper와 panel을 둘 다 애니메이션하지 않는다.
     *
     * 버튼 wrapper는 즉시 교체하고,
     * 실제 패널 하나만 slide 애니메이션한다.
     *
     * 따라서 이중 움직임이나
     * 중간 겹침 현상이 최소화된다.
     * =============================================================
     */
    function initStackedCollapsible($content, cls, $targets) {

        /*
         * wikitable이 들어 있는 요소를 실제 패널로 사용
         */
        var $panel = $targets.filter(function () {
            return $(this).find('table.wikitable').length > 0;
        }).first();

        if (!$panel.length) {
            return;
        }


        /*
         * 실제 패널이 아닌 동일 ID 요소 중
         * 해당 toggle을 포함하는 요소 = 상단 버튼 wrapper
         */
        var $topWrapper = $targets.not($panel).filter(function () {
            return $(this).find('.' + cls).length > 0;
        }).first();

        if (!$topWrapper.length) {
            return;
        }


        var $topToggle = $topWrapper.find('.' + cls).first();
        var $panelToggle = $panel.find('.' + cls).first();


        if (!$topToggle.length || !$panelToggle.length) {
            return;
        }



        /*
         * =========================================================
         * 최초 상태
         * =========================================================
         */
        $panel
            .stop(true, true)
            .addClass('mw-collapsed')
            .hide()
            .css({
                height: '',
                overflow: '',
                paddingTop: '',
                paddingBottom: '',
                marginTop: '',
                marginBottom: ''
            });


        $topWrapper
            .stop(true, true)
            .show()
            .css({
                height: '',
                overflow: '',
                paddingTop: '',
                paddingBottom: '',
                marginTop: '',
                marginBottom: ''
            });


        $topToggle.attr('aria-expanded', 'false');
        $panelToggle.attr('aria-expanded', 'false');



        /*
         * =========================================================
         * 위쪽 버튼 클릭 → 펼치기
         * =========================================================
         */
        $topToggle
            .off('click.smoothSlide')
            .on('click.smoothSlide', function (e) {

                e.preventDefault();
                e.stopImmediatePropagation();


                /*
                 * 애니메이션 중 재클릭 방지
                 */
                if ($panel.is(':animated')) {
                    return false;
                }


                /*
                 * 이미 열려 있으면 중단
                 */
                if ($panel.is(':visible')) {
                    return false;
                }


                /*
                 * -------------------------------------------------
                 * 상단 버튼 wrapper는 즉시 숨김
                 *
                 * wrapper 자체를 애니메이션하지 않으므로
                 * 이중 움직임이 발생하지 않는다.
                 * -------------------------------------------------
                 */
                $topWrapper
                    .stop(true, true)
                    .hide();


                /*
                 * MediaWiki collapsed 상태 제거
                 */
                $panel.removeClass('mw-collapsed');


                /*
                 * -------------------------------------------------
                 * 실제 패널 하나만 부드럽게 펼침
                 * -------------------------------------------------
                 */
                $panel
                    .stop(true, true)
                    .hide()
                    .slideDown(260, function () {

                        /*
                         * animation 종료 후
                         * jQuery가 만든 inline style 정리
                         */
                        $(this).css({
                            height: '',
                            overflow: '',
                            paddingTop: '',
                            paddingBottom: '',
                            marginTop: '',
                            marginBottom: ''
                        });
                    });


                /*
                 * ARIA
                 */
                $topToggle.attr('aria-expanded', 'true');
                $panelToggle.attr('aria-expanded', 'true');


                return false;
            });



        /*
         * =========================================================
         * 패널 안쪽 버튼 클릭 → 접기
         * =========================================================
         */
        $panelToggle
            .off('click.smoothSlide')
            .on('click.smoothSlide', function (e) {

                e.preventDefault();
                e.stopImmediatePropagation();


                /*
                 * 애니메이션 중 재클릭 방지
                 */
                if ($panel.is(':animated')) {
                    return false;
                }


                /*
                 * -------------------------------------------------
                 * 실제 패널 하나만 접음
                 * -------------------------------------------------
                 */
                $panel
                    .stop(true, true)
                    .slideUp(260, function () {

                        /*
                         * 패널을 완전히 닫은 뒤
                         * collapsed 상태 복원
                         */
                        $(this)
                            .addClass('mw-collapsed')
                            .css({
                                display: 'none',
                                height: '',
                                overflow: '',
                                paddingTop: '',
                                paddingBottom: '',
                                marginTop: '',
                                marginBottom: ''
                            });


                        /*
                         * -------------------------------------------------
                         * 원래 상단 버튼 즉시 복귀
                         *
                         * 별도 애니메이션을 하지 않기 때문에
                         * 닫힘 동작도 한 번의 움직임으로 보인다.
                         * -------------------------------------------------
                         */
                        $topWrapper
                            .stop(true, true)
                            .show()
                            .css({
                                height: '',
                                overflow: '',
                                paddingTop: '',
                                paddingBottom: '',
                                marginTop: '',
                                marginBottom: ''
                            });
                    });


                /*
                 * ARIA
                 */
                $topToggle.attr('aria-expanded', 'false');
                $panelToggle.attr('aria-expanded', 'false');


                return false;
            });
    }

});