show icons instead of text for file actions

remotes/origin/stable
Robin Appelman 14 years ago
parent 74249c65da
commit ece6bd663c
  1. 2
      apps/files_imageviewer/js/lightbox.js
  2. 8
      apps/media/js/files.js
  3. 3
      files/css/files.css
  4. 45
      files/js/fileactions.js
  5. 4
      files/js/filelist.js
  6. 2
      files/templates/part.list.php

@ -7,7 +7,7 @@ $(document).ready(function() {
$( 'body' ).append(overlay);
var container=$('<div id="lightbox"/>');
$( 'body' ).append(container);
FileActions.register('image','View',function(filename){
FileActions.register('image','View','',function(filename){
var location='ajax/download.php?files='+filename+'&dir='+$('#dir').val();
overlay.show();
if(!images[location]){

@ -40,11 +40,11 @@ function loadPlayer(type,ready){
$(document).ready(function() {
loadPlayer.done=false
FileActions.register('audio','Add to playlist',addAudio);
FileActions.register('application/ogg','Add to playlist',addAudio);
// FileActions.register('audio','Add to playlist','',addAudio);
// FileActions.register('application/ogg','Add to playlist','',addAudio);
FileActions.register('audio','Play',playAudio);
FileActions.register('application/ogg','Play',playAudio);
FileActions.register('audio','Play','',playAudio);
FileActions.register('application/ogg','','Play',playAudio);
FileActions.setDefault('audio','Play');
FileActions.setDefault('application/ogg','Play');
});

@ -26,7 +26,7 @@ table th, table td { border-bottom:1px solid #ddd; text-align:left; font-weight:
table td { border-bottom:1px solid #eee; font-style:normal; }
table th#headerSize, table td.filesize, table th#headerDate, table td.date { width:5em; padding:0 1em; text-align:right; cursor:help; }
table td.selection, table th.selection, table td.fileaction { width:2em; text-align:center; }
table td.filename a { display:block; background-image:url('../img/file.png'); text-decoration:none; }
table td.filename a.name { display:block; background-image:url('../img/file.png'); text-decoration:none; }
table td.filename a, table td.login, table td.logout, table td.download, table td.upload, table td.create, table td.delete { padding:.5em .5em .5em 3em; background-position:1em center; background-repeat:no-repeat; }
table td.filename a:hover, table td.filename a:focus { outline:0; }
table td.filename a:active { outline:0; }
@ -53,6 +53,7 @@ table td.delete { background-image:url('../img/delete.png'); }
#selectedActions { float:right; display:none; }
#selectedActions a { margin:0 .5em; }
#uploadsize-message { display:none; }
a.file_action { float:right; display:inline; padding:3px !important }
/* add breadcrumb divider to the File item in navigation panel */
#plugins li:first-child { background-position:15.7em 0px; background-repeat:no-repeat; background-image:url("/owncloud/core/img/breadcrumb-divider-start.png"); width:15.7em; padding-right:11px; }

@ -1,11 +1,14 @@
FileActions={
actions:{},
defaults:{},
register:function(mime,name,action){
icons:{},
currentFile:null,
register:function(mime,name,icon,action){
if(!FileActions.actions[mime]){
FileActions.actions[mime]={};
}
FileActions.actions[mime][name]=action;
FileActions.icons[name]=icon;
},
setDefault:function(mime,name){
FileActions.defaults[mime]=name;
@ -49,14 +52,17 @@ FileActions={
return actions[name];
},
display:function(parent){
$('#file_menu').empty();
parent.append($('#file_menu'));
FileActions.currentFile=parent;
var actions=FileActions.get(FileActions.getCurrentMimeType(),FileActions.getCurrentType());
var defaultAction=FileActions.getDefault(FileActions.getCurrentMimeType(),FileActions.getCurrentType());
for(name in actions){
if(actions[name]!=defaultAction && name!='Delete'){
var html='<a href="#" alt="'+name+'">'+name+'</a>';
var img=FileActions.icons[name];
var html='<a href="#" title="'+name+'" class="file_action"/>';
var element=$(html);
if(img){
element.append($('<img src="'+img+'"/>'));
}
element.data('action',name);
element.click(function(event){
event.stopPropagation();
@ -66,12 +72,16 @@ FileActions={
FileActions.hide();
action(currentFile);
});
$('#file_menu').append(element);
parent.children('a.name').append(element);
}
}
if(actions['Delete']){
var html='<a href="#" alt="Delete" id="action_delete">Delete</a>';
var img=FileActions.icons['Delete'];
var html='<a href="#" title="Delete" class="file_action"/>';
var element=$(html);
if(img){
element.append($('<img src="'+img+'"/>'));
}
element.data('action','Delete');
element.click(function(event){
event.stopPropagation();
@ -83,31 +93,27 @@ FileActions={
});
parent.parent().children().last().append(element);
}
$('#file_menu').show();
return false;
},
hide:function(){
$('#file_menu').hide();
$('#file_menu').empty();
$('#action_delete').remove();
$('body').append($('#file_menu'));
$('.file_action').remove();
},
getCurrentFile:function(){
return $('#file_menu').parent().parent().attr('data-file');
return FileActions.currentFile.parent().attr('data-file');
},
getCurrentMimeType:function(){
return $('#file_menu').parent().parent().attr('data-mime');
return FileActions.currentFile.parent().attr('data-mime');
},
getCurrentType:function(){
return $('#file_menu').parent().parent().attr('data-type');
return FileActions.currentFile.parent().attr('data-type');
}
}
FileActions.register('all','Download',function(filename){
FileActions.register('all','Download',OC.imagePath('core','actions/download'),function(filename){
window.location='ajax/download.php?files='+filename+'&dir='+$('#dir').val();
});
FileActions.register('all','Delete',function(filename){
FileActions.register('all','Delete',OC.imagePath('core','actions/delete'),function(filename){
$.ajax({
url: 'ajax/delete.php',
data: "dir="+encodeURIComponent($('#dir').val())+"&file="+encodeURIComponent(filename),
@ -119,9 +125,14 @@ FileActions.register('all','Delete',function(filename){
});
});
FileActions.register('all','Rename',OC.imagePath('core','actions/rename'),function(filename){
//todo
alert('Implement Me!!');
});
FileActions.setDefault('all','Download');
FileActions.register('dir','Open',function(filename){
FileActions.register('dir','Open','',function(filename){
window.location='index.php?dir='+$('#dir').val()+'/'+filename;
});

@ -5,7 +5,7 @@ FileList={
addFile:function(name,size,lastModified,loading){
var img=(loading)?'img/loading.gif':'img/file.png';
var html='<tr data-file="'+name+'" data-type="file">';
html+='<td class="filename"><input type="checkbox" /><a style="background-image:url('+img+')" href="download.php?file='+$('#dir').val()+'/'+name+'">'+name+'</a></td>';
html+='<td class="filename"><input type="checkbox" /><a class="name" style="background-image:url('+img+')" href="download.php?file='+$('#dir').val()+'/'+name+'">'+name+'</a></td>';
html+='<td class="filesize">'+size+'</td>';
html+='<td class="date">'+lastModified+'</td>';
html+='</tr>';
@ -18,7 +18,7 @@ FileList={
},
addDir:function(name,size,lastModified){
var html='<tr data-file="'+name+'" data-type="dir">';
html+='<td class="filename"><input type="checkbox" /><a style="background-image:url(img/folder.png)" href="index.php?dir='+$('#dir').val()+'/'+name+'"><strong>'+name+'</strong></a></td>';
html+='<td class="filename"><input type="checkbox" /><a class="name" style="background-image:url(img/folder.png)" href="index.php?dir='+$('#dir').val()+'/'+name+'"><strong>'+name+'</strong></a></td>';
html+='<td class="filesize">'+size+'</td>';
html+='<td class="date">'+lastModified+'</td>';
html+='</tr>';

@ -4,7 +4,7 @@
<tr data-file="<?php echo $file['name'];?>" data-type="<?php echo ($file['type'] == 'dir')?'dir':'file'?>" data-mime="<?php echo $file['mime']?>" data-size='<?php echo $file['size'];?>'>
<td class="filename">
<input type="checkbox" />
<a style="background-image:url(<?php if($file['type'] == 'dir') echo mimetype_icon('dir'); else echo mimetype_icon($file['mime']); ?>)" href="<?php if($file['type'] == 'dir') echo link_to('files', 'index.php?dir='.$file['directory'].'/'.$file['name']); else echo link_to('files', 'download.php?file='.$file['directory'].'/'.$file['name']); ?>" title="">
<a class="name" style="background-image:url(<?php if($file['type'] == 'dir') echo mimetype_icon('dir'); else echo mimetype_icon($file['mime']); ?>)" href="<?php if($file['type'] == 'dir') echo link_to('files', 'index.php?dir='.$file['directory'].'/'.$file['name']); else echo link_to('files', 'download.php?file='.$file['directory'].'/'.$file['name']); ?>" title="">
<?php if($file['type'] == 'dir'):?>
<strong><?php echo htmlspecialchars($file['name']);?></strong>
<?php else:?>

Loading…
Cancel
Save