Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[1.10] Bootstrapped Firebug, merge from 1.10rl

  • Loading branch information...
commit 443c860db6ffd4e163c840e6eec1434b6470b934 1 parent b19e3ce
Jan Odvarko janodvarko authored
Showing with 1,991 additions and 1,205 deletions.
  1. +128 −0 extension/bootstrap.js
  2. +11 −11 extension/chrome.manifest
  3. +1 −1  extension/content/firebug/accessible/a11y.js
  4. +0 −33 extension/content/firebug/browserOverlay.xul
  5. +12 −32 extension/content/firebug/chrome/chrome.js
  6. +0 −3  extension/content/firebug/firebug.js
  7. +1 −1  extension/content/firebug/firebugOverlay.xul
  8. +63 −2 extension/content/firebug/firefox/{start-button/startButton.css → browser.css}
  9. +0 −96 extension/content/firebug/firefox/browserMenuOverlay.xul
  10. +960 −0 extension/content/firebug/firefox/browserOverlay.js
  11. +0 −29 extension/content/firebug/firefox/browserOverlayWithFrame.xul
  12. +4 −42 extension/content/firebug/firefox/firebugMenu.js
  13. +0 −127 extension/content/firebug/firefox/firebugMenuOverlay.xul
  14. +0 −7 extension/content/firebug/firefox/start-button/customizeToolbarOverlay.xul
  15. +1 −177 extension/content/firebug/firefox/start-button/startButtonOverlay.js
  16. +0 −95 extension/content/firebug/firefox/start-button/startButtonOverlay.xul
  17. +5 −262 extension/content/firebug/lib/locale.js
  18. +3 −20 extension/content/firebug/lib/options.js
  19. +0 −7 extension/content/firebug/moduleConfig.js
  20. +0 −158 extension/defaults/preferences/firebug.js
  21. +0 −68 extension/defaults/preferences/tracingConsole.js
  22. BIN  extension/icon64.png
  23. +3 −2 extension/install.rdf
  24. +3 −2 extension/install.rdf.tpl.xml
  25. +12 −0 extension/modules/fbtrace.js
  26. +37 −23 extension/modules/firebug-service.js
  27. +486 −0 extension/modules/loader.js
  28. +259 −0 extension/modules/locale.js
  29. +1 −1  extension/skin/classic/firebug.css
  30. +0 −5 extension/skin/classic/win/firebug.css
  31. +1 −1  extension/update.rdf.tpl.xml
128 extension/bootstrap.js
View
@@ -0,0 +1,128 @@
+/* See license.txt for terms of usage */
+
+// ********************************************************************************************* //
+// Constants
+
+var {classes: Cc, interfaces: Ci, utils: Cu} = Components;
+
+// List of firebug modules that must be loaded at startup and unloaded on shutdown.
+// !important every new module loaded with Cu.import must be added here
+var FIREBUG_MODULES = [
+ "resource://firebug/debuggerHalter.js",
+ "resource://firebug/fbtrace.js",
+ "resource://firebug/firebug-http-observer.js",
+ "resource://firebug/firebug-service.js",
+ "resource://firebug/firebug-trace-service.js",
+ "resource://firebug/loader.js",
+ "resource://firebug/locale.js",
+ "resource://firebug/moduleLoader.js",
+ "resource://firebug/observer-service.js",
+ "resource://firebug/require-debug.js",
+ "resource://firebug/require.js",
+ "resource://firebug/storageService.js"
+];
+
+Cu.import("resource://gre/modules/Services.jsm");
+
+// ********************************************************************************************* //
+// Bootstrap API
+
+function install(params, reason)
+{
+}
+
+function uninstall(params, reason)
+{
+}
+
+function startup(params, reason)
+{
+ // Register the resource:// mappings
+ var res = Services.io.getProtocolHandler("resource").QueryInterface(Ci.nsIResProtocolHandler);
+ var resourceURI = Services.io.newURI(__SCRIPT_URI_SPEC__ + "/../modules/", null, null);
+ res.setSubstitution("firebug", resourceURI);
+ res.setSubstitution("moduleloader", resourceURI);
+
+ // Add our chrome registration. not needed for 10+
+ Components.manager.addBootstrappedManifestLocation(params.installPath);
+
+ // Load the overlay manager
+ Cu.import("resource://firebug/loader.js");
+
+ // register default values
+ FirebugLoader.registerDefaultPrefs();
+
+ //register extensions
+ FirebugLoader.startup();
+
+ // Load Firebug into all existing browser windows.
+ var enumerator = Services.wm.getEnumerator("navigator:browser");
+ while (enumerator.hasMoreElements())
+ FirebugLoader.loadIntoWindow(enumerator.getNext());
+
+ // Listen for new windows, Firebug must be loaded into them too.
+ Services.wm.addListener(WindowListener);
+}
+
+function shutdown(params, reason)
+{
+ // Don't need to clean anything up if the application is shutting down
+ if (reason == APP_SHUTDOWN)
+ return;
+
+ // Remove "new window" listener.
+ Services.wm.removeListener(WindowListener);
+
+ // remove from all windows
+ try
+ {
+ FirebugLoader.shutdown()
+ }
+ catch(e)
+ {
+ Cu.reportError(e)
+ }
+
+ // Shutdown Firebug's JSD debugger service.
+ var fbs = Cu.import("resource://firebug/firebug-service.js", {}).fbs
+ fbs.disableDebugger();
+ fbs.shutdown();
+
+ // remove default preferences
+ FirebugLoader.clearDefaultPrefs();
+
+ // Unload all Firebug modules added with Cu.import
+ FIREBUG_MODULES.forEach(Cu.unload, Cu);
+
+ // Remove our chrome registration. not needed for 10+
+ Components.manager.removeBootstrappedManifestLocation(params.installPath);
+
+ // Clear our resource registration
+ var res = Services.io.getProtocolHandler("resource").QueryInterface(Ci.nsIResProtocolHandler);
+ res.setSubstitution("firebug", null);
+ res.setSubstitution("moduleloader", null);
+}
+
+// ********************************************************************************************* //
+// Window Listener
+
+var WindowListener =
+{
+ onOpenWindow: function(win)
+ {
+ win = win.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindow).window;
+
+ // Wait for the window to finish loading
+ win.addEventListener("load", function onLoad()
+ {
+ win.removeEventListener("load", onLoad, false);
+ if (win.location.href == "chrome://browser/content/browser.xul")
+ FirebugLoader.loadIntoWindow(win)
+ }, false);
+ },
+
+ onCloseWindow: function(win) {},
+ onWindowTitleChange: function(win, aTitle) {}
+}
+
+// ********************************************************************************************* //
22 extension/chrome.manifest
View
@@ -2,10 +2,10 @@ content firebug content/firebug/
content firebug content/firebug/ contentaccessible=yes
# Maps resource://firebug/* to files in modules/*
-resource firebug modules/
+# resource firebug modules/
# Maps resource://moduleloader/* to files in modules/*
-resource moduleloader modules/
+# resource moduleloader modules/
skin firebug classic/1.0 skin/classic/
skin firebug-os classic/1.0 skin/classic/win/
@@ -47,18 +47,18 @@ locale firebug zh-CN locale/zh-CN/
locale firebug zh-TW locale/zh-TW/
#overlay chrome://browser/content/browser.xul chrome://firebug/content/browserOverlay.xul
-overlay chrome://browser/content/browser.xul chrome://firebug/content/firefox/browserOverlayWithFrame.xul
-overlay chrome://browser/content/browser.xul chrome://firebug/content/editor/external/editorsBrowserOverlay.xul
+#overlay chrome://browser/content/browser.xul chrome://firebug/content/firefox/browserOverlayWithFrame.xul
+#overlay chrome://browser/content/browser.xul chrome://firebug/content/editor/external/editorsBrowserOverlay.xul
-overlay chrome://global/content/customizeToolbar.xul chrome://firebug/content/firefox/start-button/customizeToolbarOverlay.xul
-overlay chrome://mozapps/content/extensions/about.xul chrome://firebug/content/firefox/aboutOverlay.xul
+#overlay chrome://global/content/customizeToolbar.xul chrome://firebug/content/firefox/start-button/customizeToolbarOverlay.xul
+#overlay chrome://mozapps/content/extensions/about.xul chrome://firebug/content/firefox/aboutOverlay.xul
# Sea Monkey
#overlay chrome://navigator/content/navigator.xul chrome://firebug/content/browserOverlay.xul
-overlay chrome://navigator/content/navigator.xul chrome://firebug/content/firefox/browserOverlayWithFrame.xul
+#overlay chrome://navigator/content/navigator.xul chrome://firebug/content/firefox/browserOverlayWithFrame.xul
# Support for Mac
-override chrome://firebug/skin/debugger.css chrome://firebug/skin/mac/debugger.css os=Darwin
-override chrome://firebug-os/skin/firebug.css chrome://firebug/skin/mac/firebug.css os=Darwin
-override chrome://firebug-os/skin/panel.css chrome://firebug/skin/mac/panel.css os=Darwin
-override chrome://firebug-os/skin/window.css chrome://firebug/skin/mac/window.css os=Darwin
+override chrome://firebug/skin/debugger.css chrome://firebug/skin/mac/debugger.css os=Darwin
+override chrome://firebug-os/skin/firebug.css chrome://firebug/skin/mac/firebug.css os=Darwin
+override chrome://firebug-os/skin/panel.css chrome://firebug/skin/mac/panel.css os=Darwin
+override chrome://firebug-os/skin/window.css chrome://firebug/skin/mac/window.css os=Darwin
2  extension/content/firebug/accessible/a11y.js
View
@@ -125,7 +125,7 @@ Firebug.A11yModel = Obj.extend(Firebug.Module,
var tmpElem;
//add class used by all a11y related css styles (e.g. :focus and -moz-user-focus styles)
Css.setClass(chrome.$("fbContentBox"), "useA11y");
- Css.setClass(chrome.$("fbStatusBar"), "useA11y");
+ //Css.setClass(chrome.$("fbStatusBar"), "useA11y");
tmpElem = chrome.$("fbStatusPrefix");
if (tmpElem) tmpElem.setAttribute("value", Locale.$STR("a11y.labels.firebug status"));
33 extension/content/firebug/browserOverlay.xul
View
@@ -1,33 +0,0 @@
-<?xml version="1.0"?>
-<!-- See license.txt for terms of usage -->
-
-<?xul-overlay href="chrome://firebug/content/firebugOverlay.xul"?>
-<?xul-overlay href="chrome://firebug/content/firefox/start-button/startButtonOverlay.xul"?>
-<?xul-overlay href="chrome://firebug/content/firefox/browserMenuOverlay.xul"?>
-
-<overlay xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
-
- <script type="application/x-javascript" src="chrome://firebug/content/trace.js"/>
- <script type="application/x-javascript" src="chrome://firebug/content/legacy.js"/>
- <script type="application/x-javascript" src="chrome://firebug/content/moduleConfig.js"/>
- <script type="application/x-javascript" src="chrome://firebug/content/firefox/panelBarWaiter.js"/>
- <script type="application/x-javascript" src="resource://firebug/require.js"/>
- <script type="application/x-javascript" src="resource://firebug/require-debug.js"/>
- <script type="application/x-javascript" src="chrome://firebug/content/main.js"/>
-
- <stringbundleset id="stringbundleset"/>
- <commandset id="baseMenuCommandSet"/>
- <keyset id="baseMenuKeyset"/>
- <keyset id="mainKeyset"/>
- <broadcasterset id="mainBroadcasterSet"/>
- <popupset id="mainPopupSet"/>
-
- <!-- Firebug panel -->
- <vbox id="appcontent">
- <splitter id="fbContentSplitter" collapsed="true"/>
- <vbox id="fbMainFrame" persist="height" collapsed="true">
- <vbox id="fbContentBox" flex="2" />
- </vbox>
- </vbox>
-
-</overlay>
44 extension/content/firebug/chrome/chrome.js
View
@@ -224,6 +224,9 @@ var FirebugChrome =
if (FBTrace.DBG_INITIALIZE)
FBTrace.sysout("chrome.initializeUI; Custom stylesheet appended " +
Firebug.stylesheets.length, Firebug.stylesheets);
+
+ // Fire event for window event listeners.
+ Firebug.sendLoadEvent();
}
catch (exc)
{
@@ -1027,23 +1030,24 @@ var FirebugChrome =
pos && this.syncPositionPref(pos);
- var vertical = pos == 'top' || pos == 'bottom';
- var after = pos == 'bottom' || pos == 'right';
+ var vertical = pos == "top" || pos == "bottom";
+ var after = pos == "bottom" || pos == "right";
var document = window.top.document;
- var splitter = Firefox.getElementById('fbContentSplitter');
var container = document.getElementById(vertical ? "appcontent" : "browser");
+
+ var splitter = Firefox.getElementById("fbContentSplitter");
splitter.setAttribute("orient", vertical ? "vertical" : "horizontal");
splitter.setAttribute("dir", after ? "" : "reverse");
- container.insertBefore(splitter, after ? null: container.firstChild);
+ container.insertBefore(splitter, after ? null : container.firstChild);
- var frame = document.getElementById('fbMainFrame');
+ var frame = document.getElementById("fbMainFrame");
var newFrame = frame.cloneNode(true);
- var newBrowser = newFrame.querySelector('#fbMainContainer');
- var oldBrowser = frame.querySelector('#fbMainContainer');
+ var newBrowser = newFrame.querySelector("#fbMainContainer");
+ var oldBrowser = frame.querySelector("#fbMainContainer");
- newBrowser.removeAttribute('src');
+ newBrowser.removeAttribute("src");
container.insertBefore(newFrame, after ? null: container.firstChild);
this.swapBrowsers(oldBrowser, newBrowser);
@@ -1067,30 +1071,6 @@ var FirebugChrome =
return Firebug.framePosition = pos;
},
- onPositionPopupShowing: function(popup)
- {
- Dom.eraseNode(popup);
-
- var items = [];
-
- for each(var pos in ["detached", "top", "bottom", "left", "right"])
- {
- items.push({
- label: Locale.$STR("position." + pos),
- type: "radio",
- command: Obj.bindFixed(this.setPosition, this, pos),
- checked: Firebug.framePosition == pos
- });
- }
-
- items.splice(1, 0, "-");
-
- items[0].key = "key_detachFirebug";
-
- for each(var i in items)
- Menu.createMenuItem(popup, i);
- },
-
swapBrowsers: function(oldBrowser, newBrowser)
{
var oldDoc = oldBrowser.contentDocument
3  extension/content/firebug/firebug.js
View
@@ -173,9 +173,6 @@ window.Firebug =
Events.dispatch(modules, "initialize", []);
- // Fire event for window event listeners.
- this.sendLoadEvent();
-
// This is the final of Firebug initialization.
FBTrace.timeEnd("INITIALIZATION_TIME");
},
2  extension/content/firebug/firebugOverlay.xul
View
@@ -111,7 +111,7 @@
<!-- Open In New Window & Minimize & Close -->
<hbox id="fbWindowButtons" role="toolbar" class="innerToolbar"
aria-label="firebug window" context="_child">
- <menupopup onpopupshowing="Firebug.chrome.onPositionPopupShowing(this)"/>
+ <menupopup onpopupshowing="Firebug.GlobalUI.onPositionPopupShowing(this)"/>
<toolbarbutton id="fbMinimizeButton"
class="toolbarbutton-iconic fbInternational"
tooltiptext="Minimize Firebug" command="cmd_minimizeFirebug"/>
65 ...tent/firebug/firefox/start-button/startButton.css → extension/content/firebug/firefox/browser.css
View
@@ -15,7 +15,7 @@
}
#firebug-button[firebugActive="true"] .toolbarbutton-icon {
- list-style-image: url(chrome://firebug/skin/firebug16.png);
+ list-style-image: url(chrome://firebug/skin/firebug16.png)!important;
}
/* Error badge (displays an error counter). The badge is only visible if error count
@@ -60,6 +60,14 @@
visibility: visible;
}
+/* old statusbar item look when on addonbar*/
+#addon-bar #firebug-button dropmarker {
+ display: none;
+}
+#addon-bar #firebug-button .fb-toolbarbutton{
+ padding: 0 3px!important;
+}
+
/* Slightly different positions of the badge for individual toolbars */
#nav-bar #firebug-button .badge {
margin: 3px -10px 0 -8px;
@@ -105,4 +113,57 @@
#fbStatusIcon[firebugActive="true"] {
list-style-image: url(chrome://firebug/skin/firebug16.png);
-}
+}
+
+/*************************************************************************************************/
+/* Firebug Menu & Firefox context menu */
+
+#menu_firebug, #appmenu_firebug, #menu_webDeveloper_firebug {
+ list-style-image: url(chrome://firebug/skin/firebug16.png);
+}
+
+#menu_firebugInspect {
+ list-style-image: url(chrome://firebug/skin/Templarian_inspector.png);
+ -moz-image-region: rect(0, 16px, 16px, 0);
+}
+
+#menu_firebugInspect:hover,
+#menu_firebugInspect:active {
+ -moz-image-region: rect(16px, 16px, 32px, 0);
+}
+
+/*************************************************************************************************/
+/* browser.xul & browserOverlayWithFrame */
+
+#fbMainFrame {
+ height: 270px;
+ width: 370px;
+}
+
+/*************************************************************************************************/
+/* Firebug Splitter */
+
+#fbContentSplitter{
+ border-color: threedShadow !important;
+ background-color: #FFFFFF;
+}
+
+#fbContentSplitter[dir=reverse]{
+ -moz-transform: scale(-1, -1);
+}
+
+#fbContentSplitter[orient=vertical] {
+ border-top: 1px solid !important;
+ border-bottom: none;
+ min-height: 5px;
+ max-height: 5px;
+ background-color: -moz-dialog;
+}
+
+#fbContentSplitter[orient=horizontal] {
+ border-right: 1px solid !important;
+ border-left: none;
+ min-width: 5px;
+ max-width: 5px;
+ background-color: -moz-dialog;
+}
96 extension/content/firebug/firefox/browserMenuOverlay.xul
View
@@ -1,96 +0,0 @@
-<?xml version="1.0"?>
-<!-- See license.txt for terms of usage -->
-
-<overlay xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
-
- <!-- Shortcuts and commands that must be enabled in browser.xul scope -->
- <keyset id="mainKeyset">
- <key id="key_toggleFirebug" keycode="VK_F12" command="cmd_toggleFirebug" position="1"/>
- <key id="key_toggleInspecting" key="c" modifiers="accel,shift" command="cmd_toggleInspecting" position="2"/>
- <key id="key_focusCommandLine" key="l" modifiers="accel,shift" command="cmd_focusCommandLine" position="3"/>
- <key id="key_detachFirebug" keycode="VK_F12" modifiers="accel" command="cmd_detachFirebug" position="4"/>
- <key id="key_closeFirebug" keycode="VK_F12" modifiers="shift" command="cmd_closeFirebug" position="5"/>
- </keyset>
-
- <commandset id="mainCommandSet">
- <command id="cmd_closeFirebug" oncommand="Firebug.closeFirebug(true)"/>
- <command id="cmd_toggleInspecting" oncommand="if (!Firebug.currentContext) Firebug.toggleBar(true); Firebug.Inspector.toggleInspecting(Firebug.currentContext)"
- checked="false"/>
- <command id="cmd_focusCommandLine" oncommand="if (!Firebug.currentContext) Firebug.toggleBar(true); Firebug.CommandLine.focus(Firebug.currentContext)"/>
- <command id="cmd_toggleFirebug" oncommand="Firebug.toggleBar()"/>
- <command id="cmd_detachFirebug" oncommand="Firebug.toggleDetachBar(false, true)"/>
- <command id="cmd_inspect" oncommand="Firebug.Inspector.inspectFromContextMenu(document.popupNode);"/>
- <command id="cmd_toggleDetachFirebug" oncommand="Firebug.toggleDetachBar(false, true)"/>
- <command id="cmd_increaseTextSize" oncommand="Firebug.Options.changeTextSize(1);"/>
- <command id="cmd_decreaseTextSize" oncommand="Firebug.Options.changeTextSize(-1);"/>
- <command id="cmd_normalTextSize" oncommand="Firebug.Options.setTextSize(0);"/>
- <command id="cmd_focusFirebugSearch" oncommand="if (Firebug.currentContext) Firebug.Search.onSearchCommand(document);"/>
- <command id="cmd_customizeFBKeys" oncommand="Firebug.ShortcutsModel.customizeShortcuts()"/>
-
- <command id="cmd_enablePanels" oncommand="Firebug.PanelActivation.enableAllPanels()"/>
- <command id="cmd_disablePanels" oncommand="Firebug.PanelActivation.disableAllPanels()"/>
- <command id="cmd_clearActivationList" oncommand="Firebug.PanelActivation.clearAnnotations()"/>
- <command id="cmd_clearConsole" oncommand="Firebug.Console.clear(Firebug.currentContext)"/>
- <command id="cmd_allOn" oncommand="Firebug.PanelActivation.toggleAll('on')"/>
- </commandset>
-
- <!-- Firefox page context menu -->
- <menupopup id="contentAreaContextMenu">
- <menuseparator/>
- <menuitem id="menu_firebugInspect" label="firebug.InspectElementWithFirebug"
- command="cmd_inspect" class="menuitem-iconic fbInternational" />
- </menupopup>
-
- <!-- Firefox View menu -->
- <menupopup id="menu_viewPopup">
- <menuitem id="menu_viewToggleFirebug" insertbefore="toggle_taskbar"
- label="firebug.Firebug" type="checkbox"
- key="key_toggleFirebug" command="cmd_toggleFirebug"
- class="fbInternational"/>
- </menupopup>
-
- <!-- SeaMonkey View menu -->
- <menupopup id="menu_View_Popup">
- <menuitem id="menu_viewToggleFirebug" insertafter="menuitem_fullScreen"
- label="firebug.Firebug" type="checkbox"
- key="key_toggleFirebug" command="cmd_toggleFirebug"
- class="fbInternational"/>
- </menupopup>
-
- <!-- Firefox Tools menu -->
- <menupopup id="menu_ToolsPopup">
- <menu id="menu_firebug" class="menu-iconic fbInternational"
- label="firebug.Firebug" insertbefore="javascriptConsole">
- <!-- Content comes from fbFirebugMenuPopup -->
- </menu>
- </menupopup>
-
- <!-- Firefox Tools -> WebDeveloper menu -->
- <menupopup id="menuWebDeveloperPopup">
- <menu id="menu_webDeveloper_firebug" class="menu-iconic fbInternational"
- label="firebug.Firebug" insertbefore="webConsole">
- <!-- Content comes from fbFirebugMenuPopup -->
- </menu>
- <menuseparator insertbefore="webConsole" />
- </menupopup>
-
- <!-- Firefox 4 Web Developer menu -->
- <menupopup id="appmenu_webDeveloper_popup">
- <splitmenu id="appmenu_firebug" class="fbInternational" iconic="true"
- label="firebug.Firebug" insertbefore="appmenu_webConsole"
- command="cmd_toggleFirebug" key="key_toggleFirebug">
- <!-- Content comes from fbFirebugMenuPopup -->
- </splitmenu>
- <menuseparator insertbefore="appmenu_webConsole" />
- </menupopup>
-
- <!-- SeaMonkey Tools menu -->
- <menupopup id="toolsPopup">
- <menu id="menu_firebug" class="menuitem-iconic fbInternational"
- label="firebug.Firebug"
- insertbefore="appmenu_webConsole">
- <!-- Content comes from fbFirebugMenuPopup -->
- </menu>
- </menupopup>
-
-</overlay>
960 extension/content/firebug/firefox/browserOverlay.js
View
@@ -0,0 +1,960 @@
+/* See license.txt for terms of usage */
+
+(function() {
+
+// ********************************************************************************************* //
+// Constants
+
+var Cu = Components.utils;
+
+Cu.import("resource://firebug/fbtrace.js");
+Cu.import("resource://firebug/loader.js");
+var Locale = Cu.import("resource://firebug/locale.js").Locale;
+
+// Firebug URLs used by the global menu.
+var firebugURLs =
+{
+ main: "http://www.getfirebug.com",
+ FAQ: "http://getfirebug.com/wiki/index.php/FAQ",
+ docs: "http://www.getfirebug.com/docs.html",
+ keyboard: "http://getfirebug.com/wiki/index.php/Keyboard_and_Mouse_Shortcuts",
+ discuss: "http://groups.google.com/group/firebug",
+ issues: "http://code.google.com/p/fbug/issues/list",
+ donate: "http://getfirebug.com/getinvolved",
+};
+
+// Register bundle yet before any Locale.$STR* API is used.
+Locale.registerStringBundle("chrome://firebug/locale/firebug.properties");
+
+// ********************************************************************************************* //
+// Overlay Helpers
+
+function $(id)
+{
+ return document.getElementById(id);
+}
+
+function $$(selector)
+{
+ return document.querySelectorAll(selector);
+}
+
+function $el(name, attributes, children, parent)
+{
+ attributes = attributes || {};
+
+ if (!Array.isArray(children))
+ {
+ parent = children;
+ children = null;
+ }
+
+ // localize
+ if (attributes.label)
+ attributes.label = Locale.$STR(attributes.label);
+
+ if (attributes.tooltiptext)
+ attributes.tooltiptext = Locale.$STR(attributes.tooltiptext);
+
+ // persist
+ if (attributes.persist)
+ updatePersistedValues(attributes);
+
+ var el = document.createElement(name);
+ for (var a in attributes)
+ el.setAttribute(a, attributes[a]);
+
+ for each(var a in children)
+ el.appendChild(a);
+
+ if (parent)
+ {
+ parent.appendChild(el);
+
+ // Mark to remove when Firebug is uninstalled.
+ el.setAttribute("firebugRootNode", true);
+ }
+
+ return el;
+}
+
+function $command(id, oncommand)
+{
+ // Wrap the command within a startFirebug call. If Firebug isn't yet loaded
+ // this will force it to load.
+ oncommand = "Firebug.GlobalUI.startFirebug(function(){" + oncommand + "})";
+
+ return $el("command", {
+ id: id,
+ oncommand: oncommand
+ }, $("mainCommandSet"))
+}
+
+function $key(id, keycode, modifiers, command, position)
+{
+ return $el("key", {
+ id: id,
+ keycode: keycode,
+ modifiers: modifiers,
+ command: command,
+ position: position
+ }, $("mainKeyset"))
+}
+
+function $menupopup(attributes, children, parent)
+{
+ return $el("menupopup", attributes, children, parent);
+}
+
+function $menu(attrs, children)
+{
+ return $el("menu", attrs, children);
+}
+
+function $menuseparator(attrs)
+{
+ return $el("menuseparator", attrs);
+}
+
+function $menuitem(attrs)
+{
+ return $el("menuitem", attrs);
+}
+
+function $splitmenu(attrs, children)
+{
+ return $el("splitmenu", attrs, children);
+}
+
+function $menupopupOverlay(parent, children)
+{
+ if (!parent)
+ return;
+
+ for each(var child in children)
+ {
+ var insertBefore = child.getAttribute("insertbefore");
+ var insertAfter = child.getAttribute("insertafter");
+
+ if (insertBefore)
+ parent.insertBefore(child, parent.querySelector("#" + insertBefore));
+ else if (insertAfter)
+ parent.insertAfter(child, parent.querySelector("#" + insertAfter));
+ else
+ parent.appendChild(child);
+
+ // Mark the inserted node to remove it when Firebug is uninstalled.
+ child.setAttribute("firebugRootNode", true);
+ }
+}
+
+function $toolbarButton(id, attrs, children, defaultPos)
+{
+ attrs["class"] = "toolbarbutton-1 chromeclass-toolbar-additional";
+ attrs.firebugRootNode = true;
+ attrs.id = id;
+
+ var button = $el("toolbarbutton", attrs, children, gNavToolbox.palette);
+
+ var selector = "[currentset^='" + id + ",'],[currentset*='," + id + ",'],[currentset$='," + id + "']";
+ var toolbar = document.querySelector(selector);
+ if (!toolbar)
+ return; // todo defaultPos
+
+ var currentset = toolbar.getAttribute("currentset").split(",");
+ var i = currentset.indexOf(id) + 1;
+
+ var len = currentset.length, beforeEl;
+ while (i < len && !(beforeEl = $(currentset[i])))
+ i++;
+
+ return toolbar.insertItem(id, beforeEl);
+}
+
+// ********************************************************************************************* //
+// Other Helpers
+
+function updatePersistedValues(options)
+{
+ var persist = options.persist.split(",");
+ var id = options.id;
+ var RDF = Cc["@mozilla.org/rdf/rdf-service;1"].getService(Ci.nsIRDFService);
+ var store = PlacesUIUtils.localStore; //this.RDF.GetDataSource("rdf:local-store");
+ var root = RDF.GetResource("chrome://browser/content/browser.xul#" + id);
+
+ var getPersist = function getPersist(aProperty)
+ {
+ var property = RDF.GetResource(aProperty);
+ var target = store.GetTarget(root, property, true);
+
+ if (target instanceof Ci.nsIRDFLiteral)
+ return target.Value;
+ }
+
+ for each(var attr in persist)
+ {
+ var val = getPersist(attr);
+ if (val)
+ options[attr] = val;
+ }
+}
+
+function cloneArray(arr)
+{
+ var newArr = [];
+ for (var i=0; i<arr.length; i++)
+ newArr.push(arr[i]);
+ return newArr;
+}
+
+// ********************************************************************************************* //
+
+Firebug.GlobalUI =
+{
+ nodesToRemove: [],
+
+ $: $,
+ $$: $$,
+ $el: $el,
+ $menupopupOverlay: $menupopupOverlay,
+ $menuitem: $menuitem,
+ $menuseparator: $menuseparator,
+ $command: $command,
+ $key: $key,
+ $splitmenu: $splitmenu,
+
+ $stylesheet: function(href)
+ {
+ var s = document.createProcessingInstruction("xml-stylesheet", 'href="' + href + '"');
+ document.insertBefore(s, document.documentElement);
+ this.nodesToRemove.push(s);
+ },
+
+ $script: function(src)
+ {
+ var script = document.createElementNS("http://www.w3.org/1999/xhtml", "html:script");
+ script.src = src;
+ script.type = "text/javascript";
+ script.setAttribute("firebugRootNode", true);
+ document.documentElement.appendChild(script);
+ },
+
+ // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+ /**
+ * This method is called by the Fremework to load entire Firebug. It's executed when
+ * the user requires Firebug for the first time.
+ *
+ * @param {Object} callback Executed when Firebug is fully loaded
+ */
+ startFirebug: function(callback)
+ {
+ if (Firebug.waitingForFirstLoad)
+ return;
+
+ if (Firebug.isInitialized)
+ return callback && callback(Firebug);
+
+ if (FBTrace.DBG_INITIALIZE)
+ FBTrace.sysout("overlay; Load Firebug...");
+
+ Firebug.waitingForFirstLoad = true;
+
+ var container = $("appcontent");
+
+ // List of Firbug scripts that must be loaded into the global scope (browser.xul)
+ var scriptSources = [
+ "chrome://firebug/content/trace.js",
+ "chrome://firebug/content/legacy.js",
+ "chrome://firebug/content/moduleConfig.js"
+ ]
+
+ // Create script elements.
+ scriptSources.forEach(this.$script);
+
+ // Create Firebug splitter element.
+ $el("splitter", {id: "fbContentSplitter", collapsed: "true"}, container);
+
+ // Create Firebug main frame and container.
+ $el("vbox", {id: "fbMainFrame", collapsed: "true", persist: "height,width"}, [
+ $el("browser", {
+ id: "fbMainContainer",
+ flex: "2",
+ src: "chrome://firebug/content/firefox/firebugFrame.xul",
+ disablehistory: "true"
+ })
+ ], container);
+
+ // When Firebug is fully loaded and initialized it fires an "FirebugLoaded"
+ // event to the browser document (browser.xul scope) so, wait for it now.
+ document.addEventListener("FirebugLoaded", function onLoad()
+ {
+ document.removeEventListener("FirebugLoaded", onLoad, false);
+ Firebug.waitingForFirstLoad = false;
+ callback && callback(Firebug);
+ }, false);
+ },
+
+ onOptionsShowing: function(popup)
+ {
+ for (var child = popup.firstChild; child; child = child.nextSibling)
+ {
+ if (child.localName == "menuitem")
+ {
+ var option = child.getAttribute("option");
+ if (option)
+ {
+ var checked = FirebugLoader.getPref(option);
+ child.setAttribute("checked", checked);
+ }
+ }
+ }
+ },
+
+ onToggleOption: function(menuItem)
+ {
+ var option = menuItem.getAttribute("option");
+ var checked = menuItem.getAttribute("checked") == "true";
+
+ FirebugLoader.setPref(option, checked);
+ },
+
+ onMenuShowing: function(popup)
+ {
+ var currPos = FirebugLoader.getPref("framePosition");
+ var detachFirebug = document.getElementById("menu_detachFirebug");
+ if (detachFirebug)
+ {
+ detachFirebug.setAttribute("label", (currPos == "detached" ?
+ Locale.$STR("firebug.AttachFirebug") : Locale.$STR("firebug.DetachFirebug")));
+ }
+
+ var toggleFirebug = document.getElementById("menu_toggleFirebug");
+ if (toggleFirebug)
+ {
+ var collapsed = "true";
+ if (Firebug.chrome)
+ {
+ var fbContentBox = Firebug.chrome.$("fbContentBox");
+ collapsed = fbContentBox.getAttribute("collapsed");
+ }
+
+ toggleFirebug.setAttribute("label", (collapsed == "true" ?
+ Locale.$STR("firebug.ShowFirebug") : Locale.$STR("firebug.HideFirebug")));
+
+ // If Firebug is detached, hide the menu ('Open Firebug' shortcut doesn't hide,
+ // but just focuses the external window)
+ if (currPos == "detached")
+ toggleFirebug.setAttribute("collapsed", (collapsed == "true" ? "false" : "true"));
+ }
+ },
+
+ onPositionPopupShowing: function(popup)
+ {
+ while (popup.lastChild)
+ popup.removeChild(popup.lastChild);
+
+ // Load Firebug before the position is changed.
+ var oncommand = "Firebug.GlobalUI.startFirebug(function(){" +
+ "Firebug.chrome.setPosition('%pos%')" + "})";
+
+ var items = [];
+ var currPos = FirebugLoader.getPref("framePosition");
+ for each (var pos in ["detached", "top", "bottom", "left", "right"])
+ {
+ var item = $menuitem({
+ label: Locale.$STR("position." + pos),
+ type: "radio",
+ oncommand: oncommand.replace("%pos%", pos),
+ checked: (currPos == pos)
+ });
+
+ if (pos == "detached")
+ items.key = "key_detachFirebug";
+
+ popup.appendChild(item);
+ }
+
+ return true;
+ },
+
+ openAboutDialog: function()
+ {
+ // Firefox 4.0+
+ Components.utils["import"]("resource://gre/modules/AddonManager.jsm");
+ AddonManager.getAddonByID("firebug@software.joehewitt.com", function(addon)
+ {
+ openDialog("chrome://mozapps/content/extensions/about.xul", "",
+ "chrome,centerscreen,modal", addon);
+ });
+ },
+
+ visitWebsite: function(which)
+ {
+ var url = firebugURLs[which];
+ if (url)
+ gBrowser.selectedTab = gBrowser.addTab(url, null, null, null);
+ },
+
+ setPosition: function(newPosition)
+ {
+ // todo
+ },
+
+ getVersion: function()
+ {
+ var versionURL = "chrome://firebug/content/branch.properties";
+ var ioService = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
+
+ var channel = ioService.newChannel(versionURL, null, null);
+ var input = channel.open();
+ var sis = Cc["@mozilla.org/scriptableinputstream;1"].
+ createInstance(Ci.nsIScriptableInputStream);
+ sis.init(input);
+
+ var content = sis.readBytes(input.available());
+ sis.close();
+
+ var m = /RELEASE=(.*)/.exec(content);
+ if (m)
+ var release = m[1];
+ else
+ return "no RELEASE in " + versionURL;
+
+ m = /VERSION=(.*)/.exec(content);
+ if (m)
+ var version = m[1];
+ else
+ return "no VERSION in " + versionURL;
+
+ return version+""+release;
+ },
+
+ // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+ // External Editors
+
+ onEditorsShowing: function(popup)
+ {
+ Firebug.GlobalUI.startFirebug(function()
+ {
+ Firebug.ExternalEditors.onEditorsShowing(popup);
+ });
+
+ return true;
+ }
+}
+
+// ********************************************************************************************* //
+// Global Firebug CSS
+
+Firebug.GlobalUI.$stylesheet("chrome://firebug/content/firefox/browser.css");
+
+// ********************************************************************************************* //
+// Broadcasters
+
+/**
+ * This element (a broadcaster) is storing Firebug state information. Other elements
+ * (like for example the Firebug start button) can watch it and display the info to
+ * the user.
+ */
+$el("broadcaster", {id: "firebugStatus", suspended: true}, $("mainBroadcasterSet"));
+
+// ********************************************************************************************* //
+// Global Commands
+
+$command("cmd_closeFirebug", "Firebug.closeFirebug(true)");
+$command("cmd_toggleInspecting", "if (!Firebug.currentContext) Firebug.toggleBar(true); Firebug.Inspector.toggleInspecting(Firebug.currentContext)");
+$command("cmd_focusCommandLine", "if (!Firebug.currentContext) Firebug.toggleBar(true); Firebug.CommandLine.focus(Firebug.currentContext)");
+$command("cmd_toggleFirebug", "Firebug.toggleBar()");
+$command("cmd_detachFirebug", "Firebug.goDoCommand(this)");
+$command("cmd_inspect", "Firebug.Inspector.inspectFromContextMenu(document.popupNode);");
+$command("cmd_toggleDetachFirebug", "Firebug.toggleDetachBar(false, true)");
+$command("cmd_increaseTextSize", "Firebug.Options.changeTextSize(1);");
+$command("cmd_decreaseTextSize", "Firebug.Options.changeTextSize(-1);");
+$command("cmd_normalTextSize", "Firebug.Options.setTextSize(0);");
+$command("cmd_focusFirebugSearch", "if (Firebug.currentContext) Firebug.Search.onSearchCommand(document);");
+$command("cmd_customizeFBKeys", "Firebug.ShortcutsModel.customizeShortcuts()");
+$command("cmd_enablePanels", "Firebug.PanelActivation.enableAllPanels()");
+$command("cmd_disablePanels", "Firebug.PanelActivation.disableAllPanels()");
+$command("cmd_clearActivationList", "Firebug.PanelActivation.clearAnnotations()");
+$command("cmd_clearConsole", "Firebug.Console.clear(Firebug.currentContext)");
+$command("cmd_allOn", "Firebug.PanelActivation.toggleAll('on')");
+$command("cmd_toggleOrient", ""); //todo
+$command("cmd_toggleOrient", ""); //todo
+$command("cmd_toggleOrient", ""); //todo
+$command("cmd_toggleProfiling", ""); //todo
+
+$command("cmd_openInEditor", "Firebug.ExternalEditors.onContextMenuCommand(event)");
+
+// ********************************************************************************************* //
+// Global Shortcuts
+
+$key("key_toggleFirebug", "VK_F12", "", "cmd_toggleFirebug", 1);
+$key("key_toggleInspecting", "c", "accel,shift", "cmd_toggleInspecting", 2);
+$key("key_focusCommandLine", "l", "accel,shift", "cmd_focusCommandLine", 3);
+$key("key_detachFirebug", "VK_F12", "accel", "cmd_detachFirebug", 4);
+$key("key_closeFirebug", "VK_F12", "shift", "cmd_closeFirebug", 5);
+
+/* Used by the global menu, but should be really global shortcuts?
+key_increaseTextSize
+key_decreaseTextSize
+key_normalTextSize
+key_help
+key_toggleProfiling
+key_focusFirebugSearch
+key_customizeFBKeys
+*/
+
+// ********************************************************************************************* //
+// Firebug Start Button Popup Menu
+
+$menupopupOverlay($("mainPopupSet"), [
+ $menupopup({id: "fbStatusContextMenu",
+ onpopupshowing: "Firebug.GlobalUI.onOptionsShowing(this)"}, [
+ $menu({label:"firebug.uiLocation", "class": "fbInternational"}, [
+ $menupopup({onpopupshowing: "Firebug.GlobalUI.onPositionPopupShowing(this)"})
+ ]),
+ $menuseparator(),
+ $menuitem({
+ id: "menu_ClearConsole",
+ label: "firebug.ClearConsole",
+ command: "cmd_clearConsole",
+ key: "key_clearConsole"
+ }),
+ $menuitem({
+ id: "menu_showErrorCount",
+ type: "checkbox",
+ label: "firebug.Show Error Count",
+ oncommand: "Firebug.GlobalUI.onToggleOption(this)",
+ option: "showErrorCount"
+ }),
+ $menuseparator(),
+ $menuitem({
+ id: "menu_enablePanels",
+ label: "firebug.menu.Enable All Panels",
+ command: "cmd_enablePanels"
+ }),
+ $menuitem({
+ id: "menu_disablePanels",
+ label: "firebug.menu.Disable All Panels",
+ command: "cmd_disablePanels"
+ }),
+ $menuseparator(),
+ $menuitem({
+ id: "menu_AllOn",
+ type: "checkbox",
+ label: "On_for_all_web_pages",
+ command: "cmd_allOn"
+ }),
+ $menuitem({
+ id: "menu_clearActivationList",
+ label: "firebug.menu.Clear Activation List",
+ command: "cmd_clearActivationList"
+ })
+ ])
+])
+
+// ********************************************************************************************* //
+// Firebug Global Menu
+
+/**
+ * There are more instances of Firebug Menu (e.g. one in Firefox -> Tools -> Web Developer
+ * and one in Firefox 4 (top-left orange button menu) -> Web Developer
+ *
+ * If extensions want to override the menu thay need to iterate all existing instance
+ * using document.querySelectorAll(".fbFirebugMenuPopup") and appen new menu items to all
+ * of them. Iteration must be done in the global space (browser.xul)
+ *
+ * The same menu is also used for Firebug Icon Menu (Firebug's toolbar). This menu is cloned
+ * and initialized as soon as Firebug UI is actually loaded. Sine it's cloned from the original
+ * (global scope) extensions don't have to extend it (possible new menu items are already there).
+ */
+var firebugMenuPopup = $menupopup({id: "fbFirebugMenuPopup",
+ "class": "fbFirebugMenuPopup",
+ onpopupshowing: "return Firebug.GlobalUI.onMenuShowing(this);"}, [
+
+ // Open/close Firebug
+ $menuitem({
+ id: "menu_toggleFirebug",
+ label: "firebug.ShowFirebug",
+ command: "cmd_toggleFirebug",
+ key: "key_toggleFirebug",
+ "class": "fbInternational"
+ }),
+ $menuitem({
+ id: "menu_closeFirebug",
+ label: "firebug.CloseFirebug",
+ command: "cmd_closeFirebug",
+ key: "key_closeFirebug",
+ "class": "fbInternational"
+ }),
+
+ // Firebug UI position
+ $menu({label:"firebug.uiLocation", "class": "fbInternational"}, [
+ $menupopup({onpopupshowing: "Firebug.GlobalUI.onPositionPopupShowing(this)"})
+ ]),
+
+ $menuseparator(),
+
+ // External Editors
+ $menu({id: "FirebugMenu_OpenWith", label:"firebug.OpenWith", "class": "fbInternational",
+ insertafter: "menu_openActionsSeparator", openFromContext: "true",
+ command: "cmd_openInEditor"}, [
+ $menupopup({id:"fbFirebugMenu_OpenWith",
+ onpopupshowing: "return Firebug.GlobalUI.onEditorsShowing(this);"})
+ ]),
+
+ // Text Size
+ $menu({id: "FirebugMenu_TextSize", label:"firebug.TextSize", "class": "fbInternational"}, [
+ $menupopup({}, [
+ $menuitem({
+ id: "menu_increaseTextSize",
+ label: "firebug.IncreaseTextSize",
+ command: "cmd_increaseTextSize",
+ key: "key_increaseTextSize",
+ "class": "fbInternational"
+ }),
+ $menuitem({
+ id: "menu_decreaseTextSize",
+ label: "firebug.DecreaseTextSize",
+ command: "cmd_decreaseTextSize",
+ key: "key_decreaseTextSize",
+ "class": "fbInternational"
+ }),
+ $menuitem({
+ id: "menu_normalTextSize",
+ label: "firebug.NormalTextSize",
+ command: "cmd_normalTextSize",
+ key: "key_normalTextSize",
+ "class": "fbInternational"
+ }),
+ ])
+ ]),
+
+ // Options
+ $menu({id: "FirebugMenu_Options", label:"firebug.Options", "class": "fbInternational"}, [
+ $menupopup({id: "FirebugMenu_OptionsPopup",
+ onpopupshowing: "return Firebug.GlobalUI.onOptionsShowing(this);"}, [
+ $menuitem({
+ id: "menu_toggleShowErrorCount",
+ type: "checkbox",
+ label: "firebug.Show_Error_Count",
+ oncommand: "Firebug.GlobalUI.onToggleOption(this)",
+ option: "showErrorCount",
+ "class": "fbInternational"
+ }),
+ $menuitem({
+ id: "menu_showTooltips",
+ type: "checkbox",
+ label: "firebug.ShowTooltips",
+ oncommand: "Firebug.GlobalUI.onToggleOption(this)",
+ option: "showInfoTips",
+ "class": "fbInternational"
+ }),
+ $menuitem({
+ id: "menu_shadeBoxModel",
+ type: "checkbox",
+ label: "firebug.ShadeBoxModel",
+ oncommand: "Firebug.GlobalUI.onToggleOption(this)",
+ option: "shadeBoxModel",
+ "class": "fbInternational"
+ }),
+ $menuitem({
+ id: "showQuickInfoBox",
+ type: "checkbox",
+ label: "firebug.Show_Quick_Info_Box",
+ oncommand: "Firebug.GlobalUI.onToggleOption(this)",
+ option: "showQuickInfoBox",
+ "class": "fbInternational"
+ }),
+ $menuitem({
+ id: "menu_enableA11y",
+ type: "checkbox",
+ label: "firebug.menu.Enable Accessibility Enhancements",
+ oncommand: "Firebug.GlobalUI.onToggleOption(this)",
+ option: "a11y.enable",
+ "class": "fbInternational"
+ }),
+ $menuitem({
+ id: "menu_activateSameOrigin",
+ type: "checkbox",
+ label: "firebug.menu.Activate Same Origin URLs",
+ oncommand: "Firebug.GlobalUI.onToggleOption(this)",
+ option: "activateSameOrigin",
+ "class": "fbInternational"
+ }),
+ $menuitem({
+ id: "menu_toggleOrient",
+ type: "checkbox",
+ label: "firebug.Vertical",
+ command: "cmd_toggleOrient",
+ option: "viewPanelOrient",
+ "class": "fbInternational"
+ }),
+ $menuseparator({id: "menu_optionsSeparator"}),
+ $menuitem({
+ id: "menu_resetAllOptions",
+ label: "firebug.menu.Reset All Firebug Options",
+ command: "cmd_resetAllOptions",
+ "class": "fbInternational"
+ }),
+ ])
+ ]),
+
+ $menuseparator({id: "FirebugBetweenOptionsAndSites", collapsed: "true"}),
+
+ // Sites
+ $menu({id: "FirebugMenu_Sites", label:"firebug.menu.Firebug Online", "class": "fbInternational"}, [
+ $menupopup({}, [
+ $menuitem({
+ id: "menu_firebugUrlWebsite",
+ label: "firebug.Website",
+ oncommand: "Firebug.GlobalUI.visitWebsite('main')",
+ "class": "fbInternational"
+ }),
+ $menuitem({
+ id: "menu_firebugFAQ",
+ label: "firebug.FAQ",
+ command: "cmd_openHelp",
+ key: "key_help",
+ "class": "fbInternational"
+ }),
+ $menuitem({
+ id: "menu_firebugDoc",
+ label: "firebug.Documentation",
+ oncommand: "Firebug.GlobalUI.visitWebsite('docs')",
+ "class": "fbInternational"
+ }),
+ $menuitem({
+ id: "menu_firebugKeyboard",
+ label: "firebug.KeyShortcuts",
+ oncommand: "Firebug.GlobalUI.visitWebsite('keyboard')",
+ "class": "fbInternational"
+ }),
+ $menuitem({
+ id: "menu_firebugForums",
+ label: "firebug.Forums",
+ oncommand: "Firebug.GlobalUI.visitWebsite('discuss')",
+ "class": "fbInternational"
+ }),
+ $menuitem({
+ id: "menu_firebugIssues",
+ label: "firebug.Issues",
+ oncommand: "Firebug.GlobalUI.visitWebsite('issues')",
+ "class": "fbInternational"
+ }),
+ $menuitem({
+ id: "menu_firebugDonate",
+ label: "firebug.Donate",
+ oncommand: "Firebug.GlobalUI.visitWebsite('donate')",
+ "class": "fbInternational"
+ }),
+ ])
+ ]),
+
+ $menuseparator({id: "menu_miscActionsSeparator", collapsed: "true"}),
+
+ $menuseparator({id: "menu_toolsSeparator", collapsed: "true"}),
+
+ $menuitem({
+ id: "menu_customizeShortcuts",
+ label: "firebug.menu.Customize shortcuts",
+ command: "cmd_customizeFBKeys",
+ key: "key_customizeFBKeys",
+ "class": "fbInternational"
+ }),
+
+ $menuseparator({id: "menu_aboutSeparator"}),
+
+ $menuitem({
+ id: "Firebug_About",
+ label: "firebug.About",
+ oncommand: "Firebug.GlobalUI.openAboutDialog()",
+ "class": "firebugAbout fbInternational"
+ }),
+]);
+
+// ********************************************************************************************* //
+// Global Menu Overlays
+
+// Firefox page context menu
+$menupopupOverlay($("contentAreaContextMenu"), [
+ $menuseparator(),
+ $menuitem({
+ id: "menu_firebugInspect",
+ label: "firebug.InspectElementWithFirebug",
+ command: "cmd_inspect",
+ "class": "menuitem-iconic fbInternational"
+ })
+]);
+
+// Firefox view menu
+$menupopupOverlay($("menu_viewPopup"), [
+ $menuitem({
+ id: "menu_viewToggleFirebug",
+ insertbefore: "toggle_taskbar",
+ label: "firebug.Firebug",
+ type: "checkbox",
+ key: "key_toggleFirebug",
+ command: "cmd_toggleFirebug",
+ "class": "fbInternational"
+ })
+]);
+
+// SeaMonkey view menu
+$menupopupOverlay($("menu_View_Popup"), [
+ $menuitem({
+ id: "menu_viewToggleFirebug",
+ insertafter: "menuitem_fullScreen",
+ label: "firebug.Firebug",
+ type: "checkbox",
+ key: "key_toggleFirebug",
+ command: "cmd_toggleFirebug",
+ "class": "menuitem-iconic fbInternational"
+ })
+]);
+
+// Firefox Tools -> Web Developer Menu
+$menupopupOverlay($("menuWebDeveloperPopup"), [
+ $menu({
+ id: "menu_webDeveloper_firebug",
+ insertbefore: "webConsole",
+ label: "firebug.Firebug",
+ "class": "menu-iconic fbInternational"
+ }, [firebugMenuPopup.cloneNode(true)]),
+ $menuseparator({
+ insertbefore: "webConsole"
+ })
+]);
+
+// Firefox 4 Web Developer Menu
+$menupopupOverlay($("appmenu_webDeveloper_popup"), [
+ $splitmenu({
+ id: "appmenu_firebug",
+ insertbefore: "appmenu_webConsole",
+ command: "cmd_toggleFirebug",
+ key: "key_toggleFirebug",
+ label: "firebug.Firebug",
+ command: "cmd_toggleFirebug",
+ iconic: "true",
+ "class": "fbInternational"
+ }, [firebugMenuPopup.cloneNode(true)]),
+ $menuseparator({
+ insertbefore: "appmenu_webConsole"
+ })
+]);
+
+// Sea Monkey Tools Menu
+$menupopupOverlay($("toolsPopup"), [
+ $menu({
+ id: "menu_firebug",
+ insertbefore: "appmenu_webConsole",
+ command: "cmd_toggleFirebug",
+ key: "key_toggleFirebug",
+ label: "firebug.Firebug",
+ "class": "menuitem-iconic fbInternational"
+ }, [firebugMenuPopup.cloneNode(true)])
+]);
+
+// ********************************************************************************************* //
+// Firefox Toolbar Buttons
+
+$toolbarButton("inspector-button", {
+ label: "firebug.Inspect",
+ tooltiptext: "firebug.InspectElement",
+ observes: "cmd_toggleInspecting",
+ image: "chrome://firebug/skin/inspect.png"
+});
+
+// TODO: why contextmenu doesn't work without cloning
+$toolbarButton("firebug-button", {
+ label: "firebug.Firebug",
+ tooltiptext: "firebug.ShowFirebug",
+ type: "menu-button",
+ command: "cmd_toggleFirebug",
+ contextmenu: "fbStatusContextMenu",
+ observes: "firebugStatus",
+ style: "list-style-image:url(chrome://firebug/skin/firebug-gray-16.png)"
+}, [$("fbStatusContextMenu").cloneNode(true)]);
+
+// Appends Firebug start button into Firefox toolbar automatically after installation.
+// The button is appended only once so, if the user removes it, it isn't appended again.
+// TODO: merge into $toolbarButton?
+if (!$("firebug-button") && !FirebugLoader.getPref("toolbarCustomizationDone"))
+{
+ FirebugLoader.setPref("toolbarCustomizationDone", true);
+
+ // Get the current navigation bar button set (a string of button IDs) and append
+ // ID of the Firebug start button into it.
+ var startButtonId = "firebug-button";
+ var navBarId = "nav-bar";
+ var navBar = $(navBarId);
+ var currentSet = navBar.currentSet;
+
+ if (FBTrace.DBG_INITIALIZE)
+ FBTrace.sysout("Startbutton; curSet (before modification): " + currentSet);
+
+ // Append only if the button is not already there.
+ var curSet = currentSet.split(",");
+ if (curSet.indexOf(startButtonId) == -1)
+ {
+ navBar.insertItem(startButtonId);
+ navBar.setAttribute("currentset", navBar.currentSet);
+ navBar.ownerDocument.persist("nav-bar", "currentset");
+
+ // Check whether insertItem really works
+ var curSet = navBar.currentSet.split(",");
+ if (curSet.indexOf(startButtonId) == -1)
+ {
+ FBTrace.sysout("Startbutton; navBar.insertItem doesn't work", curSet);
+ }
+
+ if (FBTrace.DBG_INITIALIZE)
+ FBTrace.sysout("Startbutton; curSet (after modification): " + navBar.currentSet);
+
+ try
+ {
+ // The current global scope is browser.xul.
+ BrowserToolboxCustomizeDone(true);
+ }
+ catch (e)
+ {
+ if (FBTrace.DBG_ERRORS)
+ FBTrace.sysout("startButton; appendToToolbar EXCEPTION " + e, e);
+ }
+ }
+
+ // Don't forget to show the navigation bar - just in case it's hidden.
+ navBar.removeAttribute("collapsed");
+ document.persist(navBarId, "collapsed");
+}
+
+// ********************************************************************************************* //
+// Localization
+
+// Internationalize all elements with 'fbInternational' class. Clone before internationalizing.
+var elements = cloneArray(document.getElementsByClassName("fbInternational"));
+Locale.internationalizeElements(document, elements, ["label", "tooltiptext", "aria-label"]);
+
+// ********************************************************************************************* //
+// Update About Menu
+
+var version = Firebug.GlobalUI.getVersion();
+if (version)
+{
+ var nodes = document.querySelectorAll(".firebugAbout");
+ nodes = cloneArray(nodes);
+ for (var i=0; i<nodes.length; i++)
+ {
+ var node = nodes[i];
+ var aboutLabel = node.getAttribute("label");
+ node.setAttribute("label", aboutLabel + " " + version);
+ node.classList.remove("firebugAbout");
+ }
+}
+
+if (FBTrace.DBG_INITIALIZE)
+ FBTrace.sysout("Firebug global overlay applied");
+
+// ********************************************************************************************* //
+})()
29 extension/content/firebug/firefox/browserOverlayWithFrame.xul
View
@@ -1,29 +0,0 @@
-<?xml version="1.0"?>
-<!-- See license.txt for terms of usage -->
-
-<?xul-overlay href="chrome://firebug/content/firefox/start-button/startButtonOverlay.xul"?>
-<?xul-overlay href="chrome://firebug/content/firefox/browserMenuOverlay.xul"?>
-
-<!-- CSS for fbContentSplitter -->
-<?xml-stylesheet href="chrome://firebug/content/firebug.css"?>
-
-<overlay xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
-
- <script type="application/x-javascript" src="chrome://firebug/content/trace.js"/>
- <script type="application/x-javascript" src="chrome://firebug/content/legacy.js"/>
- <script type="application/x-javascript" src="chrome://firebug/content/moduleConfig.js"/>
-
- <!-- Firebug UI is loaded within 'fbMainContainer' browser. Note that there
- are some small Firbug UI pieces that are part of the browser.xul scope,
- such as the Firebug start button or Firebug menu, which is part of the
- Firefox menu. -->
- <vbox id="appcontent">
- <splitter id="fbContentSplitter" collapsed="true"/>
- <vbox persist="height,width" id="fbMainFrame" collapsed="true">
- <browser id="fbMainContainer" flex="2"
- src="chrome://firebug/content/firefox/firebugFrame.xul"
- disablehistory="true"/>
- </vbox>
- </vbox>
-
-</overlay>
46 extension/content/firebug/firefox/firebugMenu.js
View
@@ -26,52 +26,12 @@ Firebug.FirebugMenu = Obj.extend(Firebug.Module,
{
Firebug.Module.initializeUI.apply(this, arguments);
- // Put Firebug version on all "About" menu items. This men item appears in
- // Firefox Tools menu (Firefox UI) as well as Firebug Icon menu (Firebug UI)
- this.updateAboutMenu(document);
- this.updateAboutMenu(top.document);
-
- // Initialize Firebug Tools, Web Developer and Firebug Icon menus.
- var firebugMenuPopup = Firebug.chrome.$("fbFirebugMenuPopup");
-
- // If 'Web Developer' menu is available (introduced in Firefox 6)
- // Remove the old entry in Tools menu.
- if (Firefox.getElementById("menu_webDeveloper_firebug"))
- {
- var menuFirebug = Firefox.getElementById("menu_firebug");
- if (menuFirebug)
- menuFirebug.parentNode.removeChild(menuFirebug);
- }
-
- // Initialize content of Firebug menu at various places.
- this.initializeMenu(Firefox.getElementById("menu_webDeveloper_firebug"), firebugMenuPopup);
- this.initializeMenu(Firefox.getElementById("menu_firebug"), firebugMenuPopup);
- this.initializeMenu(Firefox.getElementById("appmenu_firebug"), firebugMenuPopup);
+ // Initialize Firebug Icon menu. The content comes from the global space.
+ var firebugMenuPopup = Firefox.$("fbFirebugMenuPopup");
this.initializeMenu(Firebug.chrome.$("fbFirebugMenu"), firebugMenuPopup);
},
/**
- * Append version info to all "About" menu items.
- * @param {Object} doc The scope document where to look for XUL menu elements.
- */
- updateAboutMenu: function(doc)
- {
- var version = Firebug.getVersion();
- if (version)
- {
- var nodes = doc.querySelectorAll(".firebugAbout");
- nodes = Arr.cloneArray(nodes);
- for (var i=0; i<nodes.length; i++)
- {
- var node = nodes[i];
- var aboutLabel = node.getAttribute("label");
- node.setAttribute("label", aboutLabel + " " + version);
- Css.removeClass(node, "firebugAbout");
- }
- }
- },
-
- /**
* Insert Firebug menu into specified location in the UI. Firebug menu appears
* at several location depending on Firefox version and/or application (e.g. SeaMonkey)
*/
@@ -96,4 +56,6 @@ Firebug.registerModule(Firebug.FirebugMenu);
// ********************************************************************************************* //
return Firebug.FirebugMenu;
+
+// ********************************************************************************************* //
});
127 extension/content/firebug/firefox/firebugMenuOverlay.xul
View
@@ -105,131 +105,4 @@
<key id="key_help" keycode="VK_F1" command="cmd_openHelp"/>
</keyset>
- <!-- Firebug Menu Definition -->
- <vbox id="fbContentBox">
-
- <!-- Firebug Tools & Icon menu & Web Developer menu -->
- <menupopup id="fbFirebugMenuPopup" role="menu"
- onpopupshowing="return Firebug.chrome.onMenuShowing(this);">
-
- <!-- Open -->
- <menuitem id="menu_toggleFirebug"
- label="firebug.ShowFirebug" command="cmd_toggleFirebug"
- key="key_toggleFirebug" class="fbInternational"/>
- <menu label="firebug.uiLocation" class="fbInternational">
- <menupopup onpopupshowing="Firebug.chrome.onPositionPopupShowing(this)"/>
- </menu>
- <menuitem id="menu_closeFirebug" label="firebug.CloseFirebug"
- command="cmd_closeFirebug"
- key="key_closeFirebug" class="fbInternational"/>
-
- <menuseparator id="menu_openActionsSeparator"/>
-
- <!-- Text Size -->
- <menu id="FirebugMenu_TextSize" label="firebug.TextSize" class="fbInternational">
- <menupopup>
- <menuitem id="menu_increaseTextSize" label="firebug.IncreaseTextSize"
- command="cmd_increaseTextSize"
- key="key_increaseTextSize" class="fbInternational"/>
- <menuitem id="menu_decreaseTextSize" label="firebug.DecreaseTextSize"
- command="cmd_decreaseTextSize"
- key="key_decreaseTextSize" class="fbInternational"/>
- <menuitem id="menu_normalTextSize" label="firebug.NormalTextSize"
- command="cmd_normalTextSize"
- key="key_normalTextSize" class="fbInternational"/>
- </menupopup>
- </menu>
-
- <!-- Options -->
- <menu id="FirebugMenu_Options" label="firebug.Options" class="fbInternational">
- <menupopup onpopupshowing="return Firebug.chrome.onOptionsShowing(this);"
- id="FirebugMenu_OptionsPopup">
- <menuitem id="menu_toggleShowErrorCount"
- type="checkbox" label="firebug.Show_Error_Count"
- oncommand="Firebug.chrome.onToggleOption(this)"
- option="showErrorCount"
- class="fbInternational"/>
- <menuitem id="menu_showTooltips"
- type="checkbox" label="firebug.ShowTooltips"
- oncommand="Firebug.chrome.onToggleOption(this)"
- option="showInfoTips" class="fbInternational"/>
- <menuitem id="menu_shadeBoxModel"
- type="checkbox" label="inspect.option.Shade_Box_Model"
- oncommand="Firebug.chrome.onToggleOption(this)"
- option="shadeBoxModel" class="fbInternational"
- tooltiptext="inspect.option.tip.Shade_Box_Model"/>
- <menuitem id="showQuickInfoBox"
- type="checkbox" label="inspect.option.Show_Quick_Info_Box"
- oncommand="Firebug.chrome.onToggleOption(this)"
- option="showQuickInfoBox" class="fbInternational"
- tooltiptext="inspect.option.tip.Show_Quick_Info_Box"/>
- <menuitem id="menu_enableA11y"
- type="checkbox"
- label="firebug.menu.Enable Accessibility Enhancements"
- oncommand="Firebug.chrome.onToggleOption(this)"
- option="a11y.enable"
- class="fbInternational"/>
- <menuitem id="menu_activateSameOrigin"
- type="checkbox" label="firebug.menu.Activate Same Origin URLs"
- oncommand="Firebug.chrome.onToggleOption(this)"
- option="activateSameOrigin" class="fbInternational"/>
- <menuitem id="menu_toggleOrient"
- type="checkbox" label="firebug.Vertical"
- command="cmd_toggleOrient"
- option="viewPanelOrient"
- class="fbInternational"/>
- <menuseparator id="menu_optionsSeparator"/>
- <menuitem id="menu_resetAllOptions"
- label="firebug.menu.Reset All Firebug Options"
- command="cmd_resetAllOptions"
- class="fbInternational"/>
- </menupopup>
- </menu>
-
- <menuseparator id="FirebugBetweenOptionsAndSites" collapsed="true"/>
-
- <!-- Sites -->
- <menu label="firebug.menu.Firebug Online" id="FirebugMenu_Sites" class="fbInternational">
- <menupopup id="FirebugMenu_SitesPopup">
- <menuitem id="menu_firebugUrlWebsite" label="firebug.Website"
- oncommand="Firebug.visitWebsite('main')" class="fbInternational"/>
- <menuitem id="menu_firebugFAQ" label="firebug.FAQ"
- command="cmd_openHelp" key="key_help" class="fbInternational"/>
- <menuitem id="menu_firebugDoc" label="firebug.Documentation"
- oncommand="Firebug.visitWebsite('docs')" class="fbInternational"/>
- <menuitem id="menu_firebugKeyboard" label="firebug.KeyShortcuts"
- oncommand="Firebug.visitWebsite('keyboard')" class="fbInternational"/>
- <menuitem id="menu_firebugForums" label="firebug.Forums"
- oncommand="Firebug.visitWebsite('discuss')" class="fbInternational"/>
- <menuitem id="menu_firebugIssues" label="firebug.Issues"
- oncommand="Firebug.visitWebsite('issues')" class="fbInternational"/>
- <menuitem id="menu_firebugDonate" label="firebug.Donate"
- oncommand="Firebug.visitWebsite('donate')" class="fbInternational"/>
- </menupopup>
- </menu>
-
- <menuseparator id="menu_miscActionsSeparator"/>
-
- <menuitem id="menu_inspectElement" label="firebug.InspectElement" type="checkbox"
- command="cmd_toggleInspecting" key="key_toggleInspecting" class="fbInternational"/>
- <menuitem id="menu_profileScript" label="firebug.ProfileScript" type="checkbox"
- command="cmd_toggleProfiling" key="key_toggleProfiling" class="fbInternational"/>
- <menuitem id="menu_focusCommandLine" label="console.option.Show_Command_Line"
- command="cmd_focusCommandLine" key="key_focusCommandLine" class="fbInternational"/>
- <menuitem id="menu_focusFirebugSearch" label="firebug.Search"
- command="cmd_focusFirebugSearch" key="key_focusFirebugSearch" class="fbInternational"/>
-
- <menuseparator id="menu_toolsSeparator"/>
-
- <menuitem id="menu_customizeShortcuts"
- label="firebug.menu.Customize shortcuts"
- command="cmd_customizeFBKeys" key="key_customizeFBKeys"
- class="fbInternational" />
-
- <menuseparator id="menu_aboutSeparator"/>
-
- <menuitem id="Firebug_About" class="firebugAbout fbInternational"
- label="firebug.About" oncommand="Firebug.chrome.openAboutDialog()"/>
- </menupopup>
- </vbox>
</overlay>
7 extension/content/firebug/firefox/start-button/customizeToolbarOverlay.xul
View
@@ -1,7 +0,0 @@
-<?xml version="1.0"?>
-
-<?xml-stylesheet href="chrome://firebug/content/firefox/start-button/startButton.css"?>
-
-<overlay id="FirebugOverlay"
- xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
-</overlay>
178 extension/content/firebug/firefox/start-button/startButtonOverlay.js
View
@@ -17,9 +17,6 @@ function(Obj, Firebug, Firefox, Locale, Events, Dom, Options) {
const Cc = Components.classes;
const Ci = Components.interfaces;
-var appInfo = Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULAppInfo);
-var versionChecker = Cc["@mozilla.org/xpcom/version-comparator;1"].getService(Ci.nsIVersionComparator);
-
// ********************************************************************************************* //
// Module Implementation
@@ -41,55 +38,8 @@ Firebug.StartButton = Obj.extend(Firebug.Module,
{
Firebug.Module.initializeUI.apply(this, arguments);
- // Associate a popup-menu with the start button (the same as it's
- // used for the obsolete status bar icon.
- var startButton = Firefox.getElementById("firebug-button");
- if (startButton)
- {
- var popup = Firefox.getElementById("fbStatusContextMenu");
- startButton.appendChild(popup.cloneNode(true));
-
- // In case of Firefox 4+ the button is a bit different.
- if (appInfo.name == "Firefox" && versionChecker.compare(appInfo.version, "4.0*") >= 0)
- startButton.setAttribute("firefox", "4");
-
- // Put Firebug version in tooltip.
- var version = Firebug.getVersion();
- if (version)
- {
- var fbStatusBar = Firefox.getElementById("fbStatusBar");
- if (fbStatusBar)
- fbStatusBar.setAttribute("tooltiptext", "Firebug " + version);
- }
- }
-
- this.updateStatusIcon();
-
if (FBTrace.DBG_INITIALIZE)
- FBTrace.sysout("Startbutton initializeUI "+startButton);
- },
-
- addOnLoadListener: function(win)
- {
- this.browserWin = win;
-
- this.onLoadBinding = Obj.bind(this.onLoad, this);
- Events.addEventListener(this.browserWin, "load", this.onLoadBinding, false);
- },
-
- onLoad: function()
- {
- Events.removeEventListener(this.browserWin, "load", this.onLoadBinding, false);
-
- try
- {
- this.appendToToolbar();
- }
- catch (e)
- {
- if (FBTrace.DBG_ERRORS)
- FBTrace.sysout("startButton; onLoad.appendToToolbar EXCEPTION " + e, e);
- }
+ FBTrace.sysout("StartButton initializeUI " + startButton);
},
shutdown: function()
@@ -97,133 +47,13 @@ Firebug.StartButton = Obj.extend(Firebug.Module,
},
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
- /**
- * Appends Firebug start button into Firefox toolbar automatically after installation.
- * The button is appended only once so, if the user removes it, it isn't appended again.
- */
- appendToToolbar: function()
- {
- if (Options.get("toolbarCustomizationDone"))
- return;
-
- Options.set("toolbarCustomizationDone", true);
-
- // Get the current navigation bar button set (a string of button IDs) and append
- // ID of the Firebug start button into it.
- var startButtonId = "firebug-button";
- var navBarId = "nav-bar";
-
- // xxxHonza: do not use Firefox.getElementById, it depends on Firebug.chrome
- // that doesn't have to be set (loaded) yet.
- //var navBar = Firefox.getElementById(navBarId);
- var navBar = top.document.getElementById(navBarId);
- var currentSet = navBar.currentSet;
-
- if (FBTrace.DBG_INITIALIZE)
- FBTrace.sysout("Startbutton; curSet (before modification): " + currentSet);
-
- // Append only if the button is not already there.
- var curSet = currentSet.split(",");
- if (curSet.indexOf(startButtonId) == -1)
- {
- navBar.insertItem(startButtonId);
- navBar.setAttribute("currentset", navBar.currentSet);
- navBar.ownerDocument.persist("nav-bar", "currentset");
-
- // Check whether insertItem really works
- var curSet = navBar.currentSet.split(",");
- if (curSet.indexOf(startButtonId) == -1)
- {
- FBTrace.sysout("Startbutton; navBar.insertItem doesn't work", curSet);
- }
-
- if (FBTrace.DBG_INITIALIZE)
- FBTrace.sysout("Startbutton; curSet (after modification): " + navBar.currentSet);
-
- try
- {
- // The current global scope is not browser.xul.
- top.BrowserToolboxCustomizeDone(true);
- }
- catch (e)
- {
- if (FBTrace.DBG_ERRORS)
- FBTrace.sysout("startButton; appendToToolbar EXCEPTION " + e, e);
- }
- }
-
- // Don't forget to show the navigation bar - just in case it's hidden.
- Dom.collapse(navBar, false);
- document.persist(navBarId, "collapsed");
- },
-
- // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
- // Support for the status bar
-
- /**
- * The status bar icon is hidden by default since Firebug 1.8 (Firefox 4).
- * The toolbar icon (start button) is the preferred Firebug entry point.
- */
- updateStatusIcon: function()
- {
- var show = Options.get("showStatusIcon");
- var statusBar = Firefox.getElementById("fbStatusBar");
- if (statusBar)
- Dom.collapse(statusBar, !show);
- },
-
- updateOption: function(name, value)
- {
- if (name === "showStatusIcon")
- this.updateStatusIcon();
- },
-
- onClickStatusText: function(context, event)
- {
- if (event.button != 0)
- return;
-
- if (!context || !context.errorCount)
- return;
-
- var panel = Firebug.chrome.getSelectedPanel();
- if (panel && panel.name != "console")
- {
- Firebug.chrome.selectPanel("console");
- Events.cancelEvent(event);
- }
- },
-
- onClickStatusIcon: function(context, event)
- {
- if (event.button != 0)
- return;
- else if (Events.isControl(event))
- Firebug.toggleDetachBar(true);
- else if (context && context.errorCount)
- Firebug.toggleBar(undefined, "console");
- else
- Firebug.toggleBar();
- },
-
- // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Error count
showCount: function(errorCount)
{
- var statusBar = Firefox.getElementById("fbStatusBar");
- var statusText = Firefox.getElementById("fbStatusText");
-
- if (!statusBar)
- return;
-
var firebugButton = Firefox.getElementById("firebug-button");
if (errorCount && Firebug.showErrorCount)
{
- statusBar.setAttribute("showErrors", "true")
- statusText.setAttribute("value", Locale.$STRP("plural.Error_Count2", [errorCount]));
-
if (firebugButton)
{
firebugButton.setAttribute("showErrors", "true");
@@ -232,9 +62,6 @@ Firebug.StartButton = Obj.extend(Firebug.Module,
}
else
{
- statusBar.removeAttribute("showErrors");
- statusText.setAttribute("value", "");
-
if (firebugButton)
{
firebugButton.removeAttribute("showErrors");
@@ -348,9 +175,6 @@ Firebug.StartButton = Obj.extend(Firebug.Module,
// ********************************************************************************************* //
// Registration
-// Firebug start button must be appended when the top window (browser) is loaded.
-Firebug.StartButton.addOnLoadListener(top);
-
Firebug.registerModule(Firebug.StartButton);
// ********************************************************************************************* //
95 extension/content/firebug/firefox/start-button/startButtonOverlay.xul
View
@@ -1,95 +0,0 @@
-<?xml version="1.0"?>
-<!-- See license.txt for terms of usage -->
-
-<?xml-stylesheet href="chrome://firebug/content/firefox/start-button/startButton.css"?>
-
-<overlay xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
-
- <popupset id="mainPopupSet">
-
- <!-- Popup menu shared by the Status bar icon and Firebug button (the toolbar button
- available in Customizable Toolbar dialog, see below) -->
- <menupopup id="fbStatusContextMenu"
- onpopupshowing="Firebug.chrome.onOptionsShowing(this)">
- <menu label="firebug.uiLocation" class="fbInternational">
- <menupopup onpopupshowing="Firebug.chrome.onPositionPopupShowing(this)"/>
- </menu>
- <menuseparator/>
- <menuitem
- id="menu_ClearConsole"
- label="firebug.ClearConsole"
- command="cmd_clearConsole"
- key="key_clearConsole"
- class="fbInternational"/>
- <menuitem
- id="menu_showErrorCount"
- type="checkbox"
- label="firebug.Show Error Count"
- oncommand="Firebug.chrome.onToggleOption(this)"
- option="showErrorCount"
- class="fbInternational"/>
- <menuseparator/>
- <menuitem
- id="menu_enablePanels"
- label="firebug.menu.Enable All Panels"
- command="cmd_enablePanels"
- class="fbInternational"/>
- <menuitem
- id="menu_disablePanels"
- label="firebug.menu.Disable All Panels"
- command="cmd_disablePanels"
- class="fbInternational"/>
- <menuseparator/>
- <menuitem
- id="menu_AllOn"
- type="checkbox"
- label="On_for_all_web_pages"
- command="cmd_allOn"
- class="fbInternational"/>
- <menuitem
- id="menu_clearActivationList"
- label="firebug.menu.Clear Activation List"
- command="cmd_clearActivationList"
- class="fbInternational"/>
- </menupopup>
- </popupset>
-
- <!-- Buttons for Firefox Customize Toolbar dialog -->
- <toolbarpalette id="BrowserToolbarPalette">
-
- <!-- DOM Inspector -->
- <toolbarbutton id="inspector-button" label="firebug.Inspect"
- class="toolbarbutton-1 chromeclass-toolbar-additional fbInternational"
- observes="cmd_toggleInspecting" tooltiptext="firebug.InspectElement"/>
-
- <!-- Firebug button -->
- <toolbarbutton id="firebug-button" label="firebug.Firebug"
- class="toolbarbutton-1 chromeclass-toolbar-additional fbInternational"
- command="cmd_toggleFirebug" tooltiptext="firebug.ShowFirebug"
- type="menu-button" contextmenu="fbStatusContextMenu"
- observes="firebugStatus">
- <!-- menu fbStatusContextMenu is cloned here -->
- </toolbarbutton>
- </toolbarpalette>
-
- <!-- The broadcaster holds the current Firebug activation state. The state
- (i.e. attributes of the broadcaster are shared among all observers,
- which is: fbStatusIcon and firebug-button. -->
- <broadcasterset id="mainBroadcasterSet">
- <broadcaster id="firebugStatus" />
- </broadcasterset>
-
- <!-- Extend Firefox status bar -->
- <statusbar id="status-bar">
- <statusbarpanel id="fbStatusBar" context="fbStatusContextMenu" role="button"
- aria-labelledby="fbStatusPrefix fbStatusText" aria-describedby="fbStatusIcon"
- onmouseup="Firebug.StartButton.onClickStatusIcon(Firebug.currentContext, event);"
- tooltiptext="Firebug">
- <image id="fbStatusIcon" observes="firebugStatus"/>
- <label id="fbStatusPrefix" collapsed="true" />
- <label id="fbStatusText"
- onmouseup="Firebug.StartButton.onClickStatusText(Firebug.currentContext, event);" />
- </statusbarpanel>
- </statusbar>
-
-</overlay>
267 extension/content/firebug/lib/locale.js
View
@@ -1,271 +1,14 @@
/* See license.txt for terms of usage */
-define([
- "firebug/lib/trace",
- "firebug/lib/options",
-],
-function(FBTrace, Options) {
+define([], function() {
// ********************************************************************************************* //
-// Globals
+// Module
-var Ci = Components.interfaces;
-var Cc = Components.classes;
+// The entire localization support is implemented in Mozilla Module so, it can be
+// used yet before the Firebug is fully loaded.
-// Import of PluralForm object.
-Components.utils["import"]("resource://gre/modules/PluralForm.jsm");
-
-var stringBundleService = Cc["@mozilla.org/intl/stringbundle;1"].getService(Ci.nsIStringBundleService);
-var categoryManager = Cc["@mozilla.org/categorymanager;1"].getService(Ci.nsICategoryManager);
-
-// This module
-var Locale = {};
-
-// ********************************************************************************************* //
-// Localization
-
-/*
- * $STR - intended for localization of a static string.
- * $STRF - intended for localization of a string with dynamically inserted values.
- * $STRP - intended for localization of a string with dynamically plural forms.
- *
- * Notes:
- * 1) Name with _ in place of spaces is the key in the firebug.properties file.
- * 2) If the specified key isn't localized for particular language, both methods use
- * the part after the last dot (in the specified name) as the return value.
- *
- * Examples:
- * $STR("Label"); - search for key "Label" within the firebug.properties file
- * and returns its value. If the key doesn't exist returns "Label".
- *
- * $STR("Button Label"); - search for key "Button_Label" withing the firebug.properties
- * file. If the key doesn't exist returns "Button Label".
- *
- * $STR("net.Response Header"); - search for key "net.Response_Header". If the key doesn't
- * exist returns "Response Header".
- *
- * firebug.properties:
- * net.timing.Request_Time=Request Time: %S [%S]
- *
- * var param1 = 10;
- * var param2 = "ms";
- * $STRF("net.timing.Request Time", param1, param2); -> "Request Time: 10 [ms]"
- *
- * - search for key "net.timing.Request_Time" within the firebug.properties file. Parameters
- * are inserted at specified places (%S) in the same order as they are passed. If the
- * key doesn't exist the method returns "Request Time".
- */
-Locale.$STR = function(name, bundle)
-{
- var strKey = name.replace(" ", "_", "g");
-
- if (!Options.get("useDefaultLocale"))
- {
- try
- {
- if (typeof bundle == "string")
- bundle = document.getElementById(bundle);
-
- if (bundle)
- return bundle.getString(strKey);
- else
- return Locale.getStringBundle().GetStringFromName(strKey);
- }
- catch (err)
- {
- if (FBTrace.DBG_LOCALE)
- FBTrace.sysout("lib.getString FAILS '" + name + "'", err);
- }
- }
-
- try
- {
- // The en-US string should be always available.
- var defaultBundle = Locale.getDefaultStringBundle();
- if (defaultBundle)
- return defaultBundle.GetStringFromName(strKey);
- }
- catch (err)
- {
- if (FBTrace.DBG_LOCALE)
- FBTrace.sysout("lib.getString (default) FAILS '" + name + "'", err);
- }
-
- // Don't panic now and use only the label after last dot.
- var index = name.lastIndexOf(".");
- if (index > 0 && name.charAt(index-1) != "\\")
- name = name.substr(index + 1);
- name = name.replace("_", " ", "g");
- return name;
-}
-
-Locale.$STRF = function(name, args, bundle)
-{
- var strKey = name.replace(" ", "_", "g");
-
- if (!Options.get("useDefaultLocale"))
- {
- try
- {
- // xxxHonza: Workaround for #485511
- if (!bundle)
- bundle = "strings_firebug";
-
- if (typeof bundle == "string")
- bundle = document.getElementById(bundle);
-
- if (bundle)
- return bundle.getFormattedString(strKey, args);
- else
- return Locale.getStringBundle().formatStringFromName(strKey, args, args.length);
- }
- catch (err)
- {
- if (FBTrace.DBG_LOCALE)
- FBTrace.sysout("lib.getString FAILS '" + name + "'", err);
- }
- }
-
- try
- {
- // The en-US string should be always available.
- var defaultBundle = Locale.getDefaultStringBundle();
- if (defaultBundle)
- return defaultBundle.formatStringFromName(strKey, args, args.length);
- }
- catch (err)
- {
- if (FBTrace.DBG_LOCALE)
- FBTrace.sysout("lib.getString (default) FAILS '" + name + "'", err);
- }
-
- // Don't panic now and use only the label after last dot.
- var index = name.lastIndexOf(".");
- if (index > 0)
- name = name.substr(index + 1);
-
- return name;
-}
-
-Locale.$STRP = function(name, args, index, bundle)
-{
- // xxxHonza:
- // pluralRule from chrome://global/locale/intl.properties for Chinese is 1,
- // which is wrong, it should be 0.
-
- var getPluralForm = PluralForm.get;
- var getNumForms = PluralForm.numForms;
-
- // Get custom plural rule; otherwise the rule from chrome://global/locale/intl.properties
- // (depends on the current locale) is used.
- var pluralRule = Locale.getPluralRule();
- if (!isNaN(parseInt(pluralRule, 10)))
- [getPluralForm, getNumForms] = PluralForm.makeGetter(pluralRule);
-
- // Index of the argument with plural form (there must be only one arg that needs plural form).
- if (!index)
- index = 0;
-
- // Get proper plural form from the string (depends on the current Firefox locale).
- var translatedString = Locale.$STRF(name, args, bundle);
- if (translatedString.search(";") > 0)
- return getPluralForm(args[index], translatedString);
-
- // translatedString contains no ";", either rule 0 or getString fails
- return translatedString;
-}
-
-/*
- * Use the current value of the attribute as a key to look up the localized value.
- */
-Locale.internationalize = function(element, attr, args)
-{
- if (typeof element == "string")
- element = document.getElementById(element);
-
- if (element)
- {
- var xulString = element.getAttribute(attr);
- if (xulString)
- {
- var localized = args ? Locale.$STRF(xulString, args) : Locale.$STR(xulString);
- // Set localized value of the attribute only if it exists.
- if (localized)
- element.setAttribute(attr, localized);
- }
- }
- else
- {
- if (FBTrace.DBG_LOCALE)
- FBTrace.sysout("Failed to internationalize element with attr "+attr+" args:"+args);
- }
-}
-
-Locale.internationalizeElements = function(doc, elements, attributes)
-{
- for (var i=0; i<elements.length; i++)
- {
- var element = doc.getElementById(elements[i]);
- if (!element)
- continue;
-
- for (var j=0; j<attributes.length; j++)
- {
- if (element.hasAttribute(attributes[j]))
- Locale.internationalize(element, attributes[j]);
- }
- }
-}
-
-Locale.registerStringBundle = function(bundleURI)
-{
- // Notice that this category entry must not be persistent in Fx 4.0
- categoryManager.addCategoryEntry("strings_firebug", bundleURI, "", false, true);
- this.stringBundle = null;
-}
-
-Locale.getStringBundle = function()
-{
- if (!this.stringBundle)
- this.stringBundle = stringBundleService.createExtensibleBundle("strings_firebug");
- return this.stringBundle;
-}
-
-Locale.getDefaultStringBundle = function()
-{
- if (!this.defaultStringBundle)
- {
- var bundle = document.getElementById("strings_firebug");
- if (!bundle)
- return null;
-
- var ioService = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
- var chromeRegistry = Cc["@mozilla.org/chrome/chrome-registry;1"].
- getService(Ci.nsIChromeRegistry);
-
- var uri = ioService.newURI(bundle.src, "UTF-8", null);
- var fileURI = chromeRegistry.convertChromeURL(uri).spec;
- var parts = fileURI.split("/");
- parts[parts.length - 2] = "en-US";
- this.defaultStringBundle = stringBundleService.createBundle(parts.join("/"));
- }
- return this.defaultStringBundle;
-}
-
-Locale.getPluralRule = function()
-{
- try
- {
- return this.getStringBundle().GetStringFromName("pluralRule");
- }
- catch (err)
- {
- }
-}
-
-// ********************************************************************************************* //
-
-return Locale;
+return Components.utils["import"]("resource://firebug/locale.js").Locale;
// ********************************************************************************************* //
});
23 extension/content/firebug/lib/options.js
View
@@ -20,6 +20,8 @@ const nsIPrefService = Ci.nsIPrefService;
const prefService = PrefService.getService(nsIPrefService);
const prefs = PrefService.getService(nsIPrefBranch2);
+const getPref = Components.utils.import("resource://firebug/loader.js", {}).FirebugLoader.getPref;
+
const prefNames = // XXXjjb TODO distribute to modules
[
// Global
@@ -235,26 +237,7 @@ var Options =
return Options.getPref(this.prefDomain, name);
},
- getPref: function(prefDomain, name)
- {
- var prefName = prefDomain + "." + name;
-
- var type = prefs.getPrefType(prefName);
-
- var value;
- if (type == nsIPrefBranch.PREF_STRING)
- value = prefs.getCharPref(prefName);
- else if (type == nsIPrefBranch.PREF_INT)
- value = prefs.getIntPref(prefName);
- else if (type == nsIPrefBranch.PREF_BOOL)
- value = prefs.getBoolPref(prefName);
-
- if (FBTrace.DBG_OPTIONS)
- FBTrace.sysout("options.getPref "+prefName+" has type "+
- this.getPreferenceTypeName(type)+" and value "+value);
-
- return value;
- },
+ getPref: getPref,
set: function(name, value)
{
7 extension/content/firebug/moduleConfig.js
View
@@ -1,12 +1,5 @@
/* See license