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

편집 요약 없음
태그: 되돌려진 기여
편집 요약 없음
태그: 수동 되돌리기
1번째 줄: 1번째 줄:
/* MediaWiki:Common.js */
/* MediaWiki:Common.js */
$(document).ready(function () {
mw.hook('wikipage.content').add(function ($content) {
    // 캡처링 단계에서 미디어위키 기본 즉시 토글 동작 가로채기
     $content.find('[class*="mw-customtoggle-"]').each(function () {
     $(document).on('click', '[class*="mw-customtoggle-"]', function (e) {
         var $toggle = $(this);
         e.preventDefault();
         var classList = ($toggle.attr('class') || '').split(/\s+/);
         e.stopPropagation();
        e.stopImmediatePropagation(); // 기본 makeCollapsible 실행 중단


         var classList = (this.className || '').split(/\s+/);
         classList.forEach(function (cls) {
        for (var i = 0; i < classList.length; i++) {
             if (cls.indexOf('mw-customtoggle-') === 0) {
             if (classList[i].indexOf('mw-customtoggle-') === 0) {
                 var targetId = 'mw-customcollapsible-' + cls.replace('mw-customtoggle-', '');
                 var targetId = 'mw-customcollapsible-' + classList[i].replace('mw-customtoggle-', '');
                 var $target = $('#' + targetId);
                 var $target = $('#' + targetId);


                 if ($target.length) {
                 if ($target.length) {
                     // 슬라이드 토글 애니메이션 실행
                     $toggle.off('click.smoothSlide').on('click.smoothSlide', function (e) {
                    $target.stop(true, true).slideToggle(250);
                        var $contentTarget = $target.find('.mw-collapsible-content');
                        var $animTarget = $contentTarget.length ? $contentTarget : $target;
 
                        // 너비 고정 후 슬라이드 실행
                        $animTarget.stop(true, true).slideToggle(200, function () {
                            // 애니메이션 완료 후 잔여 inline style 제거
                            if ($(this).is(':visible')) {
                                $(this).css('display', '');
                            }
                        });
                    });
                 }
                 }
             }
             }
         }
         });
     });
     });
});
});

2026년 8월 20일 (목) 14:53 판

/* MediaWiki:Common.js */
mw.hook('wikipage.content').add(function ($content) {
    $content.find('[class*="mw-customtoggle-"]').each(function () {
        var $toggle = $(this);
        var classList = ($toggle.attr('class') || '').split(/\s+/);

        classList.forEach(function (cls) {
            if (cls.indexOf('mw-customtoggle-') === 0) {
                var targetId = 'mw-customcollapsible-' + cls.replace('mw-customtoggle-', '');
                var $target = $('#' + targetId);

                if ($target.length) {
                    $toggle.off('click.smoothSlide').on('click.smoothSlide', function (e) {
                        var $contentTarget = $target.find('.mw-collapsible-content');
                        var $animTarget = $contentTarget.length ? $contentTarget : $target;

                        // 너비 고정 후 슬라이드 실행
                        $animTarget.stop(true, true).slideToggle(200, function () {
                            // 애니메이션 완료 후 잔여 inline style 제거
                            if ($(this).is(':visible')) {
                                $(this).css('display', '');
                            }
                        });
                    });
                }
            }
        });
    });
});