Publish Vulpes Preview 15 sources for desktop, Android and Tundra
Share Gaia assets and adapters, keep private profiles and development documents local, and update both public READMEs.
This commit is contained in:
parent
93e3a48004
commit
b38dea0597
25901 changed files with 9982925 additions and 369 deletions
108
gaia/apps/communications/contacts/js/contacts_bulk_delete.js
Executable file
108
gaia/apps/communications/contacts/js/contacts_bulk_delete.js
Executable file
|
|
@ -0,0 +1,108 @@
|
|||
/* globals Contacts, utils, contactsRemover, Promise,
|
||||
Search, ConfirmDialog, Loader */
|
||||
'use strict';
|
||||
|
||||
var contacts = window.contacts || {};
|
||||
|
||||
(function(exports) {
|
||||
|
||||
var cancelled = false;
|
||||
|
||||
/**
|
||||
* Loads the overlay class before showing
|
||||
*/
|
||||
function requireOverlay(callback) {
|
||||
Loader.utility('Overlay', callback);
|
||||
}
|
||||
|
||||
// Shows a dialog to confirm the bulk delete
|
||||
var showConfirm = function showConfirm(n) {
|
||||
return new Promise(function doShowConfirm(resolve, reject) {
|
||||
var cancelObject = {
|
||||
title: 'cancel',
|
||||
callback: function onCancel() {
|
||||
ConfirmDialog.hide();
|
||||
reject();
|
||||
}
|
||||
};
|
||||
|
||||
var removeObject = {
|
||||
title: 'delete',
|
||||
isDanger: true,
|
||||
callback: function onRemove() {
|
||||
ConfirmDialog.hide();
|
||||
resolve();
|
||||
}
|
||||
};
|
||||
|
||||
ConfirmDialog.show(null,
|
||||
{'id': 'ContactConfirmDel', 'args': {n: n}}, cancelObject,
|
||||
removeObject);
|
||||
});
|
||||
};
|
||||
|
||||
var doDelete = function doDelete(ids, done) {
|
||||
cancelled = false;
|
||||
var progress = utils.overlay.show('DeletingContacts', 'progressBar');
|
||||
progress.setTotal(ids.length);
|
||||
utils.overlay.showMenu();
|
||||
|
||||
utils.overlay.oncancel = function() {
|
||||
cancelled = true;
|
||||
contactsRemoverObj.finish();
|
||||
};
|
||||
|
||||
var contactsRemoverObj = new contactsRemover();
|
||||
contactsRemoverObj.init(ids, function onInitDone() {
|
||||
contactsRemoverObj.start();
|
||||
});
|
||||
|
||||
contactsRemoverObj.onDeleted = function onDeleted(currentId) {
|
||||
if (window.Search && Search.isInSearchMode()) {
|
||||
Search.invalidateCache();
|
||||
Search.removeContact(currentId);
|
||||
}
|
||||
contacts.List.remove(currentId);
|
||||
progress.update();
|
||||
};
|
||||
|
||||
contactsRemoverObj.onError = function onError() {
|
||||
Contacts.hideOverlay();
|
||||
utils.status.show({
|
||||
id: 'deleteError-general'
|
||||
});
|
||||
contacts.Settings.refresh();
|
||||
};
|
||||
|
||||
contactsRemoverObj.onFinished = function onFinished() {
|
||||
Contacts.hideOverlay();
|
||||
utils.status.show({
|
||||
id: 'DeletedTxt',
|
||||
args: {n: contactsRemoverObj.getDeletedCount()}
|
||||
});
|
||||
contacts.Settings.refresh();
|
||||
|
||||
if (typeof done === 'function') {
|
||||
done();
|
||||
}
|
||||
};
|
||||
|
||||
contactsRemoverObj.onCancelled = contactsRemoverObj.onFinished;
|
||||
|
||||
};
|
||||
// Start the delete of the contacts
|
||||
var performDelete = function performDelete(promise, done) {
|
||||
var self = this;
|
||||
requireOverlay(function onOverlay() {
|
||||
promise.onsuccess = function onSuccess(ids) {
|
||||
showConfirm(ids.length).then(self.doDelete.bind(null, ids, done));
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
exports.BulkDelete = {
|
||||
'performDelete': performDelete,
|
||||
'doDelete': doDelete
|
||||
};
|
||||
|
||||
})(window);
|
||||
Loading…
Reference in a new issue