// 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
${romanCount}`; h2s[i].parentElement.prepend(partieCount); h2s[i].nextElementSibling?.remove(); } } })(); console.log('end titles');