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

편집 요약 없음
편집 요약 없음
5번째 줄: 5번째 줄:
     });
     });


     // 페이지 로드 시 기본 상태 설정 (기본적으로 접힌 상태)
     // 페이지 로드 시 기본 상태 설정 (기본적으로 접힌 상태로 시작)
     $('.custom-toggle').each(function() {
     $('.custom-toggle').each(function() {
         var $this = $(this);
         var $this = $(this);
       
        // 기본적으로 접힌 상태로 설정
        $this.next('.custom-content').hide();  // 기본적으로 숨김 처리 (접힌 상태)
        // 접기 상태 설정
         var isCollapsed = $this.data('collapsed') === true;
         var isCollapsed = $this.data('collapsed') === true;
 
         if (!isCollapsed) {
        // 기본적으로 접힌 상태로 설정
             $this.next('.custom-content').show(); // 펼쳐진 상태로 설정 (옵션일 경우)
         if (isCollapsed) {
             $this.next('.custom-content').hide(); // 접힌 상태로 숨김
        } else {
            $this.next('.custom-content').show(); // 펼쳐진 상태로 표시
         }
         }
     });
     });

2024년 11월 29일 (금) 23:07 판

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

    // 페이지 로드 시 기본 상태 설정 (기본적으로 접힌 상태로 시작)
    $('.custom-toggle').each(function() {
        var $this = $(this);
        
        // 기본적으로 접힌 상태로 설정
        $this.next('.custom-content').hide();  // 기본적으로 숨김 처리 (접힌 상태)

        // 접기 상태 설정
        var isCollapsed = $this.data('collapsed') === true;
        if (!isCollapsed) {
            $this.next('.custom-content').show(); // 펼쳐진 상태로 설정 (옵션일 경우)
        }
    });

    // .toggle-collapse 클릭 이벤트 핸들러
    $('.toggle-collapse').click(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;

        // 지정된 행 수만큼 다음 행을 즉시 표시/숨김
        var $row = $this.closest('tr');
        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);
    });

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