1 /* See license.txt for terms of usage */ 2 3 define([ 4 "firebug/lib/trace", 5 "firebug/lib/options", 6 "firebug/lib/locale", 7 "firebug/firefox/browserOverlayLib", 8 ], 9 function(FBTrace, Options, Locale, BrowserOverlayLib) { 10 with (BrowserOverlayLib) { 11 12 // ********************************************************************************************* // 13 // Constants 14 15 var shortcuts = [ 16 "toggleFirebug", 17 "toggleInspecting", 18 "focusCommandLine", 19 "detachFirebug", 20 "closeFirebug", 21 "toggleBreakOn" 22 ] 23 24 /* Used by the browser menu, but should be really global shortcuts? 25 key_increaseTextSize 26 key_decreaseTextSize 27 key_normalTextSize 28 key_help 29 key_toggleProfiling 30 key_focusFirebugSearch 31 key_customizeFBKeys 32 */ 33 34 // ********************************************************************************************* // 35 // BrowserCommands Implementation 36 37 var BrowserCommands = 38 { 39 overlay: function(doc) 40 { 41 this.overlayCommands(doc); 42 this.overlayShortcuts(doc); 43 }, 44 45 overlayCommands: function(doc) 46 { 47 $command(doc, "cmd_firebug_closeFirebug", "Firebug.closeFirebug(true);"); 48 $command(doc, "cmd_firebug_toggleInspecting", "if (!Firebug.currentContext) Firebug.toggleBar(true); Firebug.Inspector.toggleInspecting(Firebug.currentContext);"); 49 $command(doc, "cmd_firebug_focusCommandLine", "if (!Firebug.currentContext) Firebug.toggleBar(true); Firebug.CommandLine.focus(Firebug.currentContext);"); 50 $command(doc, "cmd_firebug_toggleFirebug", "Firebug.toggleBar();"); 51 $command(doc, "cmd_firebug_detachFirebug", "Firebug.toggleDetachBar(false, true);"); 52 $command(doc, "cmd_firebug_inspect", "Firebug.Inspector.inspectFromContextMenu(arg);", "document.popupNode"); 53 $command(doc, "cmd_firebug_toggleBreakOn", "if (Firebug.currentContext) Firebug.chrome.breakOnNext(Firebug.currentContext, event);"); 54 $command(doc, "cmd_firebug_toggleDetachFirebug", "Firebug.toggleDetachBar(false, true);"); 55 $command(doc, "cmd_firebug_increaseTextSize", "Firebug.Options.changeTextSize(1);"); 56 $command(doc, "cmd_firebug_decreaseTextSize", "Firebug.Options.changeTextSize(-1);"); 57 $command(doc, "cmd_firebug_normalTextSize", "Firebug.Options.setTextSize(0);"); 58 $command(doc, "cmd_firebug_focusFirebugSearch", "if (Firebug.currentContext) Firebug.Search.onSearchCommand(document);"); 59 $command(doc, "cmd_firebug_customizeFBKeys", "Firebug.ShortcutsModel.customizeShortcuts();"); 60 $command(doc, "cmd_firebug_enablePanels", "Firebug.PanelActivation.enableAllPanels();"); 61 $command(doc, "cmd_firebug_disablePanels", "Firebug.PanelActivation.disableAllPanels();"); 62 $command(doc, "cmd_firebug_clearActivationList", "Firebug.PanelActivation.clearAnnotations();"); 63 $command(doc, "cmd_firebug_clearConsole", "Firebug.Console.clear(Firebug.currentContext);"); 64 $command(doc, "cmd_firebug_allOn", "Firebug.PanelActivation.toggleAll('on');"); 65 $command(doc, "cmd_firebug_toggleOrient", "Firebug.chrome.toggleOrient();"); 66 $command(doc, "cmd_firebug_resetAllOptions", "Firebug.resetAllOptions(true);"); 67 $command(doc, "cmd_firebug_toggleProfiling", ""); //todo 68 $command(doc, "cmd_firebug_openInEditor", "Firebug.ExternalEditors.onContextMenuCommand(event)"); 69 }, 70 71 overlayShortcuts: function(doc) 72 { 73 var keyset = $(doc, "mainKeyset"); 74 75 for (var i=0; i<shortcuts.length ; i++) 76 { 77 var id = shortcuts[i]; 78 var shortcut = Options.get("key.shortcut." + id); 79 var tokens = shortcut.split(" "); 80 var key = tokens.pop(); 81 82 var keyProps = { 83 id: "key_firebug_" + id, 84 modifiers: tokens.join(","), 85 command: "cmd_firebug_" + id, 86 position: 1 87 }; 88 89 if (key.length <= 1) 90 keyProps.key = key; 91 else if (doc.defaultView.KeyEvent["DOM_"+key]) 92 keyProps.keycode = key; 93 94 $el(doc, "key", keyProps, keyset); 95 } 96 97 keyset.parentNode.insertBefore(keyset, keyset.nextSibling); 98 } 99 } 100 101 // ********************************************************************************************* // 102 // Registration 103 104 return BrowserCommands; 105 106 // ********************************************************************************************* // 107 }}); 108