Commit 18f877b5 authored by ichim-david's avatar ichim-david

Changed the following:

- Chained call to render and show methods of ChatBoxView
- Cached target for subscribeToContact
- Removed check of length > 0
parent 5c5b7b9d
...@@ -584,8 +584,8 @@ ...@@ -584,8 +584,8 @@
'</form>'), '</form>'),
render: function () { render: function () {
this.$el.attr('id', this.model.get('box_id')); this.$el.attr('id', this.model.get('box_id'))
this.$el.html(this.template(this.model.toJSON())); .html(this.template(this.model.toJSON()));
this.insertClientStoredMessages(); this.insertClientStoredMessages();
return this; return this;
}, },
...@@ -600,11 +600,9 @@ ...@@ -600,11 +600,9 @@
}, },
show: function () { show: function () {
this.$el.css({'opacity': 0}); this.$el.css({'opacity': 0,
this.$el.css({'display': 'inline'}); 'display': 'inline'})
this.$el.animate({ .animate({opacity: '1'}, 200);
opacity: '1'
}, 200);
return this; return this;
}, },
...@@ -662,7 +660,7 @@ ...@@ -662,7 +660,7 @@
$.getJSON(portal_url + "/search-users?q=" + $(ev.target).find('input.username').val(), function (data) { $.getJSON(portal_url + "/search-users?q=" + $(ev.target).find('input.username').val(), function (data) {
var $results_el = $('#found-users'); var $results_el = $('#found-users');
$(data).each(function (idx, obj) { $(data).each(function (idx, obj) {
if ($results_el.children().length > 0) { if ($results_el.children().length) {
$results_el.empty(); $results_el.empty();
} }
$results_el.append( $results_el.append(
...@@ -680,12 +678,13 @@ ...@@ -680,12 +678,13 @@
subscribeToContact: function (ev) { subscribeToContact: function (ev) {
ev.preventDefault(); ev.preventDefault();
var jid = $(ev.target).attr('data-recipient'), var $target = $(ev.target),
name = $(ev.target).text(); jid = $target.attr('data-recipient'),
name = $target.text();
xmppchat.connection.roster.add(jid, name, [], function (iq) { xmppchat.connection.roster.add(jid, name, [], function (iq) {
xmppchat.connection.roster.subscribe(jid); xmppchat.connection.roster.subscribe(jid);
}); });
$(ev.target).parent().remove(); $target.parent().remove();
$('form.search-xmpp-contact').hide(); $('form.search-xmpp-contact').hide();
} }
......
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