편집 요약 없음 |
편집 요약 없음 태그: 되돌려진 기여 |
||
| 1번째 줄: | 1번째 줄: | ||
$(document).ready(function() { | $(document).ready(function() { | ||
// | // 모든 접기 틀은 기본적으로 접혀 있도록 설정 | ||
$('.custom-toggle'). | $('.custom-toggle').each(function() { | ||
$(this).next('.custom-content'). | $(this).next('.custom-content').hide(); | ||
}); | }); | ||
// 페이지 | // '유형'에 맞는 접기 틀만 펼쳐지도록 | ||
var pageType = mw.config.get('wgPageName'); // 페이지 이름을 통해 유형을 파악 | |||
// 접기 틀마다 '유형'에 맞춰 펼칠지 접을지 설정 | |||
$('.custom-toggle').each(function() { | $('.custom-toggle').each(function() { | ||
var $this = $(this); | var $this = $(this); | ||
var | var type = $this.data('type'); // 유형 값을 가져옵니다. | ||
if ( | if (type === pageType) { | ||
// '유형'이 현재 페이지 이름과 같으면 펼쳐짐 | |||
$this.next('.custom-content').show(); | $this.next('.custom-content').show(); | ||
} | } | ||
}); | |||
// 접기 토글 이벤트 처리 | |||
$('.custom-toggle').click(function() { | |||
$(this).next('.custom-content').slideToggle(); | |||
}); | }); | ||
2024년 11월 29일 (금) 23:24 판
$(document).ready(function() {
// 모든 접기 틀은 기본적으로 접혀 있도록 설정
$('.custom-toggle').each(function() {
$(this).next('.custom-content').hide();
});
// '유형'에 맞는 접기 틀만 펼쳐지도록
var pageType = mw.config.get('wgPageName'); // 페이지 이름을 통해 유형을 파악
// 접기 틀마다 '유형'에 맞춰 펼칠지 접을지 설정
$('.custom-toggle').each(function() {
var $this = $(this);
var type = $this.data('type'); // 유형 값을 가져옵니다.
if (type === pageType) {
// '유형'이 현재 페이지 이름과 같으면 펼쳐짐
$this.next('.custom-content').show();
}
});
// 접기 토글 이벤트 처리
$('.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 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>');
});
});