Skip to content

Commit

Permalink
Link added to confirmation modal
Browse files Browse the repository at this point in the history
  • Loading branch information
mkokio committed Dec 15, 2023
1 parent 65eccfa commit 84985c5
Showing 1 changed file with 56 additions and 48 deletions.
104 changes: 56 additions & 48 deletions resources/views/dashboard.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,55 +146,63 @@ class="form-control"
*/
document.addEventListener("DOMContentLoaded", function () {
const form = document.getElementById('event-form');
const loading = document.getElementById('loading');
const confirmationModal = document.getElementById('confirmationModal');
const confirmSubmit = document.getElementById('confirmSubmit');
const cancelSubmit = document.getElementById('cancelSubmit');
const eventTitlePlaceholder = document.getElementById('event_title_placeholder');
const eventDescriptionPlaceholder = document.getElementById('description_placeholder');
const eventLocationPlaceholder = document.getElementById('location_placeholder');
const eventStartDatePlaceholder = document.getElementById('start_date_placeholder');
const eventStartTimePlaceholder = document.getElementById('start_time_placeholder');
const eventEndDatePlaceholder = document.getElementById('end_date_placeholder');
const eventEndTimePlaceholder = document.getElementById('end_time_placeholder');
const linkText = document.getElementById('link-text').value;
const linkUrl = document.getElementById('link-url').value;
const linkPlaceholder = document.getElementById('link_placeholder');
if (form && confirmationModal && confirmSubmit && cancelSubmit && eventTitlePlaceholder && eventDescriptionPlaceholder && eventLocationPlaceholder) {
form.addEventListener('submit', function (event) {
event.preventDefault();
eventTitlePlaceholder.textContent = document.getElementById('event_title').value;
eventDescriptionPlaceholder.textContent = document.getElementById('description').value;
eventLocationPlaceholder.textContent = document.getElementById('location').value;
eventStartDatePlaceholder.textContent = document.getElementById('start_date').value;
eventStartTimePlaceholder.textContent = document.getElementById('start_time').value;
eventEndDatePlaceholder.textContent = document.getElementById('end_date').value;
eventEndTimePlaceholder.textContent = document.getElementById('end_time').value;
confirmationModal.style.display = 'block';
linkPlaceholder.textContent = linkText;
linkPlaceholder.href = linkUrl;
});
confirmSubmit.addEventListener('click', function() {
loading.style.display = 'block';
confirmationModal.style.display = 'none';
setTimeout(function () {
form.submit();
}, 500);
});
cancelSubmit.addEventListener('click', function() {
confirmationModal.style.display = 'none';
});
} else {
console.error('Some elements are missing.');
}
});
const form = document.getElementById('event-form');
const loading = document.getElementById('loading');
const confirmationModal = document.getElementById('confirmationModal');
const confirmSubmit = document.getElementById('confirmSubmit');
const cancelSubmit = document.getElementById('cancelSubmit');
const eventTitlePlaceholder = document.getElementById('event_title_placeholder');
const eventDescriptionPlaceholder = document.getElementById('description_placeholder');
const eventLocationPlaceholder = document.getElementById('location_placeholder');
const eventStartDatePlaceholder = document.getElementById('start_date_placeholder');
const eventStartTimePlaceholder = document.getElementById('start_time_placeholder');
const eventEndDatePlaceholder = document.getElementById('end_date_placeholder');
const eventEndTimePlaceholder = document.getElementById('end_time_placeholder');
const linkTextElement = document.getElementById('link-text');
const linkUrlElement = document.getElementById('link-url');
const linkPlaceholder = document.getElementById('link_placeholder');
if (form && confirmationModal && confirmSubmit && cancelSubmit && eventTitlePlaceholder && eventDescriptionPlaceholder && eventLocationPlaceholder) {
form.addEventListener('submit', function (event) {
event.preventDefault();
eventTitlePlaceholder.textContent = document.getElementById('event_title').value;
eventDescriptionPlaceholder.textContent = document.getElementById('description').value;
eventLocationPlaceholder.textContent = document.getElementById('location').value;
eventStartDatePlaceholder.textContent = document.getElementById('start_date').value;
eventStartTimePlaceholder.textContent = document.getElementById('start_time').value;
eventEndDatePlaceholder.textContent = document.getElementById('end_date').value;
eventEndTimePlaceholder.textContent = document.getElementById('end_time').value;
confirmationModal.style.display = 'block';
const linkText = linkTextElement.value;
const linkUrl = linkUrlElement.value;
linkPlaceholder.textContent = linkText;
linkPlaceholder.href = linkUrl;
});
confirmSubmit.addEventListener('click', function() {
const linkText = linkTextElement.value;
const linkUrl = linkUrlElement.value;
linkPlaceholder.textContent = linkText;
linkPlaceholder.href = linkUrl;
loading.style.display = 'block';
confirmationModal.style.display = 'none';
setTimeout(function () {
form.submit();
}, 500);
});
cancelSubmit.addEventListener('click', function() {
confirmationModal.style.display = 'none';
});
} else {
console.error('Some elements are missing.');
}
});
</script>
</x-app-layout>

0 comments on commit 84985c5

Please sign in to comment.