Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vpat 37: run JS aria edits + localization #4021

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions chrome/content/zotero/runJS.html
Original file line number Diff line number Diff line change
@@ -1,36 +1,37 @@
<html id="run-js">
<head>
<title>Run JavaScript</title>
<title data-l10n-id="runJS-title"></title>
<link href="chrome://zotero-platform/content/zotero.css" rel="stylesheet"/>
</head>
<body>
<nav>
<button onclick="run()">Run</button>
<button data-l10n-id="runJS-run" onclick="run()"></button>
<span id="run-label"></span>
<button id="help-button" onclick="openHelp()">Help</button>
<button data-l10n-id="runJS-help" id="help-button" onclick="openHelp()"></button>
</nav>

<main>
<div class="textbox-container">
<div class="textbox-header">
<label class="textbox-label" for="editor-code">Code:</label>
<label id="run-as-async-label" for="run-as-async">
<label id="code-editor-label" data-l10n-id="runJS-editor-label" class="textbox-label"></label>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert. "Code:" should be localized, but it is fine as a label. This is a developer tool called "Run JavaScript". It's obvious what "Code" means.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. In all VPAT issues, the degree to which the labels are descriptive is brought up very often, which is where my "Javascript code editor" came from. But as a rule of thumb, I guess it's better to not change existing labels at this point and we can always revise them later if the VPAT review indicates that it's necessary. I pushed these little tweaks

<div>
<label id="run-as-async-label" data-l10n-id="runJS-run-async" for="run-as-async"></label>
<input id="run-as-async" type="checkbox" onclick="update()">
Run as async function
</label>
</div>
</div>
<iframe
src="chrome://zotero/content/ace/ace.html"
id="editor-code"
class="editor-code"
aria-labelledby="code-editor-label"
></iframe>
</div>

<div class="textbox-container">
<div class="textbox-header">
<label id="result-label" class="textbox-label" for="result"/>
<label id="result-label" class="textbox-label" for="result" data-l10n-id="runJS-result"/>
</div>
<textarea id="result" readonly></textarea>
<textarea id="result" readonly aria-disabled="true"></textarea>
</div>
</main>

Expand Down
5 changes: 3 additions & 2 deletions chrome/content/zotero/runJS.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
function update() {
var isAsync = document.getElementById('run-as-async').checked;
var resultLabel = document.getElementById('result-label');
var val = isAsync ? 'Return value' : 'Result';
resultLabel.textContent = val + ':';
var type = isAsync ? 'async' : 'none';
resultLabel.setAttribute('data-l10n-args', `{"type":"${type}"}`);
}

async function run() {
Expand Down Expand Up @@ -85,6 +85,7 @@ window.addEventListener("load", function (e) {
return;
}

MozXULElement.insertFTLIfNeeded("zotero.ftl");
var codeWin = document.getElementById("editor-code").contentWindow;
codeEditor = codeWin.editor;
var session = codeEditor.getSession();
Expand Down
11 changes: 11 additions & 0 deletions chrome/locale/en-US/zotero/zotero.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ return-or-enter =

general-remove = Remove
general-add = Add
general-help = Help

menu-print =
.label = { general-print }
Expand Down Expand Up @@ -242,6 +243,16 @@ rtfScan-complete-page =

rtfScan-complete-page-description = Your document has now been scanned and processed. Please ensure that it is formatted correctly.

runJS-title = Run JavaScript
runJS-editor-label = Code:
runJS-run = Run
runJS-help = { general-help }
runJS-result = {
$type ->
[async] Return value:
*[other] Result:
}
runJS-run-async = Run as async function

bibliography-style-label = Citation Style:
bibliography-locale-label = Language:
Expand Down
Loading