Browse Source

correction pb h3

Valentin 10 months ago
parent
commit
2d6ee7c833

+ 2 - 2
user/themes/carnet-atterrissage/css/mep_carnet.css

@@ -30,7 +30,7 @@
     height: 30mm;
   }
   @left-top {
-    content: 'Titre sous-section';
+    content: '';
     white-space: nowrap;
     font-family: 'Ortica';
     font-weight: bold;
@@ -42,7 +42,7 @@
     text-align: right;
   }
   @left-bottom {
-    content: 'Partie générale';
+    content: '';
     white-space: nowrap;
     font-family: 'Ortica';
     font-weight: bold;

+ 21 - 14
user/themes/carnet-atterrissage/js/layout.js

@@ -7,15 +7,21 @@ class setMarginTexts extends Paged.Handler {
 
     afterPreview(pages) {
         // afficher correctement les éléments en marge
-        let topLeftBoxes = document.getElementsByClassName('pagedjs_margin-left-top');
-        for (let i = 0; i < topLeftBoxes.length; i++) {
-            topLeftBoxes[i].childNodes[0].style.marginTop = topLeftBoxes[i].childNodes[0].offsetWidth / 2 - topLeftBoxes[i].childNodes[0].offsetHeight / 2 + "px";
+        let topLeftBoxes = document.querySelectorAll('.pagedjs_margin-left-top');
+        for (let topLeftBox of topLeftBoxes) {
+            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');
-        for (let i = 0; i < bottomLeftBoxes.length; i++) {
-            bottomLeftBoxes[i].childNodes[0].style.marginBottom = bottomLeftBoxes[i].childNodes[0].offsetWidth / 2 - bottomLeftBoxes[i].childNodes[0].offsetHeight / 2 + "px";
+        let bottomLeftBoxes = document.querySelectorAll('.pagedjs_margin-left-bottom');
+        for (let bottomLeftBox of bottomLeftBoxes) {
+            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
         for(let i = 0; i < labeurs.length; i++) {
             if (labeurs[i] == labeurs[i].parentNode.firstElementChild
@@ -90,13 +96,13 @@ class setMarginTexts extends Paged.Handler {
             }
         }
         // encarts bleed
-        let encarts = document.querySelectorAll('.latour, .lampe')
-            for (let i = 0; i < encarts.length; i++) {
-                if (encarts[i].parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode
-                .classList.contains('pagedjs_right_page')) {
-                    encarts[i].style.marginRight = '-22mm';
-                    encarts[i].style.paddingRight = '22mm';
-                }
+        let encarts = document.querySelectorAll('.latour, .lampe');
+        for (let i = 0; i < encarts.length; i++) {
+            if (encarts[i].parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode
+            .classList.contains('pagedjs_right_page')) {
+                encarts[i].style.marginRight = '-22mm';
+                encarts[i].style.paddingRight = '22mm';
+            }
             if (encarts[i].hasAttribute('data-split-original')) {
                 let plainColor = document.createElement('div');
                 let plainHeight = encarts[i]
@@ -131,7 +137,7 @@ class setMarginTexts extends Paged.Handler {
         // TITRES
         let h3s = document.querySelectorAll('h3');
         for (let h3 of h3s) {
-            if (h3.nextSibling.firstChild.tagName == "IMG") {
+            if (h3.nextSibling?.firstChild.tagName == "IMG") {
                 h3.style.position = "absolute";
                 h3.style.top = "40%";
 
@@ -176,6 +182,7 @@ class setMarginTexts extends Paged.Handler {
                 h4.style.color = "#d98a29";
             }
         }
+
         // loading
         document.querySelector('body').style.opacity = "1";
         document.querySelector('body').style.overflow = "scroll";

+ 2 - 5
user/themes/carnet-atterrissage/js/parsing.js

@@ -24,25 +24,22 @@ let baliseWords = [
     'breakafter'
 ];
 
-// Get the HTML content of the "body" element
 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) {
   if (baliseWords.includes(word)) {
     return '<div class="' + word + '">';
   } else {
-    return match; // No replacement if the word is not in the list
+    return match;
   }
 }).replace(/\[\/([^\]]+)\]/g, function(match, word) {
   if (baliseWords.includes(word)) {
     return '</div>';
   } 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);