diff --git a/customize.dist/translations/messages.fr.js b/customize.dist/translations/messages.fr.js
index b96d497d3..6cfd73d73 100644
--- a/customize.dist/translations/messages.fr.js
+++ b/customize.dist/translations/messages.fr.js
@@ -65,6 +65,7 @@ define(function () {
out.forgetButton = 'OUBLIER';
out.forgetButtonTitle = 'Enlever ce document de la liste en page d\'accueil';
out.forgetPrompt = 'Cliquer sur OK supprimera l\'URL de ce document de la mémoire de votre navigateur (localStorage), êtes-vous sûr ?';
+ out.movedToTrash = 'Ce document a été déplacé vers la corbeille.
Accéder à mon Drive';
out.shareButton = 'Partager';
out.shareSuccess = 'URL copiée dans le presse-papiers';
diff --git a/customize.dist/translations/messages.js b/customize.dist/translations/messages.js
index abfec9239..1c1f1fb62 100644
--- a/customize.dist/translations/messages.js
+++ b/customize.dist/translations/messages.js
@@ -67,6 +67,7 @@ define(function () {
out.forgetButton = 'FORGET';
out.forgetButtonTitle = 'Remove this document from your home page listings';
out.forgetPrompt = 'Clicking OK will remove the URL for this pad from localStorage, are you sure?';
+ out.movedToTrash = 'That pad has been moved to the trash.
Access my Drive';
out.shareButton = 'Share';
out.shareSuccess = 'Copied URL to clipboard';
diff --git a/www/code/main.js b/www/code/main.js
index c74656a66..dff4be7dc 100644
--- a/www/code/main.js
+++ b/www/code/main.js
@@ -415,7 +415,7 @@ define([
/* add a forget button */
var forgetCb = function (err, title) {
if (err) { return; }
- document.title = title;
+ setEditable(false);
};
var $forgetPad = Cryptpad.createButton('forget', true, {}, forgetCb);
$rightside.append($forgetPad);
diff --git a/www/common/cryptpad-common.js b/www/common/cryptpad-common.js
index ae00ba324..93d610c1c 100644
--- a/www/common/cryptpad-common.js
+++ b/www/common/cryptpad-common.js
@@ -43,6 +43,14 @@ define([
}
return;
};
+ var getRealtime = common.getRealtime = function () {
+ if (store) {
+ if (store.getProxy() && store.getProxy().info) {
+ return store.getProxy().info.realtime;
+ }
+ }
+ return;
+ };
var whenRealtimeSyncs = common.whenRealtimeSyncs = function (realtime, cb) {
realtime.sync();
@@ -897,8 +905,18 @@ define([
callback(err, null);
return;
}
- var parsed = common.parsePadUrl(href);
- callback(null, common.getDefaultName(parsed, []));
+ var n = getNetwork();
+ var r = getRealtime();
+ if (n && r) {
+ whenRealtimeSyncs(r, function () {
+ n.disconnect();
+ callback();
+ });
+ } else {
+ callback();
+ }
+ common.alert(Messages.movedToTrash);
+ return;
});
});
diff --git a/www/common/fileObject.js b/www/common/fileObject.js
index 272517ec8..82fc9b2eb 100644
--- a/www/common/fileObject.js
+++ b/www/common/fileObject.js
@@ -242,18 +242,31 @@ define([
return ret;
};
- var removeFileFromRoot = function (root, href) {
+ // Remove the selected 'href' from the tree located at 'path', and push its locations to the 'paths' array
+ var removeFileFromRoot = function (path, href) {
+ var paths = [];
+ var root = findElement(files, path);
if (isFile(root)) { return; }
for (var e in root) {
if (isFile(root[e])) {
if (compareFiles(href, root[e])) {
root[e] = undefined;
delete root[e];
+ if (paths.indexOf(path) === -1) {
+ paths.push(path);
+ }
}
} else {
- removeFileFromRoot(root[e], href);
+ var nPath = path.slice();
+ nPath.push(e);
+ removeFileFromRoot(nPath, href).forEach(function (p) {
+ if (paths.indexOf(p) === -1) {
+ paths.push(p);
+ }
+ });
}
}
+ return paths;
};
var isInTrashRoot = exp.isInTrashRoot = function (path) {
@@ -735,17 +748,26 @@ define([
var forgetPad = exp.forgetPad = function (href) {
if (workgroup) { return; }
- if (!href) { return; }
+ if (!href || !isFile(href)) { return; }
+ var path;
var rootFiles = getRootFiles().slice();
if (rootFiles.indexOf(href) !== -1) {
- removeFileFromRoot(files[ROOT], href);
+ var paths = removeFileFromRoot([ROOT], href);
+ path = paths[0];
}
var unsortedIdx = getUnsortedFiles().indexOf(href);
if (unsortedIdx !== -1) {
files[UNSORTED].splice(unsortedIdx, 1);
+ path = [UNSORTED];
+ }
+ var templateIdx = getTemplateFiles().indexOf(href);
+ if (templateIdx !== -1) {
+ files[TEMPLATE].splice(templateIdx, 1);
+ path = [TEMPLATE];
}
+ if (!path) { return; }
var key = getTitle(href);
- pushToTrash(key, href, [UNSORTED]);
+ pushToTrash(key, href, path);
};
var addUnsortedPad = exp.addPad = function (href, path, name) {
diff --git a/www/pad/main.js b/www/pad/main.js
index f105e7582..48b2ef2d2 100644
--- a/www/pad/main.js
+++ b/www/pad/main.js
@@ -628,7 +628,7 @@ define([
/* add a forget button */
var forgetCb = function (err, title) {
if (err) { return; }
- document.title = title;
+ setEditable(false);
};
var $forgetPad = Cryptpad.createButton('forget', true, {}, forgetCb);
$rightside.append($forgetPad);
diff --git a/www/poll/main.js b/www/poll/main.js
index fe540e159..69954b409 100644
--- a/www/poll/main.js
+++ b/www/poll/main.js
@@ -660,6 +660,11 @@ define([
});
};
+ var disconnect = function (info) {
+ //setEditable(false); // TODO
+ Cryptpad.alert(Messages.common_connectionLost);
+ };
+
var create = function (info) {
var realtime = APP.realtime = info.realtime;
var myID = APP.myID = info.myID;
@@ -702,7 +707,7 @@ define([
/* add a forget button */
var forgetCb = function (err, title) {
if (err) { return; }
- document.title = title;
+ disconnect();
};
var $forgetPad = Cryptpad.createButton('forget', true, {}, forgetCb);
$rightside.append($forgetPad);
@@ -733,11 +738,6 @@ define([
});
};
- var disconnect = function (info) {
- //setEditable(false); // TODO
- Cryptpad.alert(Messages.common_connectionLost);
- };
-
// don't initialize until the store is ready.
Cryptpad.ready(function () {
var config = {
diff --git a/www/slide/main.js b/www/slide/main.js
index e6931603d..cefcf0f26 100644
--- a/www/slide/main.js
+++ b/www/slide/main.js
@@ -458,8 +458,7 @@ define([
/* add a forget button */
var forgetCb = function (err, title) {
if (err) { return; }
- APP.title = title;
- setTabTitle();
+ setEditable(false);
};
var $forgetPad = Cryptpad.createButton('forget', true, {}, forgetCb);
$rightside.append($forgetPad);