summaryrefslogtreecommitdiffstats
path: root/core/js
diff options
context:
space:
mode:
authorRobin Appelman <icewind1991@gmail.com>2011-08-22 14:53:52 +0200
committerRobin Appelman <icewind1991@gmail.com>2011-08-22 14:53:52 +0200
commit13b7cb59ebea9726532cf8c171cad9899e6f21dc (patch)
tree2f562b079cf055fd821c3fafa72bfb580201f210 /core/js
parentaf3080402b06e86213c19e99c904b650d074f041 (diff)
downloadnextcloud-server-13b7cb59ebea9726532cf8c171cad9899e6f21dc.tar.gz
nextcloud-server-13b7cb59ebea9726532cf8c171cad9899e6f21dc.zip
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)
Diffstat (limited to 'core/js')
-rw-r--r--core/js/js.js65
1 files changed, 45 insertions, 20 deletions
diff --git a/core/js/js.js b/core/js/js.js
index 9ad9810a7e0..ee841227695 100644
--- a/core/js/js.js
+++ b/core/js/js.js
@@ -183,6 +183,31 @@ function SVGSupport() {
return !!document.createElementNS && !!document.createElementNS('http://www.w3.org/2000/svg', "svg").createSVGRect;
}
+//replace all svg images with png for browser compatibility
+function replaceSVG(){
+ $('img.svg').each(function(index,element){
+ element=$(element);
+ var src=element.attr('src');
+ element.attr('src',src.substr(0,src.length-3)+'png');
+ });
+ $('.svg').each(function(index,element){
+ element=$(element);
+ var background=element.css('background-image');
+ if(background && background!='none'){
+ background=background.substr(0,background.length-4)+'png)';
+ element.css('background-image',background);
+ }
+ element.find('*').each(function(index,element) {
+ element=$(element);
+ var background=element.css('background-image');
+ if(background && background!='none'){
+ background=background.substr(0,background.length-4)+'png)';
+ element.css('background-image',background);
+ }
+ });
+ });
+}
+
/**
* prototypal inharitence functions
*
@@ -197,28 +222,28 @@ function object(o) {
$(document).ready(function(){
if(!SVGSupport()){//replace all svg images with png images for browser that dont support svg
- $('img.svg').each(function(index,element){
- element=$(element);
- var src=element.attr('src');
- element.attr('src',src.substr(0,src.length-3)+'png');
- });
- $('.svg').each(function(index,element){
- element=$(element);
- var background=element.css('background-image');
- if(background && background!='none'){
- background=background.substr(0,background.length-4)+'png)';
- element.css('background-image',background);
- }
- element.find('*').each(function(index,element) {
- element=$(element);
- var background=element.css('background-image');
- if(background && background!='none'){
- background=background.substr(0,background.length-4)+'png)';
- element.css('background-image',background);
+ 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();
})