use css to show/hide fileactions

This commit is contained in:
Robin Appelman 2012-10-28 12:47:33 +01:00
parent d9ef6da2e4
commit fe6b987b3d
3 changed files with 14 additions and 31 deletions

View File

@ -63,7 +63,6 @@ var FileActions = {
},
display: function (parent) {
FileActions.currentFile = parent;
$('#fileList span.fileactions, #fileList td.date a.action').remove();
var actions = FileActions.get(FileActions.getCurrentMimeType(), FileActions.getCurrentType(), FileActions.getCurrentPermissions());
var file = FileActions.getCurrentFile();
if ($('tr').filterAttr('data-file', file).data('renaming')) {
@ -73,15 +72,15 @@ var FileActions = {
var defaultAction = FileActions.getDefault(FileActions.getCurrentMimeType(), FileActions.getCurrentType(), FileActions.getCurrentPermissions());
for (name in actions) {
// NOTE: Temporary fix to prevent rename action in root of Shared directory
if (name == 'Rename' && $('#dir').val() == '/Shared') {
if (name === 'Rename' && $('#dir').val() === '/Shared') {
continue;
}
if ((name == 'Download' || actions[name] != defaultAction) && name != 'Delete') {
if ((name === 'Download' || actions[name] !== defaultAction) && name !== 'Delete') {
var img = FileActions.icons[name];
if (img.call) {
img = img(file);
}
var html = '<a href="#" class="action" style="display:none">';
var html = '<a href="#" class="action">';
if (img) {
html += '<img src="' + img + '"/> ';
}
@ -89,14 +88,13 @@ var FileActions = {
var element = $(html);
element.data('action', name);
element.click(function (event) {
FileActions.currentFile = $(this).parent().parent().parent();
event.stopPropagation();
event.preventDefault();
var action = actions[$(this).data('action')];
var currentFile = FileActions.getCurrentFile();
FileActions.hide();
action(currentFile);
});
element.hide();
parent.find('a.name>span.fileactions').append(element);
}
}
@ -107,9 +105,9 @@ var FileActions = {
}
// NOTE: Temporary fix to allow unsharing of files in root of Shared folder
if ($('#dir').val() == '/Shared') {
var html = '<a href="#" original-title="' + t('files', 'Unshare') + '" class="action delete" style="display:none" />';
var html = '<a href="#" original-title="' + t('files', 'Unshare') + '" class="action delete" />';
} else {
var html = '<a href="#" original-title="' + t('files', 'Delete') + '" class="action delete" style="display:none" />';
var html = '<a href="#" original-title="' + t('files', 'Delete') + '" class="action delete" />';
}
var element = $(html);
if (img) {
@ -121,22 +119,10 @@ var FileActions = {
event.preventDefault();
var action = actions[$(this).data('action')];
var currentFile = FileActions.getCurrentFile();
FileActions.hide();
action(currentFile);
});
element.hide();
parent.parent().children().last().append(element);
}
$('#fileList .action').css('-o-transition-property', 'none');//temporarly disable
$('#fileList .action').fadeIn(200, function () {
$('#fileList .action').css('-o-transition-property', 'opacity');
});
return false;
},
hide: function () {
$('#fileList span.fileactions, #fileList td.date a.action').fadeOut(200, function () {
$(this).remove();
});
},
getCurrentFile: function () {
return FileActions.currentFile.parent().attr('data-file');
@ -163,6 +149,10 @@ $(document).ready(function () {
}, function (filename) {
window.location = OC.filePath('files', 'ajax', 'download.php') + '?files=' + encodeURIComponent(filename) + '&dir=' + encodeURIComponent($('#dir').val());
});
$('#fileList tr').each(function(){
FileActions.display($(this).children('td.filename'));
});
});
FileActions.register('all', 'Delete', OC.PERMISSION_DELETE, function () {

View File

@ -62,14 +62,6 @@ $(document).ready(function() {
return false;
});
// Sets the file-action buttons behaviour :
$('tr').live('mouseenter',function(event) {
FileActions.display($(this).children('td.filename'));
});
$('tr').live('mouseleave',function(event) {
FileActions.hide();
});
var lastChecked;
// Sets the file link behaviour :

View File

@ -112,10 +112,11 @@ label.infield { cursor: text !important; }
#notification { z-index:101; background-color:#fc4; border:0; padding:0 .7em .3em; display:none; position:fixed; left:50%; top:0; -moz-border-radius-bottomleft:1em; -webkit-border-bottom-left-radius:1em; border-bottom-left-radius:1em; -moz-border-radius-bottomright:1em; -webkit-border-bottom-right-radius:1em; border-bottom-right-radius:1em; }
#notification span { cursor:pointer; font-weight:bold; margin-left:1em; }
.action, .selectedActions a { -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=50)"; filter:alpha(opacity=50); opacity:.5; -webkit-transition:opacity 200ms; -moz-transition:opacity 200ms; -o-transition:opacity 200ms; transition:opacity 200ms; }
.action { width: 16px; height: 16px; }
tr .action, .selectedActions a { -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=0)"; filter:alpha(opacity=0); opacity:0; -webkit-transition:opacity 200ms; -moz-transition:opacity 200ms; -o-transition:opacity 200ms; transition:opacity 200ms; }
tr:hover .action, .selectedActions a { -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=50)"; filter:alpha(opacity=50); opacity:.5; }
tr .action { width: 16px; height: 16px; }
.header-action { -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=80)"; filter:alpha(opacity=80); opacity:.8; }
.action:hover, .selectedActions a:hover, .header-action:hover { -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)"; filter:alpha(opacity=100); opacity:1; }
tr:hover .action:hover, .selectedActions a:hover, .header-action:hover { -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)"; filter:alpha(opacity=100); opacity:1; }
table:not(.nostyle) tr { -webkit-transition:background-color 200ms; -moz-transition:background-color 200ms; -o-transition:background-color 200ms; transition:background-color 200ms; }
tbody tr:hover, tr:active { background-color:#f8f8f8; }