MediaWiki:Minerva.js: Difference between revisions

From Church of God Knowledge Encyclopedia
Jump to navigation Jump to search
No edit summary
Tags: Mobile edit Mobile web edit
No edit summary
Tags: Mobile edit Mobile web edit
Line 27: Line 27:


document.querySelector('#p-main-categories .title-recommended').addEventListener('click', function () {
document.querySelector('#p-main-categories .title-recommended').addEventListener('click', function () {
     openList(this, 'recommended-open');
     openList(this);
});
});
document.querySelector('#p-main-categories .title-category').addEventListener('click', function () {
document.querySelector('#p-main-categories .title-category').addEventListener('click', function () {
     openList(this, 'category-open');
     openList(this);
});
});


function openList(titleLi, listClass) {
function openList(titleLi) {
     var list = document.querySelector('#p-main-categories');
     // 현재 li가 열려 있으면 닫기
    if (list.classList.contains(listClass)) {
        list.classList.remove(listClass);
    } else {
        list.classList.add(listClass);
    }
 
     if (titleLi.classList.contains('open')) {
     if (titleLi.classList.contains('open')) {
         titleLi.classList.remove('open');
         titleLi.classList.remove('open');
        let next = titleLi.nextElementSibling;
        while (next && !next.classList.contains('title-recommended') && !next.classList.contains('title-category')) {
            next.style.display = 'none';
            next = next.nextElementSibling;
        }
     } else {
     } else {
        // 열기
         titleLi.classList.add('open');
         titleLi.classList.add('open');
        let next = titleLi.nextElementSibling;
        while (next && !next.classList.contains('title-recommended') && !next.classList.contains('title-category')) {
            next.style.display = 'block';
            next = next.nextElementSibling;
        }
     }
     }
}
}

Revision as of 15:48, 25 September 2025

/* All JavaScript here will be loaded for users of the MinervaNeue skin */
// 모바일 메뉴에서 '둘러보기' 문서 보여주기

document
    .querySelector('#mw-mf-page-left #p-navigation')
    .insertAdjacentHTML(
        'afterend',
        '<ul id="p-main-categories" class="recommended-open">'+
        	'<li class="title-recommended open"><a><span>Recommended Documents</span></a><span class="ico-arrow"></span></li>'+
        	'<li class="recommended"><a href="/en/World_Mission_Society_Church_of_God"><span>Church of God(Document)</span></a></li>'+
        	'<li class="recommended"><a href="/en/Ahnsahnghong"><span>Christ Ahnsahnghong</span></a></li>'+
        	'<li class="recommended"><a href="/en/God_the_Mother"><span>God the Mother</span></a></li>'+
        	'<li class="recommended"><a href="/en/Sabbath"><span>Sabbath</span></a></li>'+
        	'<li class="recommended"><a href="/en/Passover"><span>Passover</span></a></li>'+
        	'<li class="recommended"><a href="/en/Gospel_and_the_New_Covenant"><span>Gospel and New Covenant</span></a></li>'+
        	'<li class="title-category"><a><span>Browse by Category</span></a><span class="ico-arrow"></span></li>'+
        	'<li class="category"><a href="/en/Category:Church_of_God"><span>Church of God</span></a></li>'+
        	'<li class="category"><a href="/en/Category:God_the_Father"><span>God the Father</span></a></li>'+
        	'<li class="category"><a href="/en/Category:God_the_Mother"><span>God the Mother</span></a></li>'+
        	'<li class="category"><a href="/en/Category:Gospel_of_the_New_Covenant"><span>Gospel of the New Covenant</span></a></li>'+
        	'<li class="category"><a href="/en/Category:Bible_Knowledge"><span>Bible Knowledge</span></a></li>'+
        	'<li class="category"><a href="/en/Category:Biblical_Issues"><span>Biblical Issues</span></a></li>'+
        	'<li class="category"><a href="/en/Category:Community_Service"><span>Community Service</span></a></li>'+
        	'<li class="category"><a href="/en/Category:Global_Cooperation"><span>Global Cooperation</span></a></li>'+
        '</ul>'
    );

document.querySelector('#p-main-categories .title-recommended').addEventListener('click', function () {
    openList(this);
});
document.querySelector('#p-main-categories .title-category').addEventListener('click', function () {
    openList(this);
});

function openList(titleLi) {
    // 현재 li가 열려 있으면 닫기
    if (titleLi.classList.contains('open')) {
        titleLi.classList.remove('open');
        let next = titleLi.nextElementSibling;
        while (next && !next.classList.contains('title-recommended') && !next.classList.contains('title-category')) {
            next.style.display = 'none';
            next = next.nextElementSibling;
        }
    } else {
        // 열기
        titleLi.classList.add('open');
        let next = titleLi.nextElementSibling;
        while (next && !next.classList.contains('title-recommended') && !next.classList.contains('title-category')) {
            next.style.display = 'block';
            next = next.nextElementSibling;
        }
    }
}

// 유튜브 썸네일
document.querySelectorAll('iframe').forEach(function(iframe){
    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();
            }
        });
    });
});