MediaWiki:Minerva.js: Difference between revisions

No edit summary
Tags: Mobile edit Mobile web edit
No edit summary
Tags: Mobile edit Mobile web edit
Line 6: Line 6:
     .insertAdjacentHTML(
     .insertAdjacentHTML(
         'afterend',
         'afterend',
         '<ul id="p-main-categories" class="recommended-open">'+
         '<ul id="p-main-categories">'+
         '<li class="title-recommended open"><a><span>Recommended Documents</span></a><span class="ico-arrow"></span></li>'+
         '<li class="title-recommended"><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" style="display:none;"><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" style="display:none;"><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" style="display:none;"><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" style="display:none;"><a href="/en/Sabbath"><span>Sabbath</span></a></li>'+
         '<li class="recommended"><a href="/en/Passover"><span>Passover</span></a></li>'+
         '<li class="recommended" style="display:none;"><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="recommended" style="display:none;"><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="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" style="display:none;"><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" style="display:none;"><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" style="display:none;"><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" style="display:none;"><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" style="display:none;"><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" style="display:none;"><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" style="display:none;"><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>'+
         '<li class="category" style="display:none;"><a href="/en/Category:Global_Cooperation"><span>Global Cooperation</span></a></li>'+
         '</ul>'
         '</ul>'
     );
     );


document.querySelector('#p-main-categories .title-recommended').addEventListener('click', function () {
// Recommended Documents 토글
    openList(this);
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);
        openList(this, '.recommended');
});
    });
 
// Browse by Category 토글
document.querySelector('#p-main-categories .title-category')
    .addEventListener('click', function (event) {
        event.stopPropagation(); // 사이드바 닫힘 방지
        openList(this, '.category');
    });


function openList(titleLi) {
function openList(titleLi, selector) {
     // 현재 li가 열려 있으면 닫기
     titleLi.classList.toggle('open');
    if (titleLi.classList.contains('open')) {
    let next = titleLi.nextElementSibling;
        titleLi.classList.remove('open');
    while (next && !next.classList.contains('title-recommended') && !next.classList.contains('title-category')) {
        let next = titleLi.nextElementSibling;
        if (next.matches(selector)) {
        while (next && !next.classList.contains('title-recommended') && !next.classList.contains('title-category')) {
             next.style.display = (next.style.display === 'none' || next.style.display === '') ? 'block' : 'none';
            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;
         }
         }
        next = next.nextElementSibling;
     }
     }
}
}
Line 57: Line 55:
     iframe.parentElement.classList.add('video-wrap');
     iframe.parentElement.classList.add('video-wrap');
});
});
mw.loader.using(['jquery']).then(function() {
mw.loader.using(['jquery']).then(function() {
     $(function() {
     $(function() {