Create contact from number with common punctuation
The 'Create new contact' option should now appear for numbers including parens and other common punctuation. // FREEBIE
This commit is contained in:
parent
ae52c047bf
commit
3d98b54027
3 changed files with 27 additions and 1 deletions
|
@ -123,7 +123,7 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
maybeNumber: function(number) {
|
maybeNumber: function(number) {
|
||||||
return number.match(/^\+?[0-9]*$/);
|
return number.replace(/[\s-.\(\)]*/g,'').match(/^\+?[0-9]*$/);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -125,11 +125,13 @@
|
||||||
<script type="text/javascript" src="../js/views/conversation_list_view.js" data-cover></script>
|
<script type="text/javascript" src="../js/views/conversation_list_view.js" data-cover></script>
|
||||||
<script type="text/javascript" src="../js/views/conversation_view.js" data-cover></script>
|
<script type="text/javascript" src="../js/views/conversation_view.js" data-cover></script>
|
||||||
<script type="text/javascript" src="../js/views/new_conversation_view.js" data-cover></script>
|
<script type="text/javascript" src="../js/views/new_conversation_view.js" data-cover></script>
|
||||||
|
<script type="text/javascript" src="../js/views/conversation_search_view.js"></script>
|
||||||
|
|
||||||
<script type="text/javascript" src="views/whisper_view_test.js"></script>
|
<script type="text/javascript" src="views/whisper_view_test.js"></script>
|
||||||
<script type="text/javascript" src="views/group_update_view_test.js"></script>
|
<script type="text/javascript" src="views/group_update_view_test.js"></script>
|
||||||
<script type="text/javascript" src="views/message_view_test.js"></script>
|
<script type="text/javascript" src="views/message_view_test.js"></script>
|
||||||
<script type="text/javascript" src="views/list_view_test.js"></script>
|
<script type="text/javascript" src="views/list_view_test.js"></script>
|
||||||
|
<script type="text/javascript" src="views/conversation_search_view_test.js"></script>
|
||||||
<script type="text/javascript" src="models/conversations_test.js"></script>
|
<script type="text/javascript" src="models/conversations_test.js"></script>
|
||||||
<script type="text/javascript" src="models/messages_test.js"></script>
|
<script type="text/javascript" src="models/messages_test.js"></script>
|
||||||
<script type="text/javascript" src="storage_test.js"></script>
|
<script type="text/javascript" src="storage_test.js"></script>
|
||||||
|
|
24
test/views/conversation_search_view_test.js
Normal file
24
test/views/conversation_search_view_test.js
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
describe('ConversationSearchView', function() {
|
||||||
|
it('should match partial numbers', function() {
|
||||||
|
var $el = $('<div><div class="new-contact contact hide"></div></div>');
|
||||||
|
var view = new Whisper.ConversationSearchView({el: $el, input: $('<input>')}).render();
|
||||||
|
var maybe_numbers = [
|
||||||
|
"+1 415",
|
||||||
|
"+1415",
|
||||||
|
"+1415",
|
||||||
|
"415",
|
||||||
|
"(415)",
|
||||||
|
" (415",
|
||||||
|
"(415) 123 4567",
|
||||||
|
"+1 (415) 123 4567",
|
||||||
|
" +1 (415) 123 4567",
|
||||||
|
"1 (415) 123 4567",
|
||||||
|
"1 415-123-4567",
|
||||||
|
"415-123-4567"
|
||||||
|
];
|
||||||
|
maybe_numbers.forEach(function(n) {
|
||||||
|
assert.ok(view.maybeNumber(n), n);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
Loading…
Reference in a new issue