From 861c37925598a9bf5c5ae255b7b781c8b1e5b477 Mon Sep 17 00:00:00 2001 From: Thomas Tanghus Date: Mon, 9 Jul 2012 19:32:37 +0200 Subject: [PATCH] Make sure the proper DOM is loaded and the right address book gets expanded. --- apps/contacts/js/contacts.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/apps/contacts/js/contacts.js b/apps/contacts/js/contacts.js index 3005126b71d..dd194db0161 100644 --- a/apps/contacts/js/contacts.js +++ b/apps/contacts/js/contacts.js @@ -316,7 +316,7 @@ Contacts={ $('#contacts li[data-id="'+newid+'"]').addClass('active'); $.getJSON(OC.filePath('contacts', 'ajax', 'contactdetails.php'),{'id':newid},function(jsondata){ if(jsondata.status == 'success'){ - $('#contacts h3[data-id="'+bookid+'"]').trigger('click'); + $('#contacts ul[data-id="'+bookid+'"]').slideDown(300); Contacts.UI.Card.loadContact(jsondata.data, bookid); } else { OC.dialogs.alert(jsondata.data.message, t('contacts', 'Error')); @@ -326,7 +326,8 @@ Contacts={ } // Make sure proper DOM is loaded. - if(!$('#card')[0] && newid) { + if(!$('#card').length && newid) { + console.log('Loading card DOM'); $.getJSON(OC.filePath('contacts', 'ajax', 'loadcard.php'),{requesttoken:requesttoken},function(jsondata){ if(jsondata.status == 'success'){ $('#rightcontent').html(jsondata.data.page).ready(function() { @@ -339,6 +340,7 @@ Contacts={ }); } else if(!newid) { + console.log('Loading intro'); // load intro page $.getJSON(OC.filePath('contacts', 'ajax', 'loadintro.php'),{},function(jsondata){ if(jsondata.status == 'success'){ @@ -370,6 +372,7 @@ Contacts={ return $('
  • '+data.displayname+'
  • '); }, add:function(n, fn, aid, isnew){ // add a new contact + console.log('Adding ' + fn); aid = aid?aid:$('#contacts h3.active').first().data('id'); var localAddcontact = function(n, fn, aid, isnew) { $.post(OC.filePath('contacts', 'ajax', 'addcontact.php'), { n: n, fn: fn, aid: aid, isnew: isnew }, @@ -413,8 +416,8 @@ Contacts={ }); } - var card = $('#card')[0]; - if(!card) { + if(!$('#card').length) { + console.log('Loading card DOM'); $.getJSON(OC.filePath('contacts', 'ajax', 'loadcard.php'),{'requesttoken': requesttoken},function(jsondata){ if(jsondata.status == 'success'){ $('#rightcontent').html(jsondata.data.page).ready(function() { @@ -1604,10 +1607,10 @@ Contacts={ firstrun = true; if($('#contacts h3').length == 0) { - $('#contacts').html('

    '+book.displayname+'

    '); + $('#contacts').html('

    '+book.displayname+'

    '); } else { if(!$('#contacts h3[data-id="'+b+'"]').length) { - $('

    '+book.displayname+'

    ') + $('

    '+book.displayname+'

    ') .appendTo('#contacts'); } } -- 2.39.5