MediaWiki:Common.js: Difference between revisions

From Happy Paws Travel Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
console.log("Common.js");
/* Load jQuery */
/* Load jQuery */
mw.loader.load('https://code.jquery.com/jquery-3.5.1.min.js');
mw.loader.load('https://code.jquery.com/jquery-3.5.1.min.js');
Line 7: Line 8:
/* 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');
console.log("After loding scripts");


document.addEventListener("DOMContentLoaded", function() {
document.addEventListener("DOMContentLoaded", function() {
    console.log("Fix cards");
     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) {

Revision as of 04:10, 29 June 2024

console.log("Common.js");
/* Load jQuery */
mw.loader.load('https://code.jquery.com/jquery-3.5.1.min.js');

/* 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');
console.log("After loding scripts");


document.addEventListener("DOMContentLoaded", function() {
    console.log("Fix cards");
    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++;
        }
    });
});