1
0
mirror of https://github.com/owncloudarchive/contacts.git synced 2025-01-18 07:52:21 +01:00

Open contact from search without reloading app.

This commit is contained in:
Thomas Tanghus 2012-11-01 02:01:00 +01:00
parent 09843741e3
commit 307409b7e2
4 changed files with 27 additions and 8 deletions

View File

@ -452,10 +452,10 @@ OC.Contacts = OC.Contacts || {
message: 'error in: ' + settings.url + ', '+'error: ' + xhr.responseText,
});
});
if(id) {
//if(id) {
this.currentid = parseInt(id);
console.log('init, id:', id);
}
//}
// Holds an array of {id,name} maps
this.scrollTimeoutMiliSecs = 100;
this.isScrolling = false;
@ -583,6 +583,7 @@ OC.Contacts = OC.Contacts || {
self.loading(self.$rightContent, false);
self.Groups.loadGroups(self.numcontacts, function() {
self.loading($('#leftcontent'), false);
console.log('Groups loaded, currentid', self.currentid);
if(self.currentid) {
self.openContact(self.currentid);
}
@ -1053,14 +1054,19 @@ OC.Contacts = OC.Contacts || {
},
closeContact: function(id) {
if(typeof this.currentid === 'number') {
this.Contacts.findById(id).close();
if(this.Contacts.findById(id).close()) {
this.$contactList.show();
this.jumpToContact(id);
delete this.currentid;
}
}
this.$groups.find('optgroup,option:not([value="-1"])').remove();
},
openContact: function(id) {
console.log('Contacts.openContact', id);
if(this.currentid) {
this.closeContact(this.currentid);
}
this.currentid = parseInt(id);
this.$contactList.hide();
this.$toggleAll.hide();

View File

@ -255,6 +255,9 @@ OC.Contacts = OC.Contacts || {};
console.log('Contact.close', this);
if(this.$fullelem) {
this.$fullelem.remove();
return true;
} else {
return false;
}
}

View File

@ -76,6 +76,15 @@ Contacts_Import={
});
}
}
var openContact = function(id) {
if(typeof OC.Contacts !== 'undefined') {
OC.Contacts.openContact(id);
} else {
window.location.href = OC.linkTo('contacts', 'index.php') + '?id=' + id;
}
}
$(document).ready(function(){
if(typeof FileActions !== 'undefined'){
FileActions.register('text/vcard','importaddressbook', OC.PERMISSION_READ, '', Contacts_Import.importdialog);

View File

@ -9,12 +9,13 @@ class SearchProvider extends \OC_Search_Provider{
return array();
}
$results=array();
$l = new OC_l10n('contacts');
$l = new \OC_l10n('contacts');
foreach($addressbooks as $addressbook) {
$vcards = VCard::all($addressbook['id']);
foreach($vcards as $vcard) {
if(substr_count(strtolower($vcard['fullname']), strtolower($query)) > 0) {
$link = \OCP\Util::linkTo('contacts', 'index.php').'?id='.urlencode($vcard['id']);
//$link = \OCP\Util::linkTo('contacts', 'index.php').'?id='.urlencode($vcard['id']);
$link = 'javascript:openContact(' . $vcard['id'] . ')';
$results[]=new \OC_Search_Result($vcard['fullname'], '', $link, (string)$l->t('Contact'));//$name,$text,$link,$type
}
}