add rename button to /code/ and /pad/

pull/1/head
ansuz 9 years ago
parent 93dcf29c15
commit a3da10766a

@ -212,6 +212,24 @@ define([
onLocal(); onLocal();
})); }));
var $setTitle = $('<button>', {
id: 'name-pad'
})
.addClass('cryptpad-rename')
.click(function () {
var title = window.prompt("How would you like this pad to be titled?",
Cryptpad.getPadTitle());
if (title === null) {
return;
}
Cryptpad.setPadTitle(title);
document.title = title;
});
$bar.find('.rtwysiwyg-toolbar-rightside')
.append($setTitle);
/* Let the user select different syntax highlighting modes */ /* Let the user select different syntax highlighting modes */
var syntaxDropdown = '<select title="syntax highlighting" id="language-mode">\n' + var syntaxDropdown = '<select title="syntax highlighting" id="language-mode">\n' +
Modes.map(function (o) { Modes.map(function (o) {
@ -256,7 +274,8 @@ define([
}); });
window.location.hash = info.channel + secret.key; window.location.hash = info.channel + secret.key;
Cryptpad.rememberPad(); var title = document.title = Cryptpad.getPadTitle();
Cryptpad.rememberPad(title);
}; };
var updateUserList = function(shjson) { var updateUserList = function(shjson) {

@ -16,6 +16,7 @@ define([
var SAVE_ELEMENT_CLS = 'cryptpad-saveContent'; var SAVE_ELEMENT_CLS = 'cryptpad-saveContent';
var LOAD_ELEMENT_CLS = 'cryptpad-loadContent'; var LOAD_ELEMENT_CLS = 'cryptpad-loadContent';
var SET_TITLE_CLS = 'cryptpad-rename';
/** The toolbar class which contains the user list, debug link and lag. */ /** The toolbar class which contains the user list, debug link and lag. */
var TOOLBAR_CLS = 'rtwysiwyg-toolbar'; var TOOLBAR_CLS = 'rtwysiwyg-toolbar';
@ -109,7 +110,7 @@ define([
} }
.{{TOOLBAR_CLS}} button { .{{TOOLBAR_CLS}} button {
box-sizing: border-box; box-sizing: border-box;
height: 101%; height: 100%;
background-color: inherit; background-color: inherit;
border: 1px solid #A6A6A6; border: 1px solid #A6A6A6;
border-radius: 5px; border-radius: 5px;
@ -117,7 +118,7 @@ define([
padding-right: 5px; padding-right: 5px;
padding-left: 5px; padding-left: 5px;
} }
.{{TOOLBAR_CLS}} .{{SAVE_ELEMENT_CLS}}, .{{TOOLBAR_CLS}} .{{LOAD_ELEMENT_CLS}} { .{{TOOLBAR_CLS}} .{{SAVE_ELEMENT_CLS}}, .{{TOOLBAR_CLS}} .{{LOAD_ELEMENT_CLS}}, .{{TOOLBAR_CLS}} .{{SET_TITLE_CLS}} {
float: right; float: right;
margin-right: 5px; margin-right: 5px;
cursor: pointer; cursor: pointer;
@ -130,6 +131,9 @@ define([
content: 'IMPORT'; content: 'IMPORT';
} }
.{{TOOLBAR_CLS}} .{{SET_TITLE_CLS}}:after {
content: 'RENAME';
}
.{{TOOLBAR_CLS}} select { .{{TOOLBAR_CLS}} select {
border: 0px; border: 0px;
margin-left: 5px; margin-left: 5px;
@ -141,6 +145,7 @@ define([
TOOLBAR_CLS: TOOLBAR_CLS, TOOLBAR_CLS: TOOLBAR_CLS,
SAVE_ELEMENT_CLS: SAVE_ELEMENT_CLS, SAVE_ELEMENT_CLS: SAVE_ELEMENT_CLS,
LOAD_ELEMENT_CLS: LOAD_ELEMENT_CLS, LOAD_ELEMENT_CLS: LOAD_ELEMENT_CLS,
SET_TITLE_CLS: SET_TITLE_CLS,
USERNAME_BUTTON_GROUP: USERNAME_BUTTON_GROUP, USERNAME_BUTTON_GROUP: USERNAME_BUTTON_GROUP,
DEBUG_LINK_CLS: DEBUG_LINK_CLS, DEBUG_LINK_CLS: DEBUG_LINK_CLS,
}).trim(); }).trim();

@ -71,6 +71,7 @@ define([
// document itself and causes problems when it's sent across the wire and reflected back // document itself and causes problems when it's sent across the wire and reflected back
removePlugins: 'resize', removePlugins: 'resize',
extraPlugins: 'autolink', extraPlugins: 'autolink',
//skin: 'moono',
}); });
editor.on('instanceReady', function (Ckeditor) { editor.on('instanceReady', function (Ckeditor) {
@ -368,9 +369,30 @@ define([
realtimeOptions.onLocal(); realtimeOptions.onLocal();
})); }));
var $rightside = $bar.find('.rtwysiwyg-toolbar-rightside');
var $rename = $('<button>', {
id: 'name-pad',
})
.addClass('cryptpad-rename')
.click(function () {
var suggestion = $(inner).find('h1:first-of-type').text();
var title = window.prompt("How would you like to title this pad?", suggestion);
if (title === null) { return; }
Cryptpad.setPadTitle(title);
document.title = title;
});
$rightside.append($rename);
// set the hash // set the hash
window.location.hash = info.channel + secret.key; window.location.hash = info.channel + secret.key;
Cryptpad.rememberPad();
var title = document.title = Cryptpad.getPadTitle();
Cryptpad.rememberPad(title);
}; };
// this should only ever get called once, when the chain syncs // this should only ever get called once, when the chain syncs

Loading…
Cancel
Save