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

Contacts: Simplified unload handling

This commit is contained in:
Thomas Tanghus 2012-11-16 04:39:57 +01:00
parent e5988c623d
commit 873452eda9

View File

@ -1069,22 +1069,6 @@ OC.Contacts = OC.Contacts || {};
return this.contacts[parseInt(id)];
};
ContactList.prototype.warnNotDeleted = function(e) {
e = e || window.event;
var warn = t('contacts', 'Some contacts are marked for deletion, but not deleted yet. Please wait for them to be deleted.');
if (e) {
e.returnValue = String(warn);
}
if(OC.Contacts.Contacts.deletionQueue.length > 0) {
// This is run almost instantly. It's just to allow us to
// show the warning. Only shows in Chrome afaik...
setTimeout(function() {
this.deleteContacts();
}, 1);
}
return warn;
}
ContactList.prototype.delayedDelete = function(id) {
var self = this;
if(utils.isUInt(id)) {
@ -1101,7 +1085,14 @@ OC.Contacts = OC.Contacts || {};
});
console.log('deletionQueue', this.deletionQueue);
if(!window.onbeforeunload) {
window.onbeforeunload = this.warnNotDeleted;
window.onbeforeunload = function(e) {
e = e || window.event;
var warn = t('contacts', 'Some contacts are marked for deletion, but not deleted yet. Please wait for them to be deleted.');
if (e) {
e.returnValue = String(warn);
}
return warn;
}
}
if(this.$contactList.find('tr:visible').length === 0) {
$(document).trigger('status.visiblecontacts');