Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: lib/ui.js

Issue 6525035187535872: issue #390 - Integrate parts of Element Hiding Helper functionality into Adblock Plus (Closed)
Patch Set: Created July 18, 2014, 12:54 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« chrome/locale/en-US/ehh-composer.dtd ('K') | « defaults/prefs.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/ui.js
===================================================================
--- a/lib/ui.js
+++ b/lib/ui.js
@@ -215,6 +215,68 @@
};
optionsObserver.init();
+let InspectorObserver =
+{
+ init: function()
+ {
+ let gDevTools;
+ try
+ {
+ ({gDevTools}) = Cu.import("resource:///modules/devtools/gDevTools.jsm", null);
+ }
+ catch(e)
+ {
+ // No developer tools or unsupported version - ignore.
+ return;
+ }
+
+ gDevTools.on("inspector-ready", this.inspectorReady);
+ onShutdown.add(function()
+ {
+ gDevTools.off("inspector-ready", this.inspectorReady);
+ }.bind(this));
+ },
+
+ get inspectorButtonTooltip()
+ {
+ // Randomize URI to work around bug 719376
+ let stringBundle = Services.strings.createBundle("chrome://adblockplus/locale/global.properties?" + Math.random());
+ let result = stringBundle.GetStringFromName("inspector.button.tooltiptext");
+
+ delete this.inspectorButtonTooltip;
+ this.__defineGetter__("inspectorButtonTooltip", function() result);
+ return this.inspectorButtonTooltip;
+ },
+
+ inspectorReady: function(eventName, toolbox, panel)
+ {
+ let panelWindow = panel.panelWin;
+ let inspectBtn = panelWindow.document.getElementById("inspector-breadcrumbs");
+ if (!inspectBtn)
+ return;
+
+ let tooltiptext = InspectorObserver.inspectorButtonTooltip;
+ button = panelWindow.document.createElement("toolbarbutton");
+ button.setAttribute("id", "abp-inspector-toolbarbutton");
+ button.setAttribute("class", "devtools-toolbarbutton");
+ button.setAttribute("tooltiptext", tooltiptext);
+ button.setAttribute("tabindex", "0");
+ button.addEventListener("command", function()
+ {
+ panelWindow.openDialog("chrome://adblockplus/content/ui/ehh-composer.xul", "_blank",
+ "chrome,centerscreen,resizable,dialog=no", panel.selection.node);
+ }, false);
+
+ //Override button style for light DevTools theme
+ let style = panelWindow.document.createProcessingInstruction("xml-stylesheet", 'href="chrome://adblockplus/skin/devToolsOverlay.css" type="text/css"');
+ panelWindow.document.insertBefore(style, panelWindow.document.firstChild);
+
+ inspectBtn.parentNode.insertBefore(button, inspectBtn);
+ }
+};
+
+InspectorObserver.init();
+
/**
* Session restore observer instance, stored to prevent it from being garbage
* collected.
« chrome/locale/en-US/ehh-composer.dtd ('K') | « defaults/prefs.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld