Skip to content

Commit

Permalink
wait with printing till style is loaded
Browse files Browse the repository at this point in the history
  • Loading branch information
corneliusweiss authored and edspencer committed Dec 5, 2010
1 parent 600117a commit 3fdbe4d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
8 changes: 8 additions & 0 deletions print.css
Expand Up @@ -20,4 +20,12 @@ table td {
border-style: none solid solid;
border-width: 1px;
border-color: #ededed;
}

@media print {
thead {display: table-header-group;}
}

#csscheck {
display: none;
}
20 changes: 18 additions & 2 deletions renderers/Base.js
Expand Up @@ -18,7 +18,22 @@ Ext.ux.Printer.BaseRenderer = Ext.extend(Object, {

win.document.write(this.generateHTML(component));
win.document.close();


this.doPrintOnStylesheetLoad.defer(10, this, [win]);
},

/**
* check if style is loaded and do print afterwards
*
* @param {window} win
*/
doPrintOnStylesheetLoad: function(win) {
var el = win.document.getElementById('csscheck'),
comp = el.currentStyle || getComputedStyle(el, null);
if (comp.display !== "none") {
this.doPrintOnStylesheetLoad.defer(10, this, [win]);
return;
}
win.print();
win.close();
},
Expand All @@ -34,10 +49,11 @@ Ext.ux.Printer.BaseRenderer = Ext.extend(Object, {
'<html>',
'<head>',
'<meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />',
'<link href="' + this.stylesheetPath + '" rel="stylesheet" type="text/css" media="screen,print" />',
'<link href="' + this.stylesheetPath + '?' + new Date().getTime() + '" rel="stylesheet" type="text/css" media="screen,print" />',
'<title>' + this.getTitle(component) + '</title>',
'</head>',
'<body>',
'<div id="csscheck"></div>',
this.generateBody(component),
'</body>',
'</html>'
Expand Down

0 comments on commit 3fdbe4d

Please sign in to comment.