aboutsummaryrefslogtreecommitdiff
path: root/p/scripts/main.js
diff options
context:
space:
mode:
authorGravatar Alexis Degrugillier <github@ainw.org> 2019-04-16 08:04:00 +0200
committerGravatar Alexis Degrugillier <github@ainw.org> 2019-04-16 18:50:32 +0200
commitd5ea3e96ef67e091d55354f6c5342801a9e8b48e (patch)
tree2b922f9df91d62c612cda824ed56dad64593adee /p/scripts/main.js
parent1d933dfe1303a34a7d23ba4721a5eaa9d2b641ce (diff)
Add theme to print page
Before, the printed page didn't have any usable CSS. Now, it uses the css files available in the application. It means that custom CSS can be add to target printed page. See #2149
Diffstat (limited to 'p/scripts/main.js')
-rw-r--r--p/scripts/main.js12
1 files changed, 4 insertions, 8 deletions
diff --git a/p/scripts/main.js b/p/scripts/main.js
index d85a3ae15..4fd91235e 100644
--- a/p/scripts/main.js
+++ b/p/scripts/main.js
@@ -859,15 +859,11 @@ function init_stream(stream) {
el = ev.target.closest('.item.share > a[href="#"]');
if (el) { //Print
- const content = '<html><head><style>' +
- 'body { font-family: Serif; text-align: justify; }' +
- 'a { color: #000; text-decoration: none; }' +
- 'a:after { content: " [" attr(href) "]"}' +
- '</style></head><body>' +
- el.closest('.flux_content').querySelector('.content').innerHTML +
- '</body></html>';
const tmp_window = window.open();
- tmp_window.document.writeln(content);
+ for (var i = 0; i < document.styleSheets.length; i++) {
+ tmp_window.document.writeln('<link href="' + document.styleSheets[i].href + '" rel="stylesheet" type="text/css" />');
+ }
+ tmp_window.document.writeln(el.closest('.flux_content').querySelector('.content').innerHTML);
tmp_window.document.close();
tmp_window.focus();
tmp_window.print();