Permalink
Browse files

wait with printing till style is loaded

  • Loading branch information...
1 parent 600117a commit 3fdbe4da1b463bf6e8869f500cea8f0758283200 @corneliusweiss corneliusweiss committed with Nov 29, 2010
Showing with 26 additions and 2 deletions.
  1. +8 −0 print.css
  2. +18 −2 renderers/Base.js
View
@@ -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;
}
View
@@ -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();
},
@@ -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>'

0 comments on commit 3fdbe4d

Please sign in to comment.