MediaWiki:Common.js: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
| (3 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
/* Load Popper.js */ | /* Load Popper.js */ | ||
mw.loader.load('https://cdn.jsdelivr.net/npm/@popperjs/core@2.5.4/dist/umd/popper.min.js'); | mw.loader.load('https://cdn.jsdelivr.net/npm/@popperjs/core@2.5.4/dist/umd/popper.min.js'); | ||
| Line 8: | Line 4: | ||
/* Load Bootstrap JS */ | /* Load Bootstrap JS */ | ||
mw.loader.load('https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js'); | mw.loader.load('https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js'); | ||
function initializePlacesButtons() { | |||
var count = 1; | var count = 1; | ||
document.querySelectorAll('.btn.btn-primary.places-button').forEach(function(button) { | document.querySelectorAll('.btn.btn-primary.places-button').forEach(function(button) { | ||
| Line 22: | Line 15: | ||
button.setAttribute('aria-controls', uniqueId); | button.setAttribute('aria-controls', uniqueId); | ||
count++; | count++; | ||
} | } | ||
}); | |||
} | |||
if (document.readyState !== 'loading') { | |||
initializePlacesButtons(); | |||
} else { | |||
document.addEventListener('DOMContentLoaded', function () { | |||
initializePlacesButtons(); | |||
}); | }); | ||
} | } | ||
Latest revision as of 07:26, 29 June 2024
/* Load Popper.js */
mw.loader.load('https://cdn.jsdelivr.net/npm/@popperjs/core@2.5.4/dist/umd/popper.min.js');
/* Load Bootstrap JS */
mw.loader.load('https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js');
function initializePlacesButtons() {
var count = 1;
document.querySelectorAll('.btn.btn-primary.places-button').forEach(function(button) {
var uniqueId = 'details-places-' + count;
var collapseDiv = button.parentElement.nextElementSibling;
if (collapseDiv) {
collapseDiv.id = uniqueId;
button.setAttribute('data-target', '#' + uniqueId);
button.setAttribute('aria-controls', uniqueId);
count++;
}
});
}
if (document.readyState !== 'loading') {
initializePlacesButtons();
} else {
document.addEventListener('DOMContentLoaded', function () {
initializePlacesButtons();
});
}