phone: look for phone number in contacts (#8788)

This commit is contained in:
Frédéric Péters 2015-11-03 17:15:12 +01:00
parent b16e6de751
commit e78ec2f38e
1 changed files with 7 additions and 3 deletions

View File

@ -1,5 +1,5 @@
$(function() {
function refresh_bottom_cells() {
function refresh_bottom_cells(callback) {
var source_type = $('div.source div[data-source-type]').data('source-type');
var source_pk = $('div.source .active[data-source-pk]').data('source-pk');
$('.cell[data-zone-url]').each(function(idx, zone) {
@ -13,6 +13,7 @@ $(function() {
$(zone).find('select').select2();
$(zone).removeClass('has-page-displayed');
$(zone).removeClass('has-contact-displayed');
if (typeof(callback) === 'function') callback();
},
error: function(error) { console.log(':(', error); }
});
@ -369,7 +370,6 @@ $(function() {
});
if ($('.source-phone').length) {
var zone = $('.source-phone .source [data-zone-url]');
function check_calls() {
if ($('.phonecall').length) { /* active phone call */
} else {
@ -379,11 +379,15 @@ $(function() {
success: function(response) {
if (response.data.calls.length != 0) {
/* got a call */
var caller = response.data.calls[0].caller;
var zone = $('.source-phone .source [data-zone-url]');
$.ajax({url: zone.data('zone-url'),
dataType: 'html',
success: function(data) {
$(zone).parent('div').html(data);
refresh_bottom_cells();
refresh_bottom_cells(function() {
$('.contacts input[name=q]').val(caller).trigger('keyup');
});
}
});
} else {