Commit 623c56c8 authored by JC Brand's avatar JC Brand

Minor refactoring.

Split showRoomInfo into two new methods.
parent 0fe4031a
...@@ -1382,7 +1382,7 @@ ...@@ -1382,7 +1382,7 @@
'submit form.add-chatroom': 'createChatRoom', 'submit form.add-chatroom': 'createChatRoom',
'click input#show-rooms': 'showRooms', 'click input#show-rooms': 'showRooms',
'click a.open-room': 'createChatRoom', 'click a.open-room': 'createChatRoom',
'click a.room-info': 'showRoomInfo', 'click a.room-info': 'toggleRoomInfo',
'change input[name=server]': 'setDomain', 'change input[name=server]': 'setDomain',
'change input[name=nick]': 'setNick' 'change input[name=nick]': 'setNick'
}, },
...@@ -1493,19 +1493,9 @@ ...@@ -1493,19 +1493,9 @@
this.updateRoomsList(); this.updateRoomsList();
}, },
showRoomInfo: function (ev) { insertRoomInfo: function ($parent, stanza) {
var target = ev.target, /* Insert room info (based on returned #disco IQ stanza)
$parent = $(target).parent('dd'), */
$div = $parent.find('div.room-info');
if ($div.length) {
$div.remove();
} else {
$parent.find('span.spinner').remove();
$parent.append('<span class="spinner hor_centered"/>');
converse.connection.disco.info(
$(target).attr('data-room-jid'),
null,
function (stanza) {
var $stanza = $(stanza); var $stanza = $(stanza);
// All MUC features found here: http://xmpp.org/registrar/disco-features.html // All MUC features found here: http://xmpp.org/registrar/disco-features.html
$parent.find('span.spinner').replaceWith( $parent.find('span.spinner').replaceWith(
...@@ -1537,8 +1527,24 @@ ...@@ -1537,8 +1527,24 @@
'label_semi_anon': __('Semi-anonymous'), 'label_semi_anon': __('Semi-anonymous'),
'label_temp_room': __('Temporary room'), 'label_temp_room': __('Temporary room'),
'label_unmoderated': __('Unmoderated') 'label_unmoderated': __('Unmoderated')
})); })
}.bind(this)); );
},
toggleRoomInfo: function (ev) {
/* Show/hide extra information about a room in the listing.
*/
var target = ev.target,
$parent = $(target).parent('dd'),
$div = $parent.find('div.room-info');
if ($div.length) {
$div.remove();
} else {
$parent.find('span.spinner').remove();
$parent.append('<span class="spinner hor_centered"/>');
converse.connection.disco.info(
$(target).attr('data-room-jid'), null, _.partial(this.insertRoomInfo, $parent)
);
} }
}, },
......
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