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

편집 요약 없음
편집 요약 없음
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(event) {
         var refId = $(this).attr('href').substring(1); // 각주의 id 가져오기
         var refId = $(this).attr('href'); // href 속성에서 각주 id 가져오기
        var tooltip = $('#' + refId).clone().find('.mw-cite-backlink').remove().end().html(); // 각주 내용에서 backlink 제거 후 가져오기
        if (refId && refId.startsWith('#')) {
        if (!tooltip) {
            refId = refId.substring(1); // # 제거 후 id 가져오기
            tooltip = $(this).attr('title') || '내용을 찾을 수 없습니다.'; // 만약 각주 내용을 찾지 못할 경우 기본 메시지 사용
            var tooltip = $('#' + refId).clone().find('.mw-cite-backlink').remove().end().html(); // 각주 내용 가져오기
            if (tooltip) {
                $('<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');
            }
         }
         }
        $('<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() {
     }, function() {
         $('#ref-tooltip').remove();
         $('#ref-tooltip').remove();

2024년 9월 23일 (월) 15:34 판

$(document).ready(function() {
    // 접기/펼치기 기능
    $('.custom-toggle').click(function() {
        $(this).next('.custom-content').slideToggle();
    });

    // 각주 팝업 기능
    $('.reference').hover(function(event) {
        var refId = $(this).attr('href'); // href 속성에서 각주 id 가져오기
        if (refId && refId.startsWith('#')) {
            refId = refId.substring(1); // # 제거 후 id 가져오기
            var tooltip = $('#' + refId).clone().find('.mw-cite-backlink').remove().end().html(); // 각주 내용 가져오기
            if (tooltip) {
                $('<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'
            });
    });
});