refactor code + propre
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
// aligner les paragraphes sur la marge haute
|
||||
if (debug) console.log('start alignTopMargin');
|
||||
|
||||
(function() {
|
||||
|
||||
const labeurs = document.querySelectorAll('.labeur, .free'),
|
||||
moments = document.querySelectorAll('.moment');
|
||||
|
||||
for (let i = 0; i < labeurs.length; i++) {
|
||||
if (labeurs[i] == labeurs[i].parentNode?.firstElementChild
|
||||
&& !labeurs[i].firstElementChild?.hasAttribute("data-split-from")) {
|
||||
if (labeurs[i].firstElementChild) {
|
||||
labeurs[i].firstElementChild.style.marginTop = "0px";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (let i = 0; i < moments.length; i++) {
|
||||
if (moments[i].previousElementSibling?.tagName === "P"
|
||||
&& moments[i].previousElementSibling === moments[i].parentNode.firstElementChild) {
|
||||
moments[i].parentNode.removeChild(moments[i].parentNode.firstElementChild);
|
||||
}
|
||||
}
|
||||
|
||||
})();
|
||||
|
||||
|
||||
if (debug) console.log('end alignTopMargin');
|
||||
@@ -0,0 +1,40 @@
|
||||
// images collées en bas de page
|
||||
if (debug) console.log('start bottomImgs');
|
||||
|
||||
(function() {
|
||||
|
||||
let bottomImgs = document.querySelectorAll('.bottomimg, .tripleimgs_bottom, .tripleimgs2_bottom');
|
||||
|
||||
for (let bottomImg of bottomImgs) {
|
||||
let pageBottom = bottomImg.closest('.pagedjs_area').getBoundingClientRect().bottom;
|
||||
let imgBottomPos = pageBottom - bottomImg.lastElementChild.getBoundingClientRect().bottom;
|
||||
bottomImg.style.transform = `translateY(${imgBottomPos}px)`;
|
||||
}
|
||||
|
||||
// pour les images en bas dans les pages avec du texte
|
||||
let bottomVignettes = document.querySelectorAll('.imgsmall_bottom');
|
||||
|
||||
for (let bottomVignette of bottomVignettes) {
|
||||
let pageBottom = bottomVignette.closest('.pagedjs_area').getBoundingClientRect().bottom;
|
||||
let vignetteSize = bottomVignette.getBoundingClientRect().height;
|
||||
|
||||
if (bottomVignette.previousElementSibling) {
|
||||
let textBottom = bottomVignette.previousElementSibling.getBoundingClientRect().bottom;
|
||||
|
||||
if (bottomVignette.previousElementSibling.classList.contains('labeur') ||
|
||||
bottomVignette.previousElementSibling.classList.contains('citation') ||
|
||||
bottomVignette.previousElementSibling.classList.contains('free') ||
|
||||
bottomVignette.previousElementSibling.classList.contains('temps')) {
|
||||
bottomVignette.style.marginTop = `${(pageBottom - textBottom) - vignetteSize}px`;
|
||||
}
|
||||
|
||||
bottomVignette.style.transform = 'translateY(12px)';
|
||||
} else {
|
||||
let vignetteBottom = bottomVignette.getBoundingClientRect().bottom;
|
||||
bottomVignette.style.transform = `translateY(${pageBottom - vignetteBottom}px)`;
|
||||
}
|
||||
}
|
||||
|
||||
})();
|
||||
|
||||
if (debug) console.log('end bottomImgs');
|
||||
@@ -0,0 +1,157 @@
|
||||
// set all the relative to parts colors
|
||||
if (debug) console.log('start colors');
|
||||
|
||||
(function() {
|
||||
|
||||
const colors = [
|
||||
'#5595a1',
|
||||
'#5f9796',
|
||||
'#65998d',
|
||||
'#6f9b80',
|
||||
'#799e75',
|
||||
'#83a16b',
|
||||
'#8ba460',
|
||||
'#95a358',
|
||||
'#9ca151',
|
||||
'#a59d4a',
|
||||
'#af9944',
|
||||
'#b8963d',
|
||||
'#c19238',
|
||||
'#cb8e31',
|
||||
'#cb6f31',
|
||||
'#d86145'
|
||||
];
|
||||
|
||||
const sprays = [
|
||||
'/user/themes/carnet-atterrissage/assets/sprays/spary_couleurs-page001.png',
|
||||
'/user/themes/carnet-atterrissage/assets/sprays/spary_couleurs-page002.png',
|
||||
'/user/themes/carnet-atterrissage/assets/sprays/spary_couleurs-page003.png',
|
||||
'/user/themes/carnet-atterrissage/assets/sprays/spary_couleurs-page004.png',
|
||||
'/user/themes/carnet-atterrissage/assets/sprays/spary_couleurs-page005.png',
|
||||
'/user/themes/carnet-atterrissage/assets/sprays/spary_couleurs-page006.png',
|
||||
'/user/themes/carnet-atterrissage/assets/sprays/spary_couleurs-page007.png',
|
||||
'/user/themes/carnet-atterrissage/assets/sprays/spary_couleurs-page008.png',
|
||||
'/user/themes/carnet-atterrissage/assets/sprays/spary_couleurs-page009.png',
|
||||
'/user/themes/carnet-atterrissage/assets/sprays/spary_couleurs-page010.png',
|
||||
'/user/themes/carnet-atterrissage/assets/sprays/spary_couleurs-page011.png',
|
||||
'/user/themes/carnet-atterrissage/assets/sprays/spary_couleurs-page012.png',
|
||||
'/user/themes/carnet-atterrissage/assets/sprays/spary_couleurs-page013.png',
|
||||
'/user/themes/carnet-atterrissage/assets/sprays/spary_couleurs-page014.png',
|
||||
'/user/themes/carnet-atterrissage/assets/sprays/spary_couleurs-page015.png',
|
||||
'/user/themes/carnet-atterrissage/assets/sprays/spary_couleurs-page016.png'
|
||||
];
|
||||
|
||||
let allPages = document.querySelectorAll('.pagedjs_page');
|
||||
let atelierColor = '';
|
||||
let bgColor = 'rgb(245, 245, 245)';
|
||||
let atelierIndex = 0;
|
||||
|
||||
for (let page of allPages) {
|
||||
if (page.firstElementChild.classList.contains('atelier_cover_page')) {
|
||||
atelierColor = colors[atelierIndex];
|
||||
if (atelierColor == undefined) atelierColor = colors[colors.length];
|
||||
atelierIndex++;
|
||||
}
|
||||
|
||||
if (page.firstElementChild.classList.contains('partie_cover_page')) atelierIndex = 0;
|
||||
|
||||
let pageCounter = page.querySelector('.pagedjs_margin-left-middle')
|
||||
if (pageCounter) pageCounter.style.color = atelierColor;
|
||||
|
||||
let citations = page.querySelectorAll('.citation');
|
||||
for (let citation of citations) {
|
||||
// dessiner et colorer les guillemets
|
||||
if (citation.innerText.charAt(0) === '“') citation.innerText = citation.innerText.substring(1);
|
||||
|
||||
if (citation.innerText.charAt(citation.innerText.length - 1) === '”') {
|
||||
citation.innerText = citation.innerText.substring(0, citation.innerText.length - 1);
|
||||
}
|
||||
|
||||
let guillemetOuvrant = document.createElement('div');
|
||||
guillemetOuvrant.innerText = '“';
|
||||
guillemetOuvrant.style.color = atelierColor;
|
||||
guillemetOuvrant.classList.add('guillement_ouvrant');
|
||||
citation.prepend(guillemetOuvrant);
|
||||
|
||||
let guillemetFermant = document.createElement('div');
|
||||
guillemetFermant.innerText = '”';
|
||||
guillemetFermant.style.color = atelierColor;
|
||||
guillemetFermant.classList.add('guillement_fermant');
|
||||
citation.append(guillemetFermant);
|
||||
}
|
||||
|
||||
let atelierTitle = page.querySelector('h3');
|
||||
if (atelierTitle) atelierTitle.style.color = atelierColor;
|
||||
|
||||
let bibliographie = page.querySelector('.bibliographie');
|
||||
if (bibliographie) {
|
||||
bibliographie.style.color = atelierColor;
|
||||
// set bg et sprays
|
||||
let bibliographiePage = bibliographie.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement; // désolé
|
||||
bibliographiePage.style.backgroundColor = bgColor;
|
||||
|
||||
let nextPage;
|
||||
if (bibliographiePage.parentElement.classList.contains('pagedjs_sheet')) {
|
||||
nextPage = bibliographiePage.parentElement?.parentElement?.nextElementSibling?.firstElementChild;
|
||||
} else {
|
||||
nextPage = bibliographiePage.parentElement?.nextElementSibling?.firstElementChild;
|
||||
}
|
||||
|
||||
if (!bibliographie.closest('.pagedjs_page').previousElementSibling.querySelector('.bibliographie')) {
|
||||
if (nextPage) {
|
||||
nextPage.style.backgroundColor = bgColor;
|
||||
}
|
||||
|
||||
let sprayImg = document.createElement('img');
|
||||
sprayImg.setAttribute('src', sprays[atelierIndex - 1]);
|
||||
sprayImg.style.height = "242mm";
|
||||
sprayImg.style.width = "60mm";
|
||||
sprayImg.style.position = "absolute";
|
||||
sprayImg.style.top = "-22mm";
|
||||
sprayImg.style.right = "-20mm";
|
||||
sprayImg.style.mixBlendMode = "multiply";
|
||||
|
||||
let nextBiblioPageEl = bibliographiePage.parentElement.nextElementSibling?.querySelector('.bibliographie');
|
||||
if (nextBiblioPageEl) {
|
||||
bibliographiePage.parentElement.nextElementSibling?.querySelector('.bibliographie').insertAdjacentElement("afterend", sprayImg);
|
||||
} else {
|
||||
bibliographiePage.parentElement.parentElement.nextElementSibling?.querySelector('.pagedjs_page_content').appendChild(sprayImg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let h4 = page.querySelector('h4');
|
||||
if (h4 && h4?.nextElementSibling?.classList.contains('bibliographie')) {
|
||||
h4.style.color = atelierColor;
|
||||
}
|
||||
|
||||
let serpentins = document.querySelectorAll('img[alt="serpentin"]');
|
||||
for (let serpentin of serpentins) {
|
||||
let page = serpentin.closest('.pagedjs_page');
|
||||
let nextPage = page.nextElementSibling;
|
||||
page.style.backgroundColor = "rgb(245, 245, 245)";
|
||||
nextPage.style.backgroundColor = "rgb(245, 245, 245)";
|
||||
}
|
||||
|
||||
let links = page.querySelectorAll('a');
|
||||
for (let link of links) {
|
||||
link.style.color = atelierColor;
|
||||
}
|
||||
|
||||
let notesNumber = page.querySelectorAll('.note, .note_texte_number');
|
||||
for (let note of notesNumber) {
|
||||
note.style.color = atelierColor;
|
||||
}
|
||||
|
||||
if (atelierColor) {
|
||||
let lightColor = `${atelierColor}1a`;
|
||||
let encarts = page.querySelectorAll('.lampe, .latour, .lampe_nohead, .latour_nohead, .encart-split');
|
||||
for (let encart of encarts) {
|
||||
encart.style.backgroundColor = lightColor;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
})();
|
||||
|
||||
if (debug) console.log('end colors');
|
||||
@@ -0,0 +1,9 @@
|
||||
// identifier la dernière page
|
||||
if (debug) console.log('start getLastPage');
|
||||
|
||||
(function() {
|
||||
let lastElement = $('.pagedjs_page').last();
|
||||
lastElement.addClass('last-page');
|
||||
})();
|
||||
|
||||
if (debug) console.log('end getLastPage');
|
||||
@@ -0,0 +1,25 @@
|
||||
// afficher les renvoie de notes des images
|
||||
if (debug) console.log('start imgsFootnotes');
|
||||
|
||||
(function() {
|
||||
|
||||
let notesImg = document.querySelectorAll('.note_img');
|
||||
for (let noteImg of notesImg) {
|
||||
let noteNumber = noteImg.getAttribute('id').split("_");
|
||||
noteNumber = noteNumber[noteNumber.length - 1];
|
||||
|
||||
noteImg.innerText = noteNumber;
|
||||
noteImg.style.position = "absolute";
|
||||
|
||||
if (noteImg.parentElement.classList.contains('imgsmall_bottom')) {
|
||||
noteImg.style.left = '78px'; // hardcoded pas beau
|
||||
} else if (noteImg.parentElement.classList.contains('imgfullspreadright_bleed')) {
|
||||
noteImg.style.color = "white";
|
||||
noteImg.style.top = "0";
|
||||
noteImg.style.left = "0.5cm";
|
||||
}
|
||||
}
|
||||
|
||||
})();
|
||||
|
||||
if (debug) console.log('end imgsFootnotes');
|
||||
@@ -0,0 +1,77 @@
|
||||
// images double-page
|
||||
if (debug) console.log('start imgsFullspread');
|
||||
|
||||
(function() {
|
||||
|
||||
let fullspreadElements = document.querySelectorAll('.imgfullspreadleft, .imgfullspreadright, .imgfullspreadright_bleedtop, .imgfullspreadright_bleed, .doublepage_bigleft, .doublepage_bigright');
|
||||
|
||||
for (let fullspreadEl of fullspreadElements) {
|
||||
let imgSrc = fullspreadEl.firstElementChild?.getAttribute('src');
|
||||
let nextPage = fullspreadEl.closest('.pagedjs_page')?.nextElementSibling?.querySelector('.pagedjs_page_content');
|
||||
let imgOverflowEl = document.createElement('div');
|
||||
|
||||
switch(true) {
|
||||
case fullspreadEl.classList.contains('imgfullspreadleft'):
|
||||
imgOverflowEl.setAttribute('class', 'imgfullspreadleft-right');
|
||||
break;
|
||||
case fullspreadEl.classList.contains('imgfullspreadright'):
|
||||
imgOverflowEl.setAttribute('class', 'imgfullspreadright-right');
|
||||
break;
|
||||
case fullspreadEl.classList.contains('imgfullspreadright_bleedtop'):
|
||||
imgOverflowEl.setAttribute('class', 'imgfullspreadright_bleedtop-right');
|
||||
break;
|
||||
case fullspreadEl.classList.contains('imgfullspreadright_bleed'):
|
||||
imgOverflowEl.setAttribute('class', 'imgfullspreadright_bleed-right');
|
||||
break;
|
||||
case fullspreadEl.classList.contains('doublepage_bigleft'):
|
||||
imgOverflowEl.setAttribute('class', 'overflow_bigimgleft');
|
||||
break;
|
||||
case fullspreadEl.classList.contains('doublepage_bigright'):
|
||||
imgOverflowEl.setAttribute('class', 'overflow_bigimgright');
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
let imgOverflow = document.createElement('img');
|
||||
imgOverflow.src = imgSrc;
|
||||
imgOverflowEl.append(imgOverflow);
|
||||
|
||||
if (nextPage) nextPage.append(imgOverflowEl);
|
||||
|
||||
if (fullspreadEl.classList.contains('imgfullspreadright')
|
||||
|| fullspreadEl.classList.contains('imgfullspreadright_bleedtop')
|
||||
|| fullspreadEl.classList.contains('imgfullspreadright_bleed')) {
|
||||
let imgLeft = fullspreadEl.firstElementChild;
|
||||
let imgMargin = imgOverflowEl.getBoundingClientRect().right - imgLeft?.getBoundingClientRect().right;
|
||||
if (imgLeft) imgLeft.style.marginLeft = `${imgMargin}px`;
|
||||
}
|
||||
if (fullspreadEl.classList.contains('doublepage_bigleft')
|
||||
|| fullspreadEl.classList.contains('doublepage_bigright')) {
|
||||
let smallImgSrc = fullspreadEl.lastElementChild?.getAttribute('src');
|
||||
fullspreadEl.lastElementChild?.remove();
|
||||
let smallImg = document.createElement('img');
|
||||
smallImg.setAttribute('src', smallImgSrc);
|
||||
let smallImgEl = document.createElement('div');
|
||||
smallImgEl.classList.add('dp_sm_img');
|
||||
smallImgEl.append(smallImg);
|
||||
if (fullspreadEl.classList.contains('doublepage_bigleft') && nextPage) {
|
||||
nextPage.append(smallImgEl);
|
||||
} else {
|
||||
fullspreadEl.parentElement?.append(smallImgEl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// fullpage img page gauche
|
||||
let fullPageImgs = document.querySelectorAll('.fullpageimage');
|
||||
for (let fullPageImg of fullPageImgs) {
|
||||
if (fullPageImg.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode // désolé
|
||||
.classList.contains('pagedjs_left_page')) {
|
||||
fullPageImg.style.marginLeft = '-22mm';
|
||||
}
|
||||
}
|
||||
|
||||
})();
|
||||
|
||||
if (debug) console.log('end imgsFullspread');
|
||||
@@ -0,0 +1,39 @@
|
||||
// gestion des encarts splittés
|
||||
if (debug) console.log('start inserts');
|
||||
|
||||
(function() {
|
||||
|
||||
let encarts = document.querySelectorAll('.latour, .lampe, .latour_nohead, .lampe_nohead');
|
||||
for (let encart of encarts) {
|
||||
|
||||
if (encart.hasAttribute('data-split-to')) {
|
||||
let plainColor = document.createElement('div');
|
||||
plainColor.setAttribute('class', 'encart-split');
|
||||
let plainHeight = encart.closest('.pagedjs_sheet').getBoundingClientRect().bottom - encart.getBoundingClientRect().bottom;
|
||||
if (encart.closest('.pagedjs_page').classList.contains('pagedjs_right_page')) {
|
||||
plainColor.style.width = "149mm";
|
||||
} else {
|
||||
plainColor.style.width = "129mm";
|
||||
}
|
||||
plainColor.style.height = `${plainHeight}px`;
|
||||
encart.parentNode.append(plainColor);
|
||||
}
|
||||
|
||||
if (encart.hasAttribute('data-split-from')) {
|
||||
encart.style.marginTop = "0mm";
|
||||
let plainColor = document.createElement('div');
|
||||
plainColor.setAttribute('class', 'encart-split');
|
||||
if (encart.closest('.pagedjs_page').classList.contains('pagedjs_right_page')) {
|
||||
plainColor.style.width = "149mm";
|
||||
} else {
|
||||
plainColor.style.width = "129mm";
|
||||
}
|
||||
plainColor.style.height = "22mm";
|
||||
plainColor.style.top = "-22mm";
|
||||
encart.parentNode.prepend(plainColor);
|
||||
}
|
||||
}
|
||||
|
||||
})();
|
||||
|
||||
if (debug) console.log('end inserts');
|
||||
@@ -0,0 +1,81 @@
|
||||
// afficher les éléments en marge
|
||||
if (debug) console.log('start margins');
|
||||
|
||||
(function() {
|
||||
|
||||
let topLeftBoxes = document.querySelectorAll('.pagedjs_margin-left-top');
|
||||
|
||||
for (let topLeftBox of topLeftBoxes) {
|
||||
let contentDiv = topLeftBox.firstElementChild;
|
||||
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.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";
|
||||
}
|
||||
|
||||
let bottomLeftBoxes = document.querySelectorAll('.pagedjs_margin-left-bottom');
|
||||
|
||||
for (let bottomLeftBox of bottomLeftBoxes) {
|
||||
let contentDiv = bottomLeftBox.firstElementChild;
|
||||
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.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";
|
||||
}
|
||||
|
||||
})();
|
||||
|
||||
if (debug) console.log('end margins');
|
||||
@@ -0,0 +1,16 @@
|
||||
// supprimer les paragraphes vides
|
||||
if (debug) console.log('start removeEmptyParagraphs');
|
||||
|
||||
(function() {
|
||||
|
||||
let paragraphes = document.querySelectorAll("p");
|
||||
|
||||
for (let i = 0; i < paragraphes.length; i++) {
|
||||
if (paragraphes[i].innerHTML == "") {
|
||||
paragraphes[i].remove();
|
||||
}
|
||||
}
|
||||
|
||||
})();
|
||||
|
||||
if (debug) console.log('end removeEmptyParagraphs');
|
||||
@@ -0,0 +1,95 @@
|
||||
// layout des pages de titres
|
||||
console.log('start titles');
|
||||
|
||||
(function() {
|
||||
|
||||
// titres ateliers
|
||||
let h3s = document.querySelectorAll('h3');
|
||||
|
||||
for (let h3 of h3s) {
|
||||
|
||||
if (h3.nextSibling?.firstChild?.tagName === "IMG") {
|
||||
let coverPhoto;
|
||||
let photoContainer = h3.nextElementSibling;
|
||||
|
||||
if (h3.nextSibling?.children.length === 2) {
|
||||
coverPhoto = h3.nextElementSibling.children[1];
|
||||
let coverDessin = document.createElement('img');
|
||||
coverDessin.setAttribute('src', photoContainer.firstElementChild.getAttribute('src'));
|
||||
h3.prepend(coverDessin);
|
||||
coverDessin.style.width = '100%';
|
||||
coverDessin.style.height = 'auto';
|
||||
photoContainer.firstElementChild.remove();
|
||||
} else {
|
||||
coverPhoto = h3.nextElementSibling.firstChild;
|
||||
}
|
||||
|
||||
photoContainer.style.position = 'absolute';
|
||||
photoContainer.style.width = '53mm';
|
||||
photoContainer.style.height = '220mm';
|
||||
photoContainer.style.overflow = 'hidden';
|
||||
photoContainer.style.top = "-22mm";
|
||||
photoContainer.style.left = "96mm";
|
||||
photoContainer.style.margin = '0';
|
||||
|
||||
coverPhoto.style.width = 'auto';
|
||||
coverPhoto.style.height = '100%';
|
||||
|
||||
let nextImg = document.createElement('img');
|
||||
nextImg.setAttribute('src', coverPhoto.getAttribute('src'));
|
||||
let nextContainer = document.createElement('div');
|
||||
|
||||
nextContainer.style.position = "absolute";
|
||||
nextContainer.style.top = "-22mm";
|
||||
nextContainer.style.left = "-8mm";
|
||||
nextContainer.style.height = "220mm";
|
||||
nextContainer.style.width = "224mm";
|
||||
nextContainer.style.overflow = "hidden";
|
||||
nextContainer.style.marginLeft = "-53mm";
|
||||
nextImg.style.height = "100%";
|
||||
nextImg.style.width = "auto";
|
||||
|
||||
nextContainer.append(nextImg);
|
||||
|
||||
h3.closest('.pagedjs_page').nextElementSibling?.querySelector('.pagedjs_page_content').append(nextContainer);
|
||||
}
|
||||
|
||||
h3.style.position = 'absolute';
|
||||
h3.style.top = `${(h3.closest('.pagedjs_page_content').offsetHeight - h3.offsetHeight) / 3}px`;
|
||||
|
||||
h3.closest('.pagedjs_pagebox').querySelector('.pagedjs_margin-left').innerHTML = '';
|
||||
h3.closest('.pagedjs_sheet').classList.add('atelier_cover_page');
|
||||
}
|
||||
|
||||
// titres parties
|
||||
let h2s = document.querySelectorAll('h2');
|
||||
for (let i = 0; i < h2s.length; i++) {
|
||||
if (i != 0) {
|
||||
let parentSheet = h2s[i].closest('.pagedjs_sheet');
|
||||
parentSheet.querySelector('.pagedjs_margin-left').innerHTML = '';
|
||||
parentSheet.classList.add('partie_cover_page');
|
||||
parentSheet.parentElement.nextElementSibling?.firstElementChild.classList.add('partie_cover_page_right');
|
||||
let partieCount = document.createElement('div');
|
||||
partieCount.classList.add('partie_count');
|
||||
let romanCount;
|
||||
switch (i) {
|
||||
case 1: romanCount = 'I'; break;
|
||||
case 2: romanCount = 'II'; break;
|
||||
case 3: romanCount = 'III'; break;
|
||||
case 4: romanCount = 'IV'; break;
|
||||
case 5: romanCount = 'V'; break;
|
||||
case 6: romanCount = 'VI'; break;
|
||||
case 7: romanCount = 'VII'; break;
|
||||
case 8: romanCount = 'VIII'; break;
|
||||
case 9: romanCount = 'IX'; break;
|
||||
case 10: romanCount = 'X'; break;
|
||||
}
|
||||
partieCount.innerHTML = `Partie<br>${romanCount}`;
|
||||
h2s[i].parentElement.prepend(partieCount);
|
||||
h2s[i].nextElementSibling?.remove();
|
||||
}
|
||||
}
|
||||
|
||||
})();
|
||||
|
||||
console.log('end titles');
|
||||
@@ -0,0 +1,19 @@
|
||||
// afficher l'interface par dessus le livre
|
||||
if (debug) console.log('start ui');
|
||||
|
||||
(function() {
|
||||
|
||||
// indication du chargement
|
||||
let chargement = document.createElement('div');
|
||||
chargement.setAttribute('id', 'chargement');
|
||||
chargement.innerHTML = 'chargement';
|
||||
chargement.style.color = "orange";
|
||||
chargement.style.position = "fixed";
|
||||
chargement.style.fontWeight = "bold";
|
||||
chargement.style.zIndex = "9999";
|
||||
document.querySelector('body').prepend(chargement);
|
||||
|
||||
})();
|
||||
|
||||
|
||||
if (debug) console.log('end ui');
|
||||
@@ -0,0 +1,18 @@
|
||||
// éléments justifiés pas nécessaires
|
||||
if (debug) console.log('start unjustifyLastSplit');
|
||||
|
||||
(function() {
|
||||
|
||||
let justifiedSplitElements = document.querySelectorAll("[data-align-last-split-element='justify']");
|
||||
for (let justifiedSplitEl of justifiedSplitElements) {
|
||||
for (let elChild of justifiedSplitEl.childNodes) {
|
||||
let elStyle = elChild.style;
|
||||
if (elStyle != undefined) {
|
||||
elStyle.textAlignLast = "left";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
})();
|
||||
|
||||
if (debug) console.log('end unjustifyLastSplit');
|
||||
Reference in New Issue
Block a user