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

StayByMe
둘러보기로 이동 검색으로 이동
편집 요약 없음
태그: 되돌려진 기여
편집 요약 없음
태그: 되돌려진 기여
2번째 줄: 2번째 줄:
$(document).ready(function() {
$(document).ready(function() {
     // Add a toggle button to each collapsible section
     // Add a toggle button to each collapsible section
     $('.mw-portlet.collapsible .mw-portlet-body').before('<div class="mw-portlet-toggle">[+]</div>');
     $('.mw-portlet').each(function() {
        var portlet = $(this);
        var header = portlet.find('.pBody');
        var body = portlet.find('.pBody ul');


    // Hide the content of each collapsible section by default
        if (body.length) {
    $('.mw-portlet.collapsible .mw-portlet-body').hide();
            var toggleButton = $('<span class="mw-portlet-toggle">[+]</span>');
            header.prepend(toggleButton);


    // Toggle the content when the toggle button is clicked
            body.hide();
    $('.mw-portlet-toggle').click(function() {
 
        $(this).next('.mw-portlet-body').slideToggle();
            toggleButton.click(function() {
        // Toggle the plus/minus icon
                body.slideToggle();
        var text = $(this).text() == '[+]' ? '[−]' : '[+]';
                var text = toggleButton.text() == '[+]' ? '[−]' : '[+]';
        $(this).text(text);
                toggleButton.text(text);
            });
        }
     });
     });
});
});

2024년 6월 25일 (화) 00:27 판

/* 이 자바스크립트 설정은 모든 문서, 모든 사용자에게 적용됩니다. */
$(document).ready(function() {
    // Add a toggle button to each collapsible section
    $('.mw-portlet').each(function() {
        var portlet = $(this);
        var header = portlet.find('.pBody');
        var body = portlet.find('.pBody ul');

        if (body.length) {
            var toggleButton = $('<span class="mw-portlet-toggle">[+]</span>');
            header.prepend(toggleButton);

            body.hide();

            toggleButton.click(function() {
                body.slideToggle();
                var text = toggleButton.text() == '[+]' ? '[−]' : '[+]';
                toggleButton.text(text);
            });
        }
    });
});