Skip to content

Commit

Permalink
fixed problem with pdf layout
Browse files Browse the repository at this point in the history
  • Loading branch information
thawn committed Jan 23, 2017
1 parent 7daf89d commit d170e71
Showing 1 changed file with 12 additions and 23 deletions.
35 changes: 12 additions & 23 deletions src/assets/js/print.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,33 +221,13 @@ var toggleField = function($checkbox) {
}
}

var tileStyle = (function() {
// Create the <style> tag
var style = document.createElement("style");

// WebKit hack :(
style.appendChild(document.createTextNode(""));

// Add the <style> element to the page
document.head.appendChild(style);

return style.sheet;
})();

var changeTileSize = function($id) {
var numRules = tileStyle.cssRules.length;
if ($id.val()) {
var PPcm = 56.692845103;
var size = $id.val() * PPcm;
for (i=0;i<numRules;i++) {
tileStyle.removeRule(0);
}
tileStyle.insertRule(
'.album { min-width: ' + size + 'px; min-height: ' + size + 'px; max-width: ' + size + 'px; max-height: ' + size + 'px; overflow: hidden;}',0);
$('.album').css({ 'min-width': size + 'px', 'min-height': size + 'px', 'max-width': size + 'px', 'max-height': size + 'px', 'overflow': 'hidden'});
} else {
for (i=0;i<numRules;i++) {
tileStyle.removeRule(0);
}
$('.album').removeAttr('style');
}
}

Expand Down Expand Up @@ -283,7 +263,7 @@ var savePDF = function() {
function(data,textStatus,jqXHR) {
if (data.success) {
setTimeout(function() { window.open('/print.pdf'); }, 10000);
notify($('#pdf-save'), '', 'Creating pdf, please wait...', 'bg-info',
notify($('#pdf-save'), '', 'Creating pdf, please wait about 10 s... (you need to allow popups to see the pdf. otherwise open "http://'+window.location.host+'/print.pdf" manually', 'bg-info',
10000);
} else {
notify($('#pdf-save'), '', jqXHR.statusText, 'bg-danger',
Expand All @@ -301,6 +281,15 @@ $(function() {
// fetch the configuration from the database
getConfig();

tileStyle = (function() {
// Create the <style> tag
var style = document.createElement("style");
// WebKit hack :(
style.appendChild(document.createTextNode(""));
// Add the <style> element to the page
document.getElementById('wrap-all-print').appendChild(style);
return style.sheet;
})();
// save visible layout as pdf
$('#pdf-save').click(function(){
savePDF();
Expand Down

0 comments on commit d170e71

Please sign in to comment.