diff --git a/customize.dist/translations/messages.fr.js b/customize.dist/translations/messages.fr.js index 8f761c5bb..8f3d1881d 100644 --- a/customize.dist/translations/messages.fr.js +++ b/customize.dist/translations/messages.fr.js @@ -9,7 +9,7 @@ define(function () { out.main_slogan = "L'unité est la force, la collaboration est la clé"; out.type = {}; - out.type.pad = 'Pad'; + out.type.pad = 'Texte'; out.type.code = 'Code'; out.type.poll = 'Sondage'; out.type.slide = 'Présentation'; diff --git a/www/common/cryptpad-common.js b/www/common/cryptpad-common.js index aa180b73a..1b47f6c41 100644 --- a/www/common/cryptpad-common.js +++ b/www/common/cryptpad-common.js @@ -195,9 +195,11 @@ define([ }; // If we have a hash in the URL specifying a path, it means the document was created from // the drive and should be stored at the selected path. - if (/#\?path=/.test(window.location.href)) { - var arr = window.location.hash.match(/\?path=(.+)/); - common.initialPath = arr[1] || undefined; + if (/[?&]path=/.test(window.location.hash)) { + var patharr = window.location.hash.match(/[?&]path=([^&]+)/); + var namearr = window.location.hash.match(/[?&]name=([^&]+)/); + common.initialPath = patharr[1] || undefined; + common.initialName = namearr[1] ? decodeURIComponent(namearr[1]) : undefined; window.location.hash = ''; } if (!secretHash && !/#/.test(window.location.href)) { @@ -578,7 +580,7 @@ define([ var data = makePad(href, name); renamed.push(data); if (USE_FS_STORE && typeof(getStore().addPad) === "function") { - getStore().addPad(href, common.initialPath, name); + getStore().addPad(href, common.initialPath, common.initialName || name); } } diff --git a/www/drive/main.js b/www/drive/main.js index 046035398..12f6b415a 100644 --- a/www/drive/main.js +++ b/www/drive/main.js @@ -871,14 +871,18 @@ define([ } AppConfig.availablePadTypes.forEach(function (type) { var path = filesOp.isPathInTrash(currentPath) ? '' : '/#?path=' + encodeURIComponent(currentPath); + var attributes = { + 'class': 'newdoc', + 'data-type': type + }; + // In root, do not redirect instantly, but ask for a name first. Cf handlers below + if (!isInRoot) { + attributes.href = '/' + type + path; + attributes.target = '_blank'; + } options.push({ tag: 'a', - attributes: { - 'class': 'newdoc', - 'data-type': type, - 'href': '/' + type + path, - 'target': '_blank' - }, + attributes: attributes, content: Messages.type[type] }); }); @@ -892,13 +896,27 @@ define([ $block.find('button').addClass('new').addClass('element'); // Handlers - $block.find('a.newFolder').click(function () { - var onCreated = function (info) { - module.newFolder = info.newPath; - refresh(); - }; - filesOp.createNewFolder(currentPath, null, onCreated); - }); + if (isInRoot) { + $block.find('a.newFolder').click(function () { + var onCreated = function (info) { + module.newFolder = info.newPath; + refresh(); + }; + filesOp.createNewFolder(currentPath, null, onCreated); + }); + $block.find('a.newdoc').click(function () { + var type = $(this).data('type'); + if (!type) { + throw new Error("Unable to get the pad type..."); + } + var onNamed = function (name) { + var path = '/#?name=' + encodeURIComponent(name) + '&path=' + encodeURIComponent(currentPath); + console.log(path); + window.open('/' + type + path); + }; + Cryptpad.prompt("How would you like to name your file?", Cryptpad.getDefaultName({type: type}), onNamed); + }); + } return $block; };