From 025129079428d26cadf3d600635653b0de6cdcd5 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Tue, 19 Jul 2011 20:57:40 +0200 Subject: [PATCH] Show loading icon for uploading files, and disable file actions and DnD for uploading files. --- files/js/filelist.js | 19 ++++++++++++++++--- files/js/files.js | 15 +++++++++------ 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/files/js/filelist.js b/files/js/filelist.js index 290f062dae2..2c662087ab2 100644 --- a/files/js/filelist.js +++ b/files/js/filelist.js @@ -2,16 +2,21 @@ FileList={ update:function(fileListHtml) { $('#fileList').empty().html(fileListHtml); }, - addFile:function(name,size,lastModified){ + addFile:function(name,size,lastModified,loading){ + var img=(loading)?'img/loading.gif':'img/file.png'; var html=''; html+=''; - html+=''+name+''; + html+=''+name+''; html+=''+size+''; html+=''+lastModified+''; html+=''; html+=''; FileList.insertElement(name,'file',$(html)); - $('tr[data-file="'+name+'"] td.filename').draggable(dragOptions); + if(loading){ + $('tr[data-file="'+name+'"]').data('loading',true); + }else{ + $('tr[data-file="'+name+'"] td.filename').draggable(dragOptions); + } }, addDir:function(name,size,lastModified){ var html=''; @@ -58,5 +63,13 @@ FileList={ }else{ $('#fileList').append(element); } + }, + loadingDone:function(name){ + $('tr[data-file="'+name+'"]').data('loading',false); + $('tr[data-file="'+name+'"] td.filename a').attr('style','background-image:url(img/file.png'); + $('tr[data-file="'+name+'"] td.filename').draggable(dragOptions); + }, + isLoading:function(name){ + return $('tr[data-file="'+name+'"]').data('loading'); } } diff --git a/files/js/files.js b/files/js/files.js index 33573bfbbb9..c8cef87eb94 100644 --- a/files/js/files.js +++ b/files/js/files.js @@ -40,11 +40,13 @@ $(document).ready(function() { $('td.filename a').live('click',function(event) { event.preventDefault(); var filename=$(this).parent().parent().attr('data-file'); - var mime=$(this).parent().parent().attr('data-mime'); - var type=$(this).parent().parent().attr('data-type'); - var action=FileActions.getDefault(mime,type); - if(action){ - action(filename); + if(!FileList.isLoading(filename)){ + var mime=$(this).parent().parent().attr('data-mime'); + var type=$(this).parent().parent().attr('data-type'); + var action=FileActions.getDefault(mime,type); + if(action){ + action(filename); + } } }); @@ -152,6 +154,7 @@ $(document).ready(function() { if(size=='Pending'){ $('tr[data-file='+file.name+'] td.filesize').text(file.size); } + FileList.loadingDone(file.name); } }); $('#file_upload_form').submit(); @@ -163,7 +166,7 @@ $(document).ready(function() { }else{ var size='Pending'; } - FileList.addFile(files[i].name,size,uploadTime); + FileList.addFile(files[i].name,size,uploadTime,true); } });