From 1006a0edb76e41c07ac3b530c096bc1a5924454b Mon Sep 17 00:00:00 2001 From: Rob Bayliss Date: Sat, 9 Mar 2013 11:40:12 -0500 Subject: [PATCH 1/2] Allow both link and style tags in CSS import --- jquery.jqprint-0.3.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/jquery.jqprint-0.3.js b/jquery.jqprint-0.3.js index 3b01c47..e51d46c 100644 --- a/jquery.jqprint-0.3.js +++ b/jquery.jqprint-0.3.js @@ -35,19 +35,19 @@ $iframe.appendTo("body"); var doc = $iframe[0].contentWindow.document; } - + if (opt.importCSS) { - if ($("link[media=print]").length > 0) - { - $("link[media=print]").each( function() { - doc.write(""); + var $head = $('head', doc); + var printStyles = $('style[media="print"], link[media="print"]'); + if(printStyles.length > 0) { + $(printStyles).each(function() { + doc.write($('
').html($(this).clone()).html()); }); } - else - { - $("link").each( function() { - doc.write(""); + else { + $('link, style').each(function() { + doc.write($('
').html($(this).clone()).html()); }); } } From 0fd7e19b7c485072ba66fb4ddb3924e0812748d2 Mon Sep 17 00:00:00 2001 From: Rob Bayliss Date: Sat, 9 Mar 2013 11:46:38 -0500 Subject: [PATCH 2/2] Remove unneeded variable --- jquery.jqprint-0.3.js | 1 - 1 file changed, 1 deletion(-) diff --git a/jquery.jqprint-0.3.js b/jquery.jqprint-0.3.js index e51d46c..856d3e6 100644 --- a/jquery.jqprint-0.3.js +++ b/jquery.jqprint-0.3.js @@ -38,7 +38,6 @@ if (opt.importCSS) { - var $head = $('head', doc); var printStyles = $('style[media="print"], link[media="print"]'); if(printStyles.length > 0) { $(printStyles).each(function() {