diff options
author | Jakob Sack <kde@jakobsack.de> | 2011-08-09 13:53:58 +0200 |
---|---|---|
committer | Jakob Sack <kde@jakobsack.de> | 2011-08-09 13:53:58 +0200 |
commit | 76fc062f27a178be97b2f4bf285f7f07c6361f60 (patch) | |
tree | d69727c82e394f22bd08be14d146890592da3d70 /apps/contacts/js | |
parent | 4e5b6f72c17ec361757495e89d3f1929f3981dbb (diff) | |
download | nextcloud-server-76fc062f27a178be97b2f4bf285f7f07c6361f60.tar.gz nextcloud-server-76fc062f27a178be97b2f4bf285f7f07c6361f60.zip |
Some more work on the address book
Diffstat (limited to 'apps/contacts/js')
-rw-r--r-- | apps/contacts/js/interface.js | 148 |
1 files changed, 143 insertions, 5 deletions
diff --git a/apps/contacts/js/interface.js b/apps/contacts/js/interface.js index 6af160b3927..0aae7d15d45 100644 --- a/apps/contacts/js/interface.js +++ b/apps/contacts/js/interface.js @@ -1,9 +1,15 @@ $(document).ready(function(){ - $('.contacts_contacts').find('li').live('click',function(){ + /* $('.contacts_addressbooksexpander').click(function(){ + $('.contacts_addressbooksdetails').toggle(); + return false; + });*/ + + $('#contacts_contacts li').live('click',function(){ var id = $(this).attr('x-id'); - $.getJSON('details.php',{'id':id},function(jsondata){ + $.getJSON('ajax/getdetails.php',{'id':id},function(jsondata){ if(jsondata.status == 'success'){ - $('.contacts_details').html(jsondata.data.page); + $('#contacts_details').attr('x-id',jsondata.data.id); + $('#contacts_details').html(jsondata.data.page); } else{ alert(jsondata.data.message); @@ -12,8 +18,140 @@ $(document).ready(function(){ return false; }); - $('.contacts_addressbooksexpander').click(function(){ - $('.contacts_addressbooksdetails').toggle(); + $('#contacts_deletecard').live('click',function(){ + var id = $('#contacts_details').attr('x-id'); + $.getJSON('ajax/deletecard.php',{'id':id},function(jsondata){ + if(jsondata.status == 'success'){ + $('#contacts_contacts [x-id="'+jsondata.data.id+'"]').remove(); + $('#contacts_details').attr('x-id',''); + $('#contacts_details').html(''); + } + else{ + alert(jsondata.data.message); + } + }); + return false; + }); + + $('#contacts_addproperty').live('click',function(){ + var id = $('#contacts_details').attr('x-id'); + $.getJSON('ajax/showaddproperty.php',{'id':id},function(jsondata){ + if(jsondata.status == 'success'){ + $('#contacts_details').append(jsondata.data.page); + } + else{ + alert(jsondata.data.message); + } + }); return false; }); + + $('#contacts_addpropertyform [name="name"]').live('change',function(){ + $('#contacts_addpropertyform #contacts_addresspart').remove(); + $('#contacts_addpropertyform #contacts_phonepart').remove(); + $('#contacts_addpropertyform #contacts_fieldpart').remove(); + $('#contacts_addpropertyform #contacts_generic').remove(); + if($(this).val() == 'ADR'){ + $('#contacts_addresspart').clone().insertBefore($('#contacts_addpropertyform input[type="submit"]')); + } + else if($(this).val() == 'TEL'){ + $('#contacts_phonepart').clone().insertBefore($('#contacts_addpropertyform input[type="submit"]')); + } + else if($(this).val() == 'NOTE'){ + $('#contacts_fieldpart').clone().insertBefore($('#contacts_addpropertyform input[type="submit"]')); + } + else{ + $('#contacts_generic').clone().insertBefore($('#contacts_addpropertyform input[type="submit"]')); + } + }); + + $('#contacts_addpropertyform input[type="submit"]').live('click',function(){ + $.post('ajax/addproperty.php',$('#contacts_addpropertyform').serialize(),function(jsondata){ + if(jsondata.status == 'success'){ + $('#contacts_details').append(jsondata.data.page); + $('#contacts_addpropertyform').remove(); + } + else{ + alert(jsondata.data.message); + } + }, 'json'); + return false; + }); + + $('#contacts_newcontact').click(function(){ + $.getJSON('ajax/showaddcard.php',{},function(jsondata){ + if(jsondata.status == 'success'){ + $('#contacts_details').attr('x-id',''); + $('#contacts_details').html(jsondata.data.page); + } + else{ + alert(jsondata.data.message); + } + }); + return false; + }); + + $('#contacts_addcardform input[type="submit"]').live('click',function(){ + $.post('ajax/addcard.php',$('#contacts_addcardform').serialize(),function(jsondata){ + if(jsondata.status == 'success'){ + $('#contacts_details').attr('x-id',jsondata.data.id); + $('#contacts_details').html(jsondata.data.page); + } + else{ + alert(jsondata.data.message); + } + }, 'json'); + return false; + }); + + $('.contacts_property [x-use="edit"]').live('click',function(){ + var id = $('#contacts_details').attr('x-id'); + var checksum = $(this).parent().parent().attr('x-checksum'); + var line = $(this).parent().parent().attr('x-line'); + $.getJSON('ajax/showsetproperty.php',{'id': id, 'checksum': checksum, 'line': line },function(jsondata){ + if(jsondata.status == 'success'){ + $('.contacts_property[x-line="'+line+'"][x-checksum="'+checksum+'"] .contacts_propertyvalue').html(jsondata.data.page); + } + else{ + alert(jsondata.data.message); + } + }); + return false; + }); + + $('#contacts_setpropertyform input[type="submit"]').live('click',function(){ + $.post('ajax/setproperty.php',$('#contacts_setpropertyform').serialize(),function(jsondata){ + if(jsondata.status == 'success'){ + $('.contacts_property[x-line="'+jsondata.data.line+'"][x-checksum="'+jsondata.data.oldchecksum+'"]').replaceWith(jsondata.data.page); + } + else{ + alert(jsondata.data.message); + } + },'json'); + return false; + }); + + $('.contacts_property [x-use="delete"]').live('click',function(){ + var id = $('#contacts_details').attr('x-id'); + var checksum = $(this).parent().parent().attr('x-checksum'); + var line = $(this).parent().parent().attr('x-line'); + $.getJSON('ajax/deleteproperty.php',{'id': id, 'checksum': checksum, 'line': line },function(jsondata){ + if(jsondata.status == 'success'){ + $('.contacts_property[x-line="'+line+'"][x-checksum="'+checksum+'"]').remove(); + } + else{ + alert(jsondata.data.message); + } + }); + return false; + }); + + + $('.contacts_property').live('mouseenter',function(){ + $(this).find('span').show(); + }); + + $('.contacts_property').live('mouseleave',function(){ + $(this).find('span').hide(); + }); }); |