couvertures et textes marge

This commit is contained in:
Valentin
2023-07-27 03:17:56 +02:00
parent 4245e71ae8
commit ec262aa48e
6 changed files with 77 additions and 11 deletions
+26 -6
View File
@@ -245,8 +245,6 @@ class setMarginTexts extends Paged.Handler {
partieCount.innerHTML = 'Partie<br>' + romanCount;
h2s[i].parentElement.prepend(partieCount);
h2s[i].nextElementSibling?.remove();
h2s[i].parentElement.parentElement.parentElement.parentElement.style.display = 'flex';
h2s[i].parentElement.parentElement.parentElement.parentElement.style.alignItems = 'center';
}
}
@@ -254,18 +252,30 @@ class setMarginTexts extends Paged.Handler {
let topLeftBoxes = document.querySelectorAll('.pagedjs_margin-left-top');
for (let topLeftBox of topLeftBoxes) {
let contentDiv = topLeftBox.firstElementChild;
let textToPut;
let textToPut = document.createElement('p');
let atelierGras;
let currentPage = contentDiv.closest('.pagedjs_page');
if (currentPage.id != "page-1") {
let previousPage = currentPage.previousElementSibling;
while (previousPage) {
if (previousPage.firstElementChild.classList.contains('atelier_cover_page')) {
textToPut = previousPage.querySelector('h3').innerText;
textToPut.innerText = previousPage.querySelector('h3').innerText;
let words = textToPut.innerText.split(' ');
let num = parseInt(words[0], 10);
if (!isNaN(num)) {
atelierGras = document.createElement('span');
atelierGras.style.fontWeight = "bold";
atelierGras.innerText = `Atelier ${num} `;
textToPut.innerText = textToPut.innerText.substring(1);
}
break;
}
previousPage = previousPage.previousElementSibling;
}
}
if (atelierGras) {
textToPut.prepend(atelierGras);
}
contentDiv.append(textToPut);
contentDiv.style.marginTop = contentDiv.offsetWidth / 2 - contentDiv.offsetHeight / 2 + "px";
}
@@ -273,18 +283,28 @@ class setMarginTexts extends Paged.Handler {
let bottomLeftBoxes = document.querySelectorAll('.pagedjs_margin-left-bottom');
for (let bottomLeftBox of bottomLeftBoxes) {
let contentDiv = bottomLeftBox.firstElementChild;
let textToPut;
let textToPut = document.createElement('p');
let partieGras;
let currentPage = contentDiv.closest('.pagedjs_page');
if (currentPage.id != "page-1") {
let previousPage = currentPage.previousElementSibling;
while (previousPage) {
if (previousPage.firstElementChild.classList.contains('partie_cover_page')) {
textToPut = previousPage.querySelector('h2').innerText;
textToPut.innerText = previousPage.querySelector('h2').innerText;
partieGras = document.createElement('span');
partieGras.style.fontWeight = "bold";
partieGras.innerText = previousPage.querySelector('.partie_count').innerHTML.replace("<br>", " ") + " ";
break;
}
previousPage = previousPage.previousElementSibling;
}
}
if (!textToPut.innerText) {
textToPut.innerText = "Introduction";
}
if (partieGras) {
textToPut.prepend(partieGras);
}
contentDiv.append(textToPut);
contentDiv.style.marginBottom = contentDiv.offsetWidth / 2 - contentDiv.offsetHeight / 2 + "px";
}