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

편집 요약 없음
편집 요약 없음
태그: 되돌려진 기여
3번째 줄: 3번째 줄:
     $content.find('[class*="mw-customtoggle-"]').each(function () {
     $content.find('[class*="mw-customtoggle-"]').each(function () {
         var $toggle = $(this);
         var $toggle = $(this);
         var classList = ($toggle.attr('class') || '').split(/\s+/);
         var classNames = ($toggle.attr('class') || '').split(/\s+/);


         classList.forEach(function (cls) {
         classNames.forEach(function (cls) {
             if (cls.indexOf('mw-customtoggle-') === 0) {
             if (cls.indexOf('mw-customtoggle-') === 0) {
                 var targetId = 'mw-customcollapsible-' + cls.replace('mw-customtoggle-', '');
                 var targetId = 'mw-customcollapsible-' + cls.replace('mw-customtoggle-', '');
12번째 줄: 12번째 줄:
                 if ($target.length) {
                 if ($target.length) {
                     $toggle.off('click.smoothSlide').on('click.smoothSlide', function (e) {
                     $toggle.off('click.smoothSlide').on('click.smoothSlide', function (e) {
                         var $contentTarget = $target.find('.mw-collapsible-content');
                        e.preventDefault();
                         var $animTarget = $contentTarget.length ? $contentTarget : $target;
                         var $collapsibleContent = $target.find('.mw-collapsible-content');
                         var $animTarget = $collapsibleContent.length ? $collapsibleContent : $target;


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

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

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

        classNames.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) {
                        e.preventDefault();
                        var $collapsibleContent = $target.find('.mw-collapsible-content');
                        var $animTarget = $collapsibleContent.length ? $collapsibleContent : $target;

                        $animTarget.stop(true, true).slideToggle(200);
                    });
                }
            }
        });
    });
});