diff --git a/bin.png b/bin.png new file mode 100644 index 0000000..81e7c49 Binary files /dev/null and b/bin.png differ diff --git a/public/js/script.js b/public/js/script.js index 27b014c..9fea1f5 100644 --- a/public/js/script.js +++ b/public/js/script.js @@ -227,6 +227,7 @@ document.addEventListener("DOMContentLoaded", function () { } function deleteOption(span) { + console.log("Yash"); const optionDiv = span.parentElement; optionDiv.remove(); updateAddButtonPosition(); @@ -247,7 +248,7 @@ document.addEventListener("DOMContentLoaded", function () { newQuestionDiv.className = "question"; newQuestionDiv.innerHTML = `
- @@ -255,16 +256,16 @@ document.addEventListener("DOMContentLoaded", function () {
-
+
- -
`; @@ -277,29 +278,36 @@ document.addEventListener("DOMContentLoaded", function () { let questionContainer = element.closest(".question"); if (questionContainer) { questionContainer.remove(); + questionCount--; updateAddButtonPosition(); } } function updateAddButtonPosition() { const questions = questionsSection.querySelectorAll(".question"); - const lastQuestion = questions[questions.length - 1]; + const sidebar = document.getElementById("moveableDiv"); - if (lastQuestion) { - const selectQuestionType = lastQuestion.querySelector(".question_type"); - if (selectQuestionType) { - const sidebar = document.getElementById("moveableDiv"); - const offset = selectQuestionType.offsetTop - sidebar.offsetHeight; - sidebar.style.transform = `translateY(${offset}px)`; - console.log(`Moving sidebar to: ${offset}px`); - } else { - console.warn("No .question_type found in last question."); - } + if (questions.length > 0) { + const lastQuestion = questions[questions.length - 1]; + const offsetTop = lastQuestion.offsetTop; + const sidebarHeight = sidebar.offsetHeight; + const containerHeight = questionsSection.offsetHeight; + + // Calculate the position of the last question relative to the top of the container + const newPosition = offsetTop + lastQuestion.offsetHeight; + + // Ensure the sidebar stays within the bounds of the container + if (newPosition + sidebarHeight <= containerHeight) { + sidebar.style.transform = `translateY(${newPosition}px)`; + console.log(`Moving sidebar to: ${newPosition}px`); } else { - const sidebar = document.getElementById("moveableDiv"); - sidebar.style.transform = `translateY(0px)`; - console.log(`Moving sidebar to: 0px`); + sidebar.style.transform = `translateY(${containerHeight - sidebarHeight}px)`; + console.log(`Moving sidebar to bottom of container`); } + } else { + sidebar.style.transform = `translateY(0px)`; + console.log("No questions, moving sidebar to top"); + } } function saveForm() { @@ -369,6 +377,7 @@ document.addEventListener("DOMContentLoaded", function () { window.addNewQuestion = addNewQuestion; window.deleteQuestion = deleteQuestion; window.addOption = addOption; + window.deleteOption = deleteOption; window.changeQuestionType = changeQuestionType; window.saveForm = saveForm; diff --git a/resources/views/forms/create.blade.php b/resources/views/forms/create.blade.php index e26974a..263b814 100644 --- a/resources/views/forms/create.blade.php +++ b/resources/views/forms/create.blade.php @@ -54,18 +54,18 @@
-
+
-
+
- +
- @@ -73,15 +73,15 @@
-
+
- -
diff --git a/resources/views/forms/edit.blade.php b/resources/views/forms/edit.blade.php index 8d781f9..a3fb83e 100644 --- a/resources/views/forms/edit.blade.php +++ b/resources/views/forms/edit.blade.php @@ -21,43 +21,43 @@ -
-
- - - - +
- +
@csrf @method('PUT')
- +
- +
@foreach ($questions as $index => $question)
- + {{-- --}}
- + {{-- --}}
diff --git a/resources/views/responses/viewResponses.blade.php b/resources/views/responses/viewResponses.blade.php index eb4a537..24ac7e9 100644 --- a/resources/views/responses/viewResponses.blade.php +++ b/resources/views/responses/viewResponses.blade.php @@ -10,7 +10,7 @@ - +
@@ -55,16 +55,16 @@ @else
- + - + @foreach ($responses as $responseGroup) - + @@ -74,7 +74,7 @@ @endforeach
User Submitted At Actions
{{ $responseGroup->first()->user->name ?? 'Anonymous' }} View Response + class="text-blue-600 hover:text-blue-700 hover:underline focus:outline-none">View Response