From ba0b314f5e8b17defa898108d5aab71f8dcfcad9 Mon Sep 17 00:00:00 2001 From: yflory Date: Thu, 23 Feb 2017 18:15:44 +0100 Subject: [PATCH] Fix the 'new' button in drive which was broken in non root categories --- www/common/cryptpad-common.js | 1 - www/drive/main.js | 15 ++++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/www/common/cryptpad-common.js b/www/common/cryptpad-common.js index b98c947f4..c03664036 100644 --- a/www/common/cryptpad-common.js +++ b/www/common/cryptpad-common.js @@ -706,7 +706,6 @@ define([ common.initialName = sessionStorage[newPadNameKey]; delete sessionStorage[newPadNameKey]; } - // Deprecated if (sessionStorage[newPadPathKey]) { common.initialPath = sessionStorage[newPadPathKey]; delete sessionStorage[newPadPathKey]; diff --git a/www/drive/main.js b/www/drive/main.js index 4c5e667bc..605eb82c8 100644 --- a/www/drive/main.js +++ b/www/drive/main.js @@ -958,16 +958,11 @@ define([ } AppConfig.availablePadTypes.forEach(function (type) { if (type === 'drive') { return; } - var path = filesOp.isPathInTrash(currentPath) ? '' : '/#?path=' + encodeURIComponent(currentPath); var attributes = { 'class': 'newdoc', - 'data-type': type + 'data-type': type, + 'href': '#' }; - // In root, do not redirect instantly, but ask for a name first. Cf handlers below - if (!isInRoot) { - attributes.href = '/' + type + path; - attributes.target = '_blank'; - } options.push({ tag: 'a', attributes: attributes, @@ -997,6 +992,12 @@ define([ var name = Cryptpad.getDefaultName({type: type}); filesOp.createNewFile(currentPath, name, type, onCreated); }); + } else { + $block.find('a.newdoc').click(function (e) { + var type = $(this).attr('data-type') || 'pad'; + sessionStorage[Cryptpad.newPadPathKey] = filesOp.isPathInTrash(currentPath) ? '' : currentPath; + window.open('/' + type + '/'); + }); } return $block;