limit card size to one print page

This commit is contained in:
Bengt Brodersen 2015-05-08 02:29:53 +02:00
parent bf1e3dda70
commit b0102884e4

View File

@ -36,6 +36,7 @@
}); });
function init(){ function init(){
addJQueryFunctions(); addJQueryFunctions();
addConsoleFunctions(); addConsoleFunctions();
addStringFunctions(); addStringFunctions();
@ -82,10 +83,23 @@
var printWindow = printFrame[0].contentWindow; var printWindow = printFrame[0].contentWindow;
var printDocument = printWindow.document; var printDocument = printWindow.document;
if(!isDev){ if(!isDev){
if(!isDev){
ga('send', 'event', 'button', 'click', 'print', jQuery(".card", printDocument).length ); ga('send', 'event', 'button', 'click', 'print', jQuery(".card", printDocument).length );
}
} }
printWindow.matchMedia("print").addListener(function() {
jQuery(".page",printDocument).each(function(position, page) {
var height = jQuery(page).height()
- jQuery(page).find(".card-header").outerHeight()
- jQuery(page).find(".card-footer").outerHeight()
- jQuery(page).find(".content-header").outerHeight()
- 40;
jQuery(page).find(".description").css("max-height", height+"px");
var lineHeight = jQuery(page).find(".description").css("line-height");
lineHeight = lineHeight.substring(0, lineHeight.length - 2);
var lineClamp = Math.floor(height / lineHeight);
jQuery(page).find(".description").css("-webkit-line-clamp", lineClamp+"");
});
});
printWindow.print(); printWindow.print();
} }
@ -568,6 +582,7 @@
/*! /*!
HTML { HTML {
font-size: 1.0cm; font-size: 1.0cm;
overflow: hidden;
} }
.page { .page {
position: relative; position: relative;
@ -593,23 +608,17 @@
border-radius: 0.1cm; border-radius: 0.1cm;
overflow: hidden; overflow: hidden;
} }
.multiCardPage {
page-break-after: avoid;
}
@media print { @media print {
.page { .page {
max-height:100% ;
height: 100%;
background: white; background: white;
border-style: none; border-style: none;
padding: 0.0cm; padding: 0.0cm;
margin: 0.0cm; margin: 0.0cm;
margin-top: 1.0cm;
-webkit-box-shadow: none; -webkit-box-shadow: none;
box-shadow: none; box-shadow: none;
@ -618,12 +627,14 @@
print-color-adjust: exact; print-color-adjust: exact;
} }
.page:first-of-type { .multiCardPage {
margin-top: 0cm; height: auto;
margin-bottom: 1.0cm;
page-break-after: avoid;
} }
.page:last-of-type { .page:last-of-type {
page-break-after: auto; page-break-after: avoid;
} }
} }
@ -721,10 +732,11 @@
height: 3.2rem; height: 3.2rem;
background: #d0d0d0; background: #d0d0d0;
} }
.card { .card {
position: relative; position: relative;
min-width: 17.0rem; min-width: 17.0rem;
max-height: 100%;
overflow: hidden;
} }
.author{ .author{
line-height: 0.8rem; line-height: 0.8rem;
@ -775,18 +787,21 @@
position: relative; position: relative;
font-size: 1.1rem; font-size: 1.1rem;
line-height: 1.1rem; line-height: 1.1rem;
margin-bottom: 0.6rem; //margin-bottom: 0.6rem;
} }
.card-footer { .card-footer {
position: relative; position: relative;
page-break-inside: avoid;
} }
.summary { .summary {
font-weight: bold; font-weight: bold;
} }
.description { .description {
display: block;
font-size: 0.6rem; font-size: 0.6rem;
line-height: 0.6rem; line-height: 0.6rem;
overflow: hidden;
display: -webkit-box;
-webkit-box-orient: vertical;
} }
.key { .key {
position: absolute; position: absolute;