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

편집 요약 없음
편집 요약 없음
태그: 되돌려진 기여
60번째 줄: 60번째 줄:
     });
     });
});
});
    // Smooth toggle for rows with animations
    $('.smooth-toggle').click(function() {
        var $this = $(this);
        var $content = $this.closest('tr').next('.custom-content');
        if ($content.hasClass('expanded')) {
            $content.removeClass('expanded').css('max-height', '0');
        } else {
            $content.addClass('expanded').css('max-height', '1000px');
        }
        // Update button text
        var expandText = $this.data('expand-text') || '펼치기';
        var collapseText = $this.data('collapse-text') || '접기';
        $this.text($content.hasClass('expanded') ? collapseText : expandText);
    });
    // Deprecated <nolinkstyle> handling is commented out.
    /*
    $('nolinkstyle').each(function() {
        var $this = $(this);
        var content = $this.html();
        $this.replaceWith('<span class="nolinkstyle">' + content + '</span>');
    });
    */

2024년 11월 28일 (목) 19:54 판

$(document).ready(function() {
    // 기존의 .custom-toggle 클릭 이벤트 핸들러
    $('.custom-toggle').click(function() {
        $(this).next('.custom-content').slideToggle();
    });

    // .toggle-collapse 클릭 이벤트 핸들러
    $('.toggle-collapse').click(function() {
        var $this = $(this);
        var rowsToToggle = parseInt($this.data('rows')) || 1;
        var isCollapsed = $this.data('collapsed') === true;
        var $row = $this.closest('tr');

        // 사용자 정의 텍스트 확인
        var expandText = $this.data('expand-text') || '펼치기';
        var collapseText = $this.data('collapse-text') || expandText; // 접기 텍스트가 없을 경우 펼치기 텍스트와 동일하게

        // 지정된 행 수만큼 다음 행을 즉시 표시/숨김
        for (var i = 0; i < rowsToToggle; i++) {
            $row = $row.next();
            if ($row.length) { // 다음 행이 존재하는지 확인
                $row.toggle(); // 슬라이드 애니메이션 없이 토글
            }
        }

        // 상태 토글
        $this.data('collapsed', !isCollapsed);
        $this.text($this.data('collapsed') ? expandText : collapseText);
    });

    // 페이지 로드 시 기본 상태 설정
    $('.toggle-collapse').each(function() {
        var $this = $(this);
        var rowsToToggle = parseInt($this.data('rows')) || 1;
        var isCollapsed = $this.data('collapsed') === true;

        // 사용자 정의 텍스트 확인
        var expandText = $this.data('expand-text') || '펼치기';
        var collapseText = $this.data('collapse-text') || expandText; // 접기 텍스트가 없을 경우 펼치기 텍스트와 동일하게

        if (isCollapsed) {
            var $row = $this.closest('tr');
            for (var i = 0; i < rowsToToggle; i++) {
                $row = $row.next();
                if ($row.length) { // 다음 행이 존재하는지 확인
                    $row.hide(); // 페이지 로드 시 슬라이드 애니메이션 없이 즉시 숨김
                }
            }
            $this.text(expandText);
        } else {
            $this.text(collapseText);
        }
    });

    // <nolinkstyle> 태그를 .nolinkstyle 클래스로 변환
    $('nolinkstyle').each(function() {
        var $this = $(this);
        var content = $this.html();
        $this.replaceWith('<span class="nolinkstyle">' + content + '</span>');
    });
});


    // Smooth toggle for rows with animations
    $('.smooth-toggle').click(function() {
        var $this = $(this);
        var $content = $this.closest('tr').next('.custom-content');

        if ($content.hasClass('expanded')) {
            $content.removeClass('expanded').css('max-height', '0');
        } else {
            $content.addClass('expanded').css('max-height', '1000px');
        }

        // Update button text
        var expandText = $this.data('expand-text') || '펼치기';
        var collapseText = $this.data('collapse-text') || '접기';
        $this.text($content.hasClass('expanded') ? collapseText : expandText);
    });

    // Deprecated <nolinkstyle> handling is commented out.
    /*
    $('nolinkstyle').each(function() {
        var $this = $(this);
        var content = $this.html();
        $this.replaceWith('<span class="nolinkstyle">' + content + '</span>');
    });
    */