From 4e684b9e9dd7c31e04d65e506dfe6e0bb0eaccdb Mon Sep 17 00:00:00 2001 From: Thomas Tanghus Date: Sun, 15 Jul 2012 09:54:31 +0200 Subject: [PATCH] Fixed sorting of addressbooks. --- apps/contacts/js/contacts.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/apps/contacts/js/contacts.js b/apps/contacts/js/contacts.js index 25739cc9747..a9fe38ead1a 100644 --- a/apps/contacts/js/contacts.js +++ b/apps/contacts/js/contacts.js @@ -1509,16 +1509,26 @@ Contacts={ $.getJSON(OC.filePath('contacts', 'ajax', 'contacts.php'),opts,function(jsondata){ if(jsondata.status == 'success'){ var books = jsondata.data.entries; - $.each(jsondata.data.entries, function(b, book) { + $.each(books, function(b, book) { if($('#contacts h3[data-id="'+b+'"]').length == 0) { firstrun = true; - // TODO: Make sure address books are sorted properly. if($('#contacts h3').length == 0) { $('#contacts').html('

'+book.displayname+'

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

'+book.displayname+'

') - .appendTo('#contacts'); + var item = $('

'+book.displayname+'

') + var added = false; + $('#contacts h3').each(function(){ + if ($(this).text().toLowerCase() > book.displayname.toLowerCase()) { + $(this).before(item).fadeIn('fast'); + added = true; + return false; + } + }); + if(!added) { + $('#contacts').append(item); + } + } } $('#contacts h3[data-id="'+b+'"]').on('click', function(event) {