summaryrefslogtreecommitdiff
path: root/lib/viewers
diff options
context:
space:
mode:
authorAleksander Machniak <alec@alec.pl>2013-06-12 13:37:25 (GMT)
committerAleksander Machniak <alec@alec.pl>2013-06-12 13:37:25 (GMT)
commitf7171728f5b2f34691017690e03cfb1470047894 (patch)
treef9f9aa775fc7f32f37572c0d2ed0e640fd786434 /lib/viewers
parent00242de66b483749f389c33db4c6fd0b727a78c4 (diff)
downloadkolab-chwala-f7171728f5b2f34691017690e03cfb1470047894.tar.gz
Create only one print frame element
Diffstat (limited to 'lib/viewers')
-rw-r--r--lib/viewers/text/file_editor.js15
1 files changed, 8 insertions, 7 deletions
diff --git a/lib/viewers/text/file_editor.js b/lib/viewers/text/file_editor.js
index 4a9449c..9e698a2 100644
--- a/lib/viewers/text/file_editor.js
+++ b/lib/viewers/text/file_editor.js
@@ -38,12 +38,13 @@ function file_editor()
// There's no print function in Ace Editor
// it's also not possible to print the page as is
// we'd copy the content to a hidden iframe
- var iframe = document.createElement('iframe');
-
- iframe.style.display = 'none';
- iframe.onload = function() { iframe.focus(); iframe.contentWindow.print(); };
- iframe.src = this.href + '&force-type=text/plain';
-
- document.body.appendChild(iframe);
+ if (!this.print_frame) {
+ this.print_frame = document.createElement('iframe');
+ document.body.appendChild(this.print_frame);
+ this.print_frame.style.display = 'none';
+ this.print_frame.onload = function() { this.focus(); this.contentWindow.print(); };
+ }
+
+ this.print_frame.src = this.href + '&force-type=text/plain';
};
}