|
|
|
@ -21,31 +21,27 @@ Contacts={ |
|
|
|
|
* data: An object that will be passed as argument to the timeouthandler and clickhandler functions. |
|
|
|
|
*/ |
|
|
|
|
notify:function(params) { |
|
|
|
|
self = this; |
|
|
|
|
if(!self.notifier) { |
|
|
|
|
self.notifier = $('#notification'); |
|
|
|
|
} |
|
|
|
|
self.notifier.text(params.message); |
|
|
|
|
self.notifier.fadeIn(); |
|
|
|
|
self.notifier.on('click', function() { $(this).fadeOut();}); |
|
|
|
|
var notifier = $('#notification'); |
|
|
|
|
notifier.text(params.message); |
|
|
|
|
notifier.fadeIn(); |
|
|
|
|
var timer = setTimeout(function() { |
|
|
|
|
self.notifier.fadeOut(); |
|
|
|
|
notifier.fadeOut(); |
|
|
|
|
if(params.timeouthandler && $.isFunction(params.timeouthandler)) { |
|
|
|
|
params.timeouthandler(self.notifier.data(dataid)); |
|
|
|
|
self.notifier.off('click'); |
|
|
|
|
self.notifier.removeData(dataid); |
|
|
|
|
params.timeouthandler(notifier.data(dataid)); |
|
|
|
|
notifier.off('click'); |
|
|
|
|
notifier.data(dataid, null); |
|
|
|
|
} |
|
|
|
|
}, params.timeout && $.isNumeric(params.timeout) ? parseInt(params.timeout)*1000 : 10000); |
|
|
|
|
var dataid = timer.toString(); |
|
|
|
|
if(params.data) { |
|
|
|
|
self.notifier.data(dataid, params.data); |
|
|
|
|
notifier.data(dataid, params.data); |
|
|
|
|
} |
|
|
|
|
if(params.clickhandler && $.isFunction(params.clickhandler)) { |
|
|
|
|
self.notifier.on('click', function() { |
|
|
|
|
notifier.on('click', function() { |
|
|
|
|
clearTimeout(timer); |
|
|
|
|
self.notifier.off('click'); |
|
|
|
|
params.clickhandler(self.notifier.data(dataid)); |
|
|
|
|
self.notifier.removeData(dataid); |
|
|
|
|
notifier.off('click'); |
|
|
|
|
params.clickhandler(notifier.data(dataid)); |
|
|
|
|
notifier.data(dataid, null); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
@ -299,6 +295,16 @@ Contacts={ |
|
|
|
|
$('#contacts_propertymenu_dropdown a').keydown(propertyMenuItem); |
|
|
|
|
}, |
|
|
|
|
Card:{ |
|
|
|
|
id:'', |
|
|
|
|
fn:'', |
|
|
|
|
fullname:'', |
|
|
|
|
shortname:'', |
|
|
|
|
famname:'', |
|
|
|
|
givname:'', |
|
|
|
|
addname:'', |
|
|
|
|
honpre:'', |
|
|
|
|
honsuf:'', |
|
|
|
|
data:undefined, |
|
|
|
|
update:function(params) { // params {cid:int, aid:int}
|
|
|
|
|
if(!params) { params = {}; } |
|
|
|
|
$('#contacts li,#contacts h3').removeClass('active'); |
|
|
|
@ -578,12 +584,8 @@ Contacts={ |
|
|
|
|
$(this).find('input').val(''); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
with(this) { |
|
|
|
|
delete fn; delete fullname; delete givname; delete famname; |
|
|
|
|
delete addname; delete honpre; delete honsuf; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
this.fn = ''; this.fullname = ''; this.givname = ''; this.famname = ''; this.addname = ''; this.honpre = ''; this.honsuf = ''; |
|
|
|
|
var narray = undefined; |
|
|
|
|
if(this.data.FN) { |
|
|
|
|
this.fn = this.data.FN[0]['value']; |
|
|
|
|
} |
|
|
|
@ -1208,17 +1210,28 @@ Contacts={ |
|
|
|
|
$('#phototools li a').tipsy('hide'); |
|
|
|
|
var wrapper = $('#contacts_details_photo_wrapper'); |
|
|
|
|
wrapper.addClass('loading').addClass('wait'); |
|
|
|
|
delete this.photo; |
|
|
|
|
this.photo = new Image(); |
|
|
|
|
$(this.photo).load(function () { |
|
|
|
|
|
|
|
|
|
var img = new Image(); |
|
|
|
|
$(img).load(function () { |
|
|
|
|
$('img.contacts_details_photo').remove() |
|
|
|
|
$(this).addClass('contacts_details_photo'); |
|
|
|
|
$(this).addClass('contacts_details_photo').hide(); |
|
|
|
|
wrapper.removeClass('loading').removeClass('wait'); |
|
|
|
|
$(this).insertAfter($('#phototools')).fadeIn('fast'); |
|
|
|
|
$(this).insertAfter($('#phototools')).fadeIn(); |
|
|
|
|
}).error(function () { |
|
|
|
|
// notify the user that the image could not be loaded
|
|
|
|
|
Contacts.UI.notify({message:t('contacts','Error loading profile picture.')}); |
|
|
|
|
}).attr('src', OC.linkTo('contacts', 'photo.php')+'?id='+self.id+refreshstr); |
|
|
|
|
|
|
|
|
|
$.getJSON(OC.filePath('contacts', 'ajax', 'loadphoto.php'),{'id':this.id, 'refresh': refresh},function(jsondata){ |
|
|
|
|
if(jsondata.status == 'success'){ |
|
|
|
|
$('#contacts_details_photo_wrapper').data('checksum', jsondata.data.checksum); |
|
|
|
|
Contacts.UI.Card.loadPhotoHandlers(); |
|
|
|
|
} |
|
|
|
|
else{ |
|
|
|
|
OC.dialogs.alert(jsondata.data.message, t('contacts', 'Error')); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
$('#file_upload_form').show(); |
|
|
|
|
}, |
|
|
|
|
editCurrentPhoto:function(){ |
|
|
|
|
$.getJSON(OC.filePath('contacts', 'ajax', 'currentphoto.php'),{'id':this.id},function(jsondata){ |
|
|
|
@ -1480,15 +1493,7 @@ Contacts={ |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
Contacts:{ |
|
|
|
|
contacts:{}, |
|
|
|
|
batchnum:50, |
|
|
|
|
get:function(id) { |
|
|
|
|
if(!this.contacts[id]) { |
|
|
|
|
// TODO: Check if item isn't loaded yet. If so insert it.
|
|
|
|
|
this.contacts[id] = $('#contacts li[data-id="'+id+'"]'); |
|
|
|
|
} |
|
|
|
|
return this.contacts[id]; |
|
|
|
|
}, |
|
|
|
|
drop:function(event, ui) { |
|
|
|
|
var dragitem = ui.draggable, droptarget = $(this); |
|
|
|
|
if(dragitem.is('li')) { |
|
|
|
@ -1527,16 +1532,13 @@ Contacts={ |
|
|
|
|
* If 'contactlist' or 'contacts' aren't defined they will be search for based in the properties in 'data'. |
|
|
|
|
*/ |
|
|
|
|
insertContact:function(params) { |
|
|
|
|
var id, bookid; |
|
|
|
|
if(!params.contactlist) { |
|
|
|
|
// FIXME: Check if contact really exists.
|
|
|
|
|
bookid = params.data ? params.data.addressbookid : params.contact.data('bookid'); |
|
|
|
|
id = params.data ? params.data.id : params.contact.data('id'); |
|
|
|
|
var bookid = params.data ? params.data.addressbookid : params.contact.data('bookid'); |
|
|
|
|
params.contactlist = $('#contacts ul[data-id="'+bookid+'"]'); |
|
|
|
|
} |
|
|
|
|
if(!params.contacts) { |
|
|
|
|
bookid = params.data ? params.data.addressbookid : params.contact.data('bookid'); |
|
|
|
|
id = params.data ? params.data.id : params.contact.data('id'); |
|
|
|
|
var bookid = params.data ? params.data.addressbookid : params.contact.data('bookid'); |
|
|
|
|
params.contacts = $('#contacts ul[data-id="'+bookid+'"] li'); |
|
|
|
|
} |
|
|
|
|
var contact = params.data |
|
|
|
@ -1556,7 +1558,6 @@ Contacts={ |
|
|
|
|
if(!added || !params.contacts) { |
|
|
|
|
params.contactlist.append(contact); |
|
|
|
|
} |
|
|
|
|
//this.contacts[id] = contact;
|
|
|
|
|
return contact; |
|
|
|
|
}, |
|
|
|
|
next:function(reverse) { |
|
|
|
@ -1691,13 +1692,18 @@ $(document).ready(function(){ |
|
|
|
|
OCCategories.changed = Contacts.UI.Card.categoriesChanged; |
|
|
|
|
OCCategories.app = 'contacts'; |
|
|
|
|
|
|
|
|
|
$('#chooseaddressbook').on('click keydown', Contacts.UI.Addressbooks.overview); |
|
|
|
|
$('#contacts_newcontact').on('click keydown', Contacts.UI.Card.editNew); |
|
|
|
|
$('#notification').click(function(){ |
|
|
|
|
$('#notification').fadeOut(); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
$('#chooseaddressbook').click(Contacts.UI.Addressbooks.overview); |
|
|
|
|
$('#chooseaddressbook').keydown(Contacts.UI.Addressbooks.overview); |
|
|
|
|
|
|
|
|
|
var ninjahelp = $('#ninjahelp'); |
|
|
|
|
$('#contacts_newcontact').click(Contacts.UI.Card.editNew); |
|
|
|
|
$('#contacts_newcontact').keydown(Contacts.UI.Card.editNew); |
|
|
|
|
|
|
|
|
|
ninjahelp.find('.close').on('click keydown',function() { |
|
|
|
|
ninjahelp.hide(); |
|
|
|
|
$('#ninjahelp .close').on('click keydown',function() { |
|
|
|
|
$('#ninjahelp').hide(); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
$(document).on('keyup', function(event) { |
|
|
|
@ -1715,7 +1721,7 @@ $(document).ready(function(){ |
|
|
|
|
*/ |
|
|
|
|
switch(event.which) { |
|
|
|
|
case 27: // Esc
|
|
|
|
|
ninjahelp.hide(); |
|
|
|
|
$('#ninjahelp').hide(); |
|
|
|
|
break; |
|
|
|
|
case 46: |
|
|
|
|
if(event.shiftKey) { |
|
|
|
@ -1762,7 +1768,7 @@ $(document).ready(function(){ |
|
|
|
|
Contacts.UI.Contacts.update({cid:Contacts.UI.Card.id}); |
|
|
|
|
break; |
|
|
|
|
case 191: // ?
|
|
|
|
|
ninjahelp.toggle('fast'); |
|
|
|
|
$('#ninjahelp').toggle('fast'); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -1774,7 +1780,7 @@ $(document).ready(function(){ |
|
|
|
|
$('.contacts').click(); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
$(document).on('click', '#contacts', function(event){ |
|
|
|
|
$(document).on('click', '.contacts', function(event){ |
|
|
|
|
var $tgt = $(event.target); |
|
|
|
|
if ($tgt.is('li') || $tgt.is('a')) { |
|
|
|
|
var item = $tgt.is('li')?$($tgt):($tgt).parent(); |
|
|
|
|