some improvements in automatic svg replacement

This commit is contained in:
Robin Appelman 2011-08-22 15:20:24 +02:00
parent 13b7cb59eb
commit d5ba4ec825
2 changed files with 34 additions and 25 deletions

View File

@ -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();
})

View File

@ -85,6 +85,9 @@ FileActions={
}
if(actions['Delete']){
var img=FileActions.icons['Delete'];
if(img.call){
img=img(file);
}
var html='<a href="#" title="Delete" class="action" />';
var element=$(html);
if(img){
@ -121,15 +124,15 @@ FileActions={
}
}
FileActions.register('all','Download',OC.imagePath('core','actions/download'),function(filename){
FileActions.register('all','Download',function(){return OC.imagePath('core','actions/download')},function(filename){
window.location='ajax/download.php?files='+filename+'&dir='+$('#dir').val();
});
FileActions.register('all','Delete',OC.imagePath('core','actions/delete'),function(filename){
FileActions.register('all','Delete',function(){return OC.imagePath('core','actions/delete')},function(filename){
FileList.delete(filename);
});
FileActions.register('all','Rename',OC.imagePath('core','actions/rename'),function(filename){
FileActions.register('all','Rename',function(){return OC.imagePath('core','actions/rename')},function(filename){
FileList.rename(filename);
});