참고: 설정을 저장한 후에 바뀐 점을 확인하기 위해서는 브라우저의 캐시를 새로 고쳐야 합니다.
- 파이어폭스 / 사파리: Shift 키를 누르면서 새로 고침을 클릭하거나, Ctrl-F5 또는 Ctrl-R을 입력 (Mac에서는 ⌘-R)
- 구글 크롬: Ctrl-Shift-R키를 입력 (Mac에서는 ⌘-Shift-R)
- 인터넷 익스플로러 / 엣지: Ctrl 키를 누르면서 새로 고침을 클릭하거나, Ctrl-F5를 입력.
- 오페라: Ctrl-F5를 입력.
(function (mw, $) {
'use strict';
function activate(shell, key) {
if (!shell || !key) return;
var tabs = shell.querySelectorAll('.clbi-nations-simple-tab[data-continent]');
var panels = shell.querySelectorAll('.clbi-nations-simple-continent[data-continent-panel]');
var matched = false;
Array.prototype.forEach.call(tabs, function (tab) {
var active = tab.getAttribute('data-continent') === key;
tab.classList.toggle('is-active', active);
tab.setAttribute('aria-selected', active ? 'true' : 'false');
tab.setAttribute('tabindex', '0');
if (active) matched = true;
});
if (!matched && tabs.length) {
key = tabs[0].getAttribute('data-continent');
tabs[0].classList.add('is-active');
tabs[0].setAttribute('aria-selected', 'true');
}
Array.prototype.forEach.call(panels, function (panel) {
var active = panel.getAttribute('data-continent-panel') === key;
panel.classList.toggle('is-active', active);
if (active) {
panel.removeAttribute('hidden');
} else {
panel.setAttribute('hidden', 'hidden');
}
});
}
function bindShell(shell) {
if (!shell || shell.getAttribute('data-clbi-nations-simple-bound') === '1') return;
shell.setAttribute('data-clbi-nations-simple-bound', '1');
shell.addEventListener('click', function (event) {
var tab = event.target.closest ? event.target.closest('.clbi-nations-simple-tab[data-continent]') : null;
if (!tab || !shell.contains(tab)) return;
activate(shell, tab.getAttribute('data-continent'));
});
shell.addEventListener('keydown', function (event) {
var tab = event.target.closest ? event.target.closest('.clbi-nations-simple-tab[data-continent]') : null;
if (!tab || !shell.contains(tab)) return;
if (event.key !== 'Enter' && event.key !== ' ') return;
event.preventDefault();
activate(shell, tab.getAttribute('data-continent'));
});
var active = shell.querySelector('.clbi-nations-simple-tab.is-active[data-continent]') || shell.querySelector('.clbi-nations-simple-tab[data-continent]');
if (active) activate(shell, active.getAttribute('data-continent'));
}
function init(root) {
root = root && root.jquery ? root[0] : (root || document);
var shells = root.querySelectorAll ? root.querySelectorAll('.clbi-nations-simple-shell[data-clbi-nations-simple]') : [];
Array.prototype.forEach.call(shells, bindShell);
}
window.CLBI_NationsPanelSimple = { init: init, activate: activate };
$(init);
if (mw && mw.hook) {
mw.hook('wikipage.content').add(function ($content) {
init($content && $content[0] ? $content[0] : document);
});
}
}(window.mediaWiki, window.jQuery));