reuse jquery object when adding files to the file list

This commit is contained in:
Robin Appelman 2012-11-07 22:06:05 +01:00
parent e14054610f
commit 42935c5564
1 changed files with 8 additions and 6 deletions

View File

@ -32,13 +32,14 @@ var FileList={
html+='<td class="date"><span class="modified" title="'+formatDate(lastModified)+'" style="color:rgb('+modifiedColor+','+modifiedColor+','+modifiedColor+')">'+relative_modified_date(lastModified.getTime() / 1000)+'</span></td>'; html+='<td class="date"><span class="modified" title="'+formatDate(lastModified)+'" style="color:rgb('+modifiedColor+','+modifiedColor+','+modifiedColor+')">'+relative_modified_date(lastModified.getTime() / 1000)+'</span></td>';
html+='</tr>'; html+='</tr>';
FileList.insertElement(name,'file',$(html).attr('data-file',name)); FileList.insertElement(name,'file',$(html).attr('data-file',name));
var row = $('tr').filterAttr('data-file',name);
if(loading){ if(loading){
$('tr').filterAttr('data-file',name).data('loading',true); row.data('loading',true);
}else{ }else{
$('tr').filterAttr('data-file',name).find('td.filename').draggable(dragOptions); row.find('td.filename').draggable(dragOptions);
} }
if (hidden) { if (hidden) {
$('tr').filterAttr('data-file', name).hide(); row.hide();
} }
}, },
addDir:function(name,size,lastModified,hidden){ addDir:function(name,size,lastModified,hidden){
@ -66,10 +67,11 @@ var FileList={
td.append($('<span></span>').attr({ "class": "modified", "title": formatDate(lastModified), "style": 'color:rgb('+modifiedColor+','+modifiedColor+','+modifiedColor+')' }).text( relative_modified_date(lastModified.getTime() / 1000) )); td.append($('<span></span>').attr({ "class": "modified", "title": formatDate(lastModified), "style": 'color:rgb('+modifiedColor+','+modifiedColor+','+modifiedColor+')' }).text( relative_modified_date(lastModified.getTime() / 1000) ));
html.append(td); html.append(td);
FileList.insertElement(name,'dir',html); FileList.insertElement(name,'dir',html);
$('tr').filterAttr('data-file',name).find('td.filename').draggable(dragOptions); var row = $('tr').filterAttr('data-file',name);
$('tr').filterAttr('data-file',name).find('td.filename').droppable(folderDropOptions); row.find('td.filename').draggable(dragOptions);
row.find('td.filename').droppable(folderDropOptions);
if (hidden) { if (hidden) {
$('tr').filterAttr('data-file', name).hide(); row.hide();
} }
}, },
refresh:function(data) { refresh:function(data) {