decor subtitles finish js
This commit is contained in:
parent
1c1a2b0a93
commit
cc971f6152
6 changed files with 180 additions and 84 deletions
|
|
@ -4,14 +4,17 @@ import { Handler } from '/csspageweaver/lib/paged.esm.js';
|
|||
export default class itemsDecor extends Handler {
|
||||
constructor(chunker, polisher, caller) {
|
||||
super(chunker, polisher, caller);
|
||||
this.symbol = "=";
|
||||
this.symbol = "+";
|
||||
}
|
||||
|
||||
|
||||
|
||||
createDecor(symbol, sizes, sizeClass) {
|
||||
const div = document.createElement("div");
|
||||
div.className = `decor-h3 ${sizeClass}`;
|
||||
sizes.forEach(n => {
|
||||
sizes.forEach((n, i) => {
|
||||
const line = document.createElement("div");
|
||||
line.dataset.count = i + 1;
|
||||
line.textContent = symbol.repeat(n);
|
||||
div.appendChild(line);
|
||||
});
|
||||
|
|
@ -89,25 +92,46 @@ export default class itemsDecor extends Handler {
|
|||
firstDecor = this.createDecor(symbol, bigSizes, "decor-h3_big");
|
||||
secondDecor = this.createDecor(symbol, smallSizes, "decor-h3_small");
|
||||
}
|
||||
subtitle.parentNode.insertBefore(firstDecor, subtitle);
|
||||
subtitle.parentNode.insertBefore(secondDecor, subtitle);
|
||||
const container = document.createElement("div");
|
||||
container.className = "h3_container";
|
||||
subtitle.parentNode.insertBefore(container, subtitle);
|
||||
container.appendChild(firstDecor);
|
||||
container.appendChild(secondDecor);
|
||||
container.appendChild(subtitle);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
beforeParsed(content){
|
||||
content.querySelectorAll("h3").forEach(subtitle => {
|
||||
const next = subtitle.nextElementSibling;
|
||||
if (next) next.classList.add("following-h3");
|
||||
});
|
||||
content.querySelectorAll("h4").forEach(subtitle => {
|
||||
const next = subtitle.nextElementSibling;
|
||||
if (next) next.classList.add("following-h4");
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
afterPageLayout(pageElement, page, breakToken) {
|
||||
const symbol = this.symbol;
|
||||
const isLeft = pageElement.classList.contains("pagedjs_left_page");
|
||||
|
||||
pageElement.querySelectorAll("h3").forEach(subtitle => {
|
||||
this.processTitle(subtitle, symbol, true, isLeft);
|
||||
const next = subtitle.nextElementSibling;
|
||||
if (next) next.classList.add("following-h3");
|
||||
});
|
||||
|
||||
pageElement.querySelectorAll("h4").forEach(subtitle => {
|
||||
this.processTitle(subtitle, symbol, false, isLeft);
|
||||
const next = subtitle.nextElementSibling;
|
||||
if (next) next.classList.add("following-h4");
|
||||
const container = document.createElement("div");
|
||||
container.className = "h4_container";
|
||||
subtitle.parentNode.insertBefore(container, subtitle);
|
||||
container.appendChild(subtitle);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue