make the system for default fileactions more flexible

This commit is contained in:
Robin Appelman 2011-06-16 23:15:58 +02:00
parent 300b8c06cf
commit 07b72ca534
1 changed files with 8 additions and 5 deletions

View File

@ -8,7 +8,7 @@ FileActions={
FileActions.actions[mime][name]=action; FileActions.actions[mime][name]=action;
}, },
setDefault:function(mime,name){ setDefault:function(mime,name){
FileActions.defaults[mime]=FileActions.actions[mime][name]; FileActions.defaults[mime]=name;
}, },
get:function(mime,type){ get:function(mime,type){
var actions={}; var actions={};
@ -35,15 +35,18 @@ FileActions={
if(mime){ if(mime){
var mimePart=mime.substr(0,mime.indexOf('/')); var mimePart=mime.substr(0,mime.indexOf('/'));
} }
var name=false;
if(mime && FileActions.defaults[mime]){ if(mime && FileActions.defaults[mime]){
return FileActions.defaults[mime]; name=FileActions.defaults[mime];
}else if(mime && FileActions.defaults[mimePart]){ }else if(mime && FileActions.defaults[mimePart]){
return FileActions.defaults[mimePart]; name=FileActions.defaults[mimePart];
}else if(type && FileActions.defaults[type]){ }else if(type && FileActions.defaults[type]){
return FileActions.defaults[type]; name=FileActions.defaults[type];
}else{ }else{
return FileActions.defaults.all; name=FileActions.defaults.all;
} }
var actions=this.get(mime,type);
return actions[name];
}, },
display:function(parent){ display:function(parent){
$('#file_menu ul').empty(); $('#file_menu ul').empty();