From dd62533467c5abe4ba2c38e9e03e5e8b573384f6 Mon Sep 17 00:00:00 2001 From: ClemDee Date: Mon, 24 Jun 2019 10:07:16 +0200 Subject: [PATCH] Better code for displaying result of search in drive --- www/drive/inner.js | 61 +++++++++++++++++++++------------------------- 1 file changed, 28 insertions(+), 33 deletions(-) diff --git a/www/drive/inner.js b/www/drive/inner.js index 5937b6aed..fb2b0bcd9 100644 --- a/www/drive/inner.js +++ b/www/drive/inner.js @@ -2617,28 +2617,10 @@ define([ var href = r.data.href; var parsed = Hash.parsePadUrl(href); var $table = $(''); - var $icon = $('').append($icon).append($title).append($typeName).append($type).appendTo($table);
', {'rowspan': '3', 'class': 'cp-app-drive-search-icon'}) - .append(r.id ? getFileIcon(r.id) : $folderIcon.clone()); + var $icon = $('', {'rowspan': '3', 'class': 'cp-app-drive-search-icon'}); var $title = $('', { 'class': 'cp-app-drive-search-col1 cp-app-drive-search-title' }).text(r.data.title); - if (r.id) { - $title.click(function () { - openFile(null, r.data.href); - }); - } - var $typeName = $('', {'class': 'cp-app-drive-search-label2'}) - .text(Messages.fm_type); - var $type = $('', {'class': 'cp-app-drive-search-col2'}) - .text(r.id ? Messages.type[parsed.type] || parsed.type : Messages.fm_folder); - var $atimeName = $('', {'class': 'cp-app-drive-search-label2'}) - .text(r.id ? Messages.fm_lastAccess : ""); - var $atime = $('', {'class': 'cp-app-drive-search-col2'}) - .text(r.id ? new Date(r.data.atime).toLocaleString() : ""); - var $ctimeName = $('', {'class': 'cp-app-drive-search-label2'}) - .text(r.id ? Messages.fm_creation : ""); - var $ctime = $('', {'class': 'cp-app-drive-search-col2'}) - .text(r.id ? new Date(r.data.ctime).toLocaleString() : ""); if (manager.isPathIn(path, ['hrefArray'])) { path.pop(); path.push(r.data.title); @@ -2647,28 +2629,33 @@ define([ 'class': 'cp-app-drive-search-col1 cp-app-drive-search-path' }); createTitle($path, path, true); - var parentPath = path.slice(); - var $a; + var $typeName = $('', {'class': 'cp-app-drive-search-label2'}).text(Messages.fm_type); + var $type = $('', {'class': 'cp-app-drive-search-col2'}); + var $atimeName = $('', {'class': 'cp-app-drive-search-label2'}); + var $atime = $('', {'class': 'cp-app-drive-search-col2'}); + var $ctimeName = $('', {'class': 'cp-app-drive-search-label2'}); + var $ctime = $('', {'class': 'cp-app-drive-search-col2'}); + var $openDir = $('', {'class': 'cp-app-drive-search-opendir'}); if (r.id) { + $icon.append(getFileIcon(r.id)); + $type.text(Messages.type[parsed.type] || parsed.type); + $title.click(function () { + openFile(null, r.data.href); + }); + $atimeName.text(Messages.fm_lastAccess); + $atime.text(new Date(r.data.atime).toLocaleString()); + $ctimeName.text(Messages.fm_creation); + $ctime.text(new Date(r.data.ctime).toLocaleString()); + var parentPath = path.slice(); if (parentPath) { - $a = $('').text(Messages.fm_openParent).click(function (e) { + $('').text(Messages.fm_openParent).click(function (e) { e.preventDefault(); if (manager.isInTrashRoot(parentPath)) { parentPath = [TRASH]; } else { parentPath.pop(); } APP.selectedFiles = [r.id]; APP.displayDirectory(parentPath); - }); + }).appendTo($openDir); } - } - else { - $a = $('').text(Messages.fm_OpenFolder || "Open folder").click(function (e) { - e.preventDefault(); - APP.displayDirectory(path); - }); - } - var $openDir = $('', {'class': 'cp-app-drive-search-opendir'}).append($a); - - if (r.id) { $('').text(Messages.fc_prop).click(function () { APP.getProperties(r.id, function (e, $prop) { if (e) { return void logError(e); } @@ -2676,6 +2663,14 @@ define([ }); }).appendTo($openDir); } + else { + $icon.append($folderIcon.clone()); + $type.text(Messages.fm_folder); + $('').text(Messages.fm_OpenFolder || "Open folder").click(function (e) { + e.preventDefault(); + APP.displayDirectory(path); + }).appendTo($openDir); + } // rows 1-3 $('