summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorThomas Tanghus <thomas@tanghus.net>2012-06-20 21:00:07 +0200
committerThomas Tanghus <thomas@tanghus.net>2012-06-20 21:00:49 +0200
commit10a0d5a46c277ed342f19946b451db1082fb41c5 (patch)
tree9e2abb2a3a1b530ffd32f96d9015f57d066b104d /apps
parentdc8c188ffed520b719a117564db78b0a23828a75 (diff)
downloadnextcloud-server-10a0d5a46c277ed342f19946b451db1082fb41c5.tar.gz
nextcloud-server-10a0d5a46c277ed342f19946b451db1082fb41c5.zip
More changes for updating the contacts list.
Diffstat (limited to 'apps')
-rw-r--r--apps/contacts/ajax/addcontact.php2
-rw-r--r--apps/contacts/js/contacts.js32
2 files changed, 20 insertions, 14 deletions
diff --git a/apps/contacts/ajax/addcontact.php b/apps/contacts/ajax/addcontact.php
index e45072c9542..12f7bb9db96 100644
--- a/apps/contacts/ajax/addcontact.php
+++ b/apps/contacts/ajax/addcontact.php
@@ -47,4 +47,4 @@ if(!$id) {
exit();
}
-OCP\JSON::success(array('data' => array( 'id' => $id )));
+OCP\JSON::success(array('data' => array( 'id' => $id, 'aid' => $aid )));
diff --git a/apps/contacts/js/contacts.js b/apps/contacts/js/contacts.js
index 2319334c58b..8ab2a3fbb88 100644
--- a/apps/contacts/js/contacts.js
+++ b/apps/contacts/js/contacts.js
@@ -174,7 +174,7 @@ Contacts={
// TODO: Take addressbook into account
$('#fn').change(function(){
var name = $('#fn').val().strip_tags();
- var item = $('.contacts [data-id="'+Contacts.UI.Card.id+'"]');
+ var item = $('.contacts li[data-id="'+Contacts.UI.Card.id+'"]');
$(item).find('a').html(name);
Contacts.UI.Card.fn = name;
var added = false;
@@ -186,7 +186,7 @@ Contacts={
}
});
if(!added) {
- $('#leftcontent ul[data-id="'+Contacts.UI.Card.bookid+'"]').append(item);
+ $('#contacts ul[data-id="'+Contacts.UI.Card.bookid+'"]').append(item);
}
Contacts.UI.Contacts.scrollTo(Contacts.UI.Card.id);
});
@@ -250,8 +250,10 @@ Contacts={
var newid, firstitem;
if(!id) {
firstitem = $('#contacts:first-child li:first-child');
- newid = firstitem.data('id');
- bookid = firstitem.data('bookid');
+ if(firstitem.length > 0) {
+ newid = firstitem.data('id');
+ bookid = firstitem.data('bookid');
+ }
} else {
newid = id;
}
@@ -269,7 +271,7 @@ Contacts={
}
// Make sure proper DOM is loaded.
- if(!$('#card')[0]) {
+ if(!$('#card')[0] && newid) {
$.getJSON(OC.filePath('contacts', 'ajax', 'loadcard.php'),{},function(jsondata){
if(jsondata.status == 'success'){
$('#rightcontent').html(jsondata.data.page).ready(function() {
@@ -281,7 +283,7 @@ Contacts={
}
});
}
- else if($('.contacts li').length == 0) {
+ else if(!newid) {
// load intro page
$.getJSON(OC.filePath('contacts', 'ajax', 'loadintro.php'),{},function(jsondata){
if(jsondata.status == 'success'){
@@ -316,13 +318,14 @@ Contacts={
if (jsondata.status == 'success'){
$('#rightcontent').data('id',jsondata.data.id);
var id = jsondata.data.id;
+ var aid = jsondata.data.aid;
$.getJSON(OC.filePath('contacts', 'ajax', 'contactdetails.php'),{'id':id},function(jsondata){
if(jsondata.status == 'success'){
Contacts.UI.Card.loadContact(jsondata.data, aid);
- $('#leftcontent .active').removeClass('active');
+ $('#contacts .active').removeClass('active');
var item = $('<li data-id="'+jsondata.data.id+'" class="active"><a href="index.php?id='+jsondata.data.id+'" style="background: url('+OC.filePath('contacts', '', 'thumbnail.php')+'?id='+jsondata.data.id+') no-repeat scroll 0% 0% transparent;">'+Contacts.UI.Card.fn+'</a></li>');
var added = false;
- $('#leftcontent ul li').each(function(){
+ $('#contacts ul[data-id="'+aid+'"] li').each(function(){
if ($(this).text().toLowerCase() > Contacts.UI.Card.fn.toLowerCase()) {
$(this).before(item).fadeIn('fast');
added = true;
@@ -330,7 +333,7 @@ Contacts={
}
});
if(!added) {
- $('#leftcontent ul').append(item);
+ $('#contacts ul[data-id="'+aid+'"]').append(item);
}
if(isnew) { // add some default properties
Contacts.UI.Card.addProperty('EMAIL');
@@ -374,7 +377,7 @@ Contacts={
$.post(OC.filePath('contacts', 'ajax', 'deletecard.php'),{'id':Contacts.UI.Card.id},function(jsondata){
if(jsondata.status == 'success'){
var newid = '', bookid;
- var curlistitem = $('#leftcontent [data-id="'+jsondata.data.id+'"]');
+ var curlistitem = $('#contacts li[data-id="'+jsondata.data.id+'"]');
var newlistitem = curlistitem.prev();
if(newlistitem == undefined) {
newlistitem = curlistitem.next();
@@ -1541,13 +1544,16 @@ Contacts={
});
},
refreshThumbnail:function(id){
- var item = $('.contacts [data-id="'+id+'"]').find('a');
+ var item = $('.contacts li[data-id="'+id+'"]').find('a');
item.html(Contacts.UI.Card.fn);
item.css('background','url('+OC.filePath('contacts', '', 'thumbnail.php')+'?id='+id+'&refresh=1'+Math.random()+') no-repeat');
},
scrollTo:function(id){
- $('.contacts').animate({
- scrollTop: $('#leftcontent li[data-id="'+id+'"]').offset().top-20}, 'slow','swing');
+ var item = $('#contacts li[data-id="'+id+'"]');
+ if(item) {
+ $('.contacts').animate({
+ scrollTop: $('#contacts li[data-id="'+id+'"]').offset().top-20}, 'slow','swing');
+ }
}
}
}