inserts.js 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. // gestion des encarts splittés
  2. if (debug) console.log('start inserts');
  3. (function() {
  4. let encarts = document.querySelectorAll('.latour, .lampe, .latour_nohead, .lampe_nohead');
  5. for (let encart of encarts) {
  6. if (encart.hasAttribute('data-split-to')) {
  7. let plainColor = document.createElement('div');
  8. plainColor.setAttribute('class', 'encart-split');
  9. let plainHeight = encart.closest('.pagedjs_sheet').getBoundingClientRect().bottom - encart.getBoundingClientRect().bottom;
  10. if (encart.closest('.pagedjs_page').classList.contains('pagedjs_right_page')) {
  11. plainColor.style.width = "149mm";
  12. } else {
  13. plainColor.style.width = "129mm";
  14. }
  15. plainColor.style.height = `${plainHeight}px`;
  16. encart.parentNode.append(plainColor);
  17. }
  18. if (encart.hasAttribute('data-split-from')) {
  19. encart.style.marginTop = "0mm";
  20. let plainColor = document.createElement('div');
  21. plainColor.setAttribute('class', 'encart-split');
  22. if (encart.closest('.pagedjs_page').classList.contains('pagedjs_right_page')) {
  23. plainColor.style.width = "149mm";
  24. } else {
  25. plainColor.style.width = "129mm";
  26. }
  27. plainColor.style.height = "22mm";
  28. plainColor.style.top = "-22mm";
  29. encart.parentNode.prepend(plainColor);
  30. }
  31. if (encart.previousElementSibling?.classList.contains('breakbefore')) {
  32. encart.style.marginTop = "0mm";
  33. }
  34. }
  35. })();
  36. if (debug) console.log('end inserts');