diff options
author | Robin Appelman <robin@icewind.nl> | 2016-10-17 14:26:25 +0200 |
---|---|---|
committer | Robin Appelman <robin@icewind.nl> | 2016-10-19 14:18:21 +0200 |
commit | 14f78369d7bc6dcc5e0234aac27e596ed7e92953 (patch) | |
tree | 3a653905b1c9b45d7f568199b0f56ce980fbee00 /core | |
parent | 590016a978930b22b603e0b9f8408ee0d83a516d (diff) | |
download | nextcloud-server-14f78369d7bc6dcc5e0234aac27e596ed7e92953.tar.gz nextcloud-server-14f78369d7bc6dcc5e0234aac27e596ed7e92953.zip |
Use a table for the filepicker list and add size column
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'core')
-rw-r--r-- | core/css/mobile.css | 1 | ||||
-rw-r--r-- | core/css/styles.css | 41 | ||||
-rw-r--r-- | core/js/oc-dialogs.js | 33 | ||||
-rw-r--r-- | core/templates/filepicker.html | 23 |
4 files changed, 57 insertions, 41 deletions
diff --git a/core/css/mobile.css b/core/css/mobile.css index 0ef6a08c24f..b0f8421345c 100644 --- a/core/css/mobile.css +++ b/core/css/mobile.css @@ -141,6 +141,7 @@ table.multiselect thead { /* do not show dates in filepicker */ +#oc-dialog-filepicker-content .filelist .filesize, #oc-dialog-filepicker-content .filelist .date { display: none; } diff --git a/core/css/styles.css b/core/css/styles.css index 8fa7691ca7a..1141f0d7623 100644 --- a/core/css/styles.css +++ b/core/css/styles.css @@ -774,39 +774,40 @@ a.bookmarklet { background-color:#ddd; border:1px solid #ccc; padding:5px;paddin #oc-dialog-filepicker-content .dirtree span:not(:last-child) { cursor: pointer; } #oc-dialog-filepicker-content .dirtree span:last-child { font-weight: bold; } #oc-dialog-filepicker-content .dirtree span:not(:last-child)::after { content: '>'; padding: 3px;} -#oc-dialog-filepicker-content .filelist { - overflow-y:auto; +#oc-dialog-filepicker-content .filelist-container { + display: inline-block; + overflow-y: auto; height: 290px; + width: 100%; + border-top: 1px solid #eee; +} +#oc-dialog-filepicker-content .filelist { background-color:white; width:100%; } -#oc-dialog-filepicker-content .filelist li:first-child { - border-top: 1px solid #eee; -} -#oc-dialog-filepicker-content .filelist li { - position: relative; - height: 40px; - padding: 5px; +#oc-dialog-filepicker-content .filelist td { + padding: 14px; border-bottom: 1px solid #eee; } #oc-dialog-filepicker-content .filelist .filename { - position: absolute; - padding-top: 9px; - max-width: 60%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; + background-size: 32px; + background-repeat: no-repeat; + padding-left: 51px; + background-position: 7px 7px; + cursor: pointer; } -#oc-dialog-filepicker-content .filelist img { - margin: 2px 1em 0 4px; - width: 32px; -} + +#oc-dialog-filepicker-content .filelist .filesize, #oc-dialog-filepicker-content .filelist .date { - float: right; - margin-right: 10px; - margin-top: 0; - padding-top: 9px; + width: 80px; +} + +#oc-dialog-filepicker-content .filelist .filesize { + text-align: right; } #oc-dialog-filepicker-content .filepicker_element_selected { background-color:lightblue;} .ui-dialog {position:fixed !important;} diff --git a/core/js/oc-dialogs.js b/core/js/oc-dialogs.js index 2a5e39ad20d..8df62a1842e 100644 --- a/core/js/oc-dialogs.js +++ b/core/js/oc-dialogs.js @@ -173,10 +173,10 @@ var OCdialogs = { $('body').append(self.$filePicker); self.$filePicker.ready(function() { - self.$filelist = self.$filePicker.find('.filelist'); + self.$filelist = self.$filePicker.find('.filelist tbody'); self.$dirTree = self.$filePicker.find('.dirtree'); self.$dirTree.on('click', 'div:not(:last-child)', self, self._handleTreeListSelect.bind(self)); - self.$filelist.on('click', 'li', function(event) { + self.$filelist.on('click', 'tr', function(event) { self._handlePickerClick(event, $(this)); }); self._fillFilePicker(''); @@ -188,12 +188,12 @@ var OCdialogs = { var datapath; if (multiselect === true) { datapath = []; - self.$filelist.find('.filepicker_element_selected .filename').each(function(index, element) { - datapath.push(self.$filePicker.data('path') + '/' + $(element).text()); + self.$filelist.find('tr.filepicker_element_selected').each(function(index, element) { + datapath.push(self.$filePicker.data('path') + '/' + $(element).data('entryname')); }); } else { datapath = self.$filePicker.data('path'); - datapath += '/' + self.$filelist.find('.filepicker_element_selected .filename').text(); + datapath += '/' + self.$filelist.find('tr.filepicker_element_selected').data('entryname'); } callback(datapath); self.$filePicker.ocdialog('close'); @@ -685,7 +685,7 @@ var OCdialogs = { var self = this; $.get(OC.filePath('core', 'templates', 'filepicker.html'), function(tmpl) { self.$filePickerTemplate = $(tmpl); - self.$listTmpl = self.$filePickerTemplate.find('.filelist li:first-child').detach(); + self.$listTmpl = self.$filePickerTemplate.find('.filelist tr:first-child').detach(); defer.resolve(self.$filePickerTemplate); }) .fail(function(jqXHR, textStatus, errorThrown) { @@ -770,30 +770,35 @@ var OCdialogs = { $.each(files, function(idx, entry) { entry.icon = OC.MimeType.getIconUrl(entry.mimetype); - var $li = self.$listTmpl.octemplate({ + if (typeof(entry.size) !== 'undefined' && entry.size >= 0) { + var simpleSize = humanFileSize(parseInt(entry.size, 10), true); + var sizeColor = Math.round(160 - Math.pow((entry.size / (1024 * 1024)), 2)); + } else { + simpleSize = t('files', 'Pending'); + } + var $row = self.$listTmpl.octemplate({ type: entry.type, dir: dir, filename: entry.name, - date: OC.Util.relativeModifiedDate(entry.mtime) + date: OC.Util.relativeModifiedDate(entry.mtime), + size: simpleSize, + sizeColor: sizeColor, + icon: entry.icon }); if (entry.type === 'file') { var urlSpec = { file: dir + '/' + entry.name, }; - $li.find('img').attr('src', OC.MimeType.getIconUrl(entry.mimetype)); var img = new Image(); var previewUrl = OC.generateUrl('/core/preview.png?') + $.param(urlSpec); img.onload = function() { if (img.width > 5) { - $li.find('img').attr('src', previewUrl); + $row.find('td.filename').attr('style', 'background-image:url(' + previewUrl + ')'); } }; img.src = previewUrl; } - else { - $li.find('img').attr('src', OC.MimeType.getIconUrl(entry.mimetype)); - } - self.$filelist.append($li); + self.$filelist.append($row); }); self.$filelist.removeClass('icon-loading'); diff --git a/core/templates/filepicker.html b/core/templates/filepicker.html index 46d1ca3d52d..b665ca26893 100644 --- a/core/templates/filepicker.html +++ b/core/templates/filepicker.html @@ -1,10 +1,19 @@ <div id="{dialog_name}" title="{title}"> <span class="dirtree breadcrumb"></span> - <ul class="filelist"> - <li data-entryname="{filename}" data-type="{type}"> - <img /> - <span class="filename">{filename}</span> - <span class="date">{date}</span> - </li> - </ul> + <div class="filelist-container"> + <table id="filestable" class="filelist"> + <tbody> + <tr data-entryname="{filename}" data-type="{type}"> + <td class="filename" + style="background-image:url({icon})">{filename} + </td> + <td class="filesize" + style="color:rgb({sizeColor}, {sizeColor}, {sizeColor})"> + {size} + </td> + <td class="date">{date}</td> + </tr> + </tbody> + </table> + </div> </div> |