diff --git a/converse.css b/converse.css
index d2538ef91..4d965f860 100644
--- a/converse.css
+++ b/converse.css
@@ -441,7 +441,7 @@ form.search-xmpp-contact input {
text-overflow: ellipsis;
white-space: nowrap;
display: inline-block;
- width: 160px;
+ width: 170px;
}
#available-chatrooms dt,
@@ -468,6 +468,38 @@ dd.available-chatroom,
text-shadow: 0 1px 0 rgba(250, 250, 250, 1);
}
+p.room-info {
+ margin: 0;
+ padding: 0;
+ font-size: 11px;
+ font-style: normal;
+ font-weight: normal;
+ display: block;
+ white-space: normal;
+}
+
+a.room-info {
+ background: url('images/information.png') no-repeat right top;
+ width: 22px;
+ float: right;
+ display: none;
+}
+
+a.open-room {
+ display: inline-block;
+ white-space: nowrap;
+ text-overflow: ellipsis;
+ overflow-x: hidden;
+}
+
+dd.available-chatroom:hover a.room-info {
+ display: inline-block;
+}
+
+dd.available-chatroom:hover a.open-room {
+ width: 75%;
+}
+
#converse-roster dd a.remove-xmpp-contact {
background: url('images/delete_icon.png') no-repeat right top;
padding: 0 0 1em 0;
@@ -477,11 +509,11 @@ dd.available-chatroom,
display: none;
}
-#converse-roster dd:hover *[class*="remove-xmpp-contact"] {
+#converse-roster dd:hover a.remove-xmpp-contact {
display: inline-block;
}
-#converse-roster dd:hover *[class*="open-chat"] {
+#converse-roster dd:hover a.open-chat {
width: 75%;
}
diff --git a/converse.js b/converse.js
index 39459f0d3..f8af727fb 100644
--- a/converse.js
+++ b/converse.js
@@ -684,14 +684,24 @@
events: {
'submit form.add-chatroom': 'createChatRoom',
'click input#show-rooms': 'showRooms',
- 'click a.open-room': 'createChatRoom'
+ 'click a.open-room': 'createChatRoom',
+ 'click a.room-info': 'showRoomInfo'
},
room_template: _.template(
- '
' +
- '' +
- '{{name}} {{occ}}'),
+ ''+
+ '{{name}}'+
+ ' '+
+ ''),
+
+ room_description_template: _.template(
+ ''+
+ '
Description: {{desc}}
' +
+ '
Occupants: {{occ}}
' +
+ '{[ if (locked) { ]}' +
+ '
Requires authentication
' +
+ '{[ } ]}' +
+ '
'
+ ),
tab_template: _.template('Rooms'),
@@ -720,37 +730,23 @@
converse.connection.muc.listRooms(
this.muc_domain,
$.proxy(function (iq) { // Success
- var name, jid, i, that = this, $available_chatrooms = this.$el.find('#available-chatrooms');
- this.rdict = {};
+ var name, jid, i, fragment,
+ that = this,
+ $available_chatrooms = this.$el.find('#available-chatrooms');
this.rooms = $(iq).find('query').find('item');
- this.rooms.each(function (i) { that.rdict[$(this).attr('jid')] = this; });
- this.fragment = document.createDocumentFragment();
if (this.rooms.length) {
$available_chatrooms.html('Rooms on '+this.muc_domain+'');
- _.each(this.rooms, $.proxy(function (room, idx) {
- converse.connection.disco.info(
- $(room).attr('jid'),
- null,
- $.proxy(function (stanza) {
- var name = $(stanza).find('identity').attr('name');
- var desc = $(stanza).find('field[var="muc#roominfo_description"] value').text();
- var occ = $(stanza).find('field[var="muc#roominfo_occupants"] value').text();
- var locked = $(stanza).find('feature[var="muc_passwordprotected"]').length;
- var jid = $(stanza).attr('from');
- var classes = locked && 'locked' || '';
- delete this.rdict[jid];
- this.$el.find('#available-chatrooms').append(
- this.room_template({'name':name,
- 'desc':desc,
- 'occ':occ,
- 'jid':jid,
- 'classes': classes
- }));
- if (_.keys(this.rdict).length === 0) {
- $('input#show-rooms').show().siblings('img.spinner').remove();
- }
- }, this));
- }, this));
+ fragment = document.createDocumentFragment();
+ for (i=0; iNo rooms on '+this.muc_domain+'');
$('input#show-rooms').show().siblings('img.spinner').remove();
@@ -780,6 +776,31 @@
this.updateRoomsList();
},
+ showRoomInfo: function (ev) {
+ var target = ev.target,
+ $dd = $(target).parent('dd'),
+ $div = $dd.find('div.room-info');
+ if ($div.length) {
+ $div.remove();
+ } else {
+ $dd.append('');
+ converse.connection.disco.info(
+ $(target).attr('data-room-jid'),
+ null,
+ $.proxy(function (stanza) {
+ var desc = $(stanza).find('field[var="muc#roominfo_description"] value').text();
+ var occ = $(stanza).find('field[var="muc#roominfo_occupants"] value').text();
+ var locked = $(stanza).find('feature[var="muc_passwordprotected"]').length;
+ $dd.find('img.spinner').replaceWith(
+ this.room_description_template({
+ 'desc':desc,
+ 'occ':occ,
+ 'locked':locked
+ }));
+ }, this));
+ }
+ },
+
createChatRoom: function (ev) {
ev.preventDefault();
var name, server, jid, $name, $server, errors;