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

편집 요약 없음
편집 요약 없음
 
(같은 사용자의 중간 판 3개는 보이지 않습니다)
23번째 줄: 23번째 줄:


             /*
             /*
             * 중복 ID가 있을 수 있으므로 #id 대신 attribute selector 사용
             * 중복 ID가 있을 수 있으므로
            * #id 대신 attribute selector 사용
             */
             */
             var $targets = $content.find('[id="' + targetId + '"]');
             var $targets = $content.find('[id="' + targetId + '"]');
38번째 줄: 39번째 줄:
             * 아나운서 표처럼:
             * 아나운서 표처럼:
             *
             *
             * 상단 버튼 wrapper
             * [상단 버튼 wrapper]
             * 실제 내용 패널
             * [실제 내용 패널]
             *
             *
             * 이 같은 ID를 공유하고,
             * 두 요소가 같은 ID를 공유하고,
             * 실제 패널 안에 wikitable이 있는 구조
             * 실제 패널 안에 wikitable이 있는 구조
             * =====================================================
             * =====================================================
120번째 줄: 121번째 줄:
                 e.preventDefault();
                 e.preventDefault();
                 e.stopImmediatePropagation();
                 e.stopImmediatePropagation();


                 /*
                 /*
                 * 애니메이션 중 다시 눌렀을 때
                 * 애니메이션 중 재클릭 방지
                * queue가 꼬이는 것을 방지
                 */
                 */
                 if ($animTarget.is(':animated')) {
                 if ($animTarget.is(':animated')) {
                     return false;
                     return false;
                 }
                 }


                 var opening = !$animTarget.is(':visible');
                 var opening = !$animTarget.is(':visible');
140번째 줄: 142번째 줄:


                     /*
                     /*
                     * MediaWiki의 collapsed 상태를 먼저 제거
                     * MediaWiki collapsed 상태 제거
                     */
                     */
                     $target.removeClass('mw-collapsed');
                     $target.removeClass('mw-collapsed');
146번째 줄: 148번째 줄:


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


                             /*
                             /*
                             * jQuery가 남기는 애니메이션용 inline style 정리
                             * jQuery 애니메이션 inline style 정리
                             */
                             */
                             $(this).css({
                             $(this).css({
179번째 줄: 181번째 줄:


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


                             /*
                             /*
                             * 애니메이션이 끝난 뒤 collapsed 복원
                             * 애니메이션 종료 후 collapsed 복원
                             */
                             */
                             $target.addClass('mw-collapsed');
                             $target.addClass('mw-collapsed');
221번째 줄: 223번째 줄:
     * [여성 실제 패널]
     * [여성 실제 패널]
     *
     *
     * 패널은 원래 DOM 위치에 유지한다.
     * 패널을 이동시키지 않고
    * 원래 DOM 위치에서 펼친다.
    *
    * 중요한 점:
    *
    * wrapper와 panel을 둘 다 애니메이션하지 않는다.
     *
     *
     * 남성을 펼치면 여성 버튼은
     * 버튼 wrapper는 즉시 교체하고,
     * 자연스럽게 아래로 밀려난다.
     * 실제 패널 하나만 slide 애니메이션한다.
     *
     *
     * 단,
     * 따라서 이중 움직임이나
     * 상단 버튼과 패널을 완전히 동시에 움직이지 않고
     * 중간 겹침 현상이 최소화된다.
    * 짧은 시차를 주어 겹침을 방지한다.
     * =============================================================
     * =============================================================
     */
     */
265번째 줄: 271번째 줄:
             return;
             return;
         }
         }
        /*
        * =========================================================
        * 애니메이션 설정
        * =========================================================
        *
        * wrapperDuration
        *  상단 버튼이 사라지고 나타나는 속도
        *
        * panelDuration
        *  실제 패널 펼침/접힘 속도
        *
        * openDelay
        *  상단 버튼이 접히기 시작한 뒤
        *  패널이 펼쳐지기 시작하는 시점
        *
        * closeDelay
        *  패널이 접히기 시작한 뒤
        *  상단 버튼이 복귀하기 시작하는 시점
        */
        var wrapperDuration = 180;
        var panelDuration = 240;
        var openDelay = 65;
        var closeDelay = 80;




309번째 줄: 289번째 줄:
                 paddingBottom: '',
                 paddingBottom: '',
                 marginTop: '',
                 marginTop: '',
                 marginBottom: '',
                 marginBottom: ''
                opacity: ''
             });
             });


         $topWrapper
         $topWrapper
322번째 줄: 302번째 줄:
                 paddingBottom: '',
                 paddingBottom: '',
                 marginTop: '',
                 marginTop: '',
                 marginBottom: '',
                 marginBottom: ''
                opacity: ''
             });
             });


346번째 줄: 325번째 줄:


                 /*
                 /*
                 * 중복 클릭 방지
                 * 애니메이션 중 재클릭 방지
                 */
                 */
                 if (
                 if ($panel.is(':animated')) {
                    $panel.is(':animated') ||
                    $topWrapper.is(':animated') ||
                    $panel.is(':visible')
                ) {
                     return false;
                     return false;
                 }
                 }
358번째 줄: 333번째 줄:


                 /*
                 /*
                 * MediaWiki collapsed 상태 해제
                 * 이미 열려 있으면 중단
                 */
                 */
                 $panel.removeClass('mw-collapsed');
                 if ($panel.is(':visible')) {
                    return false;
                }




                 /*
                 /*
                 * -------------------------------------------------
                 * -------------------------------------------------
                 * 1.
                 * 상단 버튼 wrapper는 즉시 숨김
                * 위쪽 버튼 wrapper를 먼저 접기 시작
                 *
                 *
                 * 높이뿐 아니라 opacity도 같이 낮춰
                 * wrapper 자체를 애니메이션하지 않으므로
                 * 훨씬 자연스럽게 사라지도록 한다.
                 * 이중 움직임이 발생하지 않는다.
                 * -------------------------------------------------
                 * -------------------------------------------------
                 */
                 */
                 $topWrapper
                 $topWrapper
                     .stop(true, false)
                     .stop(true, true)
                     .css({
                     .hide();
                        overflow: 'hidden'
                    })
                    .animate(
                        {
                            height: 0,
                            paddingTop: 0,
                            paddingBottom: 0,
                            marginTop: 0,
                            marginBottom: 0,
                            opacity: 0
                        },
                        {
                            duration: wrapperDuration,
                            queue: false,


                            complete: function () {


                                $(this)
                /*
                                    .hide()
                * MediaWiki collapsed 상태 제거
                                    .css({
                */
                                        height: '',
                $panel.removeClass('mw-collapsed');
                                        overflow: '',
                                        paddingTop: '',
                                        paddingBottom: '',
                                        marginTop: '',
                                        marginBottom: '',
                                        opacity: ''
                                    });
                            }
                        }
                    );




                 /*
                 /*
                 * -------------------------------------------------
                 * -------------------------------------------------
                * 2.
                 * 실제 패널 하나만 부드럽게 펼침
                * 버튼이 어느 정도 접힌 뒤
                 * 실제 패널 펼치기 시작
                *
                * 완전 순차식이 아니기 때문에
                * 움직임이 끊겨 보이지 않는다.
                 * -------------------------------------------------
                 * -------------------------------------------------
                 */
                 */
                 setTimeout(function () {
                 $panel
                    .stop(true, true)
                    .hide()
                    .slideDown(260, function () {


                    /*
                        /*
                    * 혹시 다른 처리로 이미 표시되었으면 중단
                        * animation 종료 후
                    */
                        * jQuery가 만든 inline style 정리
                    if ($panel.is(':visible')) {
                        */
                        return;
                        $(this).css({
                    }
                            height: '',
 
                            overflow: '',
 
                            paddingTop: '',
                    $panel
                            paddingBottom: '',
                        .stop(true, false)
                            marginTop: '',
                        .hide()
                            marginBottom: ''
                        .slideDown(
                        });
                            panelDuration,
                    });
                            function () {
 
                                /*
                                * jQuery animation inline style 정리
                                */
                                $(this).css({
                                    height: '',
                                    overflow: '',
                                    paddingTop: '',
                                    paddingBottom: '',
                                    marginTop: '',
                                    marginBottom: '',
                                    opacity: ''
                                });
                            }
                        );
 
                }, openDelay);




479번째 줄: 410번째 줄:


                 /*
                 /*
                 * 중복 클릭 방지
                 * 애니메이션 중 재클릭 방지
                 */
                 */
                 if (
                 if ($panel.is(':animated')) {
                    $panel.is(':animated') ||
                    $topWrapper.is(':animated')
                ) {
                     return false;
                     return false;
                 }
                 }
491번째 줄: 419번째 줄:
                 /*
                 /*
                 * -------------------------------------------------
                 * -------------------------------------------------
                 * 1.
                 * 실제 패널 하나만 접음
                * 패널 먼저 접기 시작
                 * -------------------------------------------------
                 * -------------------------------------------------
                 */
                 */
                 $panel
                 $panel
                     .stop(true, false)
                     .stop(true, true)
                     .slideUp(
                     .slideUp(260, function () {
                        panelDuration,
                        function () {


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




                /*
                        /*
                * -------------------------------------------------
                        * -------------------------------------------------
                * 2.
                        * 원래 상단 버튼 즉시 복귀
                * 패널이 어느 정도 접힌 뒤
                        *
                * 원래 버튼을 복귀시키기 시작
                        * 별도 애니메이션을 하지 않기 때문에
                * -------------------------------------------------
                        * 닫힘 동작도 한 번의 움직임으로 보인다.
                */
                        * -------------------------------------------------
                setTimeout(function () {
                        */
 
                         $topWrapper
                    /*
                            .stop(true, true)
                    * 이미 보이는 상태라면 중복 실행하지 않음
                             .show()
                    */
                             .css({
                    if ($topWrapper.is(':visible')) {
                                height: '',
                         return;
                                overflow: '',
                    }
                                paddingTop: '',
 
                                paddingBottom: '',
 
                                marginTop: '',
                    /*
                                marginBottom: ''
                    * opacity 0으로 시작
                             });
                    */
                     });
                    $topWrapper
                        .stop(true, false)
                        .css({
                             opacity: 0
                        })
                        .hide();
 
 
                    /*
                    * 높이 복귀
                    */
                    $topWrapper
                        .slideDown({
                            duration: wrapperDuration,
 
                            step: function () {
                                /*
                                * slideDown 도중 overflow는
                                * jQuery가 자동 관리
                                */
                             },
 
                            complete: function () {
 
                                $(this).css({
                                    height: '',
                                    overflow: '',
                                    paddingTop: '',
                                    paddingBottom: '',
                                    marginTop: '',
                                    marginBottom: ''
                                });
                             }
                        });
 
 
                    /*
                    * opacity는 slideDown과 동시에 진행
                    *
                    * queue:false이므로
                    * 높이 애니메이션을 기다리지 않는다.
                    */
                     $topWrapper
                        .animate(
                            {
                                opacity: 1
                            },
                            {
                                duration: 130,
                                queue: false,
 
                                complete: function () {
 
                                    $(this).css({
                                        opacity: ''
                                    });
                                }
                            }
                        );
 
                }, closeDelay);




612번째 줄: 477번째 줄:


});
});
(function(){'use strict';function init(root){root.querySelectorAll('.portal-slider').forEach(function(box){if(box.dataset.ready)return;box.dataset.ready='1';var track=box.querySelector('.portal-slides'),slides=track.children,controls=document.createElement('div'),counter=document.createElement('span');controls.className='portal-controls';controls.append(counter);function current(){return Math.round(track.scrollLeft/Math.max(track.clientWidth,1))}function update(){counter.textContent=(current()+1)+' / '+slides.length}['이전','다음'].forEach(function(label,i){var b=document.createElement('button');b.type='button';b.setAttribute('aria-label',label+' 배너');b.textContent=i?'›':'‹';b.onclick=function(){var n=(current()+(i?1:-1)+slides.length)%slides.length;track.scrollTo({left:n*track.clientWidth,behavior:window.matchMedia('(prefers-reduced-motion:reduce)').matches?'auto':'smooth'})};controls.appendChild(b)});box.appendChild(controls);track.addEventListener('scroll',update,{passive:true});update()})}if(window.mw&&mw.hook)mw.hook('wikipage.content').add(function(c){if(c[0])init(c[0])});if(document.readyState==='loading')document.addEventListener('DOMContentLoaded',function(){init(document)});else init(document)})();
/* 프벤위키 대문 · 미디어위키:Common.js의 기존 내용 맨 아래에 추가 */
(function () {
  'use strict';
  function init(root) {
    var homes = root.querySelectorAll('.fbn-mainpage');
    homes.forEach(function (home) {
      if (home.dataset.fbnReady) return;
      home.dataset.fbnReady = '1';
      if (window.mw && mw.config.get('wgAction') === 'view' && mw.config.get('wgIsMainPage')) {
        document.body.classList.add('fbn-mainpage-view');
      }
      var slider = home.querySelector('.fbn-slider');
      var track = slider && slider.querySelector('.fbn-track');
      if (!track || !track.children.length) return;
      var slides = Array.from(track.children).filter(function (node) { return node.classList.contains('fbn-slide'); });
      if (!slides.length) return;
      var index = 0, width = track.clientWidth;
      var paused = false, hovering = false, focused = false, touching = false;
      var timer = null;
      var motion = window.matchMedia('(prefers-reduced-motion: reduce)');
      slider.tabIndex = 0;
      slider.setAttribute('role', 'region');
      slider.setAttribute('aria-roledescription', '슬라이드 쇼');
      slider.setAttribute('aria-label', '프벤위키 대문 배너');
      var controls = document.createElement('div');
      controls.className = 'fbn-controls';
      var status = document.createElement('span');
      status.className = 'fbn-status';
      status.setAttribute('aria-live', 'off');
      var playback = document.createElement('button');
      playback.type = 'button';
      playback.className = 'fbn-playback';
      var dots = document.createElement('div');
      dots.className = 'fbn-dots';
      var dotButtons = [];
      function schedule() {
        clearTimeout(timer);
        if (!home.isConnected || slides.length < 2 || paused || hovering || focused || touching || motion.matches || document.hidden) return;
        timer = setTimeout(function () { go(index + 1); }, 6000);
      }
      function update() {
        status.textContent = (index + 1) + ' / ' + slides.length;
        slides.forEach(function (slide, i) {
          slide.setAttribute('role', 'group');
          slide.setAttribute('aria-roledescription', '슬라이드');
          slide.setAttribute('aria-label', (i + 1) + ' / ' + slides.length);
          slide.setAttribute('aria-hidden', String(i !== index));
          slide.inert = i !== index;
          // Explicit tab order also covers browsers without inert support.
          slide.querySelectorAll('a').forEach(function (link) { link.tabIndex = i === index ? 0 : -1; });
          if (i === index) dotButtons[i].setAttribute('aria-current', 'true');
          else dotButtons[i].removeAttribute('aria-current');
        });
      }
      function go(next) {
        index = (next + slides.length) % slides.length;
        track.scrollTo({ left: index * track.clientWidth, behavior: motion.matches ? 'auto' : 'smooth' });
        update();
        schedule();
      }
      function playbackLabel() {
        playback.disabled = motion.matches || slides.length < 2;
        playback.textContent = motion.matches || slides.length < 2 ? '자동 재생 꺼짐' : paused ? '▶ 재생' : 'Ⅱ 일시정지';
        playback.setAttribute('aria-label', paused ? '배너 자동 재생 시작' : '배너 자동 재생 정지');
        playback.setAttribute('aria-pressed', String(paused || motion.matches));
      }
      ['이전', '다음'].forEach(function (label, i) {
        var button = document.createElement('button');
        button.type = 'button';
        button.textContent = i ? '›' : '‹';
        button.setAttribute('aria-label', label + ' 배너');
        button.disabled = slides.length < 2;
        button.addEventListener('click', function () { go(index + (i ? 1 : -1)); });
        controls.appendChild(button);
      });
      slides.forEach(function (slide, i) {
        var button = document.createElement('button');
        button.type = 'button';
        button.setAttribute('aria-label', (i + 1) + '번 배너로 이동');
        button.addEventListener('click', function () { go(i); });
        dots.appendChild(button);
        dotButtons.push(button);
      });
      playback.addEventListener('click', function () { paused = !paused; playbackLabel(); schedule(); });
      slider.appendChild(controls);
      slider.appendChild(status);
      slider.appendChild(playback);
      slider.appendChild(dots);
      track.addEventListener('scroll', function () {
        index = Math.max(0, Math.min(slides.length - 1, Math.round(track.scrollLeft / Math.max(1, width))));
        update(); schedule();
      }, { passive: true });
      slider.addEventListener('keydown', function (event) {
        if (event.key === 'ArrowLeft' || event.key === 'ArrowRight') {
          event.preventDefault(); go(index + (event.key === 'ArrowLeft' ? -1 : 1));
        }
      });
      slider.addEventListener('mouseenter', function () { hovering = true; schedule(); });
      slider.addEventListener('mouseleave', function () { hovering = false; schedule(); });
      slider.addEventListener('touchstart', function () { touching = true; schedule(); }, { passive: true });
      ['touchend', 'touchcancel'].forEach(function (eventName) {
        slider.addEventListener(eventName, function () { touching = false; schedule(); }, { passive: true });
      });
      slider.addEventListener('focusin', function () { focused = true; schedule(); });
      slider.addEventListener('focusout', function (event) { focused = slider.contains(event.relatedTarget); schedule(); });
      document.addEventListener('visibilitychange', schedule);
      function motionChanged() { playbackLabel(); schedule(); }
      if (motion.addEventListener) motion.addEventListener('change', motionChanged);
      else motion.addListener(motionChanged);
      function resize() {
        var newWidth = track.clientWidth;
        if (newWidth === width) return;
        width = newWidth;
        track.scrollTo({ left: index * width, behavior: 'instant' });
        update();
      }
      if (window.ResizeObserver) new ResizeObserver(resize).observe(track);
      else window.addEventListener('resize', resize);
      update(); playbackLabel(); schedule();
    });
  }
  if (window.mw && mw.hook) {
    mw.hook('wikipage.content').add(function (content) {
      var root = content && (content[0] || content);
      if (root && root.querySelectorAll) init(root);
    });
  }
  if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', function () { init(document); });
  else init(document);
}());

2026년 10월 12일 (월) 17:31 기준 최신판

/* 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;
            });
    }

});


(function(){'use strict';function init(root){root.querySelectorAll('.portal-slider').forEach(function(box){if(box.dataset.ready)return;box.dataset.ready='1';var track=box.querySelector('.portal-slides'),slides=track.children,controls=document.createElement('div'),counter=document.createElement('span');controls.className='portal-controls';controls.append(counter);function current(){return Math.round(track.scrollLeft/Math.max(track.clientWidth,1))}function update(){counter.textContent=(current()+1)+' / '+slides.length}['이전','다음'].forEach(function(label,i){var b=document.createElement('button');b.type='button';b.setAttribute('aria-label',label+' 배너');b.textContent=i?'›':'‹';b.onclick=function(){var n=(current()+(i?1:-1)+slides.length)%slides.length;track.scrollTo({left:n*track.clientWidth,behavior:window.matchMedia('(prefers-reduced-motion:reduce)').matches?'auto':'smooth'})};controls.appendChild(b)});box.appendChild(controls);track.addEventListener('scroll',update,{passive:true});update()})}if(window.mw&&mw.hook)mw.hook('wikipage.content').add(function(c){if(c[0])init(c[0])});if(document.readyState==='loading')document.addEventListener('DOMContentLoaded',function(){init(document)});else init(document)})();

/* 프벤위키 대문 · 미디어위키:Common.js의 기존 내용 맨 아래에 추가 */
(function () {
  'use strict';
  function init(root) {
    var homes = root.querySelectorAll('.fbn-mainpage');
    homes.forEach(function (home) {
      if (home.dataset.fbnReady) return;
      home.dataset.fbnReady = '1';
      if (window.mw && mw.config.get('wgAction') === 'view' && mw.config.get('wgIsMainPage')) {
        document.body.classList.add('fbn-mainpage-view');
      }
      var slider = home.querySelector('.fbn-slider');
      var track = slider && slider.querySelector('.fbn-track');
      if (!track || !track.children.length) return;
      var slides = Array.from(track.children).filter(function (node) { return node.classList.contains('fbn-slide'); });
      if (!slides.length) return;
      var index = 0, width = track.clientWidth;
      var paused = false, hovering = false, focused = false, touching = false;
      var timer = null;
      var motion = window.matchMedia('(prefers-reduced-motion: reduce)');
      slider.tabIndex = 0;
      slider.setAttribute('role', 'region');
      slider.setAttribute('aria-roledescription', '슬라이드 쇼');
      slider.setAttribute('aria-label', '프벤위키 대문 배너');
      var controls = document.createElement('div');
      controls.className = 'fbn-controls';
      var status = document.createElement('span');
      status.className = 'fbn-status';
      status.setAttribute('aria-live', 'off');
      var playback = document.createElement('button');
      playback.type = 'button';
      playback.className = 'fbn-playback';
      var dots = document.createElement('div');
      dots.className = 'fbn-dots';
      var dotButtons = [];

      function schedule() {
        clearTimeout(timer);
        if (!home.isConnected || slides.length < 2 || paused || hovering || focused || touching || motion.matches || document.hidden) return;
        timer = setTimeout(function () { go(index + 1); }, 6000);
      }
      function update() {
        status.textContent = (index + 1) + ' / ' + slides.length;
        slides.forEach(function (slide, i) {
          slide.setAttribute('role', 'group');
          slide.setAttribute('aria-roledescription', '슬라이드');
          slide.setAttribute('aria-label', (i + 1) + ' / ' + slides.length);
          slide.setAttribute('aria-hidden', String(i !== index));
          slide.inert = i !== index;
          // Explicit tab order also covers browsers without inert support.
          slide.querySelectorAll('a').forEach(function (link) { link.tabIndex = i === index ? 0 : -1; });
          if (i === index) dotButtons[i].setAttribute('aria-current', 'true');
          else dotButtons[i].removeAttribute('aria-current');
        });
      }
      function go(next) {
        index = (next + slides.length) % slides.length;
        track.scrollTo({ left: index * track.clientWidth, behavior: motion.matches ? 'auto' : 'smooth' });
        update();
        schedule();
      }
      function playbackLabel() {
        playback.disabled = motion.matches || slides.length < 2;
        playback.textContent = motion.matches || slides.length < 2 ? '자동 재생 꺼짐' : paused ? '▶ 재생' : 'Ⅱ 일시정지';
        playback.setAttribute('aria-label', paused ? '배너 자동 재생 시작' : '배너 자동 재생 정지');
        playback.setAttribute('aria-pressed', String(paused || motion.matches));
      }
      ['이전', '다음'].forEach(function (label, i) {
        var button = document.createElement('button');
        button.type = 'button';
        button.textContent = i ? '›' : '‹';
        button.setAttribute('aria-label', label + ' 배너');
        button.disabled = slides.length < 2;
        button.addEventListener('click', function () { go(index + (i ? 1 : -1)); });
        controls.appendChild(button);
      });
      slides.forEach(function (slide, i) {
        var button = document.createElement('button');
        button.type = 'button';
        button.setAttribute('aria-label', (i + 1) + '번 배너로 이동');
        button.addEventListener('click', function () { go(i); });
        dots.appendChild(button);
        dotButtons.push(button);
      });
      playback.addEventListener('click', function () { paused = !paused; playbackLabel(); schedule(); });
      slider.appendChild(controls);
      slider.appendChild(status);
      slider.appendChild(playback);
      slider.appendChild(dots);
      track.addEventListener('scroll', function () {
        index = Math.max(0, Math.min(slides.length - 1, Math.round(track.scrollLeft / Math.max(1, width))));
        update(); schedule();
      }, { passive: true });
      slider.addEventListener('keydown', function (event) {
        if (event.key === 'ArrowLeft' || event.key === 'ArrowRight') {
          event.preventDefault(); go(index + (event.key === 'ArrowLeft' ? -1 : 1));
        }
      });
      slider.addEventListener('mouseenter', function () { hovering = true; schedule(); });
      slider.addEventListener('mouseleave', function () { hovering = false; schedule(); });
      slider.addEventListener('touchstart', function () { touching = true; schedule(); }, { passive: true });
      ['touchend', 'touchcancel'].forEach(function (eventName) {
        slider.addEventListener(eventName, function () { touching = false; schedule(); }, { passive: true });
      });
      slider.addEventListener('focusin', function () { focused = true; schedule(); });
      slider.addEventListener('focusout', function (event) { focused = slider.contains(event.relatedTarget); schedule(); });
      document.addEventListener('visibilitychange', schedule);
      function motionChanged() { playbackLabel(); schedule(); }
      if (motion.addEventListener) motion.addEventListener('change', motionChanged);
      else motion.addListener(motionChanged);
      function resize() {
        var newWidth = track.clientWidth;
        if (newWidth === width) return;
        width = newWidth;
        track.scrollTo({ left: index * width, behavior: 'instant' });
        update();
      }
      if (window.ResizeObserver) new ResizeObserver(resize).observe(track);
      else window.addEventListener('resize', resize);
      update(); playbackLabel(); schedule();
    });
  }
  if (window.mw && mw.hook) {
    mw.hook('wikipage.content').add(function (content) {
      var root = content && (content[0] || content);
      if (root && root.querySelectorAll) init(root);
    });
  }
  if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', function () { init(document); });
  else init(document);
}());