also replace svg images with png when the server doesn't send the correct mimetype for svg images

(which breaks svg images for most browsers)
This commit is contained in:
Robin Appelman 2011-08-22 14:53:52 +02:00
parent af3080402b
commit 13b7cb59eb
1 changed files with 45 additions and 20 deletions

View File

@ -183,20 +183,8 @@ function SVGSupport() {
return !!document.createElementNS && !!document.createElementNS('http://www.w3.org/2000/svg', "svg").createSVGRect;
}
/**
* prototypal inharitence functions
*
* usage:
* MySubObject=object(MyObject)
*/
function object(o) {
function F() {}
F.prototype = o;
return new F();
}
$(document).ready(function(){
if(!SVGSupport()){//replace all svg images with png images for browser that dont support svg
//replace all svg images with png for browser compatibility
function replaceSVG(){
$('img.svg').each(function(index,element){
element=$(element);
var src=element.attr('src');
@ -218,7 +206,44 @@ $(document).ready(function(){
}
});
});
}
/**
* prototypal inharitence functions
*
* usage:
* MySubObject=object(MyObject)
*/
function object(o) {
function F() {}
F.prototype = o;
return new F();
}
$(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();
}
}
});
$('form.searchbox').submit(function(event){
event.preventDefault();
})