Don't show new contact unless input may be a phone number
This commit is contained in:
parent
4ee4872b27
commit
5762724709
1 changed files with 12 additions and 2 deletions
|
@ -61,17 +61,27 @@ var Whisper = Whisper || {};
|
|||
model: new Whisper.Conversation({
|
||||
active_at: null
|
||||
})
|
||||
}).render();
|
||||
});
|
||||
this.new_contact.render().$el.hide();
|
||||
this.$el.find('.new-contact').append(this.new_contact.el);
|
||||
},
|
||||
|
||||
filterContacts: function(query) {
|
||||
this.new_contact.model.set('name', query);
|
||||
if (this.maybeNumber(query)) {
|
||||
this.new_contact.model.set('name', query);
|
||||
this.new_contact.$el.show();
|
||||
} else {
|
||||
this.new_contact.$el.hide();
|
||||
}
|
||||
if (query.length) {
|
||||
this.typeahead_view.collection.reset(
|
||||
this.typeahead_collection.typeahead(query)
|
||||
);
|
||||
}
|
||||
},
|
||||
|
||||
maybeNumber: function(number) {
|
||||
return number.match(/^\+?[0-9]*$/);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue