nextcloud/apps/contacts/js/interface.js

154 lines
4.6 KiB
JavaScript
Raw Normal View History

2011-08-07 00:32:06 +04:00
$(document).ready(function(){
2011-08-09 15:53:58 +04:00
/* $('.contacts_addressbooksexpander').click(function(){
$('.contacts_addressbooksdetails').toggle();
return false;
});*/
2011-08-11 12:08:02 +04:00
$('#leftcontent li').live('click',function(){
var id = $(this).data('id');
2011-08-09 15:53:58 +04:00
$.getJSON('ajax/getdetails.php',{'id':id},function(jsondata){
2011-08-07 00:32:06 +04:00
if(jsondata.status == 'success'){
2011-08-11 12:08:02 +04:00
$('#rightcontent').data('id',jsondata.data.id);
$('#rightcontent').html(jsondata.data.page);
2011-08-07 00:32:06 +04:00
}
else{
alert(jsondata.data.message);
}
});
return false;
});
2011-08-07 01:29:25 +04:00
2011-08-09 15:53:58 +04:00
$('#contacts_deletecard').live('click',function(){
2011-08-11 12:08:02 +04:00
var id = $('#rightcontent').data('id');
2011-08-09 15:53:58 +04:00
$.getJSON('ajax/deletecard.php',{'id':id},function(jsondata){
if(jsondata.status == 'success'){
2011-08-11 12:08:02 +04:00
$('#leftcontent [data-id="'+jsondata.data.id+'"]').remove();
$('#rightcontent').data('id','');
$('#rightcontent').html('');
2011-08-09 15:53:58 +04:00
}
else{
alert(jsondata.data.message);
}
});
return false;
});
$('#contacts_addproperty').live('click',function(){
2011-08-11 12:08:02 +04:00
var id = $('#rightcontent').data('id');
2011-08-09 15:53:58 +04:00
$.getJSON('ajax/showaddproperty.php',{'id':id},function(jsondata){
if(jsondata.status == 'success'){
2011-08-11 12:08:02 +04:00
$('#rightcontent').append(jsondata.data.page);
2011-08-09 15:53:58 +04:00
}
else{
alert(jsondata.data.message);
}
});
2011-08-07 01:29:25 +04:00
return false;
});
2011-08-09 15:53:58 +04:00
$('#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{
$('#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_cardoptions').before(jsondata.data.page);
2011-08-09 15:53:58 +04:00
$('#contacts_addpropertyform').remove();
$('#contacts_addcontactsparts').remove();
2011-08-09 15:53:58 +04:00
}
else{
alert(jsondata.data.message);
}
}, 'json');
return false;
});
$('#contacts_newcontact').click(function(){
$.getJSON('ajax/showaddcard.php',{},function(jsondata){
if(jsondata.status == 'success'){
2011-08-11 12:08:02 +04:00
$('#rightcontent').data('id','');
$('#rightcontent').html(jsondata.data.page);
2011-08-09 15:53:58 +04:00
}
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'){
2011-08-11 12:08:02 +04:00
$('#rightcontent').data('id',jsondata.data.id);
$('#rightcontent').html(jsondata.data.page);
2011-08-09 15:53:58 +04:00
}
else{
alert(jsondata.data.message);
}
}, 'json');
return false;
});
2011-08-15 01:48:43 +04:00
$('.contacts_details_property [data-use="edit"]').live('click',function(){
2011-08-11 12:08:02 +04:00
var id = $('#rightcontent').data('id');
var checksum = $(this).parent().parent().data('checksum');
$.getJSON('ajax/showsetproperty.php',{'id': id, 'checksum': checksum },function(jsondata){
2011-08-09 15:53:58 +04:00
if(jsondata.status == 'success'){
2011-08-15 01:48:43 +04:00
$('.contacts_details_property[data-checksum="'+checksum+'"] .contacts_details_right').html(jsondata.data.page);
2011-08-09 15:53:58 +04:00
}
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'){
2011-08-15 01:48:43 +04:00
$('.contacts_details_property[data-checksum="'+jsondata.data.oldchecksum+'"]').replaceWith(jsondata.data.page);
2011-08-09 15:53:58 +04:00
}
else{
alert(jsondata.data.message);
}
},'json');
return false;
});
2011-08-15 01:48:43 +04:00
$('.contacts_details_property [data-use="delete"]').live('click',function(){
2011-08-11 12:08:02 +04:00
var id = $('#rightcontent').data('id');
var checksum = $(this).parent().parent().data('checksum');
$.getJSON('ajax/deleteproperty.php',{'id': id, 'checksum': checksum },function(jsondata){
2011-08-09 15:53:58 +04:00
if(jsondata.status == 'success'){
2011-08-15 01:48:43 +04:00
$('.contacts_details_property[data-checksum="'+checksum+'"]').remove();
2011-08-09 15:53:58 +04:00
}
else{
alert(jsondata.data.message);
}
});
return false;
});
2011-08-15 01:48:43 +04:00
$('.contacts_details_property').live('mouseenter',function(){
2011-08-09 15:53:58 +04:00
$(this).find('span').show();
});
2011-08-15 01:48:43 +04:00
$('.contacts_details_property').live('mouseleave',function(){
2011-08-09 15:53:58 +04:00
$(this).find('span').hide();
});
2011-08-07 00:32:06 +04:00
});