From: kondou Date: Sat, 6 Apr 2013 12:42:56 +0000 (+0200) Subject: Make directories show at top. X-Git-Tag: v6.0.0alpha2~932^2~5 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=fba6681f7197650934b1bf76c8ea71f832ccd226;p=nextcloud-server.git Make directories show at top. --- diff --git a/core/js/oc-dialogs.js b/core/js/oc-dialogs.js index 2a6f1ff1638..cd5412fdeda 100644 --- a/core/js/oc-dialogs.js +++ b/core/js/oc-dialogs.js @@ -296,10 +296,20 @@ var OCdialogs = { fillFilePicker:function(request, dialog_content_id) { var template = '
*NAME*
*LASTMODDATE*
'; var files = ''; + var dirs = []; + var others = []; $.each(request.data, function(index, file) { - files += template.replace('*LASTMODDATE*', OC.mtime2date(file.mtime)).replace('*NAME*', escapeHTML(file.name)).replace('*MIMETYPEICON*', file.mimetype_icon).replace('*ENTRYNAME*', escapeHTML(file.name)).replace('*ENTRYTYPE*', escapeHTML(file.type)); + if (file.type === 'dir') { + dirs.push(file); + } else { + others.push(file); + } }); - + var sorted = dirs.concat(others); + for (var i = 0; i < sorted.length; i++) { + files += template.replace('*LASTMODDATE*', OC.mtime2date(sorted[i].mtime)).replace('*NAME*', escapeHTML(sorted[i].name)).replace('*MIMETYPEICON*', sorted[i].mimetype_icon).replace('*ENTRYNAME*', escapeHTML(sorted[i].name)).replace('*ENTRYTYPE*', escapeHTML(sorted[i].type)); + } + $(dialog_content_id + ' #filelist').html(files).on('click', '[data="file"]', function() { OCdialogs.handlePickerClick(this, $(this).data('entryname'), $(this).data('dcid')); });