Ability to edit the title in the toolbar by clicking it

This commit is contained in:
yflory
2016-10-24 18:32:43 +02:00
parent 10bb5e1607
commit 9e92a597b3
3 changed files with 60 additions and 22 deletions

View File

@@ -302,13 +302,17 @@ define([
var type = parsed.type;
var untitledIndex = 1;
var name = (Messages.type)[type] + ' - ' + new Date().toString().split(' ').slice(0,4).join(' ');
if (isNameAvailable(name, parsed, recentPads)) { return name; }
while (!isNameAvailable(name + ' - ' + untitledIndex, parsed, recentPads)) { untitledIndex++; }
return name + ' - ' + untitledIndex;
return name;
/*
* Pad titles are shared in the document so it does not make sense anymore to avoid duplicates
if (isNameAvailable(name, parsed, recentPads)) { return name; }
while (!isNameAvailable(name + ' - ' + untitledIndex, parsed, recentPads)) { untitledIndex++; }
return name + ' - ' + untitledIndex;
*/
};
var isDefaultName = common.isDefaultName = function (parsed, title) {
var name = getDefaultName(parsed, []);
return title.slice(0, name.length) === name;
return title === name;
};
var makePad = function (href, title) {
@@ -622,7 +626,21 @@ define([
var renamePad = common.renamePad = function (title, callback) {
if (title === null) { return; }
common.causesNamingConflict(title, function (err, conflicts) {
if (title.trim() === "") {
var parsed = parsePadUrl(window.location.href);
title = getDefaultName(parsed);
}
common.setPadTitle(title, function (err, data) {
if (err) {
console.log("unable to set pad title");
console.log(err);
return;
}
callback(null, title);
});
/* Pad titles are shared in the document. We don't check for duplicates anymore.
common.causesNamingConflict(title, function (err, conflicts) {
if (err) {
console.log("Unable to determine if name caused a conflict");
console.error(err);
@@ -644,6 +662,7 @@ define([
callback(null, title);
});
});
*/
};
var createButton = common.createButton = function (type, rightside, data, callback) {
var button;