titles.js 4.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. // layout des pages de titres
  2. console.log('start titles');
  3. (function() {
  4. // titres ateliers
  5. let h3s = document.querySelectorAll('h3');
  6. for (let h3 of h3s) {
  7. if (h3.nextSibling?.firstChild?.tagName === "IMG") {
  8. let coverPhoto;
  9. let photoContainer = h3.nextElementSibling;
  10. if (h3.nextSibling?.children.length === 2) {
  11. coverPhoto = h3.nextElementSibling.children[1];
  12. let coverDessin = document.createElement('img');
  13. coverDessin.setAttribute('src', photoContainer.firstElementChild.getAttribute('src'));
  14. h3.prepend(coverDessin);
  15. coverDessin.style.width = '100%';
  16. coverDessin.style.height = 'auto';
  17. photoContainer.firstElementChild.remove();
  18. } else {
  19. coverPhoto = h3.nextElementSibling.firstChild;
  20. }
  21. photoContainer.style.position = 'absolute';
  22. photoContainer.style.width = '53mm';
  23. photoContainer.style.height = '220mm';
  24. photoContainer.style.overflow = 'hidden';
  25. photoContainer.style.top = "-22mm";
  26. photoContainer.style.left = "96mm";
  27. photoContainer.style.margin = '0';
  28. coverPhoto.style.width = 'auto';
  29. coverPhoto.style.height = '100%';
  30. let nextImg = document.createElement('img');
  31. nextImg.setAttribute('src', coverPhoto.getAttribute('src'));
  32. let nextContainer = document.createElement('div');
  33. nextContainer.style.position = "absolute";
  34. nextContainer.style.top = "-22mm";
  35. nextContainer.style.left = "-8mm";
  36. nextContainer.style.height = "220mm";
  37. nextContainer.style.width = "224mm";
  38. nextContainer.style.overflow = "hidden";
  39. nextContainer.style.marginLeft = "-53mm";
  40. nextImg.style.height = "100%";
  41. nextImg.style.width = "auto";
  42. nextContainer.append(nextImg);
  43. h3.closest('.pagedjs_page').nextElementSibling?.querySelector('.pagedjs_page_content').append(nextContainer);
  44. }
  45. h3.style.position = 'absolute';
  46. h3.style.top = `${(h3.closest('.pagedjs_page_content').offsetHeight - h3.offsetHeight) / 3}px`;
  47. h3.closest('.pagedjs_pagebox').querySelector('.pagedjs_margin-left').innerHTML = '';
  48. h3.closest('.pagedjs_sheet').classList.add('atelier_cover_page');
  49. }
  50. // titres parties
  51. let h2s = document.querySelectorAll('h2');
  52. for (let i = 0; i < h2s.length; i++) {
  53. if (i != 0) {
  54. let parentSheet = h2s[i].closest('.pagedjs_sheet');
  55. parentSheet.querySelector('.pagedjs_margin-left').innerHTML = '';
  56. parentSheet.classList.add('partie_cover_page');
  57. parentSheet.parentElement.nextElementSibling?.firstElementChild.classList.add('partie_cover_page_right');
  58. let partieCount = document.createElement('div');
  59. partieCount.classList.add('partie_count');
  60. let romanCount;
  61. switch (i) {
  62. case 1: romanCount = 'I'; break;
  63. case 2: romanCount = 'II'; break;
  64. case 3: romanCount = 'III'; break;
  65. case 4: romanCount = 'IV'; break;
  66. case 5: romanCount = 'V'; break;
  67. case 6: romanCount = 'VI'; break;
  68. case 7: romanCount = 'VII'; break;
  69. case 8: romanCount = 'VIII'; break;
  70. case 9: romanCount = 'IX'; break;
  71. case 10: romanCount = 'X'; break;
  72. }
  73. partieCount.innerHTML = `Partie<br>${romanCount}`;
  74. h2s[i].parentElement.prepend(partieCount);
  75. h2s[i].nextElementSibling?.remove();
  76. }
  77. }
  78. })();
  79. console.log('end titles');