Contacts: Improve loading contact.

This commit is contained in:
Thomas Tanghus 2012-05-03 11:11:26 +02:00
parent 6cc9f600d2
commit 15be032740
2 changed files with 27 additions and 18 deletions

View File

@ -174,29 +174,27 @@ Contacts={
} else {
newid = id;
}
if($('#contacts li').length > 0) {
if(!$('n')) {
$.getJSON(OC.filePath('contacts', 'ajax', 'loadcard.php'),{},function(jsondata){
if(jsondata.status == 'success'){
$('#rightcontent').html(jsondata.data.page);
Contacts.UI.loadHandlers();
if($('#contacts li').length > 0) {
//var newid = $('#contacts li:first-child').data('id');
//$('#contacts li:first-child').addClass('active');
$('#leftcontent li[data-id="'+newid+'"]').addClass('active');
$.getJSON(OC.filePath('contacts', 'ajax', 'contactdetails.php'),{'id':newid},function(jsondata){
if(jsondata.status == 'success'){
Contacts.UI.Card.loadContact(jsondata.data);
} else{
OC.dialogs.alert(jsondata.data.message, t('contacts', 'Error'));
}
});
}
} else{
} else {
OC.dialogs.alert(jsondata.data.message, t('contacts', 'Error'));
}
});
}
if($('#contacts li').length == 0) {
if($('#contacts li').length > 0) {
//var newid = $('#contacts li:first-child').data('id');
//$('#contacts li:first-child').addClass('active');
$('#leftcontent li[data-id="'+newid+'"]').addClass('active');
$.getJSON(OC.filePath('contacts', 'ajax', 'contactdetails.php'),{'id':newid},function(jsondata){
if(jsondata.status == 'success'){
Contacts.UI.Card.loadContact(jsondata.data);
} else {
OC.dialogs.alert(jsondata.data.message, t('contacts', 'Error'));
}
});
} else if($('#contacts li').length == 0) {
// load intro page
$.getJSON(OC.filePath('contacts', 'ajax', 'loadintro.php'),{},function(jsondata){
if(jsondata.status == 'success'){
@ -1446,10 +1444,20 @@ $(document).ready(function(){
$('#contacts_newcontact').keydown(Contacts.UI.Card.editNew);
$('#contacts_deletecard').click( function() { Contacts.UI.Card.doDelete();return false;} );
$('#contacts_deletecard').keydown( function() { Contacts.UI.Card.doDelete();return false;} );
$('#contacts_deletecard').keydown( function(event) {
if(event.which == 13) {
Contacts.UI.Card.doDelete();
}
return false;
});
$('#contacts_downloadcard').click( function() { Contacts.UI.Card.doExport();return false;} );
$('#contacts_downloadcard').keydown( function() { Contacts.UI.Card.doExport();return false;} );
$('#contacts_downloadcard').keydown( function(event) {
if(event.which == 13) {
Contacts.UI.Card.doExport();
}
return false;
});
// Load a contact.
$('#leftcontent li').click(function(){

View File

@ -125,6 +125,7 @@ $(document).ready(function(){
if(jsondata.status == 'success'){
$('#leftcontent li[data-id="<?php echo $id; ?>"]').addClass('active');
Contacts.UI.Card.loadContact(jsondata.data);
Contacts.UI.loadHandlers();
}
else{
OC.dialogs.alert(jsondata.data.message, t('contacts', 'Error'));