 Issue 29322778:
  Issue 2816 - Partial fix for EHH button in inspector tool, preview functionality still broken  (Closed)
    
  
    Issue 29322778:
  Issue 2816 - Partial fix for EHH button in inspector tool, preview functionality still broken  (Closed) 
  | Left: | ||
| Right: | 
| OLD | NEW | 
|---|---|
| 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", function() | 52 button.addEventListener("command", () => | 
| 53 { | 53 { | 
| 54 panelWindow.openDialog("chrome://elemhidehelper/content/composer.xul", "_b lank", | 54 let node = panel.selection.node; | 
| 55 "chrome,centerscreen,resizable,dialog=no", panel.se lection.node); | 55 let doc = null; | 
| 56 let domain = null; | |
| 
Thomas Greiner
2015/07/28 13:52:18
This variable should be named "host" from looking
 | |
| 57 if (!node) | |
| 58 { | |
| 59 // No local node available, but maybe a wrapper around a remote one | |
| 60 let {Services} = Cu.import("resource://gre/modules/Services.jsm"); | |
| 61 node = panel.selection.nodeFront; | |
| 62 doc = panel.selection.documentFront; | |
| 63 host = Services.io.newURI(panel.target.url, null, null).host; | |
| 64 } | |
| 65 if (node.nodeType == Ci.nsIDOMNode.ELEMENT_NODE) | |
| 66 { | |
| 67 panelWindow.openDialog("chrome://elemhidehelper/content/composer.xul", " _blank", | |
| 
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); | |
| 69 } | |
| 56 }, false); | 70 }, false); | 
| 57 | 71 | 
| 58 //Override button style for light DevTools theme | 72 //Override button style for light DevTools theme | 
| 59 let style = panelWindow.document.createProcessingInstruction("xml-stylesheet ", 'href="chrome://elemhidehelper/skin/devToolsOverlay.css" type="text/css"'); | 73 let style = panelWindow.document.createProcessingInstruction("xml-stylesheet ", 'href="chrome://elemhidehelper/skin/devToolsOverlay.css" type="text/css"'); | 
| 60 panelWindow.document.insertBefore(style, panelWindow.document.firstChild); | 74 panelWindow.document.insertBefore(style, panelWindow.document.firstChild); | 
| 61 | 75 | 
| 62 inspectBtn.parentNode.insertBefore(button, inspectBtn); | 76 inspectBtn.parentNode.insertBefore(button, inspectBtn); | 
| 63 } | 77 } | 
| 64 }; | 78 }; | 
| 65 | 79 | 
| 66 InspectorObserver.init(); | 80 InspectorObserver.init(); | 
| OLD | NEW |