diff --git a/js/conversation_panel.js b/js/conversation_panel.js
index d32666c9e5..1915b854df 100644
--- a/js/conversation_panel.js
+++ b/js/conversation_panel.js
@@ -22,15 +22,17 @@
extension.windows.getCurrent(function (windowInfo) {
var bg = extension.windows.getBackground();
window.$ = bg.$;
+ var body = $('body', document)
var conversation = bg.getConversationForWindow(windowInfo.id);
if (conversation) {
window.document.title = conversation.getTitle();
- new bg.Whisper.ConversationView({
+ var view = new bg.Whisper.ConversationView({
model: conversation
- }).$el.prependTo($('body', document));
- $('input.send-message', document).focus();
+ });
+ view.$el.prependTo(body);
+ view.$('input.send-message').focus();
} else {
- $('
').text('Error').prependTo($('body', document));
+ $('
').text('Error').prependTo(body);
}
});
}());
diff --git a/js/views/conversation_view.js b/js/views/conversation_view.js
index 380d808e82..49bae93143 100644
--- a/js/views/conversation_view.js
+++ b/js/views/conversation_view.js
@@ -32,13 +32,13 @@
this.render();
this.fileInput = new Whisper.FileInputView({
- el: this.$el.find('.attachments')
+ el: this.$('.attachments')
});
this.view = new Whisper.MessageListView({
collection: this.model.messageCollection
});
- this.$el.find('.discussion-container').append(this.view.el);
+ this.$('.discussion-container').append(this.view.el);
this.view.render();
setTimeout(function() {
@@ -106,22 +106,22 @@
closeMenu: function(e) {
if (e && !$(e.target).hasClass('hamburger')) {
- this.$el.find('.menu-list').hide();
+ this.$('.menu-list').hide();
}
},
endSession: function() {
this.model.endSession();
- this.$el.find('.menu-list').hide();
+ this.$('.menu-list').hide();
},
leaveGroup: function() {
this.model.leaveGroup();
- this.$el.find('.menu-list').hide();
+ this.$('.menu-list').hide();
},
toggleMenu: function() {
- this.$el.find('.menu-list').toggle();
+ this.$('.menu-list').toggle();
},
newGroupUpdate: function() {
@@ -137,12 +137,12 @@
if (confirm("Permanently delete this conversation?")) {
this.model.destroyMessages();
}
- this.$el.find('.menu-list').hide();
+ this.$('.menu-list').hide();
},
sendMessage: function(e) {
e.preventDefault();
- var input = this.$el.find('.send input.send-message');
+ var input = this.$('.send input.send-message');
var message = this.replace_colons(input.val());
var convo = this.model;
diff --git a/js/views/file_input_view.js b/js/views/file_input_view.js
index 1548802857..fa32f7f90f 100644
--- a/js/views/file_input_view.js
+++ b/js/views/file_input_view.js
@@ -25,10 +25,10 @@
tagName: 'span',
className: 'file-input',
initialize: function() {
- this.$input = this.$el.find('input[type=file]');
+ this.$input = this.$('input[type=file]');
this.thumb = new Whisper.AttachmentPreviewView();
this.$el.addClass('file-input');
- this.$default = this.$el.find('.default');
+ this.$default = this.$('.default');
},
events: {
@@ -44,7 +44,7 @@
addThumb: function(src) {
this.$default.hide();
this.thumb.src = src;
- this.$el.find('.thumbnail').append(this.thumb.render().el);
+ this.$('.thumbnail').append(this.thumb.render().el);
},
autoScale: function(file) {
diff --git a/js/views/inbox_view.js b/js/views/inbox_view.js
index 89f2b68ee1..3ee9de9782 100644
--- a/js/views/inbox_view.js
+++ b/js/views/inbox_view.js
@@ -65,13 +65,13 @@
this.openConversation.bind(this, null));
this.inbox = new Whisper.ConversationListView({
- el : this.$el.find('.conversations'),
+ el : this.$('.conversations'),
collection : bg.inbox
}).render();
this.inbox.listenTo(bg.inbox, 'sort', this.inbox.render);
- new SocketView().render().$el.appendTo(this.$el.find('.socket-status'));
+ new SocketView().render().$el.appendTo(this.$('.socket-status'));
window.addEventListener('beforeunload', function () {
this.inbox.stopListening();
diff --git a/js/views/message_detail_view.js b/js/views/message_detail_view.js
index 9b54ef22da..1bfe7504ca 100644
--- a/js/views/message_detail_view.js
+++ b/js/views/message_detail_view.js
@@ -95,14 +95,14 @@
received_at : moment(this.model.get('received_at')).toString(),
tofrom : this.model.isIncoming() ? 'From' : 'To',
}));
- this.view.render().$el.prependTo(this.$el.find('.message-container'));
+ this.view.render().$el.prependTo(this.$('.message-container'));
if (this.model.isOutgoing()) {
this.conversation.contactCollection.each(function(contact) {
var v = new ContactView({
model: contact,
conflict: this.model.getKeyConflict(contact.id)
- }).render().$el.appendTo(this.$el.find('.contacts'));
+ }).render().$el.appendTo(this.$('.contacts'));
}.bind(this));
} else {
var number = this.model.get('source');
@@ -110,7 +110,7 @@
var v = new ContactView({
model: contact,
conflict: this.model.getKeyConflict(number)
- }).render().$el.appendTo(this.$el.find('.contacts'));
+ }).render().$el.appendTo(this.$('.contacts'));
}
}
});
diff --git a/js/views/message_view.js b/js/views/message_view.js
index be92d25a42..e899ff2ffd 100644
--- a/js/views/message_view.js
+++ b/js/views/message_view.js
@@ -41,7 +41,7 @@
renderControl: function() {
if (this.model.isEndSession() || this.model.isGroupUpdate()) {
this.$el.addClass('control');
- this.$el.find('.content').text(this.model.getDescription());
+ this.$('.content').text(this.model.getDescription());
} else {
this.$el.removeClass('control');
}
@@ -62,13 +62,13 @@
twemoji.parse(this.el, { base: '/images/twemoji/', size: 16 });
- var content = this.$el.find('.content');
+ var content = this.$('.content');
content.html(this.autoLink(content.html()));
this.renderDelivered();
this.renderControl();
- this.$el.find('.attachments').append(
+ this.$('.attachments').append(
this.model.get('attachments').map(function(attachment) {
return new Whisper.AttachmentView({
model: attachment
@@ -78,7 +78,7 @@
var errors = this.model.get('errors');
if (errors && errors.length) {
- this.$el.find('.bubble').prepend(
+ this.$('.bubble').prepend(
errors.map(function(error) {
return new Whisper.MessageErrorView({
model: error,
diff --git a/js/views/new_conversation_view.js b/js/views/new_conversation_view.js
index fafd79d733..a35e863131 100644
--- a/js/views/new_conversation_view.js
+++ b/js/views/new_conversation_view.js
@@ -22,17 +22,17 @@
template: $('#new-conversation').html(),
initialize: function() {
this.render();
- this.$group_update = this.$el.find('.new-group-update-form');
- this.$create = this.$el.find('.create');
- this.$input = this.$el.find('input.search');
+ this.$group_update = this.$('.new-group-update-form');
+ this.$create = this.$('.create');
+ this.$input = this.$('input.search');
// Group avatar file input
this.avatarInput = new Whisper.FileInputView({
- el: this.$el.find('.group-avatar')
+ el: this.$('.group-avatar')
});
this.recipients_view = new Whisper.RecipientsInputView();
- this.$el.find('.scrollable').append(this.recipients_view.el);
+ this.$('.scrollable').append(this.recipients_view.el);
this.listenTo(this.getRecipients(), 'add', this.updateControls);
this.listenTo(this.getRecipients(), 'remove', this.updateControls);
},
@@ -72,7 +72,7 @@
},
create: function() {
- var errors = this.recipients_view.$el.find('.error');
+ var errors = this.recipients_view.$('.error');
if (errors.length) {
// TODO: css animation or error notification
@@ -107,7 +107,7 @@
},
createGroup: function() {
- var name = this.$el.find('.new-group-update-form .name').val();
+ var name = this.$('.new-group-update-form .name').val();
if (!name.trim().length) {
return;
}
@@ -153,7 +153,7 @@
reset: function() {
this.$create.hide();
- this.$el.find('.new-group-update-form .name').val('');
+ this.$('.new-group-update-form .name').val('');
this.$group_update.hide();
this.recipients_view.reset();
},
diff --git a/js/views/new_group_update_view.js b/js/views/new_group_update_view.js
index fa94b91dcf..1896d39ba8 100644
--- a/js/views/new_group_update_view.js
+++ b/js/views/new_group_update_view.js
@@ -24,12 +24,12 @@
initialize: function(options) {
this.render();
this.avatarInput = new Whisper.FileInputView({
- el: this.$el.find('.group-avatar')
+ el: this.$('.group-avatar')
});
this.recipients_view = new Whisper.RecipientsInputView();
- this.$el.find('.scrollable').append(this.recipients_view.el);
- this.$el.find('.avatar').addClass('default');
+ this.$('.scrollable').append(this.recipients_view.el);
+ this.$('.avatar').addClass('default');
},
events: {
'click .back': 'goBack',
@@ -47,7 +47,7 @@
send: function() {
return this.avatarInput.getFiles().then(function(avatarFiles) {
this.model.save({
- name: this.$el.find('.name').val(),
+ name: this.$('.name').val(),
avatar: avatarFiles[0],
members: _.union(this.model.get('members'), this.recipients_view.recipients.pluck('id'))
});
diff --git a/js/views/phone-input-view.js b/js/views/phone-input-view.js
index 96cf1ebd3c..86863ecfcb 100644
--- a/js/views/phone-input-view.js
+++ b/js/views/phone-input-view.js
@@ -23,7 +23,7 @@
template: $('#phone-number').html(),
render: function() {
this.$el.html($(Mustache.render(this.template)));
- this.$el.find('input.number').intlTelInput();
+ this.$('input.number').intlTelInput();
return this;
},
@@ -33,18 +33,18 @@
},
validateNumber: function() {
- var input = this.$el.find('input.number');
+ var input = this.$('input.number');
try {
- var regionCode = this.$el.find('li.active').attr('data-country-code').toUpperCase();
+ var regionCode = this.$('li.active').attr('data-country-code').toUpperCase();
var number = input.val();
var parsedNumber = libphonenumber.util.verifyNumber(number, regionCode);
- this.$el.find('.number-container').removeClass('invalid');
- this.$el.find('.number-container').addClass('valid');
+ this.$('.number-container').removeClass('invalid');
+ this.$('.number-container').addClass('valid');
return parsedNumber;
} catch(e) {
- this.$el.find('.number-container').removeClass('valid');
+ this.$('.number-container').removeClass('valid');
} finally {
input.trigger('validation');
}
diff --git a/js/views/recipients_input_view.js b/js/views/recipients_input_view.js
index d3c0dd67fd..4cc859dec5 100644
--- a/js/views/recipients_input_view.js
+++ b/js/views/recipients_input_view.js
@@ -60,8 +60,8 @@
template: $('#recipients-input').html(),
initialize: function() {
this.render();
- this.$input = this.$el.find('input.search');
- this.$new_contact = this.$el.find('.new-contact');
+ this.$input = this.$('input.search');
+ this.$new_contact = this.$('.new-contact');
// Collection of recipients selected for the new message
this.recipients = new Whisper.ConversationCollection([], {
@@ -71,7 +71,7 @@
// View to display the selected recipients
this.recipients_view = new Whisper.RecipientListView({
collection: this.recipients,
- el: this.$el.find('.recipients')
+ el: this.$('.recipients')
});
// Collection of contacts to match user input against
@@ -84,7 +84,7 @@
comparator: function(m) { return m.getTitle(); }
})
});
- this.$el.find('.contacts').append(this.typeahead_view.el);
+ this.$('.contacts').append(this.typeahead_view.el);
this.initNewContact();
},