mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 872143 - Make InputWidgetHelper use async prompts. r=mfinkle
This commit is contained in:
parent
66654705cf
commit
ef223b63c9
@ -23,44 +23,41 @@ var InputWidgetHelper = {
|
|||||||
|
|
||||||
show: function(aElement) {
|
show: function(aElement) {
|
||||||
let type = aElement.getAttribute('type');
|
let type = aElement.getAttribute('type');
|
||||||
let msg = {
|
let p = new Prompt({
|
||||||
type: "Prompt:Show",
|
window: aElement.ownerDocument.defaultView,
|
||||||
title: Strings.browser.GetStringFromName("inputWidgetHelper." + aElement.getAttribute('type')),
|
title: Strings.browser.GetStringFromName("inputWidgetHelper." + aElement.getAttribute('type')),
|
||||||
buttons: [
|
buttons: [
|
||||||
Strings.browser.GetStringFromName("inputWidgetHelper.set"),
|
Strings.browser.GetStringFromName("inputWidgetHelper.set"),
|
||||||
Strings.browser.GetStringFromName("inputWidgetHelper.clear"),
|
Strings.browser.GetStringFromName("inputWidgetHelper.clear"),
|
||||||
Strings.browser.GetStringFromName("inputWidgetHelper.cancel")
|
Strings.browser.GetStringFromName("inputWidgetHelper.cancel")
|
||||||
],
|
],
|
||||||
inputs: [
|
}).addDatePicker({
|
||||||
{ type: type, value: aElement.value }
|
value: aElement.value,
|
||||||
]
|
type: type,
|
||||||
};
|
}).show((function(data) {
|
||||||
|
let changed = false;
|
||||||
let data = JSON.parse(sendMessageToJava(msg));
|
if (data.button == -1) {
|
||||||
|
// This type is not supported with this android version.
|
||||||
let changed = false;
|
return;
|
||||||
if (data.button == -1) {
|
|
||||||
// This type is not supported with this android version.
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (data.button == 1) {
|
|
||||||
// The user cleared the value.
|
|
||||||
if (aElement.value != "") {
|
|
||||||
aElement.value = "";
|
|
||||||
changed = true;
|
|
||||||
}
|
}
|
||||||
} else if (data.button == 0) {
|
if (data.button == 1) {
|
||||||
// Commit the new value.
|
// The user cleared the value.
|
||||||
if (aElement.value != data[type]) {
|
if (aElement.value != "") {
|
||||||
aElement.value = data[type];
|
aElement.value = "";
|
||||||
changed = true;
|
changed = true;
|
||||||
|
}
|
||||||
|
} else if (data.button == 0) {
|
||||||
|
// Commit the new value.
|
||||||
|
if (aElement.value != data[type]) {
|
||||||
|
aElement.value = data[type + "0"];
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
// Else the user canceled the input.
|
||||||
// Else the user canceled the input.
|
|
||||||
|
|
||||||
if (changed)
|
|
||||||
this.fireOnChange(aElement);
|
|
||||||
|
|
||||||
|
if (changed)
|
||||||
|
this.fireOnChange(aElement);
|
||||||
|
}).bind(this));
|
||||||
},
|
},
|
||||||
|
|
||||||
_isValidInput: function(aElement) {
|
_isValidInput: function(aElement) {
|
||||||
|
@ -48,6 +48,8 @@ Prompt.prototype = {
|
|||||||
obj.id = aOptions.id || (aOptions.type + this[aOptions.type + "_count"]);
|
obj.id = aOptions.id || (aOptions.type + this[aOptions.type + "_count"]);
|
||||||
this[aOptions.type + "_count"]++;
|
this[aOptions.type + "_count"]++;
|
||||||
|
|
||||||
|
if (!this.msg.inputs)
|
||||||
|
this.msg.inputs = [];
|
||||||
this.msg.inputs.push(obj);
|
this.msg.inputs.push(obj);
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
@ -81,6 +83,13 @@ Prompt.prototype = {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
addDatePicker: function(aOptions) {
|
||||||
|
return this._addInput({
|
||||||
|
type: aOptions.type || "date",
|
||||||
|
value: aOptions.value,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
addMenulist: function(aOptions) {
|
addMenulist: function(aOptions) {
|
||||||
return this._addInput({
|
return this._addInput({
|
||||||
type: "menulist",
|
type: "menulist",
|
||||||
|
Loading…
Reference in New Issue
Block a user