Commit fea1253a authored by Fred Chasen's avatar Fred Chasen

Updates for CLI

parent 6fcb632a
The MIT License (MIT)
Copyright (c) 2015 Pagedmedia.org
Copyright (c) 2018 Adam Hyde
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
......
This diff is collapsed.
......@@ -4,9 +4,14 @@ import Styler from '../styles/styler';
// let ready = new Promise(function($){document.addEventListener('DOMContentLoaded',$,{once:true})});
let ready = new Promise(function(resolve, reject){
if (document.readyState === "interactive" || document.readyState === "complete") {
resolve(document.readyState);
return;
}
document.onreadystatechange = function ($) {
if (document.readyState === "interactive") {
resolve($);
resolve(document.readyState);
}
}
});
......@@ -59,6 +64,12 @@ ready.then(async function () {
let flow = await chunker.flow(template.content, styles);
let endTime = performance.now();
console.log("Rendering " + flow.total + " pages took " + (endTime - startTime) + " milliseconds.");
let msg = "Rendering " + flow.total + " pages took " + (endTime - startTime) + " milliseconds.";
console.log(msg);
if (typeof window.onPagesRendered !== "undefined") {
window.onPagesRendered(msg, styles.width.value + styles.width.unit, styles.height.value + styles.height.unit, styles.orientation);
}
});
......@@ -29,8 +29,12 @@ class Sheet {
this.pages = this.replacePages(this.ast);
if ("*" in this.pages) {
this.addRootVars(this.ast, this.pages["*"].width, this.pages["*"].height);
this.addRootPage(this.ast, this.pages["*"].width, this.pages["*"].height);
this.width = this.pages["*"].width;
this.height = this.pages["*"].height;
this.orientation = this.pages["*"].orientation;
this.addRootVars(this.ast, this.width, this.height);
this.addRootPage(this.ast, this.width, this.height);
}
this.stringSets = this.getStringSets(this.ast);
......
......@@ -52,6 +52,18 @@ class Styler {
this.sheets.push(sheet);
if (typeof sheet.width !== "undefined") {
this.width = sheet.width;
}
if (typeof sheet.height !== "undefined") {
this.height = sheet.height;
}
if (typeof sheet.orientation !== "undefined") {
this.orientation = sheet.orientation;
}
this.mergeBreaks(pageBreaks, sheet.pageBreaks);
stringSets = Object.assign(stringSets, sheet.stringSets);
textTargets = Object.assign(textTargets, sheet.textTargets);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment