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.js175
3 files changed, 150 insertions, 59 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 7750842dd5a..2f1ba907ba5 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) {
@@ -107,7 +112,7 @@ $(document).ready(function() {
}
});
- $('.download').live('click',function(event) {
+ $('.download').click('click',function(event) {
var files=getSelectedFiles('name').join(';');
//send the browser to the download location
@@ -117,7 +122,7 @@ $(document).ready(function() {
return false;
});
- $('.delete').live('click',function(event) {
+ $('.delete').click(function(event) {
var files=getSelectedFiles('name').join(';');
$.ajax({
@@ -125,7 +130,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'));
});
});
@@ -140,46 +145,83 @@ $(document).ready(function() {
var uploadId=form.attr('data-upload-id');
var files=this.files;
var target=form.children('iframe');
- target.load(function(){
- var response=jQuery.parseJSON(target.contents().find('body').text());
- //set mimetype and if needed filesize
- if(response){
- for(var i=0;i<response.length;i++){
- var file=response[i];
- $('tr[data-file="'+file.name+'"]').attr('data-mime',file.mime);
- if(size=='Pending'){
- $('tr[data-file='+file.name+'] td.filesize').text(file.size);
+ var totalSize=0;
+ for(var i=0;i<files.length;i++){
+ totalSize+=files[i].size;
+ }
+ if(totalSize>$('#max_upload').val()){
+ $( "#uploadsize-message" ).dialog({
+ modal: true,
+ buttons: {
+ Close: function() {
+ $( this ).dialog( "close" );
}
- FileList.loadingDone(file.name);
}
+ });
+ }else{
+ target.load(function(){
+ var response=jQuery.parseJSON(target.contents().find('body').text());
+ //set mimetype and if needed filesize
+ if(response){
+ for(var i=0;i<response.length;i++){
+ var file=response[i];
+ $('tr[data-file="'+file.name+'"]').attr('data-mime',file.mime);
+ if(size=='Pending'){
+ $('tr[data-file='+file.name+'] td.filesize').text(file.size);
+ }
+ FileList.loadingDone(file.name);
+ }
+ }
+ });
+ form.submit();
+ var date=new Date();
+ var uploadTime=formatDate(date);
+ for(var i=0;i<files.length;i++){
+ if(files[i].size>0){
+ var size=simpleFileSize(files[i].size);
+ }else{
+ var size='Pending';
+ }
+ FileList.addFile(files[i].name,size,uploadTime,true);
}
- });
- form.submit();
- var date=new Date();
- var uploadTime=formatDate(date);
- for(var i=0;i<files.length;i++){
- if(files[i].size>0){
- var size=simpleFileSize(files[i].size);
- }else{
- var size='Pending';
- }
- FileList.addFile(files[i].name,size,uploadTime,true);
+
+ //clone the upload form and hide the new one to allow users to start a new upload while the old one is still uploading
+ var clone=form.clone();
+ uploadId++;
+ clone.attr('data-upload-id',uploadId);
+ clone.attr('target','file_upload_target_'+uploadId);
+ clone.children('iframe').attr('name','file_upload_target_'+uploadId)
+ clone.insertBefore(form);
+ form.hide();
}
-
- //clone the upload form and hide the new one to allow users to start a new upload while the old one is still uploading
- var clone=form.clone();
- uploadId++;
- clone.attr('data-upload-id',uploadId);
- clone.attr('target','file_upload_target_'+uploadId);
- clone.children('iframe').attr('name','file_upload_target_'+uploadId)
- clone.insertBefore(form);
- form.hide();
});
//add multiply file upload attribute to all browsers except konqueror (which crashes when it's used)
if(navigator.userAgent.search(/konqueror/i)==-1){
$('.file_upload_start').attr('multiple','multiple')
}
+
+ //if the breadcrumb is to long, start by replacing foldernames with '...' except for the current folder
+ var crumb=$('div.crumb').first();
+ while($('div.controls').height()>40 && crumb.next('div.crumb').length>0){
+ crumb.children('a').text('...');
+ crumb=crumb.next('div.crumb');
+ }
+ //if that isn't enough, start removing items from the breacrumb except for the current folder and it's parent
+ var crumb=$('div.crumb').first();
+ var next=crumb.next('div.crumb');
+ while($('div.controls').height()>40 && next.next('div.crumb').length>0){
+ crumb.remove();
+ crumb=next;
+ next=crumb.next('div.crumb');
+ }
+ //still not enough, start shorting down the current folder name
+ var crumb=$('div.crumb>a').last();
+ while($('div.controls').height()>40 && crumb.text().length>6){
+ var text=crumb.text()
+ text=text.substr(0,text.length-6)+'...';
+ crumb.text(text);
+ }
});
var adjustNewFolderSize = function() {
@@ -276,6 +318,53 @@ 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');
+ }
+}
+
/**
* @brief get a list of selected files
* @param string property (option) the property of the file requested