편집 요약 없음 |
편집 요약 없음 |
||
| 1번째 줄: | 1번째 줄: | ||
$(document).ready(function() { | $(document).ready(function() { | ||
// . | // 페이지에서 전달된 '유형' 값을 가져옵니다. | ||
var pageType = mw.config.get('wgPageName').toLowerCase(); // 페이지 이름 또는 문서에서 유형 값을 추출 | |||
// | // 각 '접기' 틀을 처리하는 로직 | ||
$('.custom-toggle').each(function() { | $('.custom-toggle').each(function() { | ||
var $this = $(this); | var $this = $(this); | ||
// | var type = $this.data('type'); // 접기 틀에서 설정된 '유형' | ||
var isCollapsed = $this.data('collapsed') === | var isCollapsed = $this.data('collapsed') === true; | ||
// | // 기본적으로 접힌 상태로 시작 | ||
if (isCollapsed) { | if (isCollapsed) { | ||
$this.next('.custom-content'). | $this.next('.custom-content').hide(); // 접힌 상태 | ||
} else { | } else { | ||
$this.next('.custom-content'). | $this.next('.custom-content').show(); // 펼쳐진 상태 | ||
} | |||
// '유형'이 현재 페이지의 '유형'과 일치하면 펼치기 | |||
if (type && pageType.indexOf(type.toLowerCase()) !== -1) { | |||
$this.next('.custom-content').show(); // 해당 유형만 펼침 | |||
} | } | ||
}); | }); | ||
2024년 11월 29일 (금) 23:17 판
$(document).ready(function() {
// 페이지에서 전달된 '유형' 값을 가져옵니다.
var pageType = mw.config.get('wgPageName').toLowerCase(); // 페이지 이름 또는 문서에서 유형 값을 추출
// 각 '접기' 틀을 처리하는 로직
$('.custom-toggle').each(function() {
var $this = $(this);
var type = $this.data('type'); // 접기 틀에서 설정된 '유형'
var isCollapsed = $this.data('collapsed') === true;
// 기본적으로 접힌 상태로 시작
if (isCollapsed) {
$this.next('.custom-content').hide(); // 접힌 상태
} else {
$this.next('.custom-content').show(); // 펼쳐진 상태
}
// '유형'이 현재 페이지의 '유형'과 일치하면 펼치기
if (type && pageType.indexOf(type.toLowerCase()) !== -1) {
$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>');
});
});