Files
resharespace-static/_includes/sidebar_post.liquid
T

456 lines
31 KiB
Plaintext

<!--sidebar post section-->
<aside id="post-modal" class="overscroll-none overflow-y-auto fixed inset-0 w-screen z-50 justify-center hidden bg-black bg-opacity-50" aria-labelledby="modal-title" role="dialog" aria-modal="true">
<div class="relative w-full h-full max-w-lg ml-auto bg-white shadow-xl flex flex-col lg:max-w-xl">
<!-- Modal Header with Close Button -->
<div class="sticky top-0 bg-white z-10 px-4 sm:px-6 py-4 border-b border-gray-200">
<div class="flex items-center justify-between">
<h2 class="text-lg font-medium text-gray-900 font-heading" id="modal-title">
Post a New Listing
</h2>
<button type="button" onclick="toggleNavbar('post-modal'); if (typeof toggleOverlay === 'function') toggleOverlay('collapse-overlay');" class="bg-white rounded-md text-gray-400 hover:text-gray-500 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-green-500">
<span class="sr-only">Close</span>
<svg class="h-6 w-6" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor" aria-hidden="true">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" />
</svg>
</button>
</div>
</div>
<!-- Modal Body with Form -->
<div id="post-form-steps-modal" class="flex-1 overflow-y-auto p-4 sm:p-6">
<!-- Step Indicators (Compact) -->
<div class="flex justify-between mb-6">
<div id="step-indicator-1-modal" class="step-indicator-modal active-step-modal text-center flex-1">
<div class="w-8 h-8 mx-auto rounded-full bg-green-300 text-green-900 flex items-center justify-center text-xs">1</div>
<p class="text-sm mt-1 font-heading">Description</p>
</div>
<div id="step-indicator-2-modal" class="step-indicator-modal text-center text-gray-500 flex-1">
<div class="w-8 h-8 mx-auto rounded-full bg-gray-300 text-green-900 flex items-center justify-center text-xs">2</div>
<p class="text-sm mt-1 font-heading">Location</p>
</div>
<div id="step-indicator-3-modal" class="step-indicator-modal text-center text-gray-500 flex-1">
<div class="w-8 h-8 mx-auto rounded-full bg-gray-300 text-green-900 flex items-center justify-center text-xs">3</div>
<p class="text-sm mt-1 font-heading">Price & Availability</p>
</div>
<div id="step-indicator-4-modal" class="step-indicator-modal text-center text-gray-500 flex-1">
<div class="w-8 h-8 mx-auto rounded-full bg-gray-300 text-green-900 flex items-center justify-center text-xs">4</div>
<p class="text-sm mt-1 font-heading">Contact</p>
</div>
</div>
<form id="new-listing-form-modal">
<!-- Step 1: Description -->
<div id="step-1-modal" class="form-step-modal active-step-modal">
<h2 class="text-lg font-semibold text-green-900 mb-4 font-heading">Step 1: Listing Description</h2>
<div class="space-y-4">
<div>
<label for="photo-modal" class="block text-sm font-medium text-gray-700 mb-1 font-heading">Listing Photo</label>
<input type="file" id="photo-modal" name="photo" class="w-full text-sm text-gray-500 file:mr-4 file:py-2 file:px-4 file:rounded-sm file:border-0 file:text-sm file:font-semibold file:bg-green-50 file:text-green-300 hover:file:bg-green-100 border border-gray-300 rounded-sm cursor-pointer focus:outline-none focus:border-green-900" accept="image/*">
<p class="text-sm text-gray-500 mt-1">Upload one image (JPG, PNG).</p>
</div>
<div>
<label for="title-modal" class="block text-sm font-medium text-gray-700 mb-1 font-heading">Title</label>
<input type="text" id="title-modal" name="title" placeholder="e.g., Modern Coworking Hub" class="w-full px-3 py-2 border border-gray-300 rounded-sm focus:outline-none focus:border-green-900 text-sm">
</div>
<div>
<label for="description-modal" class="block text-sm font-medium text-gray-700 mb-1 font-heading">Description</label>
<textarea id="description-modal" name="description" rows="3" placeholder="Describe your space..." class="w-full px-3 py-2 border border-gray-300 rounded-sm focus:outline-none focus:border-green-900 text-sm"></textarea>
</div>
<div>
<label for="space-type-modal" class="block text-sm font-medium text-gray-700 mb-1 font-heading">Space Type</label>
<select id="space-type-modal" name="space-type" class="w-full px-3 py-2 border border-gray-300 rounded-sm focus:outline-none focus:border-green-900 text-sm bg-white">
<option value="">Select a space type</option>
<option value="coworking">Coworking</option>
<option value="room">Private Room</option>
<option value="conference">Conference Room</option>
<option value="event-space">Event Space</option>
<option value="virtual-office">Virtual Office</option>
</select>
</div>
</div>
<div class="mt-6 flex justify-end">
<button type="button" class="next-step-btn-modal bg-green-900 text-gray-100 font-semibold py-2 px-4 rounded-base inline-flex items-center justify-between border-2 border-transparent hover:border-green-300 font-heading">
Next <svg class="w-5 h-5 ml-2 -mr-1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true"><path fill-rule="evenodd" d="M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z" clip-rule="evenodd" /></svg>
</button>
</div>
</div>
<!-- Step 2: Location -->
<div id="step-2-modal" class="form-step-modal hidden">
<h2 class="text-lg font-semibold text-green-900 mb-4 font-heading">Step 2: Location</h2>
<div class="space-y-4">
<div class="relative">
<label for="location-search-modal" class="block text-sm font-medium text-gray-700 mb-1 font-heading">Select Location</label>
<input type="text" id="location-search-modal" name="location-search" placeholder="Search city or area..." class="w-full px-3 py-2 border border-gray-300 rounded-sm focus:outline-none focus:border-green-900 text-sm" autocomplete="off">
<div id="location-dropdown-modal" class="absolute z-20 mt-1 w-full rounded-md bg-white shadow-lg hidden ring-1 ring-black ring-opacity-5 max-h-48 overflow-y-auto py-1">
<a href="#" data-value="Manila, Philippines" class="location-item-modal block px-4 py-2 text-sm text-gray-700 hover:bg-green-50 hover:text-green-900">Manila, Philippines</a>
<a href="#" data-value="Makati, Philippines" class="location-item-modal block px-4 py-2 text-sm text-gray-700 hover:bg-green-50 hover:text-green-900">Makati, Philippines</a>
<a href="#" data-value="Quezon City, Philippines" class="location-item-modal block px-4 py-2 text-sm text-gray-700 hover:bg-green-50 hover:text-green-900">Quezon City, Philippines</a>
<a href="#" data-value="Cebu City, Philippines" class="location-item-modal block px-4 py-2 text-sm text-gray-700 hover:bg-green-50 hover:text-green-900">Cebu City, Philippines</a>
<a href="#" data-value="Taguig, Philippines" class="location-item-modal block px-4 py-2 text-sm text-gray-700 hover:bg-green-50 hover:text-green-900">Taguig, Philippines</a>
<p class="no-results-modal px-4 py-2 text-sm text-gray-500 hidden">No locations found.</p>
</div>
<input type="hidden" id="selected-location-modal" name="selected-location">
</div>
<div>
<label for="address-line-1-modal" class="block text-sm font-medium text-gray-700 mb-1 font-heading">Address Line 1</label>
<input type="text" id="address-line-1-modal" name="address-line-1" placeholder="e.g., 123 Main St" class="w-full px-3 py-2 border border-gray-300 rounded-sm focus:outline-none focus:border-green-900 text-sm">
</div>
<div>
<label for="address-line-2-modal" class="block text-sm font-medium text-gray-700 mb-1 font-heading">Address Line 2 (Optional)</label>
<input type="text" id="address-line-2-modal" name="address-line-2" placeholder="e.g., Brgy. Batong Dalig" class="w-full px-3 py-2 border border-gray-300 rounded-sm focus:outline-none focus:border-green-900 text-sm">
</div>
</div>
<div class="mt-6 flex justify-between">
<button type="button" class="prev-step-btn-modal bg-gray-100 text-green-900 font-semibold py-2 px-4 rounded-base inline-flex items-center justify-between border-2 border-transparent hover:border-green-300 font-heading">
<svg class="w-5 h-5 mr-2 -ml-1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">
<path fill-rule="evenodd" d="M12.707 5.293a1 1 0 010 1.414L9.414 10l3.293 3.293a1 1 0 01-1.414 1.414l-4-4a1 1 0 010-1.414l4-4a1 1 0 011.414 0z" clip-rule="evenodd" />
</svg>
Previous
</button>
<button type="button" class="next-step-btn-modal bg-green-900 text-gray-100 font-semibold py-2 px-4 rounded-base inline-flex items-center justify-between border-2 border-transparent hover:border-green-300 font-heading">
Next <svg class="w-5 h-5 ml-2 -mr-1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true"><path fill-rule="evenodd" d="M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z" clip-rule="evenodd" /></svg>
</button>
</div>
</div>
<!-- Step 3: Price & Availability -->
<div id="step-3-modal" class="form-step-modal hidden">
<h2 class="text-lg font-semibold text-green-900 mb-4 font-heading">Step 3: Price & Availability</h2>
<div class="space-y-4">
<div>
<label for="price-modal" class="block text-sm font-medium text-gray-700 mb-1 font-heading">Price (PHP per day)</label>
<div class="relative mt-1 rounded-sm shadow-sm">
<div class="pointer-events-none absolute inset-y-0 left-0 flex items-center pl-3">
<span class="text-gray-500 text-sm">₱</span>
</div>
<input type="number" id="price-modal" name="price" placeholder="e.g., 1200" class="w-full pl-7 pr-3 py-2 border border-gray-300 rounded-sm focus:outline-none focus:border-green-900 text-sm" min="0">
</div>
</div>
<div>
<h3 class="text-sm font-medium text-gray-700 mb-2 font-heading">Availability Date Range</h3>
<div class="grid grid-cols-1 md:grid-cols-2 gap-3">
{% include calendar_input.liquid
id="start_datepicker"
label="Select Date"
placeholder="YYYY-MM-DD"
%}
{% include calendar_input.liquid
id="end_datepicker"
label="Select Date"
placeholder="YYYY-MM-DD"
align_popup="right"
%}
</div>
</div>
<div>
<h3 class="text-sm font-medium text-gray-700 mb-2 font-heading">Weekly Availability & Hours</h3>
{% assign days_list_modal = "Monday,Tuesday,Wednesday,Thursday,Friday,Saturday,Sunday" | split: "," %}
<div class="mb-3">
<div class="flex flex-wrap border-b border-gray-200">
{% for day_label_modal in days_list_modal %}
<button type="button"
class="day-tab-button-modal -mb-px py-1.5 px-3 border-b-2 border-transparent text-sm font-medium text-gray-500 hover:text-gray-700 hover:border-gray-300 focus:outline-none font-heading"
data-day-target="{{ day_label_modal | downcase }}">
{{ day_label_modal | slice: 0, 3 }} <!-- Abbreviated day name -->
</button>
{% endfor %}
</div>
</div>
{% for day_label_modal in days_list_modal %}
<div id="availability-content-{{ day_label_modal | downcase }}-modal" class="day-availability-content-modal hidden">
<div class="bg-gray-50 p-3 rounded-md shadow-sm space-y-3">
<label for="available-{{ day_label_modal | downcase }}-modal" class="flex items-center justify-between w-full cursor-pointer font-heading">
<span class="text-sm font-medium text-gray-900">Available on {{ day_label_modal }}</span>
<input type="checkbox"
id="available-{{ day_label_modal | downcase }}-modal"
name="available_days[]"
value="{{ day_label_modal }}"
class="sr-only peer day-specific-availability-toggle-modal"
data-day="{{ day_label_modal | downcase }}"
onchange="toggleDayTimeSelectionModal('{{ day_label_modal | downcase }}')">
<div class="relative w-9 h-5 bg-gray-200 peer-focus:outline-none peer-focus:ring-1 peer-focus:ring-offset-1 peer-focus:ring-green-500 rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[1.5px] after:left-[1.5px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-green-900"></div>
</label>
<div id="time-selection-{{ day_label_modal | downcase }}-modal" class="day-specific-time-inputs-modal mt-3 grid grid-cols-1 sm:grid-cols-2 gap-x-3 gap-y-2 hidden">
<div>
<label for="start-time-{{ day_label_modal | downcase }}-modal" class="block text-sm font-medium text-gray-700 mb-0.5 font-heading">Open</label>
<input type="time" id="start-time-{{ day_label_modal | downcase }}-modal" name="start_time_{{ day_label_modal | downcase }}" class="w-full px-3 py-2 border border-gray-300 rounded-sm focus:outline-none focus:border-green-900 text-sm bg-white">
</div>
<div>
<label for="end-time-{{ day_label_modal | downcase }}-modal" class="block text-sm font-medium text-gray-700 mb-0.5 font-heading">Close</label>
<input type="time" id="end-time-{{ day_label_modal | downcase }}-modal" name="end_time_{{ day_label_modal | downcase }}" class="w-full px-3 py-2 border border-gray-300 rounded-sm focus:outline-none focus:border-green-900 text-sm bg-white">
</div>
</div>
</div>
</div>
{% endfor %}
</div>
</div>
<div class="mt-6 flex justify-between">
<button type="button" class="prev-step-btn-modal bg-gray-100 text-green-900 font-semibold py-2 px-4 rounded-base inline-flex items-center justify-between border-2 border-transparent hover:border-green-300 font-heading">
<svg class="w-5 h-5 mr-2 -ml-1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">
<path fill-rule="evenodd" d="M12.707 5.293a1 1 0 010 1.414L9.414 10l3.293 3.293a1 1 0 01-1.414 1.414l-4-4a1 1 0 010-1.414l4-4a1 1 0 011.414 0z" clip-rule="evenodd" />
</svg>
Previous
</button>
<button type="button" class="next-step-btn-modal bg-green-900 text-gray-100 font-semibold py-2 px-4 rounded-base inline-flex items-center justify-between border-2 border-transparent hover:border-green-300 font-heading">
Next <svg class="w-5 h-5 ml-2 -mr-1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true"><path fill-rule="evenodd" d="M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z" clip-rule="evenodd" /></svg>
</button>
</div>
</div>
<!-- Step 4: Contact Information -->
<div id="step-4-modal" class="form-step-modal hidden">
<h2 class="text-lg font-semibold text-green-900 mb-4 font-heading">Step 4: Contact Information</h2>
<div class="space-y-4">
<div>
<label for="space-name-modal" class="block text-sm font-medium text-gray-700 mb-1 font-heading">Coworking Space Name</label>
<input type="text" id="space-name-modal" name="space_name" placeholder="e.g., The Productive Corner" class="w-full px-3 py-2 border border-gray-300 rounded-sm focus:outline-none focus:border-green-900 text-sm">
</div>
<div class="grid grid-cols-1 md:grid-cols-2 gap-3">
<div>
<label for="contact-first-name-modal" class="block text-sm font-medium text-gray-700 mb-1 font-heading">Contact Person - First Name</label>
<input type="text" id="contact-first-name-modal" name="contact_first_name" placeholder="John" class="w-full px-3 py-2 border border-gray-300 rounded-sm focus:outline-none focus:border-green-900 text-sm">
</div>
<div>
<label for="contact-last-name-modal" class="block text-sm font-medium text-gray-700 mb-1 font-heading">Contact Person - Last Name</label>
<input type="text" id="contact-last-name-modal" name="contact_last_name" placeholder="Doe" class="w-full px-3 py-2 border border-gray-300 rounded-sm focus:outline-none focus:border-green-900 text-sm">
</div>
</div>
<div>
<label for="contact-number-modal" class="block text-sm font-medium text-gray-700 mb-1 font-heading">Contact Number</label>
<input type="tel" id="contact-number-modal" name="contact_number" placeholder="e.g., 09171234567" class="w-full px-3 py-2 border border-gray-300 rounded-sm focus:outline-none focus:border-green-900 text-sm">
</div>
<div>
<label for="contact-email-modal" class="block text-sm font-medium text-gray-700 mb-1 font-heading">Email Address</label>
<input type="email" id="contact-email-modal" name="contact_email" placeholder="you@example.com" class="w-full px-3 py-2 border border-gray-300 rounded-sm focus:outline-none focus:border-green-900 text-sm">
</div>
</div>
<div class="mt-6 flex justify-between items-center">
<button type="button" class="prev-step-btn-modal bg-gray-100 text-green-900 font-semibold py-2 px-4 rounded-base inline-flex items-center justify-between border-2 border-transparent hover:border-green-300 font-heading">
<svg class="w-5 h-5 mr-2 -ml-1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">
<path fill-rule="evenodd" d="M12.707 5.293a1 1 0 010 1.414L9.414 10l3.293 3.293a1 1 0 01-1.414 1.414l-4-4a1 1 0 010-1.414l4-4a1 1 0 011.414 0z" clip-rule="evenodd" />
</svg>
Previous
</button>
<button type="submit" class="bg-green-900 text-gray-100 font-semibold py-2 px-4 rounded-base inline-flex items-center justify-between border-2 border-transparent hover:border-green-300 font-heading">
Submit Listing
</button>
</div>
</div>
</form>
</div>
</div>
</aside>
<style>
.form-step-modal {
/* hidden by default, JS will manage visibility */
}
.active-step-modal {
display: block !important;
}
.step-indicator-modal.active-step-modal p {
font-weight: 600; /* semibold */
}
.step-indicator-modal .bg-green-300 { /* Active indicator circle */ }
.step-indicator-modal .bg-gray-300 { /* Inactive indicator circle */ }
</style>
<script>
document.addEventListener('DOMContentLoaded', function () {
const modalFormElement = document.getElementById('new-listing-form-modal');
if (!modalFormElement) return; // Don't run if the modal form isn't on the page
const stepsModal = modalFormElement.querySelectorAll('.form-step-modal');
const stepIndicatorsModal = document.querySelectorAll('#post-form-steps-modal .step-indicator-modal');
let currentStepModal = 0;
function showStepModal(stepIndex) {
stepsModal.forEach((step, index) => {
step.classList.toggle('active-step-modal', index === stepIndex);
step.classList.toggle('hidden', index !== stepIndex);
});
updateStepIndicatorsModal(stepIndex);
// Scroll to top of modal content area if needed
const modalBody = document.querySelector('#post-modal .overflow-y-auto');
if(modalBody) modalBody.scrollTop = 0;
}
function updateStepIndicatorsModal(activeIndex) {
stepIndicatorsModal.forEach((indicator, index) => {
const circle = indicator.querySelector('div:first-child');
const text = indicator.querySelector('p');
if (index === activeIndex) {
circle.classList.remove('bg-gray-300');
circle.classList.add('bg-green-300', 'text-green-900');
text.classList.remove('text-gray-500');
text.classList.add('text-green-900', 'font-semibold');
} else if (index < activeIndex) {
circle.classList.remove('bg-gray-300');
circle.classList.add('bg-green-300', 'text-green-900');
text.classList.remove('text-gray-500', 'text-green-900', 'font-semibold');
text.classList.add('text-gray-700');
} else {
circle.classList.remove('bg-green-300', 'text-green-900');
circle.classList.add('bg-gray-300');
text.classList.remove('text-green-900', 'font-semibold');
text.classList.add('text-gray-500');
}
});
}
modalFormElement.querySelectorAll('.next-step-btn-modal').forEach(button => {
button.addEventListener('click', () => {
if (currentStepModal < stepsModal.length - 1) {
currentStepModal++;
showStepModal(currentStepModal);
}
});
});
modalFormElement.querySelectorAll('.prev-step-btn-modal').forEach(button => {
button.addEventListener('click', () => {
if (currentStepModal > 0) {
currentStepModal--;
showStepModal(currentStepModal);
}
});
});
const locationInputModal = document.getElementById('location-search-modal');
const locationDropdownModal = document.getElementById('location-dropdown-modal');
const selectedLocationInputModal = document.getElementById('selected-location-modal');
if (locationInputModal && locationDropdownModal) {
const noResultsPModal = locationDropdownModal.querySelector('.no-results-modal');
const allLocationItemsModal = Array.from(locationDropdownModal.querySelectorAll('a.location-item-modal'));
locationInputModal.addEventListener('keyup', function() {
const filter = locationInputModal.value.toLowerCase();
let hasVisibleItems = false;
allLocationItemsModal.forEach(item => {
const text = item.textContent.toLowerCase();
if (text.includes(filter)) {
item.style.display = '';
hasVisibleItems = true;
} else {
item.style.display = 'none';
}
});
if (noResultsPModal) noResultsPModal.classList.toggle('hidden', hasVisibleItems);
locationDropdownModal.classList.toggle('hidden', !filter && !locationInputModal.matches(':focus'));
if (filter && locationInputModal.matches(':focus')) {
locationDropdownModal.classList.remove('hidden');
}
});
allLocationItemsModal.forEach(item => {
item.addEventListener('click', function(event) {
event.preventDefault();
locationInputModal.value = this.dataset.value;
if(selectedLocationInputModal) selectedLocationInputModal.value = this.dataset.value;
locationDropdownModal.classList.add('hidden');
});
});
locationInputModal.addEventListener('focus', () => {
if(locationInputModal.value || allLocationItemsModal.some(item => item.style.display !== 'none')) {
locationDropdownModal.classList.remove('hidden');
}
});
// Close dropdown if clicked outside
document.addEventListener('click', function(event) {
if (!locationInputModal.contains(event.target) && !locationDropdownModal.contains(event.target)) {
locationDropdownModal.classList.add('hidden');
}
});
}
window.toggleDayTimeSelectionModal = function(day) {
const checkbox = document.getElementById(`available-${day}-modal`);
const timeSelectionDiv = document.getElementById(`time-selection-${day}-modal`);
if (checkbox && timeSelectionDiv) {
if (checkbox.checked) {
timeSelectionDiv.classList.remove('hidden');
} else {
timeSelectionDiv.classList.add('hidden');
const startTimeInput = document.getElementById(`start-time-${day}-modal`);
const endTimeInput = document.getElementById(`end-time-${day}-modal`);
if(startTimeInput) startTimeInput.value = '';
if(endTimeInput) endTimeInput.value = '';
}
}
}
const dayTabButtonsModal = modalFormElement.querySelectorAll('.day-tab-button-modal');
const dayAvailabilityContentsModal = modalFormElement.querySelectorAll('.day-availability-content-modal');
function setActiveDayTabModal(targetDay) {
dayTabButtonsModal.forEach(button => {
const isTarget = button.dataset.dayTarget === targetDay;
button.classList.toggle('border-green-500', isTarget);
button.classList.toggle('text-green-900', isTarget);
button.classList.toggle('font-semibold', isTarget);
button.classList.toggle('text-gray-500', !isTarget);
button.classList.toggle('hover:border-gray-300', !isTarget);
button.classList.toggle('border-transparent', !isTarget);
});
dayAvailabilityContentsModal.forEach(content => {
content.classList.toggle('hidden', content.id !== `availability-content-${targetDay}-modal`);
});
const activeCheckbox = modalFormElement.querySelector(`#availability-content-${targetDay}-modal .day-specific-availability-toggle-modal`);
if (activeCheckbox) {
toggleDayTimeSelectionModal(targetDay);
}
}
dayTabButtonsModal.forEach(button => {
button.addEventListener('click', function () {
setActiveDayTabModal(this.dataset.dayTarget);
});
});
if (dayTabButtonsModal.length > 0) {
let initiallySelectedDayModal = dayTabButtonsModal[0].dataset.dayTarget;
for (let i = 0; i < dayAvailabilityContentsModal.length; i++) {
const content = dayAvailabilityContentsModal[i];
const checkbox = content.querySelector('.day-specific-availability-toggle-modal');
if (checkbox && checkbox.checked) {
initiallySelectedDayModal = checkbox.dataset.day;
break;
}
}
setActiveDayTabModal(initiallySelectedDayModal);
}
modalFormElement.addEventListener('submit', function(event) {
event.preventDefault();
const titleInput = document.getElementById('title-modal');
if (titleInput && titleInput.value.trim() === '') {
alert('Please enter a title for your listing.');
// showStepModal(0); // Switch to the step with the error
titleInput.focus();
return;
}
alert('Listing Submitted via Modal! (This is a demo and data is not saved.)');
// this.reset();
// showStepModal(0);
// toggleNavbar('post-modal'); // Close modal on submit
// if (typeof toggleOverlay === 'function') toggleOverlay('collapse-overlay');
});
showStepModal(currentStepModal); // Initialize the first step visibility
});
</script>
<!--end sidebar post section-->