Remove jshint - move everything over to eslint
Also removed all hints of previous linters
This commit is contained in:
@@ -1,8 +1,12 @@
|
||||
/* global Whisper, Backbone, ConversationController */
|
||||
|
||||
// eslint-disable-next-line func-names
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
window.Whisper = window.Whisper || {};
|
||||
|
||||
var ContactsTypeahead = Backbone.TypeaheadCollection.extend({
|
||||
const ContactsTypeahead = Backbone.TypeaheadCollection.extend({
|
||||
typeaheadAttributes: [
|
||||
'name',
|
||||
'e164_number',
|
||||
@@ -12,7 +16,7 @@
|
||||
database: Whisper.Database,
|
||||
storeName: 'conversations',
|
||||
model: Whisper.Conversation,
|
||||
fetchContacts: function() {
|
||||
fetchContacts() {
|
||||
return this.fetch({ reset: true, conditions: { type: 'private' } });
|
||||
},
|
||||
});
|
||||
@@ -24,17 +28,17 @@
|
||||
'click .remove': 'removeModel',
|
||||
},
|
||||
templateName: 'contact_pill',
|
||||
initialize: function() {
|
||||
var error = this.model.validate(this.model.attributes);
|
||||
initialize() {
|
||||
const error = this.model.validate(this.model.attributes);
|
||||
if (error) {
|
||||
this.$el.addClass('error');
|
||||
}
|
||||
},
|
||||
removeModel: function() {
|
||||
removeModel() {
|
||||
this.$el.trigger('remove', { modelId: this.model.id });
|
||||
this.remove();
|
||||
},
|
||||
render_attributes: function() {
|
||||
render_attributes() {
|
||||
return { name: this.model.getTitle() };
|
||||
},
|
||||
});
|
||||
@@ -55,7 +59,7 @@
|
||||
Whisper.RecipientsInputView = Whisper.View.extend({
|
||||
className: 'recipients-input',
|
||||
templateName: 'recipients-input',
|
||||
initialize: function(options) {
|
||||
initialize(options) {
|
||||
if (options) {
|
||||
this.placeholder = options.placeholder;
|
||||
}
|
||||
@@ -81,7 +85,7 @@
|
||||
// View to display the matched contacts from typeahead
|
||||
this.typeahead_view = new Whisper.SuggestionListView({
|
||||
collection: new Whisper.ConversationCollection([], {
|
||||
comparator: function(m) {
|
||||
comparator(m) {
|
||||
return m.getTitle().toLowerCase();
|
||||
},
|
||||
}),
|
||||
@@ -91,7 +95,7 @@
|
||||
this.listenTo(this.typeahead, 'reset', this.filterContacts);
|
||||
},
|
||||
|
||||
render_attributes: function() {
|
||||
render_attributes() {
|
||||
return { placeholder: this.placeholder || 'name or phone number' };
|
||||
},
|
||||
|
||||
@@ -102,8 +106,8 @@
|
||||
'remove .recipient': 'removeRecipient',
|
||||
},
|
||||
|
||||
filterContacts: function(e) {
|
||||
var query = this.$input.val();
|
||||
filterContacts() {
|
||||
const query = this.$input.val();
|
||||
if (query.length) {
|
||||
if (this.maybeNumber(query)) {
|
||||
this.new_contact_view.model.set('id', query);
|
||||
@@ -117,7 +121,7 @@
|
||||
}
|
||||
},
|
||||
|
||||
initNewContact: function() {
|
||||
initNewContact() {
|
||||
if (this.new_contact_view) {
|
||||
this.new_contact_view.undelegateEvents();
|
||||
this.new_contact_view.$el.hide();
|
||||
@@ -132,47 +136,45 @@
|
||||
}).render();
|
||||
},
|
||||
|
||||
addNewRecipient: function() {
|
||||
addNewRecipient() {
|
||||
this.recipients.add(this.new_contact_view.model);
|
||||
this.initNewContact();
|
||||
this.resetTypeahead();
|
||||
},
|
||||
|
||||
addRecipient: function(e, conversation) {
|
||||
addRecipient(e, conversation) {
|
||||
this.recipients.add(this.typeahead.remove(conversation.id));
|
||||
this.resetTypeahead();
|
||||
},
|
||||
|
||||
removeRecipient: function(e, data) {
|
||||
var model = this.recipients.remove(data.modelId);
|
||||
removeRecipient(e, data) {
|
||||
const model = this.recipients.remove(data.modelId);
|
||||
if (!model.get('newContact')) {
|
||||
this.typeahead.add(model);
|
||||
}
|
||||
this.filterContacts();
|
||||
},
|
||||
|
||||
reset: function() {
|
||||
reset() {
|
||||
this.delegateEvents();
|
||||
this.typeahead_view.delegateEvents();
|
||||
this.recipients_view.delegateEvents();
|
||||
this.new_contact_view.delegateEvents();
|
||||
this.typeahead.add(
|
||||
this.recipients.filter(function(model) {
|
||||
return !model.get('newContact');
|
||||
})
|
||||
this.recipients.filter(model => !model.get('newContact'))
|
||||
);
|
||||
this.recipients.reset([]);
|
||||
this.resetTypeahead();
|
||||
this.typeahead.fetchContacts();
|
||||
},
|
||||
|
||||
resetTypeahead: function() {
|
||||
resetTypeahead() {
|
||||
this.new_contact_view.$el.hide();
|
||||
this.$input.val('').focus();
|
||||
this.typeahead_view.collection.reset([]);
|
||||
},
|
||||
|
||||
maybeNumber: function(number) {
|
||||
maybeNumber(number) {
|
||||
return number.match(/^\+?[0-9]*$/);
|
||||
},
|
||||
});
|
||||
|
Reference in New Issue
Block a user