diff options
author | Robin Appelman <icewind1991@gmail.com> | 2011-07-26 16:55:28 +0200 |
---|---|---|
committer | Robin Appelman <icewind1991@gmail.com> | 2011-07-26 16:55:28 +0200 |
commit | 7b02adf71568d5001cf3566ab9ca7b294e8ef848 (patch) | |
tree | d17d74333e493c63dcb3f3a3b92008afa6bd5d5f /files | |
parent | 0e05a8648404d48fb974bb069e1b465219165a44 (diff) | |
download | nextcloud-server-7b02adf71568d5001cf3566ab9ca7b294e8ef848.tar.gz nextcloud-server-7b02adf71568d5001cf3566ab9ca7b294e8ef848.zip |
fix sorting on newly inserted items in the file list
Diffstat (limited to 'files')
-rw-r--r-- | files/js/filelist.js | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/files/js/filelist.js b/files/js/filelist.js index 2c662087ab2..08cf0245472 100644 --- a/files/js/filelist.js +++ b/files/js/filelist.js @@ -48,18 +48,25 @@ FileList={ var fileElements=$('tr[data-file][data-type="'+type+'"]'); var pos; if(name.localeCompare($(fileElements[0]).attr('data-file'))<0){ - pos=0; + pos=-1; }else if(name.localeCompare($(fileElements[fileElements.length-1]).attr('data-file'))>0){ pos=fileElements.length-1; }else{ - for(var pos=1;pos<fileElements.length-1;pos++){ + for(var pos=0;pos<fileElements.length-1;pos++){ if(name.localeCompare($(fileElements[pos]).attr('data-file'))>0 && name.localeCompare($(fileElements[pos+1]).attr('data-file'))<0){ break; } } } + alert(pos); if(fileElements.length){ - $(fileElements[pos]).after(element); + if(pos==-1){ + $(fileElements[0]).before(element); + }else{ + $(fileElements[pos]).after(element); + } + }else if(type=='dir' && $('tr[data-file]').length>0){ + $('tr[data-file]').first().before(element); }else{ $('#fileList').append(element); } |