Fix the trash button in toolbar not always working

pull/1/head
yflory 8 years ago
parent aae3fba284
commit 92050eb04f

@ -400,6 +400,7 @@ define([
}; };
var getRelativeHref = common.getRelativeHref = function (href) { var getRelativeHref = common.getRelativeHref = function (href) {
if (!href) { return; }
var parsed = common.parsePadUrl(href); var parsed = common.parsePadUrl(href);
return '/' + parsed.type + '/#' + parsed.hash; return '/' + parsed.type + '/#' + parsed.hash;
}; };
@ -563,7 +564,7 @@ define([
}; };
if (typeof(getStore().forgetPad) === "function") { if (typeof(getStore().forgetPad) === "function") {
getStore().forgetPad(href, callback); getStore().forgetPad(common.getRelativeHref(href), callback);
} }
}; };

@ -698,6 +698,7 @@ define([
var forgetPad = exp.forgetPad = function (href) { var forgetPad = exp.forgetPad = function (href) {
if (workgroup) { return; } if (workgroup) { return; }
if (!href) { return; }
var rootFiles = getRootFiles().slice(); var rootFiles = getRootFiles().slice();
if (rootFiles.indexOf(href) !== -1) { if (rootFiles.indexOf(href) !== -1) {
removeFileFromRoot(files[ROOT], href); removeFileFromRoot(files[ROOT], href);
@ -712,6 +713,7 @@ define([
var addUnsortedPad = exp.addPad = function (href, path, name) { var addUnsortedPad = exp.addPad = function (href, path, name) {
if (workgroup) { return; } if (workgroup) { return; }
if (!href) { return; }
var unsortedFiles = getUnsortedFiles(); var unsortedFiles = getUnsortedFiles();
var rootFiles = getRootFiles(); var rootFiles = getRootFiles();
var trashFiles = getTrashFiles(); var trashFiles = getTrashFiles();

@ -1810,6 +1810,8 @@ define([
return false; return false;
}).on('remove', [], function (o, p) { }).on('remove', [], function (o, p) {
var path = arguments[1]; var path = arguments[1];
if (path[0] !== 'drive') { return false; }
path = path.slice(1);
var cPath = currentPath.slice(); var cPath = currentPath.slice();
if ((filesOp.isPathInUnsorted(cPath) && filesOp.isPathInUnsorted(path)) || if ((filesOp.isPathInUnsorted(cPath) && filesOp.isPathInUnsorted(path)) ||
(filesOp.isPathInTemplate(cPath) && filesOp.isPathInTemplate(path)) || (filesOp.isPathInTemplate(cPath) && filesOp.isPathInTemplate(path)) ||

Loading…
Cancel
Save