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{ ...@@ -16,12 +16,38 @@ class ApparatPlugin extends Plugin{
this.wrapLacunas(); this.wrapLacunas();
this.showWitness("lem"); this.showWitness("lem");
this.witnessTooltiping(); 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) { showWitness(witnessClass) {
document.querySelectorAll(".apparat").forEach((e) => e.style.display = 'none'); 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 = 'inline');
document.querySelectorAll(".lacuna" + "."+witnessClass).forEach((e) => e.style.display = 'none'); 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() { witnessTooltiping() {
...@@ -32,16 +58,15 @@ class ApparatPlugin extends Plugin{ ...@@ -32,16 +58,15 @@ class ApparatPlugin extends Plugin{
} }
wrapLacunas() { wrapLacunas() {
if (document.querySelectorAll("#text .lacunaStart").length > 0) { if (document.querySelectorAll("#text .lacunaStart").length > 0) {
document.querySelectorAll('.lacunaStart').forEach((lstart) => { document.querySelectorAll('.lacunaStart').forEach((lstart) => {
const wit = lstart.getAttribute('data-lacuna-wit').replace('#',''); const wit = lstart.getAttribute('data-lacuna-wit').replace('#', '');
console.log('wit->',wit); console.log('wit->', wit);
let searchedId = lstart.getAttribute('data-lacuna-synch'); let searchedId = lstart.getAttribute('data-lacuna-synch');
console.log("searchedid ", searchedId); console.log("searchedid ", searchedId);
// let endElement = document.getElementById(searchedId); //let endElement = document.getElementById(searchedId);
// console.log('traitement de la lacuna ' + lstart.getAttribute('id')); console.log('traitement de la lacuna ' + lstart.getAttribute('id'));
// endElement = endElement.length === 0 ? document.getElementById('bas_de_page') : endElement let endElement = document.querySelector("#" + searchedId);
let endElement = document.querySelector("#" + searchedId);
endElement = endElement === null ? document.querySelector('#bas_de_page') : endElement endElement = endElement === null ? document.querySelector('#bas_de_page') : endElement
let eltsBetween = this.getElementsBetweenTree(lstart, endElement);//$(self.getElementsBetweenTree(($(this))[0], endElement[0])) let eltsBetween = this.getElementsBetweenTree(lstart, endElement);//$(self.getElementsBetweenTree(($(this))[0], endElement[0]))
console.log("Nombre d'éléments à masquer (lacune " + lstart.getAttribute('id') + ")" + eltsBetween.length); console.log("Nombre d'éléments à masquer (lacune " + lstart.getAttribute('id') + ")" + eltsBetween.length);
...@@ -53,14 +78,15 @@ class ApparatPlugin extends Plugin{ ...@@ -53,14 +78,15 @@ class ApparatPlugin extends Plugin{
span.append(elt.cloneNode(true)); span.append(elt.cloneNode(true));
elt.replaceWith(span); elt.replaceWith(span);
}) })
}) })
} }
else { else {
document.querySelectorAll('.lacunaEnd').forEach((lend) => { document.querySelectorAll('.lacunaEnd').forEach((lend) => {
let lstart = document.querySelector('#text') let lstart = document.querySelector('#text > *:first-child > *:first-child')
let endElement = lend let endElement = lend
let eltsBetween = this.getElementsBetweenTree(lstart, endElement); let eltsBetween = this.getElementsBetweenTree(lstart, endElement);
eltsBetween.forEach((elt) => { eltsBetween.forEach((elt) => {
const wit = "B";
let span = document.createElement("span"); let span = document.createElement("span");
span.classList.add('generated_lacuna'); span.classList.add('generated_lacuna');
span.classList.add('lacuna'); span.classList.add('lacuna');
...@@ -70,17 +96,19 @@ class ApparatPlugin extends Plugin{ ...@@ -70,17 +96,19 @@ class ApparatPlugin extends Plugin{
}) })
}) })
} }
/*Cas où un couple lacunaStart/lacunaEnd se trouve respectivement dans /*Cas où un couple lacunaStart/lacunaEnd se trouve respectivement dans
des fragments qui précédent et suivent le fragment courant: 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*/ nécessite une requête sur la DB pour accedéer aux autres noeuds XML*/
} }
getElementsBetweenTree(start, end) { getElementsBetweenTree(start, end) {
let ancestor = this.commonAncestor(start, end); let ancestor = this.commonAncestor(start, end);
console.log(ancestor)
console.log(start)
let before = []; let before = [];
while (start.parentNode !== ancestor) { while (start.parentNode !== ancestor) {
var el = start; var el = start;
while (el.nextSibling) while (el.nextSibling)
...@@ -114,11 +142,11 @@ class ApparatPlugin extends Plugin{ ...@@ -114,11 +142,11 @@ class ApparatPlugin extends Plugin{
commonAncestor(node1, node2) { commonAncestor(node1, node2) {
let parents1 = this.ancestors(node1) let parents1 = this.ancestors(node1)
let parents2 = this.ancestors(node2) let parents2 = this.ancestors(node2)
if (parents1[0] !== parents2[0]) throw "No common ancestor!" if (parents1[0] !== parents2[0]) throw "No common ancestor!"
let lparents1 = parents1.length > parents2.lenght ? parents2 : parents1
for (var i = 0; i < parents1.length; i++) { let lparents2 = parents2.length > parents1.lenght ? parents1 : parents2
if (parents1[i] !== parents2[i]) return parents1[i - 1] 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