Merge branch 'pad2' of github.com:xwiki-labs/cryptpad into pad2

pull/1/head
Caleb James DeLisle 7 years ago
commit ec87f3f897

@ -102,6 +102,10 @@ define([], function () {
metadataLazyObj = JSON.parse(JSON.stringify(m)); metadataLazyObj = JSON.parse(JSON.stringify(m));
change(false); change(false);
}, },
updateTitle: function (t) {
metadataObj.title = t;
change(true);
},
getMetadata: function () { getMetadata: function () {
checkUpdate(false); checkUpdate(false);
return Object.freeze(JSON.parse(JSON.stringify(metadataObj))); return Object.freeze(JSON.parse(JSON.stringify(metadataObj)));

@ -12,8 +12,8 @@ define(['jquery'], function ($) {
var getHeadingText = cfg.getHeadingText || function () { return; }; var getHeadingText = cfg.getHeadingText || function () { return; };
var updateLocalTitle = function (newTitle) { /* var updateLocalTitle = function (newTitle) {
console.log(newTitle); console.error(newTitle);
exp.title = newTitle; exp.title = newTitle;
onLocal(); onLocal();
if (typeof cfg.updateLocalTitle === "function") { if (typeof cfg.updateLocalTitle === "function") {
@ -21,7 +21,7 @@ define(['jquery'], function ($) {
} else { } else {
document.title = newTitle; document.title = newTitle;
} }
}; };*/
var $title; var $title;
exp.setToolbar = function (toolbar) { exp.setToolbar = function (toolbar) {
@ -39,11 +39,11 @@ define(['jquery'], function ($) {
} }
}; };
var renameCb = function (err, newTitle) { /*var renameCb = function (err, newTitle) {
if (err) { return; } if (err) { return; }
updateLocalTitle(newTitle);
onLocal(); onLocal();
}; //updateLocalTitle(newTitle);
};*/
// update title: href is optional; if not specified, we use window.location.href // update title: href is optional; if not specified, we use window.location.href
exp.updateTitle = function (newTitle, cb) { exp.updateTitle = function (newTitle, cb) {
@ -58,11 +58,10 @@ define(['jquery'], function ($) {
updateLocalTitle(oldTitle); updateLocalTitle(oldTitle);
return void cb(err); return void cb(err);
} }
updateLocalTitle(data); metadataMgr.updateTitle(newTitle);
//onLocal();
cb(null, data); cb(null, data);
if (!$title) { return; } if (!$title) { return; }
$title.find('span.title').text(data);
$title.find('input').val(data);
}); });
}; };
@ -75,12 +74,14 @@ define(['jquery'], function ($) {
metadataMgr.onChange(function () { metadataMgr.onChange(function () {
var md = metadataMgr.getMetadata(); var md = metadataMgr.getMetadata();
exp.updateTitle(md.title || md.defaultTitle); $title.find('span.title').text(md.title || md.defaultTitle);
$title.find('input').val(md.title || md.defaultTitle);
//exp.updateTitle(md.title || md.defaultTitle);
}); });
exp.getTitleConfig = function () { exp.getTitleConfig = function () {
return { return {
onRename: renameCb, updateTitle: exp.updateTitle,
suggestName: suggestTitle, suggestName: suggestTitle,
defaultName: exp.defaultTitle defaultName: exp.defaultTitle
}; };

@ -515,7 +515,7 @@ define([
console.error("config.title", config); console.error("config.title", config);
throw new Error("config.title is not an object"); throw new Error("config.title is not an object");
} }
var callback = config.title.onRename; var updateTitle = config.title.updateTitle;
var placeholder = config.title.defaultName; var placeholder = config.title.defaultName;
var suggestName = config.title.suggestName; var suggestName = config.title.suggestName;
@ -568,12 +568,9 @@ define([
if (name === "") { if (name === "") {
name = $input.attr('placeholder'); name = $input.attr('placeholder');
} }
console.log('here'); updateTitle(name, function (err, newtitle) {
Common.setPadTitleInDrive(name, function (err, newtitle) {
console.log('here');
if (err) { return console.error(err); } if (err) { return console.error(err); }
$text.text(newtitle); //$text.text(newtitle);
callback(null, newtitle);
$input.hide(); $input.hide();
$text.show(); $text.show();
$pencilIcon.show(); $pencilIcon.show();

@ -485,6 +485,8 @@ define([
toolbar = info.realtime.toolbar = Toolbar.create(configTb); toolbar = info.realtime.toolbar = Toolbar.create(configTb);
Title.setToolbar(toolbar); Title.setToolbar(toolbar);
var $rightside = toolbar.$rightside;
$bar.find('#cke_1_toolbar_collapser').hide(); $bar.find('#cke_1_toolbar_collapser').hide();
if (!readOnly) { if (!readOnly) {
// Expand / collapse the toolbar // Expand / collapse the toolbar
@ -559,7 +561,7 @@ define([
//Title.setToolbar(toolbar); //Title.setToolbar(toolbar);
var $rightside = toolbar.$rightside; //var $rightside = toolbar.$rightside;
var $drawer = toolbar.$drawer; var $drawer = toolbar.$drawer;
var editHash; var editHash;

Loading…
Cancel
Save