mirror of
https://github.com/owncloudarchive/contacts.git
synced 2025-01-19 08:52:22 +01:00
More changes for updating the contacts list.
This commit is contained in:
parent
1f6bb63f8d
commit
b3b67ab2cb
@ -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 )));
|
||||
|
@ -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');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user