BCards/src/BCards.Web/wwwroot/js/support-fab.js
Ricardo Carneiro b382688a8f
All checks were successful
BCards Deployment Pipeline / Run Tests (push) Successful in 4s
BCards Deployment Pipeline / PR Validation (push) Has been skipped
BCards Deployment Pipeline / Build and Push Image (push) Successful in 11m18s
BCards Deployment Pipeline / Deploy to Production (ARM - OCI) (push) Has been skipped
BCards Deployment Pipeline / Deploy to Release Swarm (ARM) (push) Successful in 17s
BCards Deployment Pipeline / Cleanup Old Resources (push) Has been skipped
BCards Deployment Pipeline / Deployment Summary (push) Successful in 0s
feat: fale conosco
2025-10-28 19:58:43 -03:00

57 lines
2.0 KiB
JavaScript

// Support FAB (Floating Action Button) for BCards
(function () {
'use strict';
function initSupportFab() {
const fabTrigger = document.getElementById('supportFabTrigger');
const fabMenu = document.getElementById('supportFabMenu');
if (!fabTrigger || !fabMenu) {
return;
}
// Toggle menu on trigger click
fabTrigger.addEventListener('click', function () {
if (fabMenu.style.display === 'none' || fabMenu.style.display === '') {
fabMenu.style.display = 'block';
fabTrigger.setAttribute('aria-expanded', 'true');
} else {
fabMenu.style.display = 'none';
fabTrigger.setAttribute('aria-expanded', 'false');
}
});
// Close menu when clicking outside
document.addEventListener('click', function (event) {
if (!fabTrigger.contains(event.target) && !fabMenu.contains(event.target)) {
fabMenu.style.display = 'none';
fabTrigger.setAttribute('aria-expanded', 'false');
}
});
// Close menu on ESC key
document.addEventListener('keydown', function (event) {
if (event.key === 'Escape' && fabMenu.style.display === 'block') {
fabMenu.style.display = 'none';
fabTrigger.setAttribute('aria-expanded', 'false');
}
});
// Close menu when clicking menu options
const menuOptions = fabMenu.querySelectorAll('.support-fab-option');
menuOptions.forEach(function (option) {
option.addEventListener('click', function () {
fabMenu.style.display = 'none';
fabTrigger.setAttribute('aria-expanded', 'false');
});
});
}
// Initialize on DOM ready
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', initSupportFab);
} else {
initSupportFab();
}
})();