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)); cb(void 0, Object.keys(storeObj));
}; };
Store.addPad = function (href, data) { Store.addPad = function (href, path, name) {
filesOp.addPad(href, data); filesOp.addPad(href, path, name);
}; };
Store.forgetPad = function (href, cb) { Store.forgetPad = function (href, cb) {

@ -173,6 +173,11 @@ define([
var getSecrets = common.getSecrets = function (secretHash) { var getSecrets = common.getSecrets = function (secretHash) {
var secret = {}; 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)) { if (!secretHash && !/#/.test(window.location.href)) {
secret.keys = Crypto.createEditCryptor(); secret.keys = Crypto.createEditCryptor();
secret.key = Crypto.createEditCryptor().editKeyStr; secret.key = Crypto.createEditCryptor().editKeyStr;
@ -491,7 +496,7 @@ define([
var data = makePad(href, name); var data = makePad(href, name);
renamed.push(data); renamed.push(data);
if (USE_FS_STORE && typeof(getStore().addPad) === "function") { 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]); pushToTrash(key, href, [UNSORTED]);
}; };
var addUnsortedPad = exp.addPad = function (href) { var addUnsortedPad = exp.addPad = function (href, path, name) {
var unsortedFiles = getUnsortedFiles().slice(); var unsortedFiles = getUnsortedFiles().slice();
var rootFiles = getRootFiles().slice(); var rootFiles = getRootFiles().slice();
var trashFiles = getTrashFiles().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) { if (unsortedFiles.indexOf(href) === -1 && rootFiles.indexOf(href) === -1 && trashFiles.indexOf(href) === -1) {
files[UNSORTED].push(href); files[UNSORTED].push(href);
} }

@ -23,7 +23,7 @@
<div id="contentContextMenu" class="contextMenu dropdown clearfix" oncontextmenu="return false;"> <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;"> <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="#" 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> </ul>
</div> </div>
<div id="trashTreeContextMenu" class="contextMenu dropdown clearfix" oncontextmenu="return false;"> <div id="trashTreeContextMenu" class="contextMenu dropdown clearfix" oncontextmenu="return false;">

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

Loading…
Cancel
Save