summaryrefslogtreecommitdiffstats
path: root/files/js
diff options
context:
space:
mode:
authorRobin Appelman <icewind1991@gmail.com>2011-07-21 22:01:55 +0200
committerRobin Appelman <icewind1991@gmail.com>2011-07-21 22:01:55 +0200
commitbe6b5c8e774f9e389e4ff4a817caa3ebf5677182 (patch)
treedc6d75dac6c1c898953b0cd362301dfe400a9f1e /files/js
parent8eefd42a7dc537ebf28e2a3827e01c42b266dcd1 (diff)
downloadnextcloud-server-be6b5c8e774f9e389e4ff4a817caa3ebf5677182.tar.gz
nextcloud-server-be6b5c8e774f9e389e4ff4a817caa3ebf5677182.zip
some work on the updated interface
Diffstat (limited to 'files/js')
-rw-r--r--files/js/filelist.js8
-rw-r--r--files/js/files.js68
2 files changed, 60 insertions, 16 deletions
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..4a3de095509 100644
--- a/files/js/files.js
+++ b/files/js/files.js
@@ -54,24 +54,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 +112,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 +124,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 +136,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 +285,49 @@ 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)');
+ }else{
+ 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