Browse Source

counting headers via pagedjs js customizations

master
Marcell Mars 2 years ago
parent
commit
3fa570c2aa
  1. 2
      _vendor/git.sandpoints.org/Drawwell/SandpointsTheme/layouts/partials/pagedjs.html
  2. 44
      _vendor/git.sandpoints.org/Drawwell/SandpointsTheme/static/js/pagedjsCustomizations.js
  3. 2
      _vendor/modules.txt

2
_vendor/git.sandpoints.org/Drawwell/SandpointsTheme/layouts/partials/pagedjs.html generated vendored

@ -2,4 +2,4 @@
<link href="/css/dyn.css" rel="stylesheet" type="text/css">
<link href="/css/print.css" rel="stylesheet" type="text/css">
<script src="/js/paged.polyfill.js"></script>
<script src="/js/repeatingHeader.js"></script>
<script src="/js/pagedjsCustomizations.js"></script>

44
_vendor/git.sandpoints.org/Drawwell/SandpointsTheme/static/js/repeatingHeader.js → _vendor/git.sandpoints.org/Drawwell/SandpointsTheme/static/js/pagedjsCustomizations.js generated vendored

@ -1,8 +1,47 @@
class RepeatingTableHeaders extends Paged.Handler {
var UID = {
_current: 0,
getNew: function(){
this._current++;
return this._current;
}
};
HTMLElement.prototype.pseudoStyle = function(element,prop,value){
var _this = this;
var _sheetId = "pseudoStyles";
var _head = document.head || document.getElementsByTagName('head')[0];
var _sheet = document.getElementById(_sheetId) || document.createElement('style');
_sheet.id = _sheetId;
var className = "pseudoStyle" + UID.getNew();
_this.className += " "+className;
_sheet.innerHTML += " ."+className+":"+element+"{"+prop+":"+value+"}";
_head.appendChild(_sheet);
return this;
};
class Sandpoints extends Paged.Handler {
constructor(chunker, polisher, caller) {
super(chunker, polisher, caller);
}
beforeParsed(content) {
var d = {};
content.querySelectorAll('*').forEach((n, i)=> {
if (n.classList.length > 0 ) {
n.classList.forEach((c, i)=>{
if (c.startsWith("css-")) {
(c in d) ? d[c]++ : d[c] = 1
let s = ""
Object.keys(d).filter(ks => ks.startsWith(c.slice(0, -1))).forEach((t, i)=> {if (c >= t) {s += `${d[t]}.`}})
n.pseudoStyle('before','content', `"${s} "`)
}
})
}
})
}
afterPageLayout(pageElement, page, breakToken, chunker) {
// Find all split table elements
let tables = pageElement.querySelectorAll("table[data-split-from]");
@ -24,7 +63,6 @@ class RepeatingTableHeaders extends Paged.Handler {
// Find if there is a header
let sourceHeader = sourceTable.querySelector("thead");
if (sourceHeader) {
console.log("Table header was cloned, because it is splitted.");
// Clone the header element
let clonedHeader = sourceHeader.cloneNode(true);
// Insert the header at the start of the split table
@ -55,4 +93,4 @@ class RepeatingTableHeaders extends Paged.Handler {
}
}
Paged.registerHandlers(RepeatingTableHeaders);
Paged.registerHandlers(Sandpoints);

2
_vendor/modules.txt vendored

@ -1 +1 @@
# git.sandpoints.org/Drawwell/SandpointsTheme v0.0.0-20210205231518-7612f79321fb
# git.sandpoints.org/Drawwell/SandpointsTheme v0.0.0-20210206114614-2c21080f414b

Loading…
Cancel
Save