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

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


         classNames.forEach(function (cls) {
         var classList = (this.className || '').split(/\s+/);
             if (cls.indexOf('mw-customtoggle-') === 0) {
        for (var i = 0; i < classList.length; i++) {
                 var targetId = 'mw-customcollapsible-' + cls.replace('mw-customtoggle-', '');
             if (classList[i].indexOf('mw-customtoggle-') === 0) {
                 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) {
                     // 슬라이드 토글 애니메이션 실행
                        e.preventDefault();
                    $target.stop(true, true).slideToggle(250);
                        var $collapsibleContent = $target.find('.mw-collapsible-content');
                        var $animTarget = $collapsibleContent.length ? $collapsibleContent : $target;
 
                        $animTarget.stop(true, true).slideToggle(200);
                    });
                 }
                 }
             }
             }
         });
         }
     });
     });
});
});

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

/* MediaWiki:Common.js */
$(document).ready(function () {
    // 캡처링 단계에서 미디어위키 기본 즉시 토글 동작 가로채기
    $(document).on('click', '[class*="mw-customtoggle-"]', function (e) {
        e.preventDefault();
        e.stopPropagation();
        e.stopImmediatePropagation(); // 기본 makeCollapsible 실행 중단

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

                if ($target.length) {
                    // 슬라이드 토글 애니메이션 실행
                    $target.stop(true, true).slideToggle(250);
                }
            }
        }
    });
});