-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflora.js
More file actions
119 lines (101 loc) · 3.5 KB
/
Copy pathflora.js
File metadata and controls
119 lines (101 loc) · 3.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/* =============================================
FLORA — Shared JavaScript (flora.js)
============================================= */
// ---- Hamburger Menu ----
(function () {
const hamburger = document.getElementById('hamburger');
const mobileNav = document.getElementById('mobileNav');
if (!hamburger || !mobileNav) return;
hamburger.addEventListener('click', function () {
const isOpen = mobileNav.classList.toggle('open');
hamburger.classList.toggle('open', isOpen);
hamburger.setAttribute('aria-expanded', isOpen);
mobileNav.setAttribute('aria-hidden', !isOpen);
});
// Close menu when clicking outside
document.addEventListener('click', function (e) {
if (!hamburger.contains(e.target) && !mobileNav.contains(e.target)) {
closeMenu();
}
});
})();
function closeMenu() {
const hamburger = document.getElementById('hamburger');
const mobileNav = document.getElementById('mobileNav');
if (!hamburger || !mobileNav) return;
mobileNav.classList.remove('open');
hamburger.classList.remove('open');
hamburger.setAttribute('aria-expanded', 'false');
mobileNav.setAttribute('aria-hidden', 'true');
}
// ---- Modal Functions ----
function showModal(title, message) {
const modal = document.getElementById('comingSoonModal');
const modalTitle = document.getElementById('modalTitle');
const modalMessage = document.getElementById('modalMessage');
if (modal && modalTitle && modalMessage) {
modalTitle.textContent = title;
modalMessage.textContent = message;
modal.classList.add('show');
document.body.style.overflow = 'hidden';
}
}
function closeModal() {
const modal = document.getElementById('comingSoonModal');
if (modal) {
modal.classList.remove('show');
document.body.style.overflow = '';
}
}
// Close modal on outside click
document.addEventListener('click', function(e) {
const modal = document.getElementById('comingSoonModal');
if (e.target === modal) {
closeModal();
}
});
// Close modal on Escape key
document.addEventListener('keydown', function(e) {
if (e.key === 'Escape') {
closeModal();
}
});
// ---- Offer Button ----
function confirmOffer() {
showModal(
'🌸 Coming Soon!',
'This feature is currently under development. Our online ordering system will be available soon. Please contact us directly for orders.'
);
}
// ---- Contact Form Submit — logs to browser console ----
function submitForm() {
const inputs = document.querySelectorAll('.frm input, .frm textarea');
const labels = ['Name', 'Email', 'Phone', 'Query Topic', 'Comments/Questions'];
const formData = {};
let isValid = true;
inputs.forEach(function (input, index) {
const value = input.value.trim();
formData[labels[index] || ('Field ' + (index + 1))] = value;
// Basic validation
if (input.hasAttribute('required') && !value) {
isValid = false;
input.style.borderColor = '#ff4444';
} else {
input.style.borderColor = '';
}
});
if (!isValid) {
showModal('⚠️ Validation Error', 'Please fill in all required fields.');
return;
}
// Log to console (template only)
console.log('%c Flora -- New Query Submission ', 'background:#02a102;color:white;font-weight:bold;padding:4px 8px;border-radius:3px;');
console.table(formData);
// Show success message
showModal(
'✅ Thank You!',
'Your query has been received (demo mode). In a production environment, this would be sent to our team.'
);
// Clear form
inputs.forEach(input => input.value = '');
}