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

편집 요약 없음
태그: 되돌려진 기여
편집 요약 없음
태그: 되돌려진 기여
1번째 줄: 1번째 줄:
$(document).ready(function () {
$(document).ready(function () {
     // .custom-toggle 클릭 이벤트 핸들러
     // 기존의 .custom-toggle 클릭 이벤트 핸들러
     $('.custom-toggle').click(function () {
     $('.custom-toggle').click(function () {
         $(this).next('.custom-content').stop().slideToggle(300); // 부드러운 전환 추가
         $(this).next('.custom-content').stop().slideToggle(300);
     });
     });


8번째 줄: 8번째 줄:
     $('.toggle-collapse').click(function () {
     $('.toggle-collapse').click(function () {
         var $this = $(this);
         var $this = $(this);
         var rowsToToggle = parseInt($this.data('rows')) || 1;
         var $rowContent = $this.closest('tr').next().find('.table-row-content');
         var isCollapsed = $this.data('collapsed') === true;
         var isCollapsed = $this.data('collapsed') === true;
        var $row = $this.closest('tr');


         // 사용자 정의 텍스트
         // 애니메이션으로 열고 닫기
         var expandText = $this.data('expand-text') || '펼치기';
         if (isCollapsed) {
        var collapseText = $this.data('collapse-text') || '접기';
            $rowContent.removeClass('open').css('height', '0');
 
         } else {
         // 애니메이션을 통해 지정된 행 수만큼 토글
             $rowContent.addClass('open').css('height', $rowContent.prop('scrollHeight') + 'px');
        for (var i = 0; i < rowsToToggle; i++) {
             $row = $row.next();
            if ($row.length) {
                $row.stop().slideToggle(300); // 부드러운 전환 추가
            }
         }
         }


         // 상태 변경 및 텍스트 업데이트
         // 상태 변경 및 텍스트 업데이트
         $this.data('collapsed', !isCollapsed);
         $this.data('collapsed', !isCollapsed);
         $this.text(isCollapsed ? expandText : collapseText);
         $this.text(isCollapsed ? '펼치기' : '접기');
     });
     });


32번째 줄: 26번째 줄:
     $('.toggle-collapse').each(function () {
     $('.toggle-collapse').each(function () {
         var $this = $(this);
         var $this = $(this);
         var rowsToToggle = parseInt($this.data('rows')) || 1;
         var $rowContent = $this.closest('tr').next().find('.table-row-content');
         var isCollapsed = $this.data('collapsed') === true;
         var isCollapsed = $this.data('collapsed') === true;
        var expandText = $this.data('expand-text') || '펼치기';
        var collapseText = $this.data('collapse-text') || '접기';


         if (isCollapsed) {
         if (isCollapsed) {
             var $row = $this.closest('tr');
             $rowContent.removeClass('open').css('height', '0');
            for (var i = 0; i < rowsToToggle; i++) {
             $this.text('펼치기');
                $row = $row.next();
                if ($row.length) {
                    $row.hide(); // 기본적으로 숨기기
                }
            }
             $this.text(expandText);
         } else {
         } else {
             $this.text(collapseText);
            $rowContent.addClass('open').css('height', $rowContent.prop('scrollHeight') + 'px');
             $this.text('접기');
         }
         }
     });
     });
});


     // <nolinkstyle> 태그를 .nolinkstyle 클래스로 변환
     // <nolinkstyle> 태그를 .nolinkstyle 클래스로 변환
58번째 줄: 45번째 줄:
         $this.replaceWith('<span class="nolinkstyle">' + content + '</span>');
         $this.replaceWith('<span class="nolinkstyle">' + content + '</span>');
     });
     });
});

2024년 11월 28일 (목) 20:40 판

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

    // .toggle-collapse 클릭 이벤트 핸들러 (표 행 전환)
    $('.toggle-collapse').click(function () {
        var $this = $(this);
        var $rowContent = $this.closest('tr').next().find('.table-row-content');
        var isCollapsed = $this.data('collapsed') === true;

        // 애니메이션으로 열고 닫기
        if (isCollapsed) {
            $rowContent.removeClass('open').css('height', '0');
        } else {
            $rowContent.addClass('open').css('height', $rowContent.prop('scrollHeight') + 'px');
        }

        // 상태 변경 및 텍스트 업데이트
        $this.data('collapsed', !isCollapsed);
        $this.text(isCollapsed ? '펼치기' : '접기');
    });

    // 페이지 로드 시 초기 상태 설정
    $('.toggle-collapse').each(function () {
        var $this = $(this);
        var $rowContent = $this.closest('tr').next().find('.table-row-content');
        var isCollapsed = $this.data('collapsed') === true;

        if (isCollapsed) {
            $rowContent.removeClass('open').css('height', '0');
            $this.text('펼치기');
        } else {
            $rowContent.addClass('open').css('height', $rowContent.prop('scrollHeight') + 'px');
            $this.text('접기');
        }
    });
});

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