Bug 756423 - Make mention of the keyboard shortcuts in the comment on Scratchpad, r=robcee

This commit is contained in:
Mark Capella 2012-07-30 17:39:00 -04:00
parent 7c84c23358
commit cfb6dcaa58
3 changed files with 48 additions and 5 deletions

View File

@ -36,6 +36,44 @@ const BUTTON_POSITION_SAVE = 0;
const BUTTON_POSITION_CANCEL = 1;
const BUTTON_POSITION_DONT_SAVE = 2;
let keysbundle = Services.strings.createBundle("chrome://global-platform/locale/platformKeys.properties");
function SP_Pretty_Key(aElemKey) {
let elemString = "";
let elemMod = aElemKey.getAttribute("modifiers");
if (elemMod.match("accel")) {
if (navigator.platform.indexOf("Mac") !== -1) {
elemString += keysbundle.GetStringFromName("VK_META") +
keysbundle.GetStringFromName("MODIFIER_SEPARATOR");
} else {
elemString += keysbundle.GetStringFromName("VK_CONTROL") +
keysbundle.GetStringFromName("MODIFIER_SEPARATOR");
}
}
if (elemMod.match("shift")) {
elemString += keysbundle.GetStringFromName("VK_SHIFT") +
keysbundle.GetStringFromName("MODIFIER_SEPARATOR");
}
if (elemMod.match("alt")) {
elemString += keysbundle.GetStringFromName("VK_ALT") +
keysbundle.GetStringFromName("MODIFIER_SEPARATOR");
}
if (elemMod.match("ctrl")) {
elemString += keysbundle.GetStringFromName("VK_CONTROL") +
keysbundle.GetStringFromName("MODIFIER_SEPARATOR");
}
if (elemMod.match("meta")) {
elemString += keysbundle.GetStringFromName("VK_META") +
keysbundle.GetStringFromName("MODIFIER_SEPARATOR");
}
return elemString + aElemKey.getAttribute("key").toUpperCase();
}
/**
* The scratchpad object handles the Scratchpad window functionality.
*/
@ -971,7 +1009,14 @@ var Scratchpad = {
}
let state = null;
let initialText = this.strings.GetStringFromName("scratchpadIntro");
let initialText = this.strings.formatStringFromName(
"scratchpadIntro",
[SP_Pretty_Key(document.getElementById("sp-key-run")),
SP_Pretty_Key(document.getElementById("sp-key-inspect")),
SP_Pretty_Key(document.getElementById("sp-key-display"))],
3);
if ("arguments" in window &&
window.arguments[0] instanceof Ci.nsIDialogParamBlock) {
state = JSON.parse(window.arguments[0].GetString(0));

View File

@ -25,9 +25,7 @@ function testOpen()
{
openScratchpad(function(win) {
is(win.Scratchpad.filename, undefined, "Default filename is undefined");
is(win.Scratchpad.getText(),
win.Scratchpad.strings.GetStringFromName("scratchpadIntro"),
"Default text is loaded")
isnot(win.Scratchpad.getText(), null, "Default text should not be null");
is(win.Scratchpad.executionContext, win.SCRATCHPAD_CONTEXT_CONTENT,
"Default execution context is content");

View File

@ -57,7 +57,7 @@ confirmClose.title=Unsaved Changes
# LOCALIZATION NOTE (scratchpadIntro): This is a multi-line comment explaining
# how to use the Scratchpad. Note that this should be a valid JavaScript
# comment inside /* and */.
scratchpadIntro=/*\n * This is a JavaScript Scratchpad.\n *\n * Enter some JavaScript, then Right Click or choose from the Execute Menu:\n * 1. Run to evaluate the selected text,\n * 2. Inspect to bring up an Object Inspector on the result, or,\n * 3. Display to insert the result in a comment after the selection.\n */\n\n
scratchpadIntro1=/*\n * This is a JavaScript Scratchpad.\n *\n * Enter some JavaScript, then Right Click or choose from the Execute Menu:\n * 1. Run to evaluate the selected text (%1$S),\n * 2. Inspect to bring up an Object Inspector on the result (%2$S), or,\n * 3. Display to insert the result in a comment after the selection. (%3$S)\n */\n\n
# LOCALIZATION NOTE (notification.browserContext): This is the message displayed
# over the top of the editor when the user has switched to browser context.