Spaces:
Running
Running
Download script.js from Mustavi/flowforge-admin-portal: direct link, hf CLI and curl.
- Browser
- Download file 2.6 kB
-
https://huggingface.co/spaces/Mustavi/flowforge-admin-portal/resolve/main/script.js
- Command line
-
hf download hf://spaces/Mustavi/flowforge-admin-portal/script.js
-
curl -L -o script.js https://huggingface.co/spaces/Mustavi/flowforge-admin-portal/resolve/main/script.js
2.6 kB
| // Global utility functions | |
| // Toggle mobile menu | |
| function toggleMobileMenu() { | |
| const mobileMenu = document.getElementById('mobile-menu'); | |
| mobileMenu.classList.toggle('hidden'); | |
| } | |
| // Initialize tooltips | |
| function initTooltips() { | |
| const tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]')); | |
| tooltipTriggerList.map(function (tooltipTriggerEl) { | |
| return new bootstrap.Tooltip(tooltipTriggerEl); | |
| }); | |
| } | |
| // Format date | |
| function formatDate(dateString) { | |
| const options = { year: 'numeric', month: 'short', day: 'numeric' }; | |
| return new Date(dateString).toLocaleDateString(undefined, options); | |
| } | |
| // Check permissions | |
| function checkPermission(permission) { | |
| // In a real app, this would check the user's permissions | |
| // For demo purposes, we'll assume the user is a super admin | |
| return true; | |
| } | |
| // Initialize modals | |
| function initModals() { | |
| const modalTriggers = document.querySelectorAll('[data-modal-toggle]'); | |
| modalTriggers.forEach(trigger => { | |
| trigger.addEventListener('click', function() { | |
| const modalId = this.getAttribute('data-modal-toggle'); | |
| const modal = document.getElementById(modalId); | |
| modal.classList.toggle('hidden'); | |
| }); | |
| }); | |
| } | |
| // Initialize dropdowns | |
| function initDropdowns() { | |
| const dropdownTriggers = document.querySelectorAll('[data-dropdown-toggle]'); | |
| dropdownTriggers.forEach(trigger => { | |
| trigger.addEventListener('click', function() { | |
| const dropdownId = this.getAttribute('data-dropdown-toggle'); | |
| const dropdown = document.getElementById(dropdownId); | |
| dropdown.classList.toggle('hidden'); | |
| }); | |
| }); | |
| } | |
| // Document ready | |
| document.addEventListener('DOMContentLoaded', function() { | |
| initTooltips(); | |
| initModals(); | |
| initDropdowns(); | |
| // Close dropdowns when clicking outside | |
| document.addEventListener('click', function(event) { | |
| const dropdowns = document.querySelectorAll('[data-dropdown]'); | |
| dropdowns.forEach(dropdown => { | |
| if (!dropdown.contains(event.target) && !event.target.matches('[data-dropdown-toggle]')) { | |
| dropdown.classList.add('hidden'); | |
| } | |
| }); | |
| }); | |
| // Close modals when clicking outside | |
| document.addEventListener('click', function(event) { | |
| const modals = document.querySelectorAll('[data-modal]'); | |
| modals.forEach(modal => { | |
| if (event.target === modal) { | |
| modal.classList.add('hidden'); | |
| } | |
| }); | |
| }); | |
| }); |