편집 요약 없음 |
편집 요약 없음 |
||
| 1번째 줄: | 1번째 줄: | ||
/* 이 자바스크립트 설정은 모든 문서, 모든 사용자에게 적용됩니다. */ | /* 이 자바스크립트 설정은 모든 문서, 모든 사용자에게 적용됩니다. */ | ||
$(document).ready(function() { | $(document).ready(function() { | ||
// | // jQuery를 사용하여 접기/펼치기 기능 추가 | ||
$('.custom-toggle').click(function() { | $('.custom-toggle').click(function() { | ||
$(this).next('.custom-content').slideToggle(); | $(this).next('.custom-content').slideToggle(); | ||
}); | }); | ||
// 각주 팝업 기능 추가 | |||
// 각주 팝업 기능 | |||
$('.reference').hover(function() { | $('.reference').hover(function() { | ||
var tooltip = $( | var refId = $(this).attr('href').substring(1); // 각주의 id 가져오기 | ||
$('<div id="ref-tooltip" | var tooltip = $('#' + refId).clone().find('.mw-cite-backlink').remove().end().html(); // 각주 내용에서 backlink 제거 후 가져오기 | ||
if (!tooltip) { | |||
tooltip = $(this).attr('title') || '내용을 찾을 수 없습니다.'; // 만약 각주 내용을 찾지 못할 경우 기본 메시지 사용 | |||
} | |||
$('<div id="ref-tooltip"></div>') | |||
.css({ | |||
position: 'absolute', | |||
background: '#f9f9f9', | |||
border: '1px solid #aaa', | |||
padding: '5px', | |||
'z-index': 100, | |||
display: 'none', | |||
'max-width': '300px', | |||
'box-shadow': '0 0 5px rgba(0,0,0,0.2)' | |||
}) | |||
.appendTo('body') | .appendTo('body') | ||
.html(tooltip) | .html(tooltip) | ||
| 21번째 줄: | 32번째 줄: | ||
}).mousemove(function(e) { | }).mousemove(function(e) { | ||
$('#ref-tooltip') | $('#ref-tooltip') | ||
.css( | .css({ | ||
top: e.pageY + 10 + 'px', | |||
left: e.pageX + 10 + 'px' | |||
}); | |||
}); | }); | ||
}); | }); | ||
2024년 9월 23일 (월) 15:32 판
/* 이 자바스크립트 설정은 모든 문서, 모든 사용자에게 적용됩니다. */
$(document).ready(function() {
// jQuery를 사용하여 접기/펼치기 기능 추가
$('.custom-toggle').click(function() {
$(this).next('.custom-content').slideToggle();
});
// 각주 팝업 기능 추가
$('.reference').hover(function() {
var refId = $(this).attr('href').substring(1); // 각주의 id 가져오기
var tooltip = $('#' + refId).clone().find('.mw-cite-backlink').remove().end().html(); // 각주 내용에서 backlink 제거 후 가져오기
if (!tooltip) {
tooltip = $(this).attr('title') || '내용을 찾을 수 없습니다.'; // 만약 각주 내용을 찾지 못할 경우 기본 메시지 사용
}
$('<div id="ref-tooltip"></div>')
.css({
position: 'absolute',
background: '#f9f9f9',
border: '1px solid #aaa',
padding: '5px',
'z-index': 100,
display: 'none',
'max-width': '300px',
'box-shadow': '0 0 5px rgba(0,0,0,0.2)'
})
.appendTo('body')
.html(tooltip)
.fadeIn('fast');
}, function() {
$('#ref-tooltip').remove();
}).mousemove(function(e) {
$('#ref-tooltip')
.css({
top: e.pageY + 10 + 'px',
left: e.pageX + 10 + 'px'
});
});
});