diff --git a/apps/contacts/js/contacts.js b/apps/contacts/js/contacts.js index 02ce84cc5f..06218e48bc 100644 --- a/apps/contacts/js/contacts.js +++ b/apps/contacts/js/contacts.js @@ -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(){ diff --git a/apps/contacts/templates/part.contact.php b/apps/contacts/templates/part.contact.php index 942417c009..8bc0457ed4 100755 --- a/apps/contacts/templates/part.contact.php +++ b/apps/contacts/templates/part.contact.php @@ -125,6 +125,7 @@ $(document).ready(function(){ if(jsondata.status == 'success'){ $('#leftcontent li[data-id=""]').addClass('active'); Contacts.UI.Card.loadContact(jsondata.data); + Contacts.UI.loadHandlers(); } else{ OC.dialogs.alert(jsondata.data.message, t('contacts', 'Error'));