Permalink
Browse files

Display a message to the user if there is no help page for a command …

…line command
  • Loading branch information...
1 parent 25b2891 commit 5411494a44893b998360b0f6361643805534f9c5 @janodvarko janodvarko committed Sep 18, 2012
@@ -6,8 +6,11 @@ define([
"firebug/lib/dom",
"firebug/console/commandLineExposed",
"firebug/chrome/window",
+ "firebug/lib/Xpcom",
+ "firebug/lib/events",
],
-function(Domplate, Locale, Dom, CommandLineExposed, Win) { with (Domplate) {
+function(Domplate, Locale, Dom, CommandLineExposed, Win, Xpcom, Events) {
+with (Domplate) {
// ********************************************************************************************* //
// Constants
@@ -19,6 +22,8 @@ var CMD_TYPE_COMMAND = 1;
var CMD_TYPE_SHORTCUT = 2;
var CMD_TYPE_PROPERTY = 3;
+const prompts = Xpcom.CCSV("@mozilla.org/embedcomp/prompt-service;1", "nsIPromptService");
+
// ********************************************************************************************* //
// Domplates
@@ -85,8 +90,17 @@ var HelpEntry = domplate(
onClick: function(event)
{
+ Events.cancelEvent(event);
+
var object = Firebug.getRepObject(event.target);
+ if (object.noUserHelpUrl)
+ {
+ prompts.alert(null, Locale.$STR("Firebug"),
+ Locale.$STR("console.cmd.helpUrlNotAvailable"));
+ return;
+ }
+
var helpUrl = "http://getfirebug.com/wiki/index.php/" + object.name;
if (object.helpUrl)
helpUrl = object.helpUrl;
@@ -162,6 +176,7 @@ var CommandLineHelp = domplate(
name: name,
desc: config.description,
nol10n: true,
+ noUserHelpUrl: !config.helpUrl,
helpUrl: config.helpUrl ? config.helpUrl: null,
type: config.getter ? CMD_TYPE_PROPERTY : CMD_TYPE_COMMAND,
})
@@ -187,6 +202,7 @@ function onExecuteCommand(context)
Firebug.registerCommand("help", {
getter: true,
+ helpUrl: "http://getfirebug.com/wiki/index.php/help",
handler: onExecuteCommand.bind(this),
description: Locale.$STR("console.cmd.help.help")
});
@@ -235,11 +235,13 @@ Firebug.registerModule(EventMonitor);
Firebug.registerCommand("monitorEvents", {
handler: monitorEvents.bind(this),
+ helpUrl: "http://getfirebug.com/wiki/index.php/monitorEvents",
description: Locale.$STR("console.cmd.help.monitorEvents")
})
Firebug.registerCommand("unmonitorEvents", {
handler: unmonitorEvents.bind(this),
+ helpUrl: "http://getfirebug.com/wiki/index.php/unmonitorEvents",
description: Locale.$STR("console.cmd.help.unmonitorEvents")
})
@@ -536,11 +536,13 @@ Firebug.registerRep(Firebug.Profiler.ProfileCall);
Firebug.registerCommand("profile", {
handler: profile.bind(this),
+ helpUrl: "http://getfirebug.com/wiki/index.php/profile",
description: Locale.$STR("console.cmd.help.profile")
})
Firebug.registerCommand("profileEnd", {
handler: profileEnd.bind(this),
+ helpUrl: "http://getfirebug.com/wiki/index.php/profileEnd",
description: Locale.$STR("console.cmd.help.profileEnd")
})
@@ -1660,3 +1660,8 @@ console.cmd.help.$0=Represents the last element selected via the Inspector.
console.cmd.help.$1=Represents the second last element selected via the Inspector.
console.cmd.help.$n=Returns one of the 5 last elements selected via the Inspector. This method takes one required parameter, which represents the index of the element (starting at 0).
console.cmd.help.help=Displays help for all available commands.
+
+# LOCALIZATION NOTE (console.cmd.helpUrlNotAvailable): A message used displayed to the user
+# if registered command doesn't have help URL associated and the user clicks on the command name.
+# List of command names is displayed if you type "help" (without quotes) into the command line.
+console.cmd.helpUrlNotAvailable=Help page for this command is not available.

0 comments on commit 5411494

Please sign in to comment.