Merge branch 'gh-pages' into develop

* gh-pages:
  limit card size to one print page

Conflicts:
	bookmarklet.js
This commit is contained in:
Bengt Brodersen 2015-05-12 12:04:40 +02:00
commit 647b9d6420

View File

@ -23,9 +23,7 @@
ga('set', 'page', '/cardprinter');
}
try {
// load jQuery
if (window.jQuery === undefined) {
appendScript('//ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js');
@ -36,6 +34,15 @@
init();
main();
});
} catch (err) {
console.log(err.message);
if(!isDev){
ga('send', 'exception', {
'exDescription': err.message,
'exFatal': true
});
}
}
function init(){
addJQueryFunctions();
@ -83,11 +90,26 @@
var printFrame = jQuery("#card-print-dialog-content-iframe");
var printWindow = printFrame[0].contentWindow;
var printDocument = printWindow.document;
if(!isDev){
if(!isDev){
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+"");
jQuery(page).width("40%");
jQuery(page).scc("float","left");
});
});
printWindow.print();
}
@ -104,14 +126,14 @@
resizeIframe(printFrame);
}
function enableMultiCardPage(enable){
function endableMultiCardPage(enable){
var printFrame = jQuery("#card-print-dialog-content-iframe");
var printWindow = printFrame[0].contentWindow;
var printDocument = printWindow.document;
if(enable){
jQuery(".page", printDocument).addClass("avoid-page-break");
jQuery(".page", printDocument).addClass("multiCardPage");
} else {
jQuery(".page", printDocument).removeClass("avoid-page-break");
jQuery(".page", printDocument).removeClass("multiCardPage");
}
}
@ -371,7 +393,7 @@
</div>
<div id="card-print-dialog-footer">
<div class="buttons">
<label style="margin-right:10px"><input id="card-scale-range" type="range" min="0.4" max="1.4" step="0.05" value="1.0" />Scale</label>
<label style="margin-right:10px"><input id="card-scale-range" type="range" min="0.2" max="1.6" step="0.1" value="1.0" />Scale</label>
<label style="margin-right:10px"><input id="hide-description-checkbox" type="checkbox"/>Hide Description</label>
<label style="margin-right:10px"><input id="multi-card-page-checkbox" type="checkbox"/>Multi Card Page</label>
<input id="card-print-dialog-print" type="button" class="aui-button aui-button-primary" value="Print" />
@ -399,7 +421,7 @@
result.find("#multi-card-page-checkbox")
.click(function() {
enableMultiCardPage(this.checked);
endableMultiCardPage(this.checked);
return true;
});
@ -569,7 +591,7 @@
*/
}));
return result;
};
}
function printPanelPageCSS(){
@ -581,22 +603,19 @@
/*!
HTML {
font-size: 1.0cm;
overflow: hidden;
}
body {
padding: 0.5cm;
}
.page {
position: relative;
overflow: auto;
margin-left: auto;
margin-right: auto;
padding: 0.5cm;
margin-top: 0.5cm;
margin-bottom: 0.5cm;
padding: 1.0cm;
margin: 1.0cm;
width: auto;
height: auto;
page-break-after: always;
page-break-inside: avoid;
background:white;
@ -614,23 +633,13 @@
@media print {
body {
padding: 0.0cm;
margin: 0.0cm;
}
.page {
background: white;
padding: 0.0cm;
margin: 0.0cm;
margin-bottom: 1.0cm;
page-break-after: always;
page-break-inside: avoid;
max-height:100% ;
height: 100%;
background: white;
border-style: none;
padding: 0.0cm;
margin: 0.0cm;
-webkit-box-shadow: none;
box-shadow: none;
@ -639,9 +648,16 @@
print-color-adjust: exact;
}
.avoid-page-break {
.multiCardPage {
height: auto;
margin-bottom: 1.0cm;
page-break-after: avoid;
}
.page:last-of-type {
page-break-after: avoid;
}
}
*/
}));
@ -737,10 +753,11 @@
height: 3.2rem;
background: #d0d0d0;
}
.card {
position: relative;
min-width: 17.0rem;
max-height: 100%;
overflow: hidden;
}
.author{
line-height: 0.8rem;
@ -791,7 +808,7 @@
position: relative;
font-size: 1.1rem;
line-height: 1.1rem;
margin-bottom: 0.6rem;
//margin-bottom: 0.6rem;
}
.card-footer {
position: relative;
@ -800,8 +817,12 @@
font-weight: bold;
}
.description {
display: block;
font-size: 0.6rem;
line-height: 0.6rem;
overflow: hidden;
display: -webkit-box;
-webkit-box-orient: vertical;
}
.key {
position: absolute;
@ -1178,13 +1199,4 @@
iframe.height(iframe[0].contentWindow.document.body.scrollHeight);
}
} catch (err) {
console.logError(err.message);
if(!isDev){
ga('send', 'exception', {
'exDescription': err.message,
'exFatal': true
});
}
};
})();