MediaWiki:Common.js: Difference between revisions
MediaWiki interface page
More actions
No edit summary |
No edit summary Tag: Reverted |
||
| Line 91: | Line 91: | ||
} | } | ||
})(); | })(); | ||
/* Show one update panel based on dropdown */ | |||
mw.loader.using(['mediawiki.util'], function () { | |||
function initTvDropdown(root) { | |||
var select = root.querySelector('#tvdd-select'); | |||
var panels = root.querySelectorAll('.tvdd__panel'); | |||
if (!select || !panels.length) return; | |||
function show(key) { | |||
panels.forEach(function(p){ | |||
if (p.getAttribute('data-key') === key) p.classList.add('is-active'); | |||
else p.classList.remove('is-active'); | |||
}); | |||
} | |||
// Initial selection: first option | |||
show(select.value); | |||
// Update on change | |||
select.addEventListener('change', function(){ | |||
show(select.value); | |||
}); | |||
} | |||
document.querySelectorAll('#tv-updates.tvdd').forEach(initTvDropdown); | |||
}); | |||