correction pb h3

This commit is contained in:
Valentin
2023-07-19 19:26:04 +02:00
parent 0b8dbccb92
commit 2d6ee7c833
3 changed files with 25 additions and 21 deletions
@@ -30,7 +30,7 @@
height: 30mm; height: 30mm;
} }
@left-top { @left-top {
content: 'Titre sous-section'; content: '';
white-space: nowrap; white-space: nowrap;
font-family: 'Ortica'; font-family: 'Ortica';
font-weight: bold; font-weight: bold;
@@ -42,7 +42,7 @@
text-align: right; text-align: right;
} }
@left-bottom { @left-bottom {
content: 'Partie générale'; content: '';
white-space: nowrap; white-space: nowrap;
font-family: 'Ortica'; font-family: 'Ortica';
font-weight: bold; font-weight: bold;
+21 -14
View File
@@ -7,15 +7,21 @@ class setMarginTexts extends Paged.Handler {
afterPreview(pages) { afterPreview(pages) {
// afficher correctement les éléments en marge // afficher correctement les éléments en marge
let topLeftBoxes = document.getElementsByClassName('pagedjs_margin-left-top'); let topLeftBoxes = document.querySelectorAll('.pagedjs_margin-left-top');
for (let i = 0; i < topLeftBoxes.length; i++) { for (let topLeftBox of topLeftBoxes) {
topLeftBoxes[i].childNodes[0].style.marginTop = topLeftBoxes[i].childNodes[0].offsetWidth / 2 - topLeftBoxes[i].childNodes[0].offsetHeight / 2 + "px"; let contentDiv = topLeftBox.firstElementChild;
contentDiv.append('Texte marge');
contentDiv.style.marginTop = contentDiv.offsetWidth / 2 - contentDiv.offsetHeight / 2 + "px";
} }
let bottomLeftBoxes = document.getElementsByClassName('pagedjs_margin-left-bottom'); let bottomLeftBoxes = document.querySelectorAll('.pagedjs_margin-left-bottom');
for (let i = 0; i < bottomLeftBoxes.length; i++) { for (let bottomLeftBox of bottomLeftBoxes) {
bottomLeftBoxes[i].childNodes[0].style.marginBottom = bottomLeftBoxes[i].childNodes[0].offsetWidth / 2 - bottomLeftBoxes[i].childNodes[0].offsetHeight / 2 + "px"; let contentDiv = bottomLeftBox.firstElementChild;
contentDiv.append('Texte marge');
contentDiv.style.marginBottom = contentDiv.offsetWidth / 2 - contentDiv.offsetHeight / 2 + "px";
} }
// cleaner pour que les paragraphes tombent sur la marge haute // cleaner pour que les paragraphes tombent sur la marge haute
for(let i = 0; i < labeurs.length; i++) { for(let i = 0; i < labeurs.length; i++) {
if (labeurs[i] == labeurs[i].parentNode.firstElementChild if (labeurs[i] == labeurs[i].parentNode.firstElementChild
@@ -90,13 +96,13 @@ class setMarginTexts extends Paged.Handler {
} }
} }
// encarts bleed // encarts bleed
let encarts = document.querySelectorAll('.latour, .lampe') let encarts = document.querySelectorAll('.latour, .lampe');
for (let i = 0; i < encarts.length; i++) { for (let i = 0; i < encarts.length; i++) {
if (encarts[i].parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode if (encarts[i].parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode
.classList.contains('pagedjs_right_page')) { .classList.contains('pagedjs_right_page')) {
encarts[i].style.marginRight = '-22mm'; encarts[i].style.marginRight = '-22mm';
encarts[i].style.paddingRight = '22mm'; encarts[i].style.paddingRight = '22mm';
} }
if (encarts[i].hasAttribute('data-split-original')) { if (encarts[i].hasAttribute('data-split-original')) {
let plainColor = document.createElement('div'); let plainColor = document.createElement('div');
let plainHeight = encarts[i] let plainHeight = encarts[i]
@@ -131,7 +137,7 @@ class setMarginTexts extends Paged.Handler {
// TITRES // TITRES
let h3s = document.querySelectorAll('h3'); let h3s = document.querySelectorAll('h3');
for (let h3 of h3s) { for (let h3 of h3s) {
if (h3.nextSibling.firstChild.tagName == "IMG") { if (h3.nextSibling?.firstChild.tagName == "IMG") {
h3.style.position = "absolute"; h3.style.position = "absolute";
h3.style.top = "40%"; h3.style.top = "40%";
@@ -176,6 +182,7 @@ class setMarginTexts extends Paged.Handler {
h4.style.color = "#d98a29"; h4.style.color = "#d98a29";
} }
} }
// loading // loading
document.querySelector('body').style.opacity = "1"; document.querySelector('body').style.opacity = "1";
document.querySelector('body').style.overflow = "scroll"; document.querySelector('body').style.overflow = "scroll";
@@ -24,25 +24,22 @@ let baliseWords = [
'breakafter' 'breakafter'
]; ];
// Get the HTML content of the "body" element
var bodyContent = $('#body').html(); var bodyContent = $('#body').html();
// Replace text between brackets only if it matches one of the words in the list
bodyContent = bodyContent.replace(/\[([^\/\]]+)\]/g, function(match, word) { bodyContent = bodyContent.replace(/\[([^\/\]]+)\]/g, function(match, word) {
if (baliseWords.includes(word)) { if (baliseWords.includes(word)) {
return '<div class="' + word + '">'; return '<div class="' + word + '">';
} else { } else {
return match; // No replacement if the word is not in the list return match;
} }
}).replace(/\[\/([^\]]+)\]/g, function(match, word) { }).replace(/\[\/([^\]]+)\]/g, function(match, word) {
if (baliseWords.includes(word)) { if (baliseWords.includes(word)) {
return '</div>'; return '</div>';
} else { } else {
return match; // No replacement if the word is not in the list return match;
} }
}); });
// Update the content of the "body" element
$('#body').empty().append(bodyContent); $('#body').empty().append(bodyContent);