mirror of
https://github.com/owncloudarchive/contacts.git
synced 2024-11-29 11:24:11 +01:00
Insert a rendered contact in the list.
This commit is contained in:
parent
ee54413419
commit
68e409cac7
62
js/app.js
62
js/app.js
@ -152,8 +152,8 @@ OC.Contacts = OC.Contacts || {
|
||||
self.$header.find('.delete').hide();
|
||||
}
|
||||
});
|
||||
$(document).bind('status.contactsLoaded', function(e, result) {
|
||||
console.log('contactsLoaded', result);
|
||||
$(document).bind('status.contacts.loaded', function(e, result) {
|
||||
console.log('status.contacts.loaded', result);
|
||||
if(result.status !== true) {
|
||||
alert('Error loading contacts!');
|
||||
}
|
||||
@ -213,6 +213,16 @@ OC.Contacts = OC.Contacts || {
|
||||
self.$header.find('.single').show();
|
||||
self.$rightContent.prepend(self.Contacts.showContact(self.currentid));
|
||||
});
|
||||
this.$header.find('.back').on('click keydown', function() {
|
||||
console.log('back');
|
||||
var listelem = self.Contacts.contacts[parseInt(self.currentid)].detach().remove();
|
||||
self.$contactList.show();
|
||||
});
|
||||
this.$header.find('.add').on('click keydown', function() {
|
||||
console.log('add');
|
||||
self.$contactList.hide();
|
||||
self.$rightContent.prepend(self.Contacts.addContact());
|
||||
});
|
||||
this.$header.find('.delete').on('click keydown', function() {
|
||||
console.log('delete');
|
||||
if(self.currentid) {
|
||||
@ -706,8 +716,9 @@ OC.Contacts = OC.Contacts || {
|
||||
self.deleteContact(listelem.data('id'), true);
|
||||
},
|
||||
clickhandler:function(listelem) {
|
||||
self.insertContact({contact:listelem});
|
||||
OC.Contacts.notify({message:t('contacts', 'Cancelled deletion of: "') + listelem.find('a').text() + '"'});
|
||||
console.log('clickhandler', listelem);
|
||||
self.insertContact(listelem);
|
||||
OC.Contacts.notify({message:t('contacts', 'Cancelled deletion of: "') + listelem.find('td.name').text() + '"'});
|
||||
window.onbeforeunload = null;
|
||||
}
|
||||
});
|
||||
@ -776,13 +787,43 @@ OC.Contacts = OC.Contacts || {
|
||||
};
|
||||
|
||||
/**
|
||||
* Insert a contact in the list
|
||||
* @param jQuery object
|
||||
*/
|
||||
* Insert a rendered contact list item into the list
|
||||
* @param contact jQuery object.
|
||||
*/
|
||||
ContactList.prototype.insertContact = function(contact) {
|
||||
console.log('insertContact', contact);
|
||||
//console.log('insertContact', contact);
|
||||
var name = contact.find('td.name').text().toLowerCase();
|
||||
var added = false
|
||||
this.$contactList.find('tr').each(function() {
|
||||
if ($(this).find('td.name').text().toLowerCase().localeCompare(name) > 0) {
|
||||
$(this).before(contact);
|
||||
added = true;
|
||||
return false;
|
||||
}
|
||||
});
|
||||
if(!added) {
|
||||
this.$contactList.append(contact);
|
||||
}
|
||||
//this.contacts[id] = contact;
|
||||
return contact;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add contact
|
||||
* @param int offset
|
||||
*/
|
||||
ContactList.prototype.addContact = function() {
|
||||
var contact = new Contact(
|
||||
this,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
this.$contactListItemTemplate,
|
||||
this.$contactFullTemplate,
|
||||
this.contactDetailTemplates
|
||||
);
|
||||
return contact.renderContact();
|
||||
}
|
||||
/**
|
||||
* Load contacts
|
||||
* @param int offset
|
||||
@ -809,9 +850,10 @@ OC.Contacts = OC.Contacts || {
|
||||
self.contactDetailTemplates
|
||||
);
|
||||
var item = self.contacts[parseInt(contact.id)].renderListItem()
|
||||
self.$contactList.append(item);
|
||||
//self.$contactList.append(item);
|
||||
self.insertContact(item);
|
||||
});
|
||||
$(document).trigger('status.contactsLoaded', {
|
||||
$(document).trigger('status.contacts.loaded', {
|
||||
status: true,
|
||||
numcontacts: jsondata.data.contacts.length
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user