Show loading icon for uploading files, and disable file actions and DnD for uploading files.

This commit is contained in:
Robin Appelman 2011-07-19 20:57:40 +02:00
Родитель ff54602be0
Коммит 0251290794
2 изменённых файлов: 25 добавлений и 9 удалений

Просмотреть файл

@ -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='<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/file.png)" href="download.php?file='+$('#dir').val()+'/'+name+'">'+name+'</a></td>';
html+='<td class="filename"><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));
$('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='<tr data-file="'+name+'" data-type="dir">';
@ -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');
}
}

Просмотреть файл

@ -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);
}
});