Add a settings category about the cursor

This commit is contained in:
yflory
2018-12-06 13:48:14 +01:00
parent c81b4d77e8
commit 081fc01694
6 changed files with 143 additions and 4 deletions

View File

@@ -427,11 +427,11 @@ define([
getColor().toString(16);
};
var getUserColor = function () {
var color = Util.find(store.proxy, ['settings', 'general', 'color']);
var color = Util.find(store.proxy, ['settings', 'general', 'cursor', 'color']);
if (!color) {
color = getRandomColor();
Store.setAttribute(null, {
attr: ['general', 'color'],
attr: ['general', 'cursor', 'color'],
value: color
}, function () {});
}

View File

@@ -160,7 +160,7 @@ define([
var updateCursor = function (ctx, data, client, cb) {
var c = ctx.clients[client];
if (!c) { return void cb({error: 'NO_CLIENT'}); }
data.color = Util.find(ctx.store.proxy, ['settings', 'general', 'color']);
data.color = Util.find(ctx.store.proxy, ['settings', 'general', 'cursor', 'color']);
data.name = ctx.store.proxy[Constants.displayNameKey] || Messages.anonymous;
data.avatar = Util.find(ctx.store.proxy, ['profile', 'avatar']);
console.log(data.color);

View File

@@ -1,10 +1,15 @@
define([
], function () {
'/common/common-util.js',
], function (Util) {
var module = {};
module.create = function (Common) {
var exp = {};
var sframeChan = Common.getSframeChannel();
var metadataMgr = Common.getMetadataMgr();
var privateData = metadataMgr.getPrivateData();
var share = Util.find(privateData, ['settings', 'general', 'cursor', 'share']);
var show = Util.find(privateData, ['settings', 'general', 'cursor', 'show']);
var execCommand = function (cmd, data, cb) {
sframeChan.query('Q_CURSOR_COMMAND', {cmd: cmd, data: data}, function (err, obj) {
@@ -14,6 +19,7 @@ define([
};
exp.updateCursor = function (obj) {
if (share === false) { return; }
execCommand('UPDATE', obj, function (err) {
if (err) { console.error(err); }
});
@@ -24,6 +30,7 @@ define([
messageHandlers.push(handler);
};
var onMessage = function (data) {
if (show === false) { return; }
messageHandlers.forEach(function (h) {
try {
h(data);

View File

@@ -552,6 +552,7 @@ define(function () {
// Settings
out.settings_cat_account = "Account";
out.settings_cat_drive = "CryptDrive";
out.settings_cat_cursor = "Cursor";
out.settings_cat_code = "Code";
out.settings_cat_pad = "Rich text";
out.settings_cat_creation = "New pad";
@@ -675,6 +676,16 @@ define(function () {
out.settings_changePasswordPending = "Your password is being updated. Please do not close or reload this page until the process has completed.";
out.settings_changePasswordNewPasswordSameAsOld = "Your new password must be different than your current password.";
// XXX
out.settings_cursorColorTitle = "Cursor color";
out.settings_cursorColorHint = "Change the color associated to your user in collaborative documents.";
out.settings_cursorShareTitle = "Share my cursor position";
out.settings_cursorShareHint = "You can decide if you want other users to see your cursor position in collaborative documents. If shared, your cursor will be displayed in the color picked above.";
out.settings_cursorShareLabel = "Share my cursor position";
out.settings_cursorShowTitle = "Show other users' cursor position";
out.settings_cursorShowHint = "You can choose if you want to see the other users' cursor in collaborative documents.";
out.settings_cursorShowLabel = "Show the cursors";
out.upload_title = "File upload";
out.upload_type = "Type";
out.upload_modal_title = "File upload options";