Commit 18410ca4 authored by JC Brand's avatar JC Brand

Add new form input for nickname when joining chatrooms

parent d83ffde0
...@@ -753,6 +753,7 @@ ...@@ -753,6 +753,7 @@
'<form class="add-chatroom" action="" method="post">'+ '<form class="add-chatroom" action="" method="post">'+
'<legend>'+ '<legend>'+
'<input type="text" name="chatroom" class="new-chatroom-name" placeholder="Room name"/>'+ '<input type="text" name="chatroom" class="new-chatroom-name" placeholder="Room name"/>'+
'<input type="text" name="nick" class="new-chatroom-nick" placeholder="Nickname"/>'+
'<input type="text" name="server" class="new-chatroom-server" placeholder="Server"/>'+ '<input type="text" name="server" class="new-chatroom-server" placeholder="Server"/>'+
'</legend>'+ '</legend>'+
'<input type="submit" name="join" value="Join"/>'+ '<input type="submit" name="join" value="Join"/>'+
...@@ -770,6 +771,15 @@ ...@@ -770,6 +771,15 @@
this.on('update-rooms-list', function (ev) { this.on('update-rooms-list', function (ev) {
this.updateRoomsList(); this.updateRoomsList();
}); });
converse.xmppstatus.model.on("change", $.proxy(function (model) {
if (!(_.has(model.changed, 'fullname'))) {
return;
}
var $nick = this.$el.find('input.new-chatroom-nick');
if (! $nick.is(':focus')) {
$nick.val(model.get('fullname'));
}
}, this));
}, },
updateRoomsList: function (domain) { updateRoomsList: function (domain) {
...@@ -864,18 +874,22 @@ ...@@ -864,18 +874,22 @@
jid = $(ev.target).attr('data-room-jid'); jid = $(ev.target).attr('data-room-jid');
} else { } else {
$name = this.$el.find('input.new-chatroom-name'); $name = this.$el.find('input.new-chatroom-name');
$nick = this.$el.find('input.new-chatroom-nick');
$server= this.$el.find('input.new-chatroom-server'); $server= this.$el.find('input.new-chatroom-server');
server = $server.val(); server = $server.val();
nick = $nick.val();
name = $name.val().trim().toLowerCase(); name = $name.val().trim().toLowerCase();
$name.val(''); // Clear the input $name.val(''); // Clear the input
if (name && server) { if (name && server && nick) {
jid = Strophe.escapeNode(name) + '@' + server; jid = Strophe.escapeNode(name) + '@' + server;
$name.removeClass('error'); $name.removeClass('error');
$nick.removeClass('error');
$server.removeClass('error'); $server.removeClass('error');
this.muc_domain = server; this.muc_domain = server;
} else { } else {
errors = true; errors = true;
if (!name) { $name.addClass('error'); } if (!name) { $name.addClass('error'); }
if (!nick) { $nick.addClass('error'); }
if (!server) { $server.addClass('error'); } if (!server) { $server.addClass('error'); }
return; return;
} }
...@@ -884,7 +898,7 @@ ...@@ -884,7 +898,7 @@
'id': jid, 'id': jid,
'jid': jid, 'jid': jid,
'name': Strophe.unescapeNode(Strophe.getNodeFromJid(jid)), 'name': Strophe.unescapeNode(Strophe.getNodeFromJid(jid)),
'nick': converse.xmppstatus.get('fullname')||converse.bare_jid, 'nick': nick,
'chatroom': true, 'chatroom': true,
'box_id' : hex_sha1(jid) 'box_id' : hex_sha1(jid)
}); });
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment