1
0
mirror of https://github.com/owncloudarchive/contacts.git synced 2024-12-01 13:24:10 +01:00
OwncloudContactsOfficial/js/interface.js

154 lines
4.6 KiB
JavaScript
Raw Normal View History

2011-08-06 22:32:06 +02:00
$(document).ready(function(){
2011-08-09 13:53:58 +02:00
/* $('.contacts_addressbooksexpander').click(function(){
$('.contacts_addressbooksdetails').toggle();
return false;
});*/
2011-08-11 10:08:02 +02:00
$('#leftcontent li').live('click',function(){
var id = $(this).data('id');
2011-08-09 13:53:58 +02:00
$.getJSON('ajax/getdetails.php',{'id':id},function(jsondata){
2011-08-06 22:32:06 +02:00
if(jsondata.status == 'success'){
2011-08-11 10:08:02 +02:00
$('#rightcontent').data('id',jsondata.data.id);
$('#rightcontent').html(jsondata.data.page);
2011-08-06 22:32:06 +02:00
}
else{
alert(jsondata.data.message);
}
});
return false;
});
2011-08-06 23:29:25 +02:00
2011-08-09 13:53:58 +02:00
$('#contacts_deletecard').live('click',function(){
2011-08-11 10:08:02 +02:00
var id = $('#rightcontent').data('id');
2011-08-09 13:53:58 +02:00
$.getJSON('ajax/deletecard.php',{'id':id},function(jsondata){
if(jsondata.status == 'success'){
2011-08-11 10:08:02 +02:00
$('#leftcontent [data-id="'+jsondata.data.id+'"]').remove();
$('#rightcontent').data('id','');
$('#rightcontent').html('');
2011-08-09 13:53:58 +02:00
}
else{
alert(jsondata.data.message);
}
});
return false;
});
$('#contacts_addproperty').live('click',function(){
2011-08-11 10:08:02 +02:00
var id = $('#rightcontent').data('id');
2011-08-09 13:53:58 +02:00
$.getJSON('ajax/showaddproperty.php',{'id':id},function(jsondata){
if(jsondata.status == 'success'){
2011-08-11 10:08:02 +02:00
$('#rightcontent').append(jsondata.data.page);
2011-08-09 13:53:58 +02:00
}
else{
alert(jsondata.data.message);
}
});
2011-08-06 23:29:25 +02:00
return false;
});
2011-08-09 13:53:58 +02: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 13:53:58 +02:00
$('#contacts_addpropertyform').remove();
$('#contacts_addcontactsparts').remove();
2011-08-09 13:53:58 +02: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 10:08:02 +02:00
$('#rightcontent').data('id','');
$('#rightcontent').html(jsondata.data.page);
2011-08-09 13:53:58 +02: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 10:08:02 +02:00
$('#rightcontent').data('id',jsondata.data.id);
$('#rightcontent').html(jsondata.data.page);
2011-08-09 13:53:58 +02:00
}
else{
alert(jsondata.data.message);
}
}, 'json');
return false;
});
$('.contacts_property [data-use="edit"]').live('click',function(){
2011-08-11 10:08:02 +02: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 13:53:58 +02:00
if(jsondata.status == 'success'){
$('.contacts_property[data-checksum="'+checksum+'"] .contacts_propertyvalue').html(jsondata.data.page);
2011-08-09 13:53:58 +02: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'){
$('.contacts_property[data-checksum="'+jsondata.data.oldchecksum+'"]').replaceWith(jsondata.data.page);
2011-08-09 13:53:58 +02:00
}
else{
alert(jsondata.data.message);
}
},'json');
return false;
});
$('.contacts_property [data-use="delete"]').live('click',function(){
2011-08-11 10:08:02 +02: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 13:53:58 +02:00
if(jsondata.status == 'success'){
$('.contacts_property[data-checksum="'+checksum+'"]').remove();
2011-08-09 13:53:58 +02:00
}
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();
});
2011-08-06 22:32:06 +02:00
});