From 726bbac5a9076dd7cdb2f257cf29b9d7c3a25790 Mon Sep 17 00:00:00 2001 From: Bengt Brodersen Date: Tue, 24 Nov 2015 09:02:18 +0100 Subject: [PATCH] improove scaling --- bookmarklet.js | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/bookmarklet.js b/bookmarklet.js index cbd3f90..e7db4ca 100644 --- a/bookmarklet.js +++ b/bookmarklet.js @@ -310,27 +310,13 @@ var cardCount = jQuery(".card", printDocument).length; var pageCount = Math.ceil(cardCount / (columnCount * rowCount)) - // size - - // size horizontal - jQuery("#styleColumnCount", printDocument).remove(); - var style = document.createElement('style'); - style.id = 'styleColumnCount'; - style.type = 'text/css'; - style.innerHTML = ".card { width: calc( 100% / " + columnCount + " - 0.0001px ); }" - jQuery("head", printDocument).append(style); - - // size horizontal - jQuery("#styleRowCount", printDocument).remove(); - var style = document.createElement('style'); - style.id = 'styleRowCount'; - style.type = 'text/css'; - style.innerHTML = ".card { height: calc( 100% / " + rowCount + " - 0.0001px ); }" - jQuery("head", printDocument).append(style); + // scale jQuery("html", printDocument).css("font-size", "1cm"); + jQuery("#styleColumnCount", printDocument).remove(); + jQuery("#styleRowCount", printDocument).remove(); // scale horizontal // substract one pixel due to rounding problems @@ -348,9 +334,24 @@ // scale min var scale = Math.min(scaleWidth, scaleHeight, 1); if (scale < 1) { - console.log("scale: " + scale ) jQuery("html", printDocument).css("font-size", scale + "cm"); } + + // size + + // size horizontal + var style = document.createElement('style'); + style.id = 'styleColumnCount'; + style.type = 'text/css'; + style.innerHTML = ".card { width: calc( 100% / " + columnCount + " - 0.0001px ); }" + jQuery("head", printDocument).append(style); + + // size horizontal + var style = document.createElement('style'); + style.id = 'styleRowCount'; + style.type = 'text/css'; + style.innerHTML = ".card { height: calc( 100% / " + rowCount + " - 0.0001px ); }" + jQuery("head", printDocument).append(style); } function cropCards() {