diff options
author | Robin Appelman <icewind1991@gmail.com> | 2011-08-22 15:20:24 +0200 |
---|---|---|
committer | Robin Appelman <icewind1991@gmail.com> | 2011-08-22 15:20:24 +0200 |
commit | d5ba4ec825c0c0c207b40546a3c545ce95e46235 (patch) | |
tree | e6b7da24616ab86dced14e86d6f84130397c6a4f /core/js/js.js | |
parent | 13b7cb59ebea9726532cf8c171cad9899e6f21dc (diff) | |
download | nextcloud-server-d5ba4ec825c0c0c207b40546a3c545ce95e46235.tar.gz nextcloud-server-d5ba4ec825c0c0c207b40546a3c545ce95e46235.zip |
some improvements in automatic svg replacement
Diffstat (limited to 'core/js/js.js')
-rw-r--r-- | core/js/js.js | 50 |
1 files changed, 28 insertions, 22 deletions
diff --git a/core/js/js.js b/core/js/js.js index ee841227695..770ce4ea695 100644 --- a/core/js/js.js +++ b/core/js/js.js @@ -180,8 +180,32 @@ if (!Array.prototype.indexOf){ * check if the browser support svg images */ function SVGSupport() { - return !!document.createElementNS && !!document.createElementNS('http://www.w3.org/2000/svg', "svg").createSVGRect; + return SVGSupport.checkMimeType.correct && !!document.createElementNS && !!document.createElementNS('http://www.w3.org/2000/svg', "svg").createSVGRect; } +SVGSupport.checkMimeType=function(){ + $.ajax({ + url: OC.imagePath('core','breadcrumb.svg'), + success:function(data,text,xhr){ + var headerParts=xhr.getAllResponseHeaders().split("\n"); + var headers={}; + $.each(headerParts,function(i,text){ + if(text){ + var parts=text.split(':',2); + var value=parts[1].trim(); + if(value[0]=='"'){ + value=value.substr(1,value.length-2); + } + headers[parts[0]]=value; + } + }); + if(headers["Content-Type"]!='image/svg+xml'){ + replaceSVG(); + SVGSupport.checkMimeType.correct=false + } + } + }); +} +SVGSupport.checkMimeType.correct=true; //replace all svg images with png for browser compatibility function replaceSVG(){ @@ -223,27 +247,9 @@ function object(o) { $(document).ready(function(){ if(!SVGSupport()){//replace all svg images with png images for browser that dont support svg replaceSVG(); - }; - $.ajax({ - url: OC.imagePath('core','breadcrumb.svg'), - success:function(data,text,xhr){ - var headerParts=xhr.getAllResponseHeaders().split("\n"); - var headers={}; - $.each(headerParts,function(i,text){ - if(text){ - var parts=text.split(':',2); - var value=parts[1].trim(); - if(value[0]=='"'){ - value=value.substr(1,value.length-2); - } - headers[parts[0]]=value; - } - }); - if(headers["Content-Type"]!='image/svg+xml'){ - replaceSVG(); - } - } - }); + }else{ + SVGSupport.checkMimeType(); + } $('form.searchbox').submit(function(event){ event.preventDefault(); }) |