Fix the forget pad button
This commit is contained in:
parent
54b0a86c2e
commit
e15a6a347f
@ -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.<br><a href="/drive/">Accéder à mon Drive</a>';
|
||||
|
||||
out.shareButton = 'Partager';
|
||||
out.shareSuccess = 'URL copiée dans le presse-papiers';
|
||||
|
||||
@ -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.<br><a href="/drive/">Access my Drive</a>';
|
||||
|
||||
out.shareButton = 'Share';
|
||||
out.shareSuccess = 'Copied URL to clipboard';
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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;
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@ -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) {
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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 = {
|
||||
|
||||
@ -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);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user