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

편집 요약 없음
편집 요약 없음
태그: 모바일 편집 모바일 웹 편집
1번째 줄: 1번째 줄:
/* All JavaScript here will be loaded for users of the MinervaNeue skin */
/* All JavaScript here will be loaded for users of the MinervaNeue skin */
// 모바일 메뉴에서 '둘러보기' 문서 보여주기
// 모바일 메뉴에서 '둘러보기' 문서 보여주기
document
document
     .querySelector('#mw-mf-page-left #p-navigation')
     .querySelector('#mw-mf-page-left #p-navigation')
26번째 줄: 27번째 줄:
     );
     );


document.querySelector('#p-main-categories .title-recommended').addEventListener('click', function () {
// Recommended Documents 토글
    openList(this, 'recommended-open');
document.querySelector('#p-main-categories .title-recommended')
});
    .addEventListener('click', function (event) {
document.querySelector('#p-main-categories .title-category').addEventListener('click', function () {
        event.stopPropagation(); // 사이드바 닫힘 방지
    openList(this, 'category-open');
        openList(this, '.recommended');
});
    });


function openList(titleLi, listClass) {
// Browse by Category 토글
    var list = document.querySelector('#p-main-categories');
document.querySelector('#p-main-categories .title-category')
     if (list.classList.contains(listClass)) {
     .addEventListener('click', function (event) {
         list.classList.remove(listClass);
         event.stopPropagation(); // 사이드바 닫힘 방지
    } else {
         openList(this, '.category');
         list.classList.add(listClass);
     });
     }


     if (titleLi.classList.contains('open')) {
function openList(titleLi, selector) {
        titleLi.classList.remove('open');
     titleLi.classList.toggle('open');
    } else {
    let next = titleLi.nextElementSibling;
        titleLi.classList.add('open');
    while (next && !next.classList.contains('title-recommended') && !next.classList.contains('title-category')) {
        if (next.matches(selector)) {
            next.style.display = (next.style.display === 'none' || next.style.display === '') ? 'block' : 'none';
        }
        next = next.nextElementSibling;
     }
     }
}
}
54번째 줄: 58번째 줄:
     if ($videoWrap && $videoWrap.classList.contains('video-wrap')) return;
     if ($videoWrap && $videoWrap.classList.contains('video-wrap')) return;
     iframe.parentElement.classList.add('video-wrap');
     iframe.parentElement.classList.add('video-wrap');
});
mw.loader.using(['jquery']).then(function() {
    $(function() {
        var modal = $('#myLayer');
        var btn = $('#selectLanguage'); // jQuery 선택자 사용
        var span = $('.close-button').first();
        btn.click(function() {
            modal.show();
        });
        span.click(function() {
            modal.hide();
        });
        $(window).click(function(event) {
            if ($(event.target).is(modal)) {
                modal.hide();
            }
        });
    });
});
});