UI part of addressbook merging.

This commit is contained in:
Thomas Tanghus 2012-07-15 21:34:56 +02:00
parent 502f420678
commit 8fba6b9bc7
1 changed files with 15 additions and 6 deletions

View File

@ -1456,20 +1456,26 @@ Contacts={
batchnum:50, batchnum:50,
drop:function(event, ui) { drop:function(event, ui) {
var dragitem = ui.draggable, droptarget = $(this); var dragitem = ui.draggable, droptarget = $(this);
//console.log('Drop ' + dragitem.data('id') +' on: ' + droptarget.data('id')); if(dragitem.is('li')) {
Contacts.UI.Contacts.dropContact(event, dragitem, droptarget);
} else {
Contacts.UI.Contacts.dropAddressbook(event, dragitem, droptarget);
}
},
dropContact:function(event, dragitem, droptarget) {
if(dragitem.data('bookid') == droptarget.data('id')) { if(dragitem.data('bookid') == droptarget.data('id')) {
return false; return false;
} }
var droplist = (droptarget.is('ul'))?droptarget:droptarget.next(); var droplist = (droptarget.is('ul'))?droptarget:droptarget.next();
$.post(OC.filePath('contacts', 'ajax', 'movetoaddressbook.php'), { ids: dragitem.data('id'), aid: $(this).data('id') }, $.post(OC.filePath('contacts', 'ajax', 'movetoaddressbook.php'), { ids: dragitem.data('id'), aid: droptarget.data('id') },
function(jsondata){ function(jsondata){
if(jsondata.status == 'success'){ if(jsondata.status == 'success'){
// Do some inserting/removing/sorting magic // Do some inserting/removing/sorting magic
var name = $(dragitem).find('a').html(); var name = $(dragitem).find('a').html();
var added = false; var added = false;
$(droplist).children().each(function(){ $(droplist).children().each(function(){
if ($(this).text().toLowerCase() > name.toLowerCase()) { if (droptarget.text().toLowerCase() > name.toLowerCase()) {
$(this).before(dragitem.detach()); //.fadeIn('slow'); droptarget.before(dragitem.detach()); //.fadeIn('slow');
added = true; added = true;
return false; return false;
} }
@ -1485,6 +1491,9 @@ Contacts={
} }
}); });
}, },
dropAddressbook:function(event, dragitem, droptarget) {
alert('Dropping address books not implemented yet');
},
// Reload the contacts list. // Reload the contacts list.
update:function(params){ update:function(params){
if(!params) { params = {}; } if(!params) { params = {}; }
@ -1534,7 +1543,7 @@ Contacts={
$('#contacts ul[data-id="'+b+'"]').slideToggle(300); $('#contacts ul[data-id="'+b+'"]').slideToggle(300);
return false; return false;
}); });
var accept = 'li:not([data-bookid="'+b+'"])'; var accept = 'li:not([data-bookid="'+b+'"]),h3:not([data-id="'+b+'"])';
$('#contacts h3[data-id="'+b+'"],#contacts ul[data-id="'+b+'"]').droppable({ $('#contacts h3[data-id="'+b+'"],#contacts ul[data-id="'+b+'"]').droppable({
drop: Contacts.UI.Contacts.drop, drop: Contacts.UI.Contacts.drop,
activeClass: 'ui-state-hover', activeClass: 'ui-state-hover',
@ -1562,7 +1571,7 @@ Contacts={
} }
}); });
if($('#contacts h3').length > 1) { if($('#contacts h3').length > 1) {
$('#contacts li').draggable({ $('#contacts li,#contacts h3').draggable({
revert: 'invalid', revert: 'invalid',
axis: 'y', containment: '#contacts', axis: 'y', containment: '#contacts',
scroll: true, scrollSensitivity: 100, scroll: true, scrollSensitivity: 100,