Fix_Empty_Drag_and_Drop_Issue : RV
This commit is contained in:
parent
072126a2f2
commit
40aa6fe055
@ -1478,7 +1478,6 @@ return false;
|
||||
}
|
||||
|
||||
let innerDivElement = document.getElementById('Max_Marks');
|
||||
console.log(innerDivElement)
|
||||
innerDivElement.addEventListener("keyup", function(event) {
|
||||
|
||||
json2nav();
|
||||
@ -1921,7 +1920,6 @@ var questionIncrement = 1;
|
||||
|
||||
$(document).ready(function(){
|
||||
array_of_Id.push('Max_Marks')
|
||||
console.log(array_of_Id);
|
||||
const arrayString = JSON.stringify(array_of_Id);
|
||||
collect_Empty_Question_Id(arrayString, 'Max_Marks');
|
||||
})
|
||||
@ -4220,14 +4218,12 @@ const titleElements = textQuestiontitleId.previousElementSibling;
|
||||
|
||||
if (mathEnabled === 'Math')
|
||||
{
|
||||
console.log('mathEnabled === true');
|
||||
ChoiceMathSwitchId.checked = true;
|
||||
$(Elements).hide();
|
||||
$(textQuestionSubtitle_mathId).show();
|
||||
}
|
||||
else
|
||||
{
|
||||
console.log('mathEnabled === false');
|
||||
ChoiceMathSwitchId.checked = false;
|
||||
$(Elements).show();
|
||||
$(textQuestionSubtitle_mathId).hide();
|
||||
|
||||
@ -73,6 +73,7 @@ var draggedItem = null;
|
||||
//Nav Pane full Element
|
||||
const container = document.getElementById('questionPaper');
|
||||
const dropTarget = e.target;
|
||||
// console.log('dropTarget : ', dropTarget)
|
||||
if (container.contains(dropTarget)) {
|
||||
//Before Insert OF the HTML Node
|
||||
if (e.clientY < dropTarget.getBoundingClientRect().top + dropTarget.clientHeight / 2) {
|
||||
@ -182,83 +183,117 @@ var draggedItem = null;
|
||||
|
||||
//THis function is Replicate the Nav Pane Change
|
||||
function insertElement(dragStartElement, dragDropElement, position){
|
||||
|
||||
var mainpaneSection = document.getElementById('addNewSection')
|
||||
//Check All is true this for
|
||||
if (dragStartElement && dragDropElement && position) {
|
||||
//Check IS before
|
||||
if (position == "before") {
|
||||
//Check DragFirst Element have id
|
||||
if (!dragStartElement.id) {
|
||||
var dragStartElementChild = dragStartElement.dragStartElementChild
|
||||
var maindragStartElement = mainpaneSection.querySelector(`#${dragStartElementChild.id.replace(/^nav_/, '')}`);
|
||||
var maindragDropElement = mainpaneSection.querySelector(`#${dragDropElement.id.replace(/^nav_/, '')}`);
|
||||
if (maindragStartElement && maindragDropElement && maindragStartElement !== maindragDropElement) {
|
||||
maindragDropElement.parentNode.insertBefore( maindragStartElement, maindragDropElement);
|
||||
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 {
|
||||
var maindragStartElement = mainpaneSection.querySelector(`#${dragStartElement.id.replace(/^nav_/, '')}`);
|
||||
var maindragDropElement = mainpaneSection.querySelector(`#${dragDropElement.id.replace(/^nav_/, '')}`);
|
||||
if (maindragStartElement && maindragDropElement && maindragStartElement !== maindragDropElement) {
|
||||
maindragDropElement.parentNode.insertBefore( maindragStartElement, maindragDropElement);
|
||||
if (QuestionStartElement && Section && QuestionStartElement !== Section) {
|
||||
Section.appendChild(QuestionStartElement)
|
||||
}
|
||||
}
|
||||
}
|
||||
// After element Node Added
|
||||
else {
|
||||
var maindragStartElement = mainpaneSection.querySelector(`#${dragStartElement.id.replace(/^nav_/, '')}`);
|
||||
var maindragDropElement = mainpaneSection.querySelector(`#${dragDropElement.id.replace(/^nav_/, '')}`);
|
||||
|
||||
// End Element is Section
|
||||
if (maindragDropElement.id.replace(/\d+/g, '') == "section_title_") {
|
||||
//Check First Element is Group
|
||||
if (maindragStartElement.id.replace(/\d+/g, '') == "draggedGroup_") {
|
||||
var groupQuestionAddSection = maindragDropElement.nextElementSibling.querySelector('.section-question-area')
|
||||
}else{
|
||||
|
||||
//Check All is true this for
|
||||
if (dragStartElement && dragDropElement && position) {
|
||||
|
||||
//Check IS before
|
||||
if (position == "before") {
|
||||
//Check DragFirst Element have id
|
||||
if (!dragStartElement.id) {
|
||||
var dragStartElementChild = dragStartElement.dragStartElementChild
|
||||
var maindragStartElement = mainpaneSection.querySelector(`#${dragStartElementChild.id.replace(/^nav_/, '')}`);
|
||||
var maindragDropElement = mainpaneSection.querySelector(`#${dragDropElement.id.replace(/^nav_/, '')}`);
|
||||
if (maindragStartElement && maindragDropElement && maindragStartElement !== maindragDropElement) {
|
||||
groupQuestionAddSection.appendChild(maindragStartElement)
|
||||
// test.parentNode.insertBefore(maindragStartElement, test)
|
||||
maindragDropElement.parentNode.insertBefore( maindragStartElement, maindragDropElement);
|
||||
}
|
||||
} else {
|
||||
var textAndChoiceAddSection = maindragDropElement.nextElementSibling.querySelector('.section-question-area');
|
||||
if (maindragStartElement && maindragDropElement && maindragStartElement !== maindragDropElement) {
|
||||
textAndChoiceAddSection.parentNode.insertBefore(maindragStartElement, textAndChoiceAddSection)
|
||||
var maindragStartElement = mainpaneSection.querySelector(`#${dragStartElement.id.replace(/^nav_/, '')}`);
|
||||
var maindragDropElement = mainpaneSection.querySelector(`#${dragDropElement.id.replace(/^nav_/, '')}`);
|
||||
if (maindragStartElement && maindragDropElement && maindragStartElement !== maindragDropElement) {
|
||||
maindragDropElement.parentNode.insertBefore( maindragStartElement, maindragDropElement);
|
||||
}
|
||||
}
|
||||
}
|
||||
//Check the Second Element is Group Question
|
||||
else if(maindragDropElement.id.replace(/\d+/g, '') == "draggedGroup_"){
|
||||
//Check First Element is Group Question
|
||||
if (maindragStartElement.id.replace(/\d+/g, '') == "draggedGroup_") {
|
||||
var groupQuestionAddGroupQuestion = maindragDropElement.querySelector('.nested-sortable');
|
||||
if (maindragStartElement && maindragDropElement && maindragStartElement !== maindragDropElement) {
|
||||
groupQuestionAddGroupQuestion.appendChild(maindragStartElement)
|
||||
}
|
||||
// After element Node Added
|
||||
else {
|
||||
var maindragStartElement = mainpaneSection.querySelector(`#${dragStartElement.id.replace(/^nav_/, '')}`);
|
||||
var maindragDropElement = mainpaneSection.querySelector(`#${dragDropElement.id.replace(/^nav_/, '')}`);
|
||||
|
||||
// End Element is Section
|
||||
if (maindragDropElement.id.replace(/\d+/g, '') == "section_title_") {
|
||||
//Check First Element is Group
|
||||
if (maindragStartElement.id.replace(/\d+/g, '') == "draggedGroup_") {
|
||||
var groupQuestionAddSection = maindragDropElement.nextElementSibling.querySelector('.section-question-area')
|
||||
if (maindragStartElement && maindragDropElement && maindragStartElement !== maindragDropElement) {
|
||||
groupQuestionAddSection.appendChild(maindragStartElement)
|
||||
// test.parentNode.insertBefore(maindragStartElement, test)
|
||||
}
|
||||
} else {
|
||||
var textAndChoiceAddSection = maindragDropElement.nextElementSibling.querySelector('.section-question-area');
|
||||
if (maindragStartElement && maindragDropElement && maindragStartElement !== maindragDropElement) {
|
||||
textAndChoiceAddSection.parentNode.insertBefore(maindragStartElement, textAndChoiceAddSection)
|
||||
}
|
||||
}
|
||||
}
|
||||
//This allows Text and Choice
|
||||
else {
|
||||
var groupQuestionAddTextChoice= maindragDropElement.querySelector('.nested-sortable').dragStartElementChild;
|
||||
if (groupQuestionAddTextChoice) {
|
||||
groupQuestionAddTextChoice.parentNode.insertBefore(maindragStartElement , groupQuestionAddTextChoice)
|
||||
} else {
|
||||
var groupQuestionAdd = maindragDropElement.querySelector('.nested-sortable')
|
||||
console.log(groupQuestionAdd);
|
||||
groupQuestionAdd.appendChild(maindragStartElement)
|
||||
console.log(groupQuestionAdd);
|
||||
alert("111")
|
||||
// test.parentNode.insertBefore(maindragStartElement , test)
|
||||
//Check the Second Element is Group Question
|
||||
else if(maindragDropElement.id.replace(/\d+/g, '') == "draggedGroup_"){
|
||||
//Check First Element is Group Question
|
||||
if (maindragStartElement.id.replace(/\d+/g, '') == "draggedGroup_") {
|
||||
var groupQuestionAddGroupQuestion = maindragDropElement.querySelector('.nested-sortable');
|
||||
if (maindragStartElement && maindragDropElement && maindragStartElement !== maindragDropElement) {
|
||||
groupQuestionAddGroupQuestion.appendChild(maindragStartElement)
|
||||
}
|
||||
}
|
||||
//This allows Text and Choice
|
||||
else {
|
||||
var groupQuestionAddTextChoice= maindragDropElement.querySelector('.nested-sortable').dragStartElementChild;
|
||||
if (groupQuestionAddTextChoice) {
|
||||
groupQuestionAddTextChoice.parentNode.insertBefore(maindragStartElement , groupQuestionAddTextChoice)
|
||||
} else {
|
||||
var groupQuestionAdd = maindragDropElement.querySelector('.nested-sortable')
|
||||
console.log(groupQuestionAdd);
|
||||
groupQuestionAdd.appendChild(maindragStartElement)
|
||||
console.log(groupQuestionAdd);
|
||||
// alert("111")
|
||||
// test.parentNode.insertBefore(maindragStartElement , test)
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
maindragDropElement.parentNode.insertBefore(maindragStartElement , maindragDropElement)
|
||||
}
|
||||
}
|
||||
}
|
||||
//no need
|
||||
else {
|
||||
var maindragStartElement = mainpaneSection.querySelector(`#${dragStartElement.id.replace(/^nav_/, '')}`);
|
||||
var maindragDropElement = mainpaneSection.querySelector(`#${dragDropElement.id.replace(/^nav_/, '')}`);
|
||||
if (maindragStartElement && maindragDropElement && maindragStartElement !== maindragDropElement) {
|
||||
maindragDropElement.parentNode.insertBefore( maindragStartElement, maindragDropElement.nextElementSibling);
|
||||
}else{
|
||||
maindragDropElement.parentNode.insertBefore(maindragStartElement , maindragDropElement)
|
||||
}
|
||||
}
|
||||
}
|
||||
//no need
|
||||
else {
|
||||
|
||||
console.log('ELSE');
|
||||
var maindragStartElement = mainpaneSection.querySelector(`#${dragStartElement.id.replace(/^nav_/, '')}`);
|
||||
var maindragDropElement = mainpaneSection.querySelector(`#${dragDropElement.id.replace(/^nav_/, '')}`);
|
||||
if (maindragStartElement && maindragDropElement && maindragStartElement !== maindragDropElement) {
|
||||
maindragDropElement.parentNode.insertBefore( maindragStartElement, maindragDropElement.nextElementSibling);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -5,17 +5,17 @@ function rtc_hide_and_show(rtcid) {
|
||||
// console.log('hideid : ', hideid);
|
||||
// console.log('hide id :' + id)
|
||||
$(hideid).hide();
|
||||
console.log('hide id :' + id);
|
||||
// console.log('hide id :' + id);
|
||||
var showid = document.getElementById(rtcid);
|
||||
$(showid).show();
|
||||
console.log('Show id :' + rtcid)
|
||||
// console.log('Show id :' + rtcid)
|
||||
localStorage.setItem('rtc',rtcid);
|
||||
|
||||
};
|
||||
|
||||
function add_button_hide_and_show(BtnID){
|
||||
|
||||
console.log('show id :'+BtnID)
|
||||
// console.log('show id :'+BtnID)
|
||||
var id = localStorage.getItem('btn');
|
||||
var hideid = document.getElementById(id);
|
||||
// console.log('hide id :' + id);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user