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 {gDevTools} = Cu.import("resource:///modules/devtools/gDevTools.jsm", null); | 7 let {gDevTools} = Cu.import("resource:///modules/devtools/gDevTools.jsm", null); |
8 | 8 |
9 let InspectorObserver = | 9 let InspectorObserver = |
10 { | 10 { |
11 init: function() | 11 init: function() |
12 { | 12 { |
13 gDevTools.on("inspector-ready", this.inspectorReady); | 13 gDevTools.on("inspector-ready", this.inspectorReady); |
14 onShutdown.add(function() | 14 onShutdown.add(function() |
15 { | 15 { |
16 gDevTools.off("inspector-ready", this.inspectorReady); | 16 gDevTools.off("inspector-ready", this.inspectorReady); |
17 }.bind(this)); | 17 }.bind(this)); |
18 }, | 18 }, |
19 | 19 |
20 get inspectorButton() | 20 get inspectorButton() |
saroyanm
2014/04/12 20:59:38
Not sure if it's make sense to change getter into
Wladimir Palant
2014/04/12 21:05:21
Yes, I think the name should be changed.
| |
21 { | 21 { |
22 // Randomize URI to work around bug 719376 | 22 // Randomize URI to work around bug 719376 |
23 let stringBundle = Services.strings.createBundle("chrome://elemhidehelper/lo cale/global.properties?" + Math.random()); | 23 let stringBundle = Services.strings.createBundle("chrome://elemhidehelper/lo cale/global.properties?" + Math.random()); |
24 let result = [stringBundle.GetStringFromName("inspector.button.accesskey"), stringBundle.GetStringFromName("inspector.button.tooltiptext")]; | 24 let result = stringBundle.GetStringFromName("inspector.button.tooltiptext"); |
Wladimir Palant
2014/04/11 18:39:10
An access key only makes sense in combination with
saroyanm
2014/04/12 10:39:35
Wladimir why we need to remove accesskey ? Isn't i
Wladimir Palant
2014/04/12 18:14:11
You probably don't know what access keys are - see
saroyanm
2014/04/12 20:23:20
Thanks for the reference Wladimir,
actually I feel
Wladimir Palant
2014/04/12 20:51:26
An access key is not the same thing as a shortcut
saroyanm
2014/04/12 20:59:38
I thought again regarding your notes Wladimir I gu
saroyanm
2014/04/12 21:03:22
Got it. Thanks.
| |
25 | 25 |
26 delete this.inspectorButton; | 26 delete this.inspectorButton; |
27 this.__defineGetter__("inspectorButton", function() result); | 27 this.__defineGetter__("inspectorButton", function() result); |
28 return this.inspectorButton; | 28 return this.inspectorButton; |
29 }, | 29 }, |
30 | 30 |
31 inspectorReady: function(eventName, toolbox, panel) | 31 inspectorReady: function(eventName, toolbox, panel) |
32 { | 32 { |
33 let panelWindow = panel.panelWin; | 33 let panelWindow = panel.panelWin; |
34 let inspectBtn = panelWindow.document.getElementById("inspector-inspect-tool button"); | 34 let inspectBtn = panelWindow.document.getElementById("inspector-inspect-tool button"); |
35 if (!inspectBtn) | 35 if (!inspectBtn) |
36 return; | 36 return; |
37 | 37 |
38 let [accesskey, tooltiptext] = InspectorObserver.inspectorButton; | 38 let tooltiptext = InspectorObserver.inspectorButton; |
39 button = panelWindow.document.createElement("toolbarbutton"); | 39 button = panelWindow.document.createElement("toolbarbutton"); |
40 button.setAttribute("id", "inspector-abp-elemhide-toolbutton"); | 40 button.setAttribute("id", "inspector-abp-elemhide-toolbutton"); |
41 button.style.listStyleImage = "url('chrome://adblockplus/skin/abp-status-16. png')"; | 41 button.style.listStyleImage = "url('chrome://adblockplus/skin/abp-status-16. png')"; |
saroyanm
2014/04/11 16:09:11
Not sure if I need to copy icon to elemhidehelper/
Wladimir Palant
2014/04/11 18:39:10
No, it's fine like that - Element Hiding Helper ca
| |
42 button.style.MozImageRegion = "rect(0px, 16px, 16px, 0px)"; | 42 button.style.MozImageRegion = "rect(0px, 16px, 16px, 0px)"; |
43 button.style.paddingTop = "4px"; | 43 button.style.paddingTop = "4px"; |
44 button.setAttribute("class", "devtools-toolbarbutton"); | 44 button.setAttribute("class", "devtools-toolbarbutton"); |
45 button.setAttribute("accesskey", accesskey); | 45 button.setAttribute("accesskey", accesskey); |
46 button.setAttribute("tooltiptext", tooltiptext); | 46 button.setAttribute("tooltiptext", tooltiptext); |
47 button.setAttribute("tabindex", "0"); | 47 button.setAttribute("tabindex", "0"); |
48 button.addEventListener("command", function() | 48 button.addEventListener("command", function() |
49 { | 49 { |
50 panelWindow.openDialog("chrome://elemhidehelper/content/composer.xul", "_b lank", | 50 panelWindow.openDialog("chrome://elemhidehelper/content/composer.xul", "_b lank", |
51 "chrome,centerscreen,resizable,dialog=no", panel.se lection.node); | 51 "chrome,centerscreen,resizable,dialog=no", panel.se lection.node); |
52 }, false); | 52 }, false); |
53 inspectBtn.parentNode.insertBefore(button, inspectBtn.nextSibling); | 53 inspectBtn.parentNode.insertBefore(button, inspectBtn.nextSibling); |
54 } | 54 } |
55 }; | 55 }; |
56 | 56 |
57 InspectorObserver.init(); | 57 InspectorObserver.init(); |
LEFT | RIGHT |