зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1077412 - Add a confirmation dialog when deleting contacts in the Desktop client. r=mikedeboer
This commit is contained in:
Родитель
d9b0f044f4
Коммит
5f169e86c9
|
@ -277,6 +277,33 @@ function injectLoopAPI(targetWindow) {
|
|||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Displays a confirmation dialog using the specified strings.
|
||||
*
|
||||
* Callback parameters:
|
||||
* - err null on success, non-null on unexpected failure to show the prompt.
|
||||
* - {Boolean} True if the user chose the OK button.
|
||||
*/
|
||||
confirm: {
|
||||
enumerable: true,
|
||||
writable: true,
|
||||
value: function(bodyMessage, okButtonMessage, cancelButtonMessage, callback) {
|
||||
try {
|
||||
let buttonFlags =
|
||||
(Ci.nsIPrompt.BUTTON_POS_0 * Ci.nsIPrompt.BUTTON_TITLE_IS_STRING) +
|
||||
(Ci.nsIPrompt.BUTTON_POS_1 * Ci.nsIPrompt.BUTTON_TITLE_IS_STRING);
|
||||
|
||||
let chosenButton = Services.prompt.confirmEx(null, "",
|
||||
bodyMessage, buttonFlags, okButtonMessage, cancelButtonMessage,
|
||||
null, null, {});
|
||||
|
||||
callback(null, chosenButton == 0);
|
||||
} catch (ex) {
|
||||
callback(cloneValueInto(ex, targetWindow));
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Call to ensure that any necessary registrations for the Loop Service
|
||||
* have taken place.
|
||||
|
|
|
@ -307,6 +307,26 @@ loop.contacts = (function(_, mozL10n) {
|
|||
this.props.startForm("contacts_edit", contact);
|
||||
break;
|
||||
case "remove":
|
||||
navigator.mozLoop.confirm(
|
||||
mozL10n.get("confirm_delete_contact_alert"),
|
||||
mozL10n.get("confirm_delete_contact_remove_button"),
|
||||
mozL10n.get("confirm_delete_contact_cancel_button"),
|
||||
(err, result) => {
|
||||
if (err) {
|
||||
throw err;
|
||||
}
|
||||
|
||||
if (!result) {
|
||||
return;
|
||||
}
|
||||
|
||||
navigator.mozLoop.contacts.remove(contact._guid, err => {
|
||||
if (err) {
|
||||
throw err;
|
||||
}
|
||||
});
|
||||
});
|
||||
break;
|
||||
case "block":
|
||||
case "unblock":
|
||||
// Invoke the API named like the action.
|
||||
|
|
|
@ -307,6 +307,26 @@ loop.contacts = (function(_, mozL10n) {
|
|||
this.props.startForm("contacts_edit", contact);
|
||||
break;
|
||||
case "remove":
|
||||
navigator.mozLoop.confirm(
|
||||
mozL10n.get("confirm_delete_contact_alert"),
|
||||
mozL10n.get("confirm_delete_contact_remove_button"),
|
||||
mozL10n.get("confirm_delete_contact_cancel_button"),
|
||||
(err, result) => {
|
||||
if (err) {
|
||||
throw err;
|
||||
}
|
||||
|
||||
if (!result) {
|
||||
return;
|
||||
}
|
||||
|
||||
navigator.mozLoop.contacts.remove(contact._guid, err => {
|
||||
if (err) {
|
||||
throw err;
|
||||
}
|
||||
});
|
||||
});
|
||||
break;
|
||||
case "block":
|
||||
case "unblock":
|
||||
// Invoke the API named like the action.
|
||||
|
|
Загрузка…
Ссылка в новой задаче