From 2ce341fed64bd3b9bcd6704d2fb6e40fc809a3df Mon Sep 17 00:00:00 2001 From: ansuz Date: Thu, 3 Aug 2017 14:12:07 +0200 Subject: [PATCH] disable input field when disconnected --- www/common/common-messaging.js | 22 +++++++++++++++++++--- www/common/cryptpad-common.js | 1 + www/contacts/main.js | 4 ++-- www/contacts/main.less | 5 ++++- 4 files changed, 26 insertions(+), 6 deletions(-) diff --git a/www/common/common-messaging.js b/www/common/common-messaging.js index 0fccf2f17..4fecba707 100644 --- a/www/common/common-messaging.js +++ b/www/common/common-messaging.js @@ -4,7 +4,22 @@ define([ '/common/curve.js', '/bower_components/marked/marked.min.js', ], function ($, Crypto, Curve, Marked) { - var Msg = {}; + var Msg = { + inputs: [], + }; + + var Messages; + var setEditable = Msg.setEditable = function (bool) { + bool = !bool; + Msg.inputs.forEach(function (input) { + input.setAttribute('disabled', bool); + if (Messages) { + // set placeholder + var placeholder = bool? Messages.disconnected: Messages.contacts_typeHere; + input.setAttribute('placeholder', placeholder); + } + }); + }; var Types = { message: 'MSG', @@ -310,10 +325,9 @@ define([ $('
', {'class': 'messages'}).appendTo($container); var $inputBlock = $('
', {'class': 'input'}).appendTo($container); - // Input - var channel = channels[data.channel]; var $input = $('