disable input field when disconnected
This commit is contained in:
@@ -4,7 +4,22 @@ define([
|
|||||||
'/common/curve.js',
|
'/common/curve.js',
|
||||||
'/bower_components/marked/marked.min.js',
|
'/bower_components/marked/marked.min.js',
|
||||||
], function ($, Crypto, Curve, Marked) {
|
], 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 = {
|
var Types = {
|
||||||
message: 'MSG',
|
message: 'MSG',
|
||||||
@@ -310,10 +325,9 @@ define([
|
|||||||
$('<div>', {'class': 'messages'}).appendTo($container);
|
$('<div>', {'class': 'messages'}).appendTo($container);
|
||||||
var $inputBlock = $('<div>', {'class': 'input'}).appendTo($container);
|
var $inputBlock = $('<div>', {'class': 'input'}).appendTo($container);
|
||||||
|
|
||||||
// Input
|
|
||||||
var channel = channels[data.channel];
|
|
||||||
var $input = $('<textarea>').appendTo($inputBlock);
|
var $input = $('<textarea>').appendTo($inputBlock);
|
||||||
$input.attr('placeholder', common.Messages.contacts_typeHere);
|
$input.attr('placeholder', common.Messages.contacts_typeHere);
|
||||||
|
Msg.inputs.push($input[0]);
|
||||||
|
|
||||||
var sending = false;
|
var sending = false;
|
||||||
var send = function () {
|
var send = function () {
|
||||||
@@ -385,6 +399,8 @@ define([
|
|||||||
var proxy = common.getProxy();
|
var proxy = common.getProxy();
|
||||||
Msg.hk = network.historyKeeper;
|
Msg.hk = network.historyKeeper;
|
||||||
var friends = getFriendList(common);
|
var friends = getFriendList(common);
|
||||||
|
Messages = Messages || common.Messages;
|
||||||
|
|
||||||
network.on('message', function(msg, sender) {
|
network.on('message', function(msg, sender) {
|
||||||
onDirectMessage(common, msg, sender);
|
onDirectMessage(common, msg, sender);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -128,6 +128,7 @@ define([
|
|||||||
common.getFriendListUI = Messaging.getFriendListUI;
|
common.getFriendListUI = Messaging.getFriendListUI;
|
||||||
common.createData = Messaging.createData;
|
common.createData = Messaging.createData;
|
||||||
common.getPendingInvites = Messaging.getPending;
|
common.getPendingInvites = Messaging.getPending;
|
||||||
|
common.enableMessaging = Messaging.setEditable;
|
||||||
|
|
||||||
// Userlist
|
// Userlist
|
||||||
common.createUserList = UserList.create;
|
common.createUserList = UserList.create;
|
||||||
|
|||||||
@@ -39,12 +39,12 @@ define([
|
|||||||
toolbar.$rightside.html(''); // Remove the drawer if we don't use it to hide the toolbar
|
toolbar.$rightside.html(''); // Remove the drawer if we don't use it to hide the toolbar
|
||||||
|
|
||||||
Cryptpad.getProxy().on('disconnect', function () {
|
Cryptpad.getProxy().on('disconnect', function () {
|
||||||
// TODO readonly
|
|
||||||
Cryptpad.alert(Messages.common_connectionLost, undefined, true);
|
Cryptpad.alert(Messages.common_connectionLost, undefined, true);
|
||||||
|
Cryptpad.enableMessaging(false);
|
||||||
});
|
});
|
||||||
Cryptpad.getProxy().on('reconnect', function () {
|
Cryptpad.getProxy().on('reconnect', function () {
|
||||||
// TODO cancel readonly
|
|
||||||
Cryptpad.findOKButton().click();
|
Cryptpad.findOKButton().click();
|
||||||
|
Cryptpad.enableMessaging(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
Cryptpad.initMessaging(Cryptpad, $list, $messages);
|
Cryptpad.initMessaging(Cryptpad, $list, $messages);
|
||||||
|
|||||||
@@ -223,7 +223,10 @@ body {
|
|||||||
resize: none;
|
resize: none;
|
||||||
line-height: 50px;
|
line-height: 50px;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
.placeholder;
|
.placeholder(#bbb);
|
||||||
|
&[disabled=true] {
|
||||||
|
.placeholder(#999);
|
||||||
|
}
|
||||||
&:placeholder-shown { line-height: 50px; }
|
&:placeholder-shown { line-height: 50px; }
|
||||||
}
|
}
|
||||||
button {
|
button {
|
||||||
|
|||||||
Reference in New Issue
Block a user