Commit ebd99d2b authored by Anne Goloubkoff-Duponchel's avatar Anne Goloubkoff-Duponchel
Browse files

corrections quand lacunaEnd seul dans fragment

parent cdf1d8f6
......@@ -16,12 +16,38 @@ class ApparatPlugin extends Plugin{
this.wrapLacunas();
this.showWitness("lem");
this.witnessTooltiping();
this.changecolorApp();
}
changecolorApp() {
document.querySelectorAll(".togglerInfobulle").forEach(toggler => {
toggler.addEventListener("focusin", (event) => {
var aColorer = toggler.parentNode.previousElementSibling;
aColorer.style.color = 'rgb(194, 35, 2)';
});
toggler.addEventListener("focusout", (event) => {
var aColorer = toggler.parentNode.previousElementSibling;
aColorer.style.color = 'inherit';
});
});
}
showWitness(witnessClass) {
document.querySelectorAll(".apparat").forEach((e) => e.style.display = 'none');
document.querySelectorAll(".lacuna, ." + witnessClass).forEach((e) => e.style.display = 'inline');
document.querySelectorAll(".lacuna" + "."+witnessClass).forEach((e) => e.style.display = 'none');
//on affiche les appels de note et les notes de bas de page uniquement pour la version par défaut
if (witnessClass != 'lem') {
document.querySelectorAll(".togglerInfobulle").forEach((e) => e.style.display = 'none');
document.querySelectorAll("#bas_de_page").forEach((e) => e.style.display = 'none');
document.querySelectorAll("#citation").forEach((e) => e.style.display = 'none');
}
else {
document.querySelectorAll(".togglerInfobulle").forEach((e) => e.style.display = 'inline');
document.querySelectorAll("#bas_de_page").forEach((e) => e.style.display = 'inline-block');
document.querySelectorAll("#citation").forEach((e) => e.style.display = 'inline-block');
}
}
witnessTooltiping() {
......@@ -34,13 +60,12 @@ class ApparatPlugin extends Plugin{
wrapLacunas() {
if (document.querySelectorAll("#text .lacunaStart").length > 0) {
document.querySelectorAll('.lacunaStart').forEach((lstart) => {
const wit = lstart.getAttribute('data-lacuna-wit').replace('#','');
console.log('wit->',wit);
const wit = lstart.getAttribute('data-lacuna-wit').replace('#', '');
console.log('wit->', wit);
let searchedId = lstart.getAttribute('data-lacuna-synch');
console.log("searchedid ", searchedId);
// let endElement = document.getElementById(searchedId);
// console.log('traitement de la lacuna ' + lstart.getAttribute('id'));
// endElement = endElement.length === 0 ? document.getElementById('bas_de_page') : endElement
//let endElement = document.getElementById(searchedId);
console.log('traitement de la lacuna ' + lstart.getAttribute('id'));
let endElement = document.querySelector("#" + searchedId);
endElement = endElement === null ? document.querySelector('#bas_de_page') : endElement
let eltsBetween = this.getElementsBetweenTree(lstart, endElement);//$(self.getElementsBetweenTree(($(this))[0], endElement[0]))
......@@ -57,10 +82,11 @@ class ApparatPlugin extends Plugin{
}
else {
document.querySelectorAll('.lacunaEnd').forEach((lend) => {
let lstart = document.querySelector('#text')
let lstart = document.querySelector('#text > *:first-child > *:first-child')
let endElement = lend
let eltsBetween = this.getElementsBetweenTree(lstart, endElement);
eltsBetween.forEach((elt) => {
const wit = "B";
let span = document.createElement("span");
span.classList.add('generated_lacuna');
span.classList.add('lacuna');
......@@ -70,7 +96,6 @@ class ApparatPlugin extends Plugin{
})
})
}
/*Cas où un couple lacunaStart/lacunaEnd se trouve respectivement dans
des fragments qui précédent et suivent le fragment courant:
nécessite une requête sur la DB pour accedéer aux autres noeuds XML*/
......@@ -78,9 +103,12 @@ class ApparatPlugin extends Plugin{
}
getElementsBetweenTree(start, end) {
let ancestor = this.commonAncestor(start, end);
let ancestor = this.commonAncestor(start, end);
console.log(ancestor)
console.log(start)
let before = [];
while (start.parentNode !== ancestor) {
var el = start;
while (el.nextSibling)
......@@ -114,11 +142,11 @@ class ApparatPlugin extends Plugin{
commonAncestor(node1, node2) {
let parents1 = this.ancestors(node1)
let parents2 = this.ancestors(node2)
if (parents1[0] !== parents2[0]) throw "No common ancestor!"
for (var i = 0; i < parents1.length; i++) {
if (parents1[i] !== parents2[i]) return parents1[i - 1]
let lparents1 = parents1.length > parents2.lenght ? parents2 : parents1
let lparents2 = parents2.length > parents1.lenght ? parents1 : parents2
for (var i = 0; i < lparents1.length; i++) {
if (lparents1[i] !== lparents2[i]) return lparents1[i - 1]
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment