Create a new pad from the file manager

pull/1/head
yflory 8 years ago
parent 4fcdece4af
commit a957b72598

@ -76,8 +76,8 @@ define([
cb(void 0, Object.keys(storeObj));
};
Store.addPad = function (href, data) {
filesOp.addPad(href, data);
Store.addPad = function (href, path, name) {
filesOp.addPad(href, path, name);
};
Store.forgetPad = function (href, cb) {

@ -173,6 +173,11 @@ define([
var getSecrets = common.getSecrets = function (secretHash) {
var secret = {};
if (/#\?path=/.test(window.location.href)) {
var arr = window.location.hash.match(/\?path=(.+)/);
common.initialPath = arr[1] || undefined;
window.location.hash = '';
}
if (!secretHash && !/#/.test(window.location.href)) {
secret.keys = Crypto.createEditCryptor();
secret.key = Crypto.createEditCryptor().editKeyStr;
@ -491,7 +496,7 @@ define([
var data = makePad(href, name);
renamed.push(data);
if (USE_FS_STORE && typeof(getStore().addPad) === "function") {
getStore().addPad(href);
getStore().addPad(href, common.initialPath, name);
}
}

@ -547,10 +547,19 @@ define([
pushToTrash(key, href, [UNSORTED]);
};
var addUnsortedPad = exp.addPad = function (href) {
var addUnsortedPad = exp.addPad = function (href, path, name) {
var unsortedFiles = getUnsortedFiles().slice();
var rootFiles = getRootFiles().slice();
var trashFiles = getTrashFiles().slice();
if (path && name) {
var newPath = decodeURIComponent(path).split(',');
var parentEl = findElement(files, newPath);
if (parentEl) {
var newName = getAvailableName(parentEl, name);
parentEl[newName] = href;
return;
}
}
if (unsortedFiles.indexOf(href) === -1 && rootFiles.indexOf(href) === -1 && trashFiles.indexOf(href) === -1) {
files[UNSORTED].push(href);
}

@ -23,7 +23,7 @@
<div id="contentContextMenu" class="contextMenu dropdown clearfix" oncontextmenu="return false;">
<ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu" style="display:block;position:static;margin-bottom:5px;">
<li><a tabindex="-1" href="#" class="newfolder" data-localization="fc_newfolder">New folder</a></li>
<li><a tabindex="-1" href="/pad?path=root%2CDir1" class="newfolder" target="_blank">New pad</a></li>
<li><a tabindex="-1" href="/pad#?path=root%2CDir1" class="newpad" target="_blank">New pad</a></li>
</ul>
</div>
<div id="trashTreeContextMenu" class="contextMenu dropdown clearfix" oncontextmenu="return false;">

@ -31,7 +31,6 @@ define([
var FILES_DATA_NAME = Messages.fm_filesDataName;
var TRASH = "trash";
var TRASH_NAME = Messages.fm_trashName;
var TIME_BEFORE_RENAME = 1000;
var LOCALSTORAGE_LAST = "cryptpad-file-lastOpened";
var LOCALSTORAGE_OPENED = "cryptpad-file-openedFolders";
var LOCALSTORAGE_VIEWMODE = "cryptpad-file-viewMode";
@ -520,7 +519,8 @@ define([
var name = path[0] === UNSORTED ? filesOp.getTitle(filesOp.findElement(files, path)) : path[path.length - 1];
msg = Messages._getKey('fm_removeDialog', [name]);
}
Cryptpad.confirm(msg, function () {
Cryptpad.confirm(msg, function (res) {
if (!res) { return; }
andThen();
});
};
@ -943,7 +943,6 @@ define([
var $dirContent = $('<div>', {id: FOLDER_CONTENT_ID});
$dirContent.data('path', path);
$dirContent.contextmenu(openContentContextMenu);
var mode = getViewMode();
if (mode) {
$dirContent.addClass(getViewModeClass());
@ -968,6 +967,7 @@ define([
} else if (isTrashRoot) {
displayTrashRoot($list, $folderHeader, $fileHeader);
} else {
$dirContent.contextmenu(openContentContextMenu);
var $newFolderButton = createNewFolderButton().appendTo($title);
if (filesOp.hasSubfolder(root)) { $list.append($folderHeader); }
// display sub directories
@ -1276,6 +1276,7 @@ define([
msg = Messages._getKey("fm_removePermanentlyDialog", [name]);
}
Cryptpad.confirm(msg, function(res) {
if (!res) { return; }
paths.forEach(function(p) {
todo(p);
});

Loading…
Cancel
Save