Commit 76ee81e0 authored by Alex Catarineu's avatar Alex Catarineu
Browse files

fixup! Bug 31286: Implementation of bridge, proxy, and firewall settings in about:preferences#tor

parent 0c9bce4d
......@@ -8,12 +8,10 @@ const { TorStrings } = ChromeUtils.import("resource:///modules/TorStrings.jsm");
class RequestBridgeDialog {
constructor() {
this._dialog = null;
this._submitCommand = null;
this._submitButton = null;
this._dialogDescription = null;
this._captchaImage = null;
this._captchaEntryTextbox = null;
this._captchaRefreshCommand = null;
this._captchaRefreshButton = null;
this._incorrectCaptchaHbox = null;
this._incorrectCaptchaLabel = null;
......@@ -26,12 +24,8 @@ class RequestBridgeDialog {
submitButton:
"accept" /* not really a selector but a key for dialog's getButton */,
dialogDescription: "description#torPreferences-requestBridge-description",
submitCommand: "command#torPreferences-requestBridge-submitCommand",
captchaImage: "image#torPreferences-requestBridge-captchaImage",
captchaEntryTextbox:
"input#torPreferences-requestBridge-captchaTextbox",
refreshCaptchaCommand:
"command#torPreferences-requestBridge-refreshCaptchaCommand",
captchaEntryTextbox: "input#torPreferences-requestBridge-captchaTextbox",
refreshCaptchaButton:
"button#torPreferences-requestBridge-refreshCaptchaButton",
incorrectCaptchaHbox:
......@@ -45,7 +39,8 @@ class RequestBridgeDialog {
const selectors = RequestBridgeDialog.selectors;
this._dialog = dialog;
this._dialog.setAttribute(
const dialogWin = dialog.parentElement;
dialogWin.setAttribute(
"title",
TorStrings.settings.requestBridgeDialogTitle
);
......@@ -61,16 +56,17 @@ class RequestBridgeDialog {
} else if (bridges) {
this._bridges = bridges;
this._submitButton.disabled = false;
this._dialog.acceptDialog();
this._dialog.cancelDialog();
}
});
this._submitCommand = this._dialog.querySelector(selectors.submitCommand);
this._submitButton = this._dialog.getButton(selectors.submitButton);
this._submitButton.setAttribute("label", TorStrings.settings.submitCaptcha);
this._submitButton.setAttribute("command", this._submitCommand.id);
this._submitButton.disabled = true;
this._dialog.addEventListener("dialogaccept", e => {
e.preventDefault();
this.onSubmitCaptcha();
});
this._dialogDescription = this._dialog.querySelector(
selectors.dialogDescription
......@@ -93,30 +89,14 @@ class RequestBridgeDialog {
TorStrings.settings.captchaTextboxPlaceholder
);
this._captchaEntryTextbox.disabled = true;
this._captchaEntryTextbox.onkeypress = evt => {
const ENTER_KEY = 13;
if (evt.keyCode == ENTER_KEY) {
// logically same as pressing the 'submit' button of the parent dialog
this.onSubmitCaptcha();
return false;
}
return true;
};
// disable submit if entry textbox is empty
this._captchaEntryTextbox.oninput = () => {
this._submitButton.disabled = this._captchaEntryTextbox.value == "";
};
this._captchaRefreshCommand = this._dialog.querySelector(
selectors.refreshCaptchaCommand
);
this._captchaRefreshButton = this._dialog.querySelector(
selectors.refreshCaptchaButton
);
this._captchaRefreshButton.setAttribute(
"command",
this._captchaRefreshCommand.id
);
this._captchaRefreshButton.disabled = true;
this._incorrectCaptchaHbox = this._dialog.querySelector(
......@@ -183,7 +163,9 @@ class RequestBridgeDialog {
this._bridges = aBridges;
this._submitButton.disabled = false;
this._dialog.acceptDialog();
// This was successful, but use cancelDialog() to close, since
// we intercept the `dialogaccept` event.
this._dialog.cancelDialog();
})
.catch(aError => {
this._bridges = [];
......
......@@ -3,13 +3,11 @@
<?xml-stylesheet href="chrome://browser/skin/preferences/preferences.css"?>
<?xml-stylesheet href="chrome://browser/content/torpreferences/torPreferences.css"?>
<dialog id="torPreferences-requestBridge-dialog" type="child" class="prefwindow"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:html="http://www.w3.org/1999/xhtml"
title="Request Bridge"
buttons="cancel,accept"
role="dialog">
<command id="torPreferences-requestBridge-submitCommand" oncommand="requestBridgeDialog.onSubmitCaptcha();"/>
<window type="child"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:html="http://www.w3.org/1999/xhtml">
<dialog id="torPreferences-requestBridge-dialog"
buttons="accept,cancel">
<!-- ok, so &#8203; is a zero-width space. We need to have *something* in the innerText so that XUL knows how tall the
description node is so that it can determine how large to make the dialog element's inner draw area. If we have
nothing in the innerText, then it collapse to 0 height, and the contents of the dialog ends up partially hidden >:( -->
......@@ -18,8 +16,9 @@
<image id="torPreferences-requestBridge-captchaImage" flex="1"/>
<hbox id="torPreferences-requestBridge-inputHbox">
<html:input id="torPreferences-requestBridge-captchaTextbox" type="text" style="-moz-box-flex: 1;"/>
<command id="torPreferences-requestBridge-refreshCaptchaCommand" oncommand="requestBridgeDialog.onRefreshCaptcha();"/>
<button id="torPreferences-requestBridge-refreshCaptchaButton" image="chrome://browser/skin/reload.svg"/>
<button id="torPreferences-requestBridge-refreshCaptchaButton"
image="chrome://browser/skin/reload.svg"
oncommand="requestBridgeDialog.onRefreshCaptcha();"/>
</hbox>
<hbox id="torPreferences-requestBridge-incorrectCaptchaHbox" align="center">
<image id="torPreferences-requestBridge-errorIcon" />
......@@ -32,4 +31,5 @@
let dialog = document.getElementById("torPreferences-requestBridge-dialog");
requestBridgeDialog.init(window, dialog);
]]></script>
</dialog>
\ No newline at end of file
</dialog>
</window>
\ No newline at end of file
......@@ -23,7 +23,8 @@ class TorLogDialog {
_populateXUL(aDialog) {
this._dialog = aDialog;
this._dialog.setAttribute("title", TorStrings.settings.torLogDialogTitle);
const dialogWin = this._dialog.parentElement;
dialogWin.setAttribute("title", TorStrings.settings.torLogDialogTitle);
this._logTextarea = this._dialog.querySelector(
TorLogDialog.selectors.logTextarea
......
......@@ -3,11 +3,11 @@
<?xml-stylesheet href="chrome://browser/skin/preferences/preferences.css"?>
<?xml-stylesheet href="chrome://browser/content/torpreferences/torPreferences.css"?>
<dialog id="torPreferences-torLog-dialog" type="child" class="prefwindow"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:html="http://www.w3.org/1999/xhtml"
buttons="accept,extra1"
role="dialog">
<window type="child"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:html="http://www.w3.org/1999/xhtml">
<dialog id="torPreferences-torLog-dialog"
buttons="accept,extra1">
<html:textarea
id="torPreferences-torDialog-textarea"
multiline="true"
......@@ -19,4 +19,5 @@
let dialog = document.getElementById("torPreferences-torLog-dialog");
torLogDialog.init(window, dialog);
]]></script>
</dialog>
\ No newline at end of file
</dialog>
</window>
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment