New toolbar temp

This commit is contained in:
yflory
2017-06-12 15:59:24 +02:00
parent 9c5bade83e
commit 376b60c21c
35 changed files with 679 additions and 25 deletions

View File

@@ -392,7 +392,6 @@ define([
'class': TITLE_CLS
}).appendTo(toolbar.$top);
// TODO: move these functions to toolbar or common?
if (typeof config.title !== "object") {
console.error("config.title", config);
throw new Error("config.title is not an object");
@@ -409,6 +408,10 @@ define([
'class': 'pencilIcon',
'title': Messages.clickToEdit
});
var $saveIcon = $('<span>', {
'class': 'saveIcon',
'title': Messages.saveTitle
}).hide();
if (config.readOnly === 1 || typeof(Cryptpad) === "undefined") { return $titleContainer; }
var $input = $('<input>', {
type: 'text',
@@ -422,6 +425,11 @@ define([
style: 'font-family: FontAwesome;'
});
$pencilIcon.append($icon).appendTo($titleContainer);
var $icon2 = $('<span>', {
'class': 'fa fa-check readonly',
style: 'font-family: FontAwesome;'
});
$saveIcon.append($icon2).appendTo($titleContainer);
}
// Events
@@ -432,26 +440,34 @@ define([
e.stopPropagation();
return true;
});
var save = function () {
var name = $input.val().trim();
if (name === "") {
name = $input.attr('placeholder');
}
Cryptpad.renamePad(name, function (err, newtitle) {
if (err) { return; }
$text.text(newtitle);
callback(null, newtitle);
$input.hide();
$text.show();
$pencilIcon.show();
$saveIcon.hide();
//$pencilIcon.css('display', '');
});
};
$input.on('keyup', function (e) {
if (e.which === 13 && toolbar.connected === true) {
var name = $input.val().trim();
if (name === "") {
name = $input.attr('placeholder');
}
Cryptpad.renamePad(name, function (err, newtitle) {
if (err) { return; }
$text.text(newtitle);
callback(null, newtitle);
$input.hide();
$text.show();
//$pencilIcon.css('display', '');
});
save();
} else if (e.which === 27) {
$input.hide();
$text.show();
$pencilIcon.show();
$saveIcon.hide();
//$pencilIcon.css('display', '');
}
});
$saveIcon.click(save);
var displayInput = function () {
if (toolbar.connected === false) { return; }
@@ -461,6 +477,8 @@ define([
$input.val(inputVal);
$input.show();
$input.focus();
$pencilIcon.hide();
$saveIcon.show();
};
$text.on('click', displayInput);
$pencilIcon.on('click', displayInput);
@@ -482,16 +500,16 @@ define([
title: Messages.header_logoTitle,
'class': "cryptpad-logo"
}).append($imgTag);
var $span = $('<span>').text('CryptPad');
var $span = $('<span>').text('CryptDrive');
var $aTagBig = $aTagSmall.clone().addClass('large').append($span);
$aTagSmall.addClass('narrow');
var onClick = function (e) {
e.preventDefault();
if (e.ctrlKey) {
window.open('/');
window.open('/drive');
return;
}
window.location = "/";
window.location = "/drive";
};
var onContext = function (e) { e.stopPropagation(); };