diff --git a/index.html b/index.html
index 250b012..f570ac6 100644
--- a/index.html
+++ b/index.html
@@ -33,6 +33,7 @@
White Space Manipulation. All values are in points, relative to original document.
1
diff --git a/src/main.js b/src/main.js
index 5a1b15c..0a97b9a 100644
--- a/src/main.js
+++ b/src/main.js
@@ -9,6 +9,7 @@ import {
handleGenerateClick,
handlePreviewClick,
handleResetSettingsClick,
+ handleSewingMarksCheckboxState,
} from './utils/clickHandlers.js';
import { renderPaperSelectOptions } from './utils/renderUtils.js';
@@ -25,6 +26,7 @@ window.addEventListener('DOMContentLoaded', () => {
const fileInput = document.getElementById('input_file');
const inputs = document.querySelectorAll('input, select');
const sourceRotation = document.getElementById('source_rotation');
+ const sewingMarks = document.getElementById('add_sewing_marks_checkbox');
const sourceRotationExamples = Array.from(
document.getElementsByClassName('source_rotation_example')
);
@@ -53,4 +55,8 @@ window.addEventListener('DOMContentLoaded', () => {
example.style.display = example.id === selectedValue ? 'block' : 'none';
});
});
+ sewingMarks.addEventListener('change', (e) => {
+ const willBeEnabled = e.srcElement.checked;
+ handleSewingMarksCheckboxState(willBeEnabled);
+ });
});
diff --git a/src/models/configuration.js b/src/models/configuration.js
index e5a56a5..4006aae 100644
--- a/src/models/configuration.js
+++ b/src/models/configuration.js
@@ -35,6 +35,10 @@ const sourceRotation = urlSafe(
z.enum(['none', '90cw', '90ccw', 'out_binding', 'in_binding'])
).default('none');
+const sewingMarkLocation = urlSafe(z.enum(['all', 'only_out', 'only_in', 'in_n_out'])).default(
+ 'all'
+);
+
/** @type { keyof typeof import("../constants").PAGE_SIZES } */
const availablePaperSizes = Object.keys(PAGE_SIZES);
@@ -97,6 +101,7 @@ export const schema = z.object({
flyleafs: urlSafe(z.coerce.number()).default(1),
sewingMarksEnabled: urlSafe(coercedBoolean).default(false),
+ sewingMarkLocation,
sewingMarksMarginPt: urlSafe(z.coerce.number()).default(72),
sewingMarksAmount: urlSafe(z.coerce.number()).default(3),
sewingMarksTapeWidthPt: urlSafe(z.coerce.number()).default(36),
diff --git a/src/signatures.js b/src/signatures.js
index 0f8a861..7bf27c5 100644
--- a/src/signatures.js
+++ b/src/signatures.js
@@ -148,26 +148,40 @@ export class Signatures {
const block = [...front_block, ...back_block];
+ console.log(
+ `Looking front_config : block.length ${block.length} : given center ${center}, front_start ${front_start} - front_end ${front_end}, back_start ${back_start} - back_end ${back_end}, pages.length ${pages.length}`
+ );
front_config.forEach((pnum) => {
const page = block[pnum - 1]; //page layouts are 1-indexed, not 0-index
pagelistdetails[0].push({
info: page,
isSigStart: front_start == 0 && pnum == 1,
isSigEnd: front_start == 0 && pnum == block.length,
+ isSigMiddle: front_end == back_start && block.length / 2 + 1 == pnum,
signatureNum: sig_num,
});
+ console.log(
+ ` >> ${pnum} :: ${page} :: ${front_end == back_start && block.length / 2 + 1 == pnum}`
+ );
});
const backlist = this.duplex ? 0 : 1;
+ console.log(
+ `Looking back_config : given center ${center}, front_start ${front_start} - front_end ${front_end}, back_start ${back_start} - back_end ${back_end}, pages.length ${pages.length}`
+ );
back_config.forEach((pnum) => {
const page = block[pnum - 1];
pagelistdetails[backlist].push({
info: page,
isSigStart: front_start == 0 && pnum == 1,
isSigEnd: front_start == 0 && pnum == block.length,
+ isSigMiddle: front_end == back_start && block.length / 2 + 1 == pnum,
signatureNum: sig_num,
});
+ console.log(
+ ` >> ${pnum} :: ${page} :: ${front_end == back_start && block.length / 2 + 1 == pnum}`
+ );
});
// Update all our counters
diff --git a/src/utils/clickHandlers.js b/src/utils/clickHandlers.js
index 6c6e3a0..5517581 100644
--- a/src/utils/clickHandlers.js
+++ b/src/utils/clickHandlers.js
@@ -53,3 +53,12 @@ export function handleResetSettingsClick(book) {
updateAddOrRemoveCustomPaperOption();
updatePaperSelectOptionsUnits();
}
+
+export function handleSewingMarksCheckboxState(sewingMarksEnabled) {
+ const sewingMarkDetailsEl = document.getElementById('sewing_marks_details');
+ if (sewingMarksEnabled) {
+ sewingMarkDetailsEl.setAttribute('open', 0);
+ } else {
+ sewingMarkDetailsEl.removeAttribute('open');
+ }
+}
diff --git a/src/utils/drawing.js b/src/utils/drawing.js
index 5fa98b8..3cd62a1 100644
--- a/src/utils/drawing.js
+++ b/src/utils/drawing.js
@@ -124,12 +124,20 @@ export function drawCropmarks(papersize, per_sheet) {
/**
* @param {@param {import("../book.js").PageInfo}} sigDetails - information about signature where marks will be printed
* @param {import("../book.js").Position} position - position info object
+ * @param sewingMarkLocation - see ./models/configuration.js for possible values
* @param {number} amount - amount of sewing crosses.
* @param {number} marginPt - distance from the end of sheet of paper to kettle mark
* @param {number} tapeWidthPt - distance between two points in a single sewwing cross.
* @returns {Point[]}
*/
-export function drawSewingMarks(sigDetails, position, amount, marginPt, tapeWidthPt) {
+export function drawSewingMarks(
+ sigDetails,
+ position,
+ sewingMarkLocation,
+ amount,
+ marginPt,
+ tapeWidthPt
+) {
// Here normalize coordinates to always think in x an y like this
// | P |H| P |
// | A |E| A |
@@ -139,7 +147,17 @@ export function drawSewingMarks(sigDetails, position, amount, marginPt, tapeWidt
// |-POSITION-| | |
// Left pages have spine position on the edge :/
+ console.log('try to draw');
if (position.isLeftPage) return [];
+ console.log(' on right');
+
+ if (sewingMarkLocation == 'only_out' && !sigDetails.isSigStart) return [];
+ console.log(' a');
+ if (sewingMarkLocation == 'only_in' && !sigDetails.isSigMiddle) return [];
+ console.log(' b');
+ if (sewingMarkLocation == 'in_n_out' && !(sigDetails.isSigStart || sigDetails.isSigMiddle))
+ return [];
+ console.log(' c');
var arePageRotated = Math.abs(position.rotation) === 90;
let totalSpineHeight = 0;
diff --git a/src/utils/formUtils.js b/src/utils/formUtils.js
index fb81749..89618a6 100644
--- a/src/utils/formUtils.js
+++ b/src/utils/formUtils.js
@@ -42,7 +42,8 @@ const fromFormToConfiguration = (form) =>
paperSizeCustomWidth: form.get('paper_size_custom_width'),
paperSizeCustomHeight: form.get('paper_size_custom_height'),
- sewingMarksEnabled: form.get('add_sewing_marks_checkbox'),
+ sewingMarksEnabled: form.has('add_sewing_marks_checkbox'),
+ sewingMarkLocation: form.get('sewing_mark_locations'),
sewingMarksMarginPt: form.get('sewing_marks_margin_pt'),
sewingMarksAmount: form.get('sewing_marks_amount'),
sewingMarksTapeWidthPt: form.get('sewing_marks_tape_width_pt'),
diff --git a/src/utils/layout.js b/src/utils/layout.js
index a040371..033792f 100644
--- a/src/utils/layout.js
+++ b/src/utils/layout.js
@@ -131,7 +131,7 @@ export function calculateDimensions(book) {
top: padding_pt.top * sy,
};
- // page_positioning has 2 options: centered, binding_alinged
+ // page_positioning has 2 options: centered, binding_aligned
const positioning = page_positioning;
const xForeEdgeShiftFunc = function () {
diff --git a/src/utils/renderUtils.js b/src/utils/renderUtils.js
index 3a3fdba..101d378 100644
--- a/src/utils/renderUtils.js
+++ b/src/utils/renderUtils.js
@@ -3,6 +3,7 @@
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
import { PAGE_SIZES } from '../constants';
+import { handleSewingMarksCheckboxState } from './clickHandlers.js';
export function renderPageCount(book) {
const pageCount = document.getElementById('page_count');
@@ -203,8 +204,11 @@ export function renderFormFromSettings(configuration) {
).checked = true;
// Set french link stitches settings
+ handleSewingMarksCheckboxState(configuration.sewingMarksEnabled);
document.querySelector('input[name="add_sewing_marks_checkbox"]').checked =
configuration.sewingMarksEnabled;
+ document.querySelector('select[name="sewing_mark_locations"]').value =
+ configuration.sewingMarkLocation;
document.querySelector('input[name="sewing_marks_margin_pt"]').value =
configuration.sewingMarksMarginPt;
document.querySelector('input[name="sewing_marks_amount"]').value =