Fix_Empty_Drag_and_Drop_Issue : RV

This commit is contained in:
VENKATESHWARAN 2024-01-23 17:32:20 +05:30
parent 072126a2f2
commit 40aa6fe055
3 changed files with 100 additions and 69 deletions

View File

@ -1478,7 +1478,6 @@ return false;
} }
let innerDivElement = document.getElementById('Max_Marks'); let innerDivElement = document.getElementById('Max_Marks');
console.log(innerDivElement)
innerDivElement.addEventListener("keyup", function(event) { innerDivElement.addEventListener("keyup", function(event) {
json2nav(); json2nav();
@ -1921,7 +1920,6 @@ var questionIncrement = 1;
$(document).ready(function(){ $(document).ready(function(){
array_of_Id.push('Max_Marks') array_of_Id.push('Max_Marks')
console.log(array_of_Id);
const arrayString = JSON.stringify(array_of_Id); const arrayString = JSON.stringify(array_of_Id);
collect_Empty_Question_Id(arrayString, 'Max_Marks'); collect_Empty_Question_Id(arrayString, 'Max_Marks');
}) })
@ -4220,14 +4218,12 @@ const titleElements = textQuestiontitleId.previousElementSibling;
if (mathEnabled === 'Math') if (mathEnabled === 'Math')
{ {
console.log('mathEnabled === true');
ChoiceMathSwitchId.checked = true; ChoiceMathSwitchId.checked = true;
$(Elements).hide(); $(Elements).hide();
$(textQuestionSubtitle_mathId).show(); $(textQuestionSubtitle_mathId).show();
} }
else else
{ {
console.log('mathEnabled === false');
ChoiceMathSwitchId.checked = false; ChoiceMathSwitchId.checked = false;
$(Elements).show(); $(Elements).show();
$(textQuestionSubtitle_mathId).hide(); $(textQuestionSubtitle_mathId).hide();

View File

@ -73,6 +73,7 @@ var draggedItem = null;
//Nav Pane full Element //Nav Pane full Element
const container = document.getElementById('questionPaper'); const container = document.getElementById('questionPaper');
const dropTarget = e.target; const dropTarget = e.target;
// console.log('dropTarget : ', dropTarget)
if (container.contains(dropTarget)) { if (container.contains(dropTarget)) {
//Before Insert OF the HTML Node //Before Insert OF the HTML Node
if (e.clientY < dropTarget.getBoundingClientRect().top + dropTarget.clientHeight / 2) { if (e.clientY < dropTarget.getBoundingClientRect().top + dropTarget.clientHeight / 2) {
@ -182,9 +183,39 @@ var draggedItem = null;
//THis function is Replicate the Nav Pane Change //THis function is Replicate the Nav Pane Change
function insertElement(dragStartElement, dragDropElement, position){ function insertElement(dragStartElement, dragDropElement, position){
var mainpaneSection = document.getElementById('addNewSection') var mainpaneSection = document.getElementById('addNewSection')
var matches = dragDropElement.id.match(/([a-zA-Z_]+)([0-9]+)/);
var Section = document.getElementById('question_area_'+matches[2]);
var innerElementCount = ''
if(Section){
innerElementCount = Section.childElementCount;
}
else{
innerElementCount = 1;
}
if(innerElementCount === 0){
var QuestionStartElement = mainpaneSection.querySelector(`#${dragStartElement.id.replace(/^nav_/, '')}`);
var QuestionDropElement = mainpaneSection.querySelector(`#${dragDropElement.id.replace(/^nav_/, '')}`);
//Check First Element is Group
if (QuestionStartElement.id.replace(/\d+/g, '') == "draggedGroup_") {
if (QuestionStartElement && Section && QuestionStartElement !== Section) {
Section.appendChild(QuestionStartElement)
}
} else {
if (QuestionStartElement && Section && QuestionStartElement !== Section) {
Section.appendChild(QuestionStartElement)
}
}
}else{
//Check All is true this for //Check All is true this for
if (dragStartElement && dragDropElement && position) { if (dragStartElement && dragDropElement && position) {
//Check IS before //Check IS before
if (position == "before") { if (position == "before") {
//Check DragFirst Element have id //Check DragFirst Element have id
@ -243,7 +274,7 @@ var draggedItem = null;
console.log(groupQuestionAdd); console.log(groupQuestionAdd);
groupQuestionAdd.appendChild(maindragStartElement) groupQuestionAdd.appendChild(maindragStartElement)
console.log(groupQuestionAdd); console.log(groupQuestionAdd);
alert("111") // alert("111")
// test.parentNode.insertBefore(maindragStartElement , test) // test.parentNode.insertBefore(maindragStartElement , test)
} }
} }
@ -254,11 +285,15 @@ var draggedItem = null;
} }
//no need //no need
else { else {
console.log('ELSE');
var maindragStartElement = mainpaneSection.querySelector(`#${dragStartElement.id.replace(/^nav_/, '')}`); var maindragStartElement = mainpaneSection.querySelector(`#${dragStartElement.id.replace(/^nav_/, '')}`);
var maindragDropElement = mainpaneSection.querySelector(`#${dragDropElement.id.replace(/^nav_/, '')}`); var maindragDropElement = mainpaneSection.querySelector(`#${dragDropElement.id.replace(/^nav_/, '')}`);
if (maindragStartElement && maindragDropElement && maindragStartElement !== maindragDropElement) { if (maindragStartElement && maindragDropElement && maindragStartElement !== maindragDropElement) {
maindragDropElement.parentNode.insertBefore( maindragStartElement, maindragDropElement.nextElementSibling); maindragDropElement.parentNode.insertBefore( maindragStartElement, maindragDropElement.nextElementSibling);
} }
} }
}
} }

View File

@ -5,17 +5,17 @@ function rtc_hide_and_show(rtcid) {
// console.log('hideid : ', hideid); // console.log('hideid : ', hideid);
// console.log('hide id :' + id) // console.log('hide id :' + id)
$(hideid).hide(); $(hideid).hide();
console.log('hide id :' + id); // console.log('hide id :' + id);
var showid = document.getElementById(rtcid); var showid = document.getElementById(rtcid);
$(showid).show(); $(showid).show();
console.log('Show id :' + rtcid) // console.log('Show id :' + rtcid)
localStorage.setItem('rtc',rtcid); localStorage.setItem('rtc',rtcid);
}; };
function add_button_hide_and_show(BtnID){ function add_button_hide_and_show(BtnID){
console.log('show id :'+BtnID) // console.log('show id :'+BtnID)
var id = localStorage.getItem('btn'); var id = localStorage.getItem('btn');
var hideid = document.getElementById(id); var hideid = document.getElementById(id);
// console.log('hide id :' + id); // console.log('hide id :' + id);