More actions
No edit summary Tag: Reverted |
No edit summary Tag: Reverted |
||
Line 40: | Line 40: | ||
$(document).ready(function() { | $(document).ready(function() { | ||
// Create the Add Category button | // Create the Add Category button | ||
var addCategoryButton = $('< | var addCategoryButton = $('<li>').append( | ||
.text('Add Category') | $('<a>').text('Add Category').click(function() { | ||
var category = prompt('Enter the category to add:'); | var category = prompt('Enter the category to add:'); | ||
if (category) { | if (category) { | ||
Line 52: | Line 51: | ||
} | } | ||
} | } | ||
}); | }) | ||
); | |||
// | // Append the button to the main navigation menu | ||
$('#p- | $('#p-navigation ul').append(addCategoryButton); | ||
}); | }); |
Revision as of 23:18, 30 December 2024
/* Any JavaScript here will be loaded for all users on every page load. */
$(function(){
$('.card').on('mousenter', function(event){
event.preventDefault();
$(this).toggleClass('hovered');
});
$('.card').on('mouseleave', function(event){
event.preventDefault();
$(this).toggleClass('hovered');
});
});
document.querySelectorAll('.sub-card').forEach(card => {
card.addEventListener('click', function(event) {
event.stopPropagation(); // Prevent event bubbling
// Toggle the expanded state of the clicked card
const isExpanded = card.getAttribute('data-expanded') === 'true';
// Flip the current sub-card
card.setAttribute('data-expanded', isExpanded ? 'false' : 'true');
// Hide all other sub-cards
document.querySelectorAll('.sub-card').forEach(otherCard => {
if (otherCard !== card) {
otherCard.setAttribute('data-expanded', 'false');
}
});
});
});
document.querySelectorAll('.card').forEach(card => {
card.addEventListener('mouseleave', function() {
// Collapse all sub-cards when mouse leaves the main card
document.querySelectorAll('.sub-card').forEach(subCard => {
subCard.setAttribute('data-expanded', 'false');
});
});
});
$(document).ready(function() {
// Create the Add Category button
var addCategoryButton = $('<li>').append(
$('<a>').text('Add Category').click(function() {
var category = prompt('Enter the category to add:');
if (category) {
var categoryMarkup = '[[' + category + ']]';
var editButton = $('#ca-edit a');
if (editButton.length) {
// Redirect to the edit page with the category preloaded
window.location.href = editButton.attr('href') + '§ion=new&preload=' + encodeURIComponent(categoryMarkup);
}
}
})
);
// Append the button to the main navigation menu
$('#p-navigation ul').append(addCategoryButton);
});