123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- // 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');
|