Spaces:
Running
Running
| // Shared JavaScript functionality | |
| document.addEventListener('DOMContentLoaded', function() { | |
| // Initialize tooltips | |
| const tooltips = document.querySelectorAll('[data-tooltip]'); | |
| tooltips.forEach(tooltip => { | |
| tooltip.addEventListener('mouseenter', showTooltip); | |
| tooltip.addEventListener('mouseleave', hideTooltip); | |
| }); | |
| // Mobile menu toggle functionality will be handled by navbar component | |
| }); | |
| function showTooltip(event) { | |
| const tooltipText = event.target.getAttribute('data-tooltip'); | |
| const tooltip = document.createElement('div'); | |
| tooltip.className = 'tooltip'; | |
| tooltip.textContent = tooltipText; | |
| document.body.appendChild(tooltip); | |
| const rect = event.target.getBoundingClientRect(); | |
| tooltip.style.position = 'absolute'; | |
| tooltip.style.top = `${rect.top - tooltip.offsetHeight - 10}px`; | |
| tooltip.style.left = `${rect.left + rect.width / 2 - tooltip.offsetWidth / 2}px`; | |
| } | |
| function hideTooltip() { | |
| const tooltip = document.querySelector('.tooltip'); | |
| if (tooltip) { | |
| tooltip.remove(); | |
| } | |
| } | |
| // Recipe search functionality | |
| function searchRecipes(query) { | |
| // This would be connected to a recipe API in a real implementation | |
| console.log(`Searching for recipes with query: ${query}`); | |
| } | |
| // Shopping list functionality | |
| function addToShoppingList(ingredient) { | |
| // This would manage a shopping list in localStorage or via an API | |
| console.log(`Added ${ingredient} to shopping list`); | |
| } |