MediaWiki:Common.js: Difference between revisions
From Makerpedia
No edit summary |
No edit summary |
||
| Line 30: | Line 30: | ||
$(document).ready(function () { | $(document).ready(function () { | ||
// | // Initially, show all galleries | ||
$("#tool-gallery"). | $("#tool-gallery, #makerspace-gallery, #machineshop-gallery, #woodshop-gallery").show(); | ||
// Filter logic when a button is clicked | // Filter logic when a button is clicked | ||
| Line 42: | Line 37: | ||
var selectedCategory = $(this).data("filter"); | var selectedCategory = $(this).data("filter"); | ||
// Hide | // Hide all galleries first | ||
$("#tool-gallery").hide(); | $("#tool-gallery, #makerspace-gallery, #machineshop-gallery, #woodshop-gallery").hide(); | ||
// Show | // Show the appropriate gallery based on the selected category | ||
if (selectedCategory === " | if (selectedCategory === "All") { | ||
$("#tool-gallery | // Show all galleries when "Show All" is clicked | ||
$("#tool-gallery, #makerspace-gallery, #machineshop-gallery, #woodshop-gallery").show(); | |||
} else if (selectedCategory === "Machine Shop Tools") { | |||
// Show only Machine Shop Tools gallery | |||
$("#machineshop-gallery").show(); | |||
} else if (selectedCategory === "Makerspace Tools") { | } else if (selectedCategory === "Makerspace Tools") { | ||
$("# | // Show only Makerspace Tools gallery | ||
$("#makerspace-gallery").show(); | |||
} else if (selectedCategory === "Wood Shop Tools") { | |||
// Show only Wood Shop Tools gallery | |||
$("#woodshop-gallery").show(); | |||
} | } | ||
}); | }); | ||
}); | }); | ||
Revision as of 03:01, 4 February 2025
/* Any JavaScript here will be loaded for all users on every page load. */
if (document) window.µ = function (id, elem) {
var ret;
var root = ((elem) ? elem : document);
switch (id.charAt(0)) {
case '|':
ret = root;
break;
case '+':
ret = document.createElement(id.substring(1));
if (elem) elem.appendChild(ret);
break;
case '#':
ret = root.querySelector(id);
break;
default:
ret = Array.prototype.slice.call(root.querySelectorAll(id));
break;
}
return ret;
};
/* add additional edit button (prioritize 'Edit' over 'Edit Source' when available) -- styled in Medik.css */
if(document.getElementById("ca-edit") != null || document.getElementById("ca-ve-edit") != null) {
let link = document.getElementById("ca-ve-edit") != null ? document.querySelector("#ca-ve-edit a").href : document.querySelector("#ca-edit a").href;
document.getElementById("content").innerHTML += '<a href='+link+'><button class="big-edit-button"><p>EDIT</p></button></a>';
}
$(document).ready(function () {
// Initially, show all galleries
$("#tool-gallery, #makerspace-gallery, #machineshop-gallery, #woodshop-gallery").show();
// Filter logic when a button is clicked
$(".filter-btn").click(function () {
var selectedCategory = $(this).data("filter");
// Hide all galleries first
$("#tool-gallery, #makerspace-gallery, #machineshop-gallery, #woodshop-gallery").hide();
// Show the appropriate gallery based on the selected category
if (selectedCategory === "All") {
// Show all galleries when "Show All" is clicked
$("#tool-gallery, #makerspace-gallery, #machineshop-gallery, #woodshop-gallery").show();
} else if (selectedCategory === "Machine Shop Tools") {
// Show only Machine Shop Tools gallery
$("#machineshop-gallery").show();
} else if (selectedCategory === "Makerspace Tools") {
// Show only Makerspace Tools gallery
$("#makerspace-gallery").show();
} else if (selectedCategory === "Wood Shop Tools") {
// Show only Wood Shop Tools gallery
$("#woodshop-gallery").show();
}
});
});