Bug 830175 - Turn buttons in the prompt service from objects with labels to just strings. r=wesj

This commit is contained in:
Kartikaya Gupta 2013-01-15 15:31:24 -05:00
parent c98b3e717b
commit 52974dc71c
4 changed files with 13 additions and 35 deletions

View File

@ -83,15 +83,6 @@ public class PromptService implements OnClickListener, OnCancelListener, OnItemC
return new SimpleDateFormat(dateFormat).format(calendar.getTime());
}
private class PromptButton {
public String label = "";
PromptButton(JSONObject aJSONButton) {
try {
label = aJSONButton.getString("label");
} catch(Exception ex) { }
}
}
private class PromptInput {
private String label = "";
private String type = "";
@ -474,17 +465,7 @@ public class PromptService implements OnClickListener, OnCancelListener, OnItemC
text = geckoObject.getString("text");
} catch(Exception ex) { }
JSONArray buttons = new JSONArray();
try {
buttons = geckoObject.getJSONArray("buttons");
} catch(Exception ex) { }
int length = buttons.length();
mButtons = new String[length];
for (int i = 0; i < length; i++) {
try {
mButtons[i] = buttons.getJSONObject(i).getString("label");
} catch(Exception ex) { }
}
mButtons = getStringArray(geckoObject, "buttons");
JSONArray inputs = new JSONArray();
try {

View File

@ -27,9 +27,9 @@ var InputWidgetHelper = {
type: "Prompt:Show",
title: Strings.browser.GetStringFromName("inputWidgetHelper." + aElement.getAttribute('type')),
buttons: [
{ label: Strings.browser.GetStringFromName("inputWidgetHelper.set") },
{ label: Strings.browser.GetStringFromName("inputWidgetHelper.clear") },
{ label: Strings.browser.GetStringFromName("inputWidgetHelper.cancel") }
Strings.browser.GetStringFromName("inputWidgetHelper.set"),
Strings.browser.GetStringFromName("inputWidgetHelper.clear"),
Strings.browser.GetStringFromName("inputWidgetHelper.cancel")
],
inputs: [
{ type: type, value: aElement.value }

View File

@ -66,7 +66,7 @@ var SelectHelper = {
if (aElement.multiple) {
result.buttons = [
{ label: Strings.browser.GetStringFromName("selectHelper.closeMultipleSelectDialog") },
Strings.browser.GetStringFromName("selectHelper.closeMultipleSelectDialog")
];
}

View File

@ -134,8 +134,8 @@ Prompt.prototype = {
if (aTitle) msg.title = aTitle;
if (aText) msg.text = aText;
msg.buttons = aButtons || [
{ label: PromptUtils.getLocaleString("OK") },
{ label: PromptUtils.getLocaleString("Cancel") }
PromptUtils.getLocaleString("OK"),
PromptUtils.getLocaleString("Cancel")
];
msg.inputs = aInputs;
return PromptUtils.sendMessageToJava(msg);
@ -181,17 +181,17 @@ Prompt.prototype = {
/* ---------- nsIPrompt ---------- */
alert: function alert(aTitle, aText) {
this.commonPrompt(aTitle, aText, [{ label: PromptUtils.getLocaleString("OK") }], "", {value: false}, []);
this.commonPrompt(aTitle, aText, [ PromptUtils.getLocaleString("OK") ], "", { value: false }, []);
},
alertCheck: function alertCheck(aTitle, aText, aCheckMsg, aCheckState) {
let data = this.commonPrompt(aTitle, aText, [{ label: PromptUtils.getLocaleString("OK") }], aCheckMsg, aCheckState, []);
let data = this.commonPrompt(aTitle, aText, [ PromptUtils.getLocaleString("OK") ], aCheckMsg, aCheckState, []);
if (aCheckMsg)
aCheckState.value = data.checkbox == "true";
},
confirm: function confirm(aTitle, aText) {
let data = this.commonPrompt(aTitle, aText, null, "", {value: false}, []);
let data = this.commonPrompt(aTitle, aText, null, "", { value: false }, []);
return (data.button == 0);
},
@ -237,7 +237,7 @@ Prompt.prototype = {
}
if (bTitle)
buttons.push({label:bTitle});
buttons.push(bTitle);
aButtonFlags >>= 8;
}
@ -289,11 +289,8 @@ Prompt.prototype = {
},
select: function select(aTitle, aText, aCount, aSelectList, aOutSelection) {
let data = this.commonPrompt(aTitle, aText, [
{ label: PromptUtils.getLocaleString("OK") }
], "", {value: false}, [
{ type: "menulist", values: aSelectList },
]);
let data = this.commonPrompt(aTitle, aText, [ PromptUtils.getLocaleString("OK") ], "",
{ value: false }, [{ type: "menulist", values: aSelectList }]);
let ok = data.button == 0;
if (ok)