summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin Appelman <icewind1991@gmail.com>2011-08-22 15:20:24 +0200
committerRobin Appelman <icewind1991@gmail.com>2011-08-22 15:20:24 +0200
commitd5ba4ec825c0c0c207b40546a3c545ce95e46235 (patch)
treee6b7da24616ab86dced14e86d6f84130397c6a4f
parent13b7cb59ebea9726532cf8c171cad9899e6f21dc (diff)
downloadnextcloud-server-d5ba4ec825c0c0c207b40546a3c545ce95e46235.tar.gz
nextcloud-server-d5ba4ec825c0c0c207b40546a3c545ce95e46235.zip
some improvements in automatic svg replacement
-rw-r--r--core/js/js.js50
-rw-r--r--files/js/fileactions.js9
2 files changed, 34 insertions, 25 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();
})
diff --git a/files/js/fileactions.js b/files/js/fileactions.js
index a0a04ff1662..04943abf74a 100644
--- a/files/js/fileactions.js
+++ b/files/js/fileactions.js
@@ -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);
});