From 3f44444f412996fb520bd143e807211835657953 Mon Sep 17 00:00:00 2001 From: yflory Date: Thu, 26 Jan 2017 13:19:28 +0100 Subject: [PATCH] Display the 'New' button in the trash --- www/common/cryptpad-common.js | 2 +- www/drive/main.js | 25 ++++++++++++------------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/www/common/cryptpad-common.js b/www/common/cryptpad-common.js index 4c68dcd03..bc4ffb42a 100644 --- a/www/common/cryptpad-common.js +++ b/www/common/cryptpad-common.js @@ -577,7 +577,7 @@ define([ if (!contains) { var data = makePad(href, name); renamed.push(data); - if (USE_FS_STORE && common.initialPath && typeof(getStore().addPad) === "function") { + if (USE_FS_STORE && typeof(getStore().addPad) === "function") { getStore().addPad(href, common.initialPath, name); } } diff --git a/www/drive/main.js b/www/drive/main.js index 7056c7bcf..addfaaf29 100644 --- a/www/drive/main.js +++ b/www/drive/main.js @@ -866,7 +866,7 @@ define([ options.push({tag: 'hr'}); } AppConfig.availablePadTypes.forEach(function (type) { - var path = '/#?path=' + encodeURIComponent(currentPath); + var path = filesOp.isPathInTrash(currentPath) ? '' : '/#?path=' + encodeURIComponent(currentPath); options.push({ tag: 'a', attributes: { @@ -1253,9 +1253,7 @@ define([ var $modeButton = createViewModeButton().appendTo($toolbar.find('.rightside')); var $title = createTitle(path).appendTo($toolbar.find('.rightside')); - if (!filesOp.isPathInTrash(path)) { - createNewButton(isInRoot).appendTo($toolbar.find('.leftside')); - } + createNewButton(isInRoot).appendTo($toolbar.find('.leftside')); var $folderHeader = getFolderListHeader(); var $fileHeader = getFileListHeader(true); @@ -1312,14 +1310,14 @@ define([ if (collapsable) { $collapse = $expandIcon.clone(); } - var $element = $('
  • ').append($collapse).append($icon).append($name) - .click(function () { - module.displayDirectory(path); - }); + var $element = $('
  • ').append($collapse).append($icon).append($name).click(function (e) { + module.displayDirectory(path); + }); if (draggable) { $element.attr('draggable', true); } if (collapsable) { $element.addClass('collapsed'); - $collapse.click(function() { + $collapse.click(function(e) { + e.stopPropagation(); if ($element.hasClass('collapsed')) { // It is closed, open it $element.removeClass('collapsed'); @@ -1697,10 +1695,11 @@ define([ return false; }).on('remove', [], function (o, p) { var path = arguments[1]; - if ((filesOp.isPathInUnsorted(currentPath) && filesOp.isPathInUnsorted(path)) || - (filesOp.isPathInTemplate(currentPath) && filesOp.isPathInTemplate(path)) || - (path.length >= currentPath.length && filesOp.isSubpath(path, currentPath)) || - (filesOp.isPathInTrash(currentPath) && filesOp.isPathInTrash(path))) { + var cPath = currentPath.slice(); + if ((filesOp.isPathInUnsorted(cPath) && filesOp.isPathInUnsorted(path)) || + (filesOp.isPathInTemplate(cPath) && filesOp.isPathInTemplate(path)) || + (path.length >= cPath.length && filesOp.isSubpath(path, cPath)) || + (filesOp.isPathInTrash(cPath) && filesOp.isPathInTrash(path))) { // Reload after a few to make sure all the change events have been received onRefresh.to = window.setTimeout(refresh, 500); }