Disable Print button for pdf attachments in Firefox (#5125)

Mozilla's PDF.js viewer does not allow printing from host page.
We try to detect such situation and disable the button to minimize
user confusion.
pull/5754/head
Aleksander Machniak 8 years ago
parent d4f5804e40
commit 94feab652c

@ -339,8 +339,21 @@ function rcube_webmail()
// init message compose form
this.init_messageform();
}
else if (this.env.action == 'get')
this.enable_command('download', 'print', true);
else if (this.env.action == 'get') {
this.enable_command('download', true);
// Mozilla's PDF.js viewer does not allow printing from host page (#5125)
// to minimize user confusion we disable the Print button
if (bw.mz && this.env.mimetype == 'application/pdf') {
n = 0; // there will be two onload events, first for the preload page
$(this.gui_objects.messagepartframe).on('load', function() {
if (n++) try { this.contentWindow.document; ref.enable_command('print', true); }
catch (e) {/* ignore */}
});
}
else
this.enable_command('print', true);
}
// show printing dialog
else if (this.env.action == 'print' && this.env.uid
&& !this.env.is_pgp_content && !this.env.pgp_mime_part

@ -54,6 +54,7 @@ if (!empty($_GET['_frame'])) {
if ($part_id && ($part = $MESSAGE->mime_parts[$part_id])) {
$filename = rcmail_attachment_name($part);
$OUTPUT->set_pagetitle($filename);
$OUTPUT->set_env('mimetype', rcmail_fix_mimetype($part->mimetype));
}
// register UI objects

Loading…
Cancel
Save