2012-01-05 01:36:34 +04:00
|
|
|
/**
|
|
|
|
* ownCloud - Addressbook
|
|
|
|
*
|
|
|
|
* @author Jakob Sack
|
|
|
|
* @copyright 2011 Jakob Sack mail@jakobsack.de
|
|
|
|
* @copyright 2011-2012 Thomas Tanghus <thomas@tanghus.net>
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 3 of the License, or any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public
|
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2011-12-04 23:25:46 +04:00
|
|
|
Contacts={
|
|
|
|
UI:{
|
|
|
|
showCardDAVUrl:function(username, bookname){
|
|
|
|
$('#carddav_url').val(totalurl + '/' + username + '/' + bookname);
|
|
|
|
$('#carddav_url').show();
|
|
|
|
$('#carddav_url_close').show();
|
|
|
|
},
|
2012-01-10 17:59:31 +04:00
|
|
|
messageBox:function(title, msg) {
|
2012-01-11 06:56:53 +04:00
|
|
|
if($('#messagebox').dialog('isOpen') == true){
|
|
|
|
// NOTE: Do we ever get here?
|
|
|
|
$('#messagebox').dialog('moveToTop');
|
|
|
|
}else{
|
|
|
|
$('#dialog_holder').load(OC.filePath('contacts', 'ajax', 'messagebox.php'), function(){
|
|
|
|
$('#messagebox').dialog(
|
2012-01-10 17:59:31 +04:00
|
|
|
{
|
2012-01-11 06:56:53 +04:00
|
|
|
autoOpen: true,
|
|
|
|
title: title,
|
|
|
|
buttons: [{
|
|
|
|
text: "Ok",
|
|
|
|
click: function() { $(this).dialog("close"); }
|
|
|
|
}],
|
|
|
|
close: function(event, ui) {
|
|
|
|
$(this).dialog('destroy').remove();
|
|
|
|
},
|
|
|
|
open: function(event, ui) {
|
|
|
|
$('#messagebox_msg').html(msg);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
2012-01-10 17:59:31 +04:00
|
|
|
},
|
2011-12-04 23:25:46 +04:00
|
|
|
Addressbooks:{
|
|
|
|
overview:function(){
|
|
|
|
if($('#chooseaddressbook_dialog').dialog('isOpen') == true){
|
|
|
|
$('#chooseaddressbook_dialog').dialog('moveToTop');
|
|
|
|
}else{
|
|
|
|
$('#dialog_holder').load(OC.filePath('contacts', 'ajax', 'chooseaddressbook.php'), function(){
|
|
|
|
$('#chooseaddressbook_dialog').dialog({
|
|
|
|
width : 600,
|
|
|
|
close : function(event, ui) {
|
|
|
|
$(this).dialog('destroy').remove();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
activation:function(checkbox, bookid)
|
|
|
|
{
|
|
|
|
$.post(OC.filePath('contacts', 'ajax', 'activation.php'), { bookid: bookid, active: checkbox.checked?1:0 },
|
|
|
|
function(data) {
|
|
|
|
/*
|
|
|
|
* Arguments:
|
|
|
|
* data.status
|
|
|
|
* data.bookid
|
2011-12-11 19:26:00 +04:00
|
|
|
* data.active
|
2011-12-04 23:25:46 +04:00
|
|
|
*/
|
|
|
|
if (data.status == 'success'){
|
|
|
|
checkbox.checked = data.active == 1;
|
2011-12-11 19:26:00 +04:00
|
|
|
Contacts.UI.Contacts.update();
|
2011-12-04 23:25:46 +04:00
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
newAddressbook:function(object){
|
|
|
|
var tr = $(document.createElement('tr'))
|
|
|
|
.load(OC.filePath('contacts', 'ajax', 'addbook.php'));
|
|
|
|
$(object).closest('tr').after(tr).hide();
|
|
|
|
/* TODO: Shouldn't there be some kinda error checking here? */
|
|
|
|
},
|
2011-12-05 06:38:06 +04:00
|
|
|
editAddressbook:function(object, bookid){
|
|
|
|
var tr = $(document.createElement('tr'))
|
|
|
|
.load(OC.filePath('contacts', 'ajax', 'editaddressbook.php') + "?bookid="+bookid);
|
|
|
|
$(object).closest('tr').after(tr).hide();
|
|
|
|
},
|
2011-12-04 23:25:46 +04:00
|
|
|
deleteAddressbook:function(bookid){
|
|
|
|
var check = confirm("Do you really want to delete this address book?");
|
|
|
|
if(check == false){
|
|
|
|
return false;
|
|
|
|
}else{
|
|
|
|
$.post(OC.filePath('contacts', 'ajax', 'deletebook.php'), { id: bookid},
|
|
|
|
function(data) {
|
|
|
|
if (data.status == 'success'){
|
2011-12-05 06:38:06 +04:00
|
|
|
$('#chooseaddressbook_dialog').dialog('destroy').remove();
|
2011-12-09 18:10:51 +04:00
|
|
|
Contacts.UI.Contacts.update();
|
2011-12-04 23:25:46 +04:00
|
|
|
Contacts.UI.Addressbooks.overview();
|
2011-12-05 06:38:06 +04:00
|
|
|
} else {
|
2012-01-11 23:07:15 +04:00
|
|
|
Contacts.UI.messageBox(t('contacts', 'Error'), data.message);
|
2012-01-10 17:59:31 +04:00
|
|
|
//alert('Error: ' + data.message);
|
2011-12-04 23:25:46 +04:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
submit:function(button, bookid){
|
2011-12-05 06:38:06 +04:00
|
|
|
var displayname = $("#displayname_"+bookid).val();
|
|
|
|
var active = $("#edit_active_"+bookid+":checked").length;
|
|
|
|
var description = $("#description_"+bookid).val();
|
2011-12-04 23:25:46 +04:00
|
|
|
|
|
|
|
var url;
|
2011-12-05 06:38:06 +04:00
|
|
|
if (bookid == 'new'){
|
|
|
|
url = OC.filePath('contacts', 'ajax', 'createaddressbook.php');
|
2011-12-04 23:25:46 +04:00
|
|
|
}else{
|
2011-12-05 06:38:06 +04:00
|
|
|
url = OC.filePath('contacts', 'ajax', 'updateaddressbook.php');
|
2011-12-04 23:25:46 +04:00
|
|
|
}
|
2011-12-05 06:38:06 +04:00
|
|
|
$.post(url, { id: bookid, name: displayname, active: active, description: description },
|
2011-12-04 23:25:46 +04:00
|
|
|
function(data){
|
|
|
|
if(data.status == 'success'){
|
|
|
|
$(button).closest('tr').prev().html(data.page).show().next().remove();
|
|
|
|
}
|
2011-12-05 06:38:06 +04:00
|
|
|
});
|
2011-12-16 20:42:07 +04:00
|
|
|
Contacts.UI.Contacts.update();
|
2011-12-04 23:25:46 +04:00
|
|
|
},
|
|
|
|
cancel:function(button, bookid){
|
|
|
|
$(button).closest('tr').prev().show().next().remove();
|
|
|
|
}
|
2011-12-11 19:26:00 +04:00
|
|
|
},
|
|
|
|
Contacts:{
|
2012-01-10 17:59:31 +04:00
|
|
|
/**
|
|
|
|
* Reload the contacts list.
|
|
|
|
*/
|
2011-12-11 19:26:00 +04:00
|
|
|
update:function(){
|
|
|
|
$.getJSON('ajax/contacts.php',{},function(jsondata){
|
|
|
|
if(jsondata.status == 'success'){
|
|
|
|
$('#contacts').html(jsondata.data.page);
|
|
|
|
}
|
|
|
|
else{
|
2012-01-11 23:07:15 +04:00
|
|
|
Contacts.UI.messageBox(t('contacts', 'Error'),jsondata.data.message);
|
2012-01-10 17:59:31 +04:00
|
|
|
//alert(jsondata.data.message);
|
2011-12-11 19:26:00 +04:00
|
|
|
}
|
|
|
|
});
|
2012-01-10 17:59:31 +04:00
|
|
|
setTimeout(Contacts.UI.Contacts.lazyupdate, 500);
|
2011-12-28 13:31:45 +04:00
|
|
|
},
|
2012-01-10 17:59:31 +04:00
|
|
|
/**
|
|
|
|
* Add thumbnails to the contact list as they become visible in the viewport.
|
|
|
|
*/
|
2011-12-28 13:31:45 +04:00
|
|
|
lazyupdate:function(){
|
|
|
|
$('#contacts li').live('inview', function(){
|
2011-12-31 02:39:31 +04:00
|
|
|
if (!$(this).find('a').attr('style')) {
|
|
|
|
$(this).find('a').css('background','url(thumbnail.php?id='+$(this).data('id')+') no-repeat');
|
2012-01-10 17:59:31 +04:00
|
|
|
}
|
2011-12-28 13:31:45 +04:00
|
|
|
});
|
2011-12-11 19:26:00 +04:00
|
|
|
}
|
2011-12-04 23:25:46 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-08-07 00:32:06 +04:00
|
|
|
$(document).ready(function(){
|
2011-09-09 01:36:47 +04:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* Event handlers
|
|
|
|
*-----------------------------------------------------------------------*/
|
2012-01-11 06:56:53 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Load the details view for a contact.
|
|
|
|
*/
|
2011-08-11 12:08:02 +04:00
|
|
|
$('#leftcontent li').live('click',function(){
|
2011-08-09 19:42:54 +04:00
|
|
|
var id = $(this).data('id');
|
2011-09-09 01:36:47 +04:00
|
|
|
var oldid = $('#rightcontent').data('id');
|
|
|
|
if(oldid != 0){
|
|
|
|
$('#leftcontent li[data-id="'+oldid+'"]').removeClass('active');
|
|
|
|
}
|
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-09-09 01:36:47 +04:00
|
|
|
$('#leftcontent li[data-id="'+jsondata.data.id+'"]').addClass('active');
|
2011-08-07 00:32:06 +04:00
|
|
|
}
|
|
|
|
else{
|
2012-01-11 23:07:15 +04:00
|
|
|
Contacts.UI.messageBox(t('contacts', 'Error'), jsondata.data.message);
|
2012-01-10 17:59:31 +04:00
|
|
|
//alert(jsondata.data.message);
|
2011-08-07 00:32:06 +04:00
|
|
|
}
|
|
|
|
});
|
|
|
|
return false;
|
|
|
|
});
|
2011-08-07 01:29:25 +04:00
|
|
|
|
2012-01-11 06:56:53 +04:00
|
|
|
/**
|
|
|
|
* Delete currently selected contact (and clear form?)
|
|
|
|
*/
|
2011-08-09 15:53:58 +04:00
|
|
|
$('#contacts_deletecard').live('click',function(){
|
2012-01-11 09:20:06 +04:00
|
|
|
$('#contacts_deletecard').tipsy('hide');
|
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','');
|
2011-09-29 01:16:32 +04:00
|
|
|
$('#rightcontent').empty();
|
2011-08-09 15:53:58 +04:00
|
|
|
}
|
|
|
|
else{
|
2012-01-11 23:07:15 +04:00
|
|
|
Contacts.UI.messageBox(t('contacts', 'Error'), jsondata.data.message);
|
2012-01-10 17:59:31 +04:00
|
|
|
//alert(jsondata.data.message);
|
2011-08-09 15:53:58 +04:00
|
|
|
}
|
|
|
|
});
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
2012-01-11 06:56:53 +04:00
|
|
|
/**
|
|
|
|
* Add a property to the contact.
|
|
|
|
* NOTE: Where does 'contacts_addproperty' exist?
|
|
|
|
*/
|
2011-08-09 15:53:58 +04:00
|
|
|
$('#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-10-22 21:22:01 +04:00
|
|
|
$('#contacts_details_list').append(jsondata.data.page);
|
|
|
|
$('#contacts_addproperty').hide();
|
2011-08-09 15:53:58 +04:00
|
|
|
}
|
|
|
|
else{
|
2012-01-11 23:07:15 +04:00
|
|
|
Contacts.UI.messageBox(t('contacts', 'Error'), jsondata.data.message);
|
2012-01-11 06:56:53 +04:00
|
|
|
alert('From handler: '+jsondata.data.message);
|
2011-08-09 15:53:58 +04:00
|
|
|
}
|
|
|
|
});
|
2011-08-07 01:29:25 +04:00
|
|
|
return false;
|
|
|
|
});
|
2011-08-09 15:53:58 +04:00
|
|
|
|
2012-01-11 06:56:53 +04:00
|
|
|
/**
|
|
|
|
* Change the inputs based on which type of property is selected for addition.
|
|
|
|
*/
|
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'){
|
2011-10-23 13:35:47 +04:00
|
|
|
$('#contacts_addresspart').clone().insertAfter($('#contacts_addpropertyform .contacts_property_name'));
|
2011-08-09 15:53:58 +04:00
|
|
|
}
|
|
|
|
else if($(this).val() == 'TEL'){
|
2011-10-23 13:35:47 +04:00
|
|
|
$('#contacts_phonepart').clone().insertAfter($('#contacts_addpropertyform .contacts_property_name'));
|
2011-08-09 15:53:58 +04:00
|
|
|
}
|
|
|
|
else{
|
2011-10-23 13:35:47 +04:00
|
|
|
$('#contacts_generic').clone().insertAfter($('#contacts_addpropertyform .contacts_property_name'));
|
2011-08-09 15:53:58 +04:00
|
|
|
}
|
2011-11-25 00:34:50 +04:00
|
|
|
$('#contacts_addpropertyform .contacts_property_data select').chosen();
|
2011-08-09 15:53:58 +04:00
|
|
|
});
|
|
|
|
|
|
|
|
$('#contacts_addpropertyform input[type="submit"]').live('click',function(){
|
|
|
|
$.post('ajax/addproperty.php',$('#contacts_addpropertyform').serialize(),function(jsondata){
|
|
|
|
if(jsondata.status == 'success'){
|
2011-10-22 23:28:20 +04:00
|
|
|
$('#contacts_addpropertyform').before(jsondata.data.page);
|
2011-08-09 15:53:58 +04:00
|
|
|
}
|
|
|
|
else{
|
2012-01-11 23:07:15 +04:00
|
|
|
Contacts.UI.messageBox(t('contacts', 'Error'), jsondata.data.message);
|
2011-08-09 15:53:58 +04:00
|
|
|
}
|
|
|
|
}, 'json');
|
|
|
|
return false;
|
|
|
|
});
|
2011-10-22 21:22:01 +04:00
|
|
|
|
2012-01-11 06:56:53 +04:00
|
|
|
/**
|
|
|
|
* Show the Addressbook chooser
|
|
|
|
*/
|
2011-12-04 23:25:46 +04:00
|
|
|
$('#chooseaddressbook').click(function(){
|
|
|
|
Contacts.UI.Addressbooks.overview();
|
|
|
|
return false;
|
|
|
|
});
|
2012-01-10 01:05:28 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Open blank form to add new contact.
|
|
|
|
*/
|
2011-08-09 15:53:58 +04:00
|
|
|
$('#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','');
|
2011-11-24 00:06:51 +04:00
|
|
|
$('#rightcontent').html(jsondata.data.page)
|
|
|
|
.find('select').chosen();
|
2011-08-09 15:53:58 +04:00
|
|
|
}
|
|
|
|
else{
|
2012-01-11 23:07:15 +04:00
|
|
|
Contacts.UI.messageBox(t('contacts', 'Error'), jsondata.data.message);
|
2012-01-10 17:59:31 +04:00
|
|
|
//alert(jsondata.data.message);
|
2011-08-09 15:53:58 +04:00
|
|
|
}
|
|
|
|
});
|
|
|
|
return false;
|
|
|
|
});
|
2012-01-10 01:05:28 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Add and insert a new contact into the list.
|
|
|
|
*/
|
2011-08-09 15:53:58 +04:00
|
|
|
$('#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-10-04 23:16:48 +04:00
|
|
|
$('#leftcontent .active').removeClass('active');
|
2012-01-10 01:05:28 +04:00
|
|
|
var item = '<li data-id="'+jsondata.data.id+'" class="active"><a href="index.php?id='+jsondata.data.id+'" style="background: url(thumbnail.php?id='+jsondata.data.id+') no-repeat scroll 0% 0% transparent;">'+jsondata.data.name+'</a></li>';
|
|
|
|
var added = false;
|
|
|
|
$('#leftcontent ul li').each(function(){
|
|
|
|
if ($(this).text().toLowerCase() > jsondata.data.name.toLowerCase()) {
|
|
|
|
$(this).before(item).fadeIn('fast');
|
|
|
|
added = true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
if(!added) {
|
|
|
|
$('#leftcontent ul').append(item);
|
|
|
|
}
|
2011-08-09 15:53:58 +04:00
|
|
|
}
|
|
|
|
else{
|
2012-01-11 23:07:15 +04:00
|
|
|
Contacts.UI.messageBox(t('contacts', 'Error'), jsondata.data.message);
|
2012-01-10 17:59:31 +04:00
|
|
|
//alert(jsondata.data.message);
|
2011-08-09 15:53:58 +04:00
|
|
|
}
|
|
|
|
}, 'json');
|
|
|
|
return false;
|
|
|
|
});
|
2012-01-11 06:56:53 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Show inputs for editing a property.
|
|
|
|
*/
|
2011-10-22 21:22:01 +04:00
|
|
|
$('.contacts_property [data-use="edit"]').live('click',function(){
|
2011-08-11 12:08:02 +04:00
|
|
|
var id = $('#rightcontent').data('id');
|
2011-12-03 00:24:48 +04:00
|
|
|
var checksum = $(this).parents('.contacts_property').first().data('checksum');
|
2011-08-09 19:42:54 +04:00
|
|
|
$.getJSON('ajax/showsetproperty.php',{'id': id, 'checksum': checksum },function(jsondata){
|
2011-08-09 15:53:58 +04:00
|
|
|
if(jsondata.status == 'success'){
|
2011-11-24 00:06:51 +04:00
|
|
|
$('.contacts_property[data-checksum="'+checksum+'"]').html(jsondata.data.page)
|
|
|
|
.find('select').chosen();
|
2011-08-09 15:53:58 +04:00
|
|
|
}
|
|
|
|
else{
|
2012-01-11 23:07:15 +04:00
|
|
|
Contacts.UI.messageBox(t('contacts', 'Error'), jsondata.data.message);
|
2012-01-10 17:59:31 +04:00
|
|
|
//alert(jsondata.data.message);
|
2011-08-09 15:53:58 +04:00
|
|
|
}
|
|
|
|
});
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
2012-01-11 06:56:53 +04:00
|
|
|
/**
|
|
|
|
* Save the edited property
|
|
|
|
*/
|
2011-08-09 15:53:58 +04:00
|
|
|
$('#contacts_setpropertyform input[type="submit"]').live('click',function(){
|
2011-10-22 21:22:01 +04:00
|
|
|
$.post('ajax/setproperty.php',$(this).parents('form').first().serialize(),function(jsondata){
|
2011-08-09 15:53:58 +04:00
|
|
|
if(jsondata.status == 'success'){
|
2011-10-22 21:22:01 +04:00
|
|
|
$('.contacts_property[data-checksum="'+jsondata.data.oldchecksum+'"]').replaceWith(jsondata.data.page);
|
2011-08-09 15:53:58 +04:00
|
|
|
}
|
|
|
|
else{
|
2012-01-11 23:07:15 +04:00
|
|
|
Contacts.UI.messageBox(t('contacts', 'Error'), jsondata.data.message);
|
2012-01-10 17:59:31 +04:00
|
|
|
//alert(jsondata.data.message);
|
2011-08-09 15:53:58 +04:00
|
|
|
}
|
|
|
|
},'json');
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
2011-10-22 21:22:01 +04:00
|
|
|
$('.contacts_property [data-use="delete"]').live('click',function(){
|
2011-08-11 12:08:02 +04:00
|
|
|
var id = $('#rightcontent').data('id');
|
2011-10-22 21:22:01 +04:00
|
|
|
var checksum = $(this).parents('li').first().data('checksum');
|
2011-08-09 19:42:54 +04:00
|
|
|
$.getJSON('ajax/deleteproperty.php',{'id': id, 'checksum': checksum },function(jsondata){
|
2011-08-09 15:53:58 +04:00
|
|
|
if(jsondata.status == 'success'){
|
2011-10-22 21:22:01 +04:00
|
|
|
$('.contacts_property[data-checksum="'+checksum+'"]').remove();
|
2011-08-09 15:53:58 +04:00
|
|
|
}
|
|
|
|
else{
|
2012-01-11 23:07:15 +04:00
|
|
|
Contacts.UI.messageBox(t('contacts', 'Error'), jsondata.data.message);
|
2012-01-10 17:59:31 +04:00
|
|
|
//alert(jsondata.data.message);
|
2011-08-09 15:53:58 +04:00
|
|
|
}
|
|
|
|
});
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2011-10-22 21:22:01 +04:00
|
|
|
$('.contacts_property').live('mouseenter',function(){
|
2011-11-24 00:06:51 +04:00
|
|
|
$(this).find('span[data-use]').show();
|
2011-08-09 15:53:58 +04:00
|
|
|
});
|
2011-10-22 21:22:01 +04:00
|
|
|
|
|
|
|
$('.contacts_property').live('mouseleave',function(){
|
2011-11-24 00:06:51 +04:00
|
|
|
$(this).find('span[data-use]').hide();
|
2011-08-09 15:53:58 +04:00
|
|
|
});
|
2011-11-24 00:06:51 +04:00
|
|
|
|
|
|
|
$('#contacts_addcardform select').chosen();
|
2011-12-17 23:05:54 +04:00
|
|
|
|
|
|
|
$('#contacts li').bind('inview', function(event, isInView, visiblePartX, visiblePartY) {
|
|
|
|
if (isInView) { //NOTE: I've kept all conditions for future reference ;-)
|
|
|
|
// element is now visible in the viewport
|
|
|
|
if (visiblePartY == 'top') {
|
|
|
|
// top part of element is visible
|
|
|
|
} else if (visiblePartY == 'bottom') {
|
|
|
|
// bottom part of element is visible
|
|
|
|
} else {
|
|
|
|
// whole part of element is visible
|
2011-12-31 02:39:31 +04:00
|
|
|
if (!$(this).find('a').attr('style')) {
|
2011-12-17 23:05:54 +04:00
|
|
|
//alert($(this).data('id') + ' has background: ' + $(this).attr('style'));
|
2011-12-31 02:39:31 +04:00
|
|
|
$(this).find('a').css('background','url(thumbnail.php?id='+$(this).data('id')+') no-repeat');
|
2011-12-17 23:05:54 +04:00
|
|
|
}/* else {
|
|
|
|
alert($(this).data('id') + ' has style ' + $(this).attr('style').match('url'));
|
|
|
|
}*/
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// element has gone out of viewport
|
|
|
|
}
|
|
|
|
});
|
2012-01-10 01:05:28 +04:00
|
|
|
|
|
|
|
$('.button').tipsy();
|
2012-01-10 17:59:31 +04:00
|
|
|
//Contacts.UI.messageBox('Hello','Sailor');
|
2011-08-07 00:32:06 +04:00
|
|
|
});
|