미디어위키:Minerva.js: 두 판 사이의 차이
Resultofunion (토론 | 기여) 편집 요약 없음 태그: 모바일 편집 모바일 웹 편집 |
Resultofunion (토론 | 기여) 편집 요약 없음 태그: 수동 되돌리기 |
||
| (같은 사용자의 중간 판 37개는 보이지 않습니다) | |||
| 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. | function wikiLink(title) { | ||
return mw.config.get('wgServer') + '/' + title.replace(/ /g, '_'); | |||
} | |||
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>추천문서</span></a><span class="ico-arrow"></span></li>' + | |||
'<li class="recommended"><a href="/"><span>하나님의 교회</span></a></li>' + | |||
'<li class="recommended"><a href="'+wikiLink("안상홍")+'"><span>그리스도 안상홍님</span></a></li>' + | |||
'<li class="recommended"><a href="'+wikiLink("어머니 하나님")+'"><span>어머니 하나님</span></a></li>' + | |||
'<li class="recommended"><a href="'+wikiLink("안식일")+'"><span>안식일</span></a></li>' + | |||
'<li class="recommended"><a href="'+wikiLink("유월절")+'"><span>유월절</span></a></li>' + | |||
'<li class="recommended"><a href="'+wikiLink("복음과 새 언약")+'"><span>복음과 새 언약</span></a></li>' + | |||
'<li class="recommended"><a href="'+wikiLink("하나님의 교회 마지막 종교개혁")+'"><span>마지막 종교개혁</span></a></li>' + | |||
'<li class="title-category"><a><span>카테고리 둘러보기</span></a><span class="ico-arrow"></span></li>' + | |||
'<li class="category"><a href="'+wikiLink("분류:하나님의 교회")+'"><span>하나님의 교회</span></a></li>' + | |||
'<li class="category"><a href="'+wikiLink("분류:아버지")+'"><span>아버지 하나님</span></a></li>' + | |||
'<li class="category"><a href="'+wikiLink("분류:어머니")+'"><span>어머니 하나님</span></a></li>' + | |||
'<li class="category"><a href="'+wikiLink("분류:새 언약 복음")+'"><span>새 언약 복음</span></a></li>' + | |||
'<li class="category"><a href="'+wikiLink("분류:성경 일반")+'"><span>성경 상식</span></a></li>' + | |||
'<li class="category"><a href="'+wikiLink("분류:성경 이슈")+'"><span>성경 이슈</span></a></li>' + | |||
'<li class="category"><a href="'+wikiLink("분류:사회 공헌")+'"><span>사회 공헌</span></a></li>' + | |||
'<li class="category"><a href="'+wikiLink("분류:국제 협력")+'"><span>국제 협력</span></a></li>' + | |||
'</ul>' | |||
); | |||
// Recommended Documents 토글 | |||
document.querySelector('#p-main-categories .title-recommended') | |||
.addEventListener('click', function (event) { | |||
event.stopPropagation(); // 사이드바 닫힘 방지 | |||
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, selector) { | |||
titleLi.classList.toggle('open'); | |||
let next = titleLi.nextElementSibling; | |||
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; | |||
} | |||
} | |||
// 유튜브 썸네일 | |||
document.querySelectorAll('iframe').forEach(function (iframe) { | |||
var $container = iframe.parentElement; | |||
var $videoWrap = $container.parentElement; | |||
if ($videoWrap && $videoWrap.classList.contains('video-wrap')) return; | |||
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(); | |||
} | |||
}); | |||
}); | |||
}); | |||
/* ------------------------------- | |||
* 모바일 언어 메뉴 삽입 | |||
* ------------------------------- */ | |||
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(); | |||
} | |||
}); | |||
// ===== 여기부터 모바일 언어 메뉴 삽입 ===== | |||
if ( mw.config.get('skin') === 'minerva' ) { | |||
var langHTML = '' | |||
+ '<ul id="mobile-language" class="recommended-open">' | |||
+ '<li><a href="https://churchofgod.wiki/en">English (영어)</a></li>' | |||
+ '<li><a href="https://churchofgod.wiki/es">Español (스페인어)</a></li>' | |||
+ '<li><a href="https://churchofgod.wiki/vi">Tiếng Việt (베트남어)</a></li>' | |||
+ '<li><a href="https://churchofgod.wiki/ne">नेपाली (네팔어)</a></li>' | |||
+ '<li><a href="https://churchofgod.wiki/pt">Português (포르투갈어)</a></li>' | |||
+ '</ul>'; | |||
var $list = $('#mobile-language'); | |||
$list.html(langHTML); | |||
} | |||
}); | }); | ||
}); | }); | ||