From c3be175ce756f5e0a5a5cae373b8d4c2794fab1f Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Thu, 17 Dec 2015 15:27:17 +0100 Subject: [PATCH] Fix PDF support detection in Firefox > 19 (#1490610) --- CHANGELOG | 1 + program/js/app.js | 31 +++++++++++++++++++------------ program/resources/dummy.pdf | Bin 0 -> 1058 bytes 3 files changed, 20 insertions(+), 12 deletions(-) create mode 100644 program/resources/dummy.pdf diff --git a/CHANGELOG b/CHANGELOG index 5b783e136..ee79237d0 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -3,6 +3,7 @@ CHANGELOG Roundcube Webmail - Fix regression in displaying contents of message/rfc822 parts (#1490606) - Fix handling of message/rfc822 attachments on replies and forwards (#1490607) +- Fix PDF support detection in Firefox > 19 (#1490610) RELEASE 1.2-beta ---------------- diff --git a/program/js/app.js b/program/js/app.js index 763736037..142432a32 100644 --- a/program/js/app.js +++ b/program/js/app.js @@ -8755,14 +8755,10 @@ function rcube_webmail() if (!this.env.browser_capabilities) this.env.browser_capabilities = {}; - if (this.env.browser_capabilities.pdf === undefined) - this.env.browser_capabilities.pdf = this.pdf_support_check(); - - if (this.env.browser_capabilities.flash === undefined) - this.env.browser_capabilities.flash = this.flash_support_check(); - - if (this.env.browser_capabilities.tif === undefined) - this.tif_support_check(); + $.each(['pdf', 'flash', 'tif'], function() { + if (ref.env.browser_capabilities[this] === undefined) + ref.env.browser_capabilities[this] = ref[this + '_support_check'](); + }); }; // Returns browser capabilities string @@ -8781,11 +8777,14 @@ function rcube_webmail() this.tif_support_check = function() { - var img = new Image(); + window.setTimeout(function() { + var img = new Image(); + img.onload = function() { ref.env.browser_capabilities.tif = 1; }; + img.onerror = function() { ref.env.browser_capabilities.tif = 0; }; + img.src = ref.assets_path('program/resources/blank.tif'); + }, 10); - img.onload = function() { ref.env.browser_capabilities.tif = 1; }; - img.onerror = function() { ref.env.browser_capabilities.tif = 0; }; - img.src = this.assets_path('program/resources/blank.tif'); + return 0; }; this.pdf_support_check = function() @@ -8821,6 +8820,14 @@ function rcube_webmail() return 1; } + window.setTimeout(function() { + $('').css({position: 'absolute', left: '-10000px'}) + .attr({data: ref.assets_path('program/resources/dummy.pdf'), width: 1, height: 1, type: 'application/pdf'}) + .load(function() { ref.env.browser_capabilities.pdf = 1; }) + .error(function() { ref.env.browser_capabilities.pdf = 0; }) + .appendTo($('body')); + }, 10); + return 0; }; diff --git a/program/resources/dummy.pdf b/program/resources/dummy.pdf new file mode 100644 index 0000000000000000000000000000000000000000..8c5ca5424e31148c4fc7bbbdf8afe12e5f73122b GIT binary patch literal 1058 zcmaJ=L1+^}6pgVhI7TdzLlJ}l$w8!@-6Xq7p%j}<(^eZBl1PKKhs|c1Zb^2^>_lQg zFhVbSDV}PrP_TkWJ(V6y5fqC`d(;ZWUTpE8*n=LdGhtJj1f0X)-M9b$`R~8~eTitS zQ|<}^-_E!FE#QX|B-ts@(}U7?rZGgC&h!Gw1C-G7*oHFyp9Hcrv%WNRUbcRLjfCPiJ z0#IfoJB1A<@QehN8qRA&ahx;t2r0uciNmVwhoNpiPo@!z@w#lN*1R1W;@hDeGYbq; zh++kPX%rhI$N3CnE6*mO9FRG8XfulSA}B8g(vmAOu0h>0m**DW-FVY_P7Va!r@hbV z?B(4`%fUu`ZEDA}bW>|>_t4RM(u2*_U)yKAn-AAwnT~}^9p~p4DjS0*_f~>#u#~*= zH1oRBrpqU^maUmAYjxi>+&}Jj&8cmFK4(67cQ3s7dT`O>z4f!Q=U#Okws)t63{Eu; z6VabK0goEU>GweyAVU{+Sc4L`SF3hZ*!VCE0+i~5jFvd%NF1W;gckL}F}X#T>#{o{ z@VHWzRR^Z3BtWBPjyFu@c?YqXpJdfnjT8t?P3s09tSG*18aO!+;a8c=PGG8$;xw_u z+=K!8pA4aJoeJOIzdGe|dDdV4J!CV{x9Lj$*~W5e|H+s6$4%$=?CMI_qb8UGXFETA zbgwrzR7`vwIEGH@Oj0dHMz{sB)