Left: | ||
Right: |
LEFT | RIGHT |
---|---|
1 /* | 1 /* |
2 * This Source Code is subject to the terms of the Mozilla Public License | 2 * This Source Code is subject to the terms of the Mozilla Public License |
3 * version 2.0 (the "License"). You can obtain a copy of the License at | 3 * version 2.0 (the "License"). You can obtain a copy of the License at |
4 * http://mozilla.org/MPL/2.0/. | 4 * http://mozilla.org/MPL/2.0/. |
5 */ | 5 */ |
6 | 6 |
7 let InspectorObserver = | 7 let InspectorObserver = |
8 { | 8 { |
9 init: function() | 9 init: function() |
10 { | 10 { |
(...skipping 11 matching lines...) Expand all Loading... | |
22 gDevTools.on("inspector-ready", this.inspectorReady); | 22 gDevTools.on("inspector-ready", this.inspectorReady); |
23 onShutdown.add(function() | 23 onShutdown.add(function() |
24 { | 24 { |
25 gDevTools.off("inspector-ready", this.inspectorReady); | 25 gDevTools.off("inspector-ready", this.inspectorReady); |
26 }.bind(this)); | 26 }.bind(this)); |
27 }, | 27 }, |
28 | 28 |
29 get inspectorButtonTooltip() | 29 get inspectorButtonTooltip() |
30 { | 30 { |
31 // Randomize URI to work around bug 719376 | 31 // Randomize URI to work around bug 719376 |
32 let stringBundle = Services.strings.createBundle("chrome://elemhidehelper/lo cale/global.properties?" + Math.random()); | 32 let stringBundle = Services.strings.createBundle("chrome://elemhidehelper/lo cale/global.properties?" + Math.random()); |
Thomas Greiner
2015/07/28 13:52:18
Here you're using "Services" without importing it
| |
33 let result = stringBundle.GetStringFromName("inspector.button.tooltiptext"); | 33 let result = stringBundle.GetStringFromName("inspector.button.tooltiptext"); |
34 | 34 |
35 Object.defineProperty(this, "inspectorButtonTooltip", {value: result, enumer able: true}); | 35 Object.defineProperty(this, "inspectorButtonTooltip", {value: result, enumer able: true}); |
36 return this.inspectorButtonTooltip; | 36 return this.inspectorButtonTooltip; |
37 }, | 37 }, |
38 | 38 |
39 inspectorReady: function(eventName, toolbox, panel) | 39 inspectorReady: function(eventName, toolbox, panel) |
40 { | 40 { |
41 let panelWindow = panel.panelWin; | 41 let panelWindow = panel.panelWin; |
42 let inspectBtn = panelWindow.document.getElementById("inspector-breadcrumbs" ); | 42 let inspectBtn = panelWindow.document.getElementById("inspector-breadcrumbs" ); |
43 if (!inspectBtn) | 43 if (!inspectBtn) |
44 return; | 44 return; |
45 | 45 |
46 let tooltiptext = InspectorObserver.inspectorButtonTooltip; | 46 let tooltiptext = InspectorObserver.inspectorButtonTooltip; |
47 button = panelWindow.document.createElement("toolbarbutton"); | 47 button = panelWindow.document.createElement("toolbarbutton"); |
48 button.setAttribute("id", "ehh-inspector-toolbarbutton"); | 48 button.setAttribute("id", "ehh-inspector-toolbarbutton"); |
49 button.setAttribute("class", "devtools-toolbarbutton"); | 49 button.setAttribute("class", "devtools-toolbarbutton"); |
50 button.setAttribute("tooltiptext", tooltiptext); | 50 button.setAttribute("tooltiptext", tooltiptext); |
51 button.setAttribute("tabindex", "0"); | 51 button.setAttribute("tabindex", "0"); |
52 button.addEventListener("command", () => | 52 button.addEventListener("command", () => |
53 { | 53 { |
54 let node = panel.selection.node; | 54 let node = panel.selection.nodeFront; |
55 let doc = null; | 55 let target = panel.target; |
56 let domain = null; | 56 if (node && target.form.elemhidehelper) |
Thomas Greiner
2015/07/28 13:52:18
This variable should be named "host" from looking
| |
57 if (!node) | |
58 { | 57 { |
59 // No local node available, but maybe a wrapper around a remote one | 58 target.client.request({ |
60 let {Services} = Cu.import("resource://gre/modules/Services.jsm"); | 59 to: target.form.elemhidehelper, |
61 node = panel.selection.nodeFront; | 60 type: "nodeinfo", |
62 doc = panel.selection.documentFront; | 61 nodeActor: node.actorID |
63 host = Services.io.newURI(panel.target.url, null, null).host; | 62 }, function(response) |
64 } | 63 { |
65 if (node.nodeType == Ci.nsIDOMNode.ELEMENT_NODE) | 64 if (!response.nodeData) |
66 { | 65 return; |
67 panelWindow.openDialog("chrome://elemhidehelper/content/composer.xul", " _blank", | 66 |
Thomas Greiner
2015/07/28 13:52:18
Detail: Please break these lines accordingly to fi
| |
68 "chrome,centerscreen,resizable,dialog=no", node, doc, host); | 67 panelWindow.openDialog("chrome://elemhidehelper/content/composer.xul", |
68 "_blank", "chrome,centerscreen,resizable,dialog=no", | |
69 response.nodeData, response.host); | |
70 }); | |
69 } | 71 } |
70 }, false); | 72 }, false); |
71 | 73 |
72 //Override button style for light DevTools theme | 74 //Override button style for light DevTools theme |
73 let style = panelWindow.document.createProcessingInstruction("xml-stylesheet ", 'href="chrome://elemhidehelper/skin/devToolsOverlay.css" type="text/css"'); | 75 let style = panelWindow.document.createProcessingInstruction("xml-stylesheet ", 'href="chrome://elemhidehelper/skin/devToolsOverlay.css" type="text/css"'); |
74 panelWindow.document.insertBefore(style, panelWindow.document.firstChild); | 76 panelWindow.document.insertBefore(style, panelWindow.document.firstChild); |
75 | 77 |
76 inspectBtn.parentNode.insertBefore(button, inspectBtn); | 78 inspectBtn.parentNode.insertBefore(button, inspectBtn); |
77 } | 79 } |
78 }; | 80 }; |
79 | 81 |
80 InspectorObserver.init(); | 82 InspectorObserver.init(); |
LEFT | RIGHT |