|
|
| 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);
| |
| });
| |
|
| |
| /* Dropdown: show only the selected update */
| |
| mw.loader.using([], function () {
| |
| function init(root) {
| |
| var sel = root.querySelector('#tvdd-select');
| |
| var panels = root.querySelectorAll('.tvdd__panel');
| |
| if (!sel || !panels.length) return;
| |
|
| |
| function show(key){
| |
| panels.forEach(function(p){
| |
| p.classList.toggle('is-active', p.getAttribute('data-key') === key);
| |
| });
| |
| }
| |
| show(sel.value);
| |
| sel.addEventListener('change', function(){ show(sel.value); });
| |
| }
| |
| document.querySelectorAll('#tv-updates.tvdd').forEach(init);
| |
| });
| |