aboutsummaryrefslogtreecommitdiffstats
path: root/files/js
diff options
context:
space:
mode:
Diffstat (limited to 'files/js')
-rw-r--r--files/js/fileactions.js26
-rw-r--r--files/js/filelist.js8
-rw-r--r--files/js/files.js80
3 files changed, 84 insertions, 30 deletions
diff --git a/files/js/fileactions.js b/files/js/fileactions.js
index b683dc0cd3a..3ad417c91c4 100644
--- a/files/js/fileactions.js
+++ b/files/js/fileactions.js
@@ -49,33 +49,39 @@ FileActions={
return actions[name];
},
display:function(parent){
- $('#file_menu ul').empty();
+ $('#file_menu').empty();
parent.append($('#file_menu'));
var actions=FileActions.get(FileActions.getCurrentMimeType(),FileActions.getCurrentType());
for(name in actions){
- var html='<li><a href="" alt="'+name+'">'+name+'</a></li>';
+ var html='<a href="#" alt="'+name+'">'+name+'</a>';
var element=$(html);
element.data('action',name);
element.click(function(event){
+ event.stopPropagation();
event.preventDefault();
- $('#file_menu').slideToggle(250);
var action=actions[$(this).data('action')];
- $('#file_menu ul').empty();
- action(FileActions.getCurrentFile());
+ var currentFile=FileActions.getCurrentFile();
+ FileActions.hide();
+ action(currentFile);
});
- $('#file_menu>ul').append(element);
+ $('#file_menu').append(element);
}
- $('#file_menu').slideToggle(250);
+ $('#file_menu').show();
return false;
},
+ hide:function(){
+ $('#file_menu').hide();
+ $('#file_menu').empty();
+ $('body').append($('#file_menu'));
+ },
getCurrentFile:function(){
- return $('#file_menu').parents('tr:first').attr('data-file');
+ return $('#file_menu').parent().parent().attr('data-file');
},
getCurrentMimeType:function(){
- return $('#file_menu').parents('tr:first').attr('data-mime');
+ return $('#file_menu').parent().parent().attr('data-mime');
},
getCurrentType:function(){
- return $('#file_menu').parents('tr:first').attr('data-type');
+ return $('#file_menu').parent().parent().attr('data-type');
}
}
diff --git a/files/js/filelist.js b/files/js/filelist.js
index 2c662087ab2..9300e311076 100644
--- a/files/js/filelist.js
+++ b/files/js/filelist.js
@@ -5,11 +5,9 @@ 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="selection"><input type="checkbox" /></td>';
- html+='<td class="filename"><a style="background-image:url('+img+')" href="download.php?file='+$('#dir').val()+'/'+name+'">'+name+'</a></td>';
+ 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="filesize">'+size+'</td>';
html+='<td class="date">'+lastModified+'</td>';
- html+='<td class="fileaction"><a href="" title="+" class="dropArrow"></a></td>';
html+='</tr>';
FileList.insertElement(name,'file',$(html));
if(loading){
@@ -20,11 +18,9 @@ FileList={
},
addDir:function(name,size,lastModified){
var html='<tr data-file="'+name+'" data-type="dir">';
- html+='<td class="selection"><input type="checkbox" /></td>';
- html+='<td class="filename"><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 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+='<td class="fileaction"><a href="" title="+" class="dropArrow"></a></td>';
html+='</tr>';
FileList.insertElement(name,'dir',$(html));
diff --git a/files/js/files.js b/files/js/files.js
index d4191215972..f1c00650d0a 100644
--- a/files/js/files.js
+++ b/files/js/files.js
@@ -31,11 +31,13 @@ $(document).ready(function() {
});
// Sets the file-action buttons behaviour :
- $('td.fileaction a').live('click',function(event) {
- event.preventDefault();
- FileActions.display($(this).parent());
+ $('tr').live('mouseenter',function(event) {
+ FileActions.display($(this).children('td.filename'));
});
-
+ $('tr').live('mouseleave',function(event) {
+ FileActions.hide();
+ });
+
// Sets the file link behaviour :
$('td.filename a').live('click',function(event) {
event.preventDefault();
@@ -54,24 +56,27 @@ $(document).ready(function() {
$('#select_all').click(function() {
if($(this).attr('checked')){
// Check all
- $('td.selection input:checkbox').attr('checked', true);
- $('td.selection input:checkbox').parent().parent().addClass('selected');
+ $('td.filename input:checkbox').attr('checked', true);
+ $('td.filename input:checkbox').parent().parent().addClass('selected');
}else{
// Uncheck all
- $('td.selection input:checkbox').attr('checked', false);
- $('td.selection input:checkbox').parent().parent().removeClass('selected');
+ $('td.filename input:checkbox').attr('checked', false);
+ $('td.filename input:checkbox').parent().parent().removeClass('selected');
}
+ procesSelection();
});
- $('td.selection input:checkbox').live('click',function() {
+ $('td.filename input:checkbox').live('click',function() {
+ var selectedCount=$('td.filename input:checkbox:checked').length;
$(this).parent().parent().toggleClass('selected');
if(!$(this).attr('checked')){
$('#select_all').attr('checked',false);
}else{
- if($('td.selection input:checkbox:checked').length==$('td.selection input:checkbox').length){
+ if(selectedCount==$('td.filename input:checkbox').length){
$('#select_all').attr('checked',true);
}
}
+ procesSelection();
});
$('#file_newfolder_form').submit(function(event) {
@@ -109,7 +114,7 @@ $(document).ready(function() {
$('.download').live('click',function(event) {
var files='';
- $('td.selection input:checkbox:checked').parent().parent().each(function(i,element){
+ $('td.filename input:checkbox:checked').parent().parent().each(function(i,element){
files+=';'+$(element).attr('data-file');
});
files=files.substr(1);//remove leading ;
@@ -121,9 +126,9 @@ $(document).ready(function() {
return false;
});
- $('.delete').live('click',function(event) {
+ $('.delete').click(function(event) {
var files='';
- $('td.selection input:checkbox:checked').parent().parent().each(function(i,element){
+ $('td.filename input:checkbox:checked').parent().parent().each(function(i,element){
files+=';'+$(element).attr('data-file');
});
files=files.substr(1);//remove leading ;
@@ -133,7 +138,7 @@ $(document).ready(function() {
data: "dir="+$('#dir').val()+"&files="+encodeURIComponent(files),
complete: function(data){
boolOperationFinished(data, function(){
- $('td.selection input:checkbox:checked').parent().parent().each(function(i,element){
+ $('td.filename input:checkbox:checked').parent().parent().each(function(i,element){
FileList.remove($(element).attr('data-file'));
});
});
@@ -282,4 +287,51 @@ var folderDropOptions={
});}
});
}
+}
+
+function procesSelection(){
+ var selectedFiles=$('tr[data-type="file"]>td.filename>input:checkbox:checked').parent().parent();
+ var selectedFolders=$('tr[data-type="dir"]>td.filename>input:checkbox:checked').parent().parent();
+ if(selectedFiles.length==0 && selectedFolders.length==0){
+ $('#headerName>span.name').text('Name');
+ $('#headerSize').text('Size (MB)');
+ $('#selectedActions').hide();
+ }else{
+ $('#selectedActions').show();
+ var totalSize=0;
+ selectedFiles.each(function(){
+ totalSize+=parseInt($(this).attr('data-size'));
+ });
+ selectedFolders.each(function(){
+ totalSize+=parseInt($(this).attr('data-size'));
+ });
+ if(totalSize>0){
+ totalSize = Math.round(totalSize/(1024*102.4))/10;
+ if(totalSize < 0.1) {
+ totalSize='<0.1';
+ }else if(totalSize > 1000) {
+ totalSize= '>1000';
+ }
+ }
+ $('#headerSize').text(totalSize+' (MB)');
+ var selection='';
+ if(selectedFiles.length>0){
+ if(selectedFiles.length==1){
+ selection+='1 File';
+ }else{
+ selection+=selectedFiles.length+' Files';
+ }
+ if(selectedFolders.length>0){
+ selection+=' ,';
+ }
+ }
+ if(selectedFolders.length>0){
+ if(selectedFolders.length==1){
+ selection+='1 Folder';
+ }else{
+ selection+=selectedFolders.length+' Folders';
+ }
+ }
+ $('#headerName>span.name').text(selection+' Selected');
+ }
} \ No newline at end of file