From d78e27a180b7523ef28e38922e41970735eb9b54 Mon Sep 17 00:00:00 2001 From: yash Date: Wed, 17 Jul 2024 12:09:33 +0530 Subject: [PATCH] Fixed add button sliding bug and resolved issue with bin icon visibility --- bin.png | Bin 0 -> 12570 bytes public/js/script.js | 47 ++++++++++------- resources/views/forms/create.blade.php | 14 ++--- resources/views/forms/edit.blade.php | 48 +++++++++--------- .../views/responses/viewResponses.blade.php | 10 ++-- 5 files changed, 64 insertions(+), 55 deletions(-) create mode 100644 bin.png diff --git a/bin.png b/bin.png new file mode 100644 index 0000000000000000000000000000000000000000..81e7c491dffc3c5c406ff8b63671e4b9a512eece GIT binary patch literal 12570 zcmbVzdpwle+xNO>n5hiYM2?}PlM0b2hi31nbX1O&V@{!%l0%4FyHG;el}MX;c`knB+F=(WS&|+k6`ioU?>Of~`evqxh zhv6~(G4=wr^O0xgXDq&6-S@ZY5*v4s&RIk;i@npMzGJnO<)=g&!#7LL*4zC#Cz~c? z8mZIce08fP<)#K}A@!>F-Tj(sN%I#hSTLu=q{R5c^l*FEsYIhB|9Z#CF^ABZ_j$>> zE{pstR`-7S(3U>p;FG7Ee7@i$>$rhPUf?FU($)WQ^2dmb;5v7m_gY^pmzJwAT{1RP zF_xZQ$9wvE>&ge_@~FUyb$ktHgXpMWkzl-y<+a>b>^*ggC92?+l>{3#sWZ^QD=`KN z!OL@QOpj5wy^Y_l8$=g{+qeiEl27d(4$kyopp^0$1I1uWWF$DxZjRqBag~UU{6Ke1 zPcD*6*rxabWxTr(vjrc)V{uELZFeO77jl+}guD(1V|lL?F#B#yFio_YP~f}%wRKWn zv@>~PurG3ZyE|&UZ~9z1(w4F}S0%O}iHRz&C#&YF#1vT5P~ESlMhk-VL`(Uum!$;E z$RszR9G9-9d=X=J#>NcMG^u;IFiE@xYk0-0RH*9yqWw^e;~!_i5fi9Pi9!fN&?5o=)_ywG?2jWAd-$H!6Q zlM1@3n07VXa?~J`viWMVU#`m84M`Z=JxY37v!-{dFnLfct^0f=_b{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C zzv)5-dZ9D&+xS#YX5H6nmqE)VNodo27L)d#8DBn~)dqu~pp2|9X2fi^`7H8PSUD#l}dHw-(cb-)rB?hQf7^ zyU;N59yK?~JmpS*YRK+Z@8?e&6FaJpw_pTCMvRVuGlo?^&r5pILXD zD$)=%@yZ^AXtzOiO)-7`kcf>;Ld;e0^wW1mk+(n(nw>_S*T-Ydzo>O9LEo_)g}Ih| zIzCTyhpok+AA$qQ>p8-`V-o* zvH1Io5;8SAG5h+ysF|ANiITQ1GJTYkhV!df2)+5^;nSxUaP0W<%k+ZuIm#SK(cK?Y lBX^Qd`MjG`7&xPvn*L3348NuW|BnHgo9!{p{nh!*e*p%1rDXsB literal 0 HcmV?d00001 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 @@
-