Skip to content

Commit 8e06bee

Browse files
committed
#24 Support links in the tooltip window
1 parent 228b35a commit 8e06bee

File tree

7 files changed

+51
-4
lines changed

7 files changed

+51
-4
lines changed

data/markup-tooltip.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,17 @@ function getRequiredSize() {
132132
*/
133133
addEventListener("click", updateSize);
134134

135+
/**
136+
* Navigation within the toolbox
137+
*/
138+
function onNavigate(event) {
139+
var target = event.target;
140+
var repObject = event.detail.repObject;
141+
142+
postChromeMessage("navigate", repObject);
143+
}
144+
addEventListener("fbsdk:navigate", onNavigate, true);
145+
135146
// Final initialize message posted to the chrome indicating that
136147
// all content modules has been successfully loaded.
137148
postChromeMessage("ready");

data/reps/element.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ var Element = React.createClass(
3232

3333
if (mode == "tiny") {
3434
return (
35-
ObjectLink({className: ""},
35+
ObjectLink({className: "element", object: grip},
3636
SPAN({className: ""},
3737
SPAN({className: "selectorTag"},
3838
this.getSelectorTag(grip)

data/reps/regexp.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ var RegExp = React.createClass(
2626
var grip = this.props.object;
2727
return (
2828
ObjectLink({className: "regexp"},
29-
SPAN({"class": "objectTitle"}, this.getTitle(grip)),
29+
SPAN({className: "objectTitle"}, this.getTitle(grip)),
3030
SPAN(" "),
31-
SPAN({"class": "regexpSource"}, this.getSource(grip))
31+
SPAN({className: "regexpSource"}, this.getSource(grip))
3232
)
3333
)
3434
},

data/reps/text-node.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ var TextNode = React.createClass(
4040
return (
4141
ObjectLink({className: "textNode"},
4242
"<",
43-
SPAN({"class": "nodeTag"}, "TextNode"),
43+
SPAN({className: "nodeTag"}, "TextNode"),
4444
" textContent=\"",
4545
SPAN({className: "nodeValue"},
4646
this.getTextContent(grip)

lib/data-tooltip.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,12 @@ const { Trace, TraceError, FBTrace } = require("firebug.sdk/lib/core/trace.js").
2626
const { Content } = require("firebug.sdk/lib/core/content.js");
2727
const { Locale } = require("firebug.sdk/lib/core/locale.js");
2828

29+
// FireQuery
30+
const { FireQueryToolboxOverlay } = require("./firequery-toolbox-overlay.js");
31+
2932
// Constants
3033
const XHTML_NS = "http://www.w3.org/1999/xhtml";
34+
const ToolboxOverlayId = FireQueryToolboxOverlay.prototype.overlayId;
3135

3236
/**
3337
* This object implements a tooltip used in the MarkupView that
@@ -36,6 +40,7 @@ const XHTML_NS = "http://www.w3.org/1999/xhtml";
3640
* of the iframe is implemented by markup-tooltip.html
3741
*/
3842
function DataTooltip(options) {
43+
this.context = options.context;
3944
this.toolbox = options.toolbox;
4045
this.markup = options.markup;
4146
this.target = options.target;
@@ -125,6 +130,18 @@ DataTooltip.prototype =
125130
});
126131
},
127132

133+
onNavigate: function(grip) {
134+
let toolboxOverlay = this.context.getOverlay(ToolboxOverlayId);
135+
return toolboxOverlay.front.getNode(grip.actor).then(response => {
136+
var node = response.node;
137+
this.markup.showNode(node).then(() => {
138+
// Mark the node as selected and focused.
139+
this.markup.markNodeAsSelected(node);
140+
this.markup.maybeFocusNewSelection();
141+
});
142+
});
143+
},
144+
128145
// Tooltip Content Communication
129146

130147
onContentMessage: function(event) {
@@ -141,6 +158,9 @@ DataTooltip.prototype =
141158
case "getPrototypeAndProperties":
142159
this.onGetPrototypeAndProperties(data.args);
143160
break;
161+
case "navigate":
162+
this.onNavigate(data.args);
163+
break;
144164
}
145165
},
146166

lib/firequery-actor.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,21 @@ var FireQueryActor = ActorClass(
359359
response: RetVal("json"),
360360
}),
361361

362+
/**
363+
* Returns nodeActor/nodeFront according to given actor ID.
364+
*/
365+
getNode: method(expectState("attached", function(actorId) {
366+
let walkerActor = this.conn.getActor(this.walkerActorID);
367+
return walkerActor.getNodeActorFromObjectActor(actorId);
368+
}), {
369+
request: {
370+
actor: Arg(0, "string"),
371+
},
372+
response: {
373+
node: RetVal("disconnectedNode"),
374+
}
375+
}),
376+
362377
// Events
363378

364379
/**

lib/inspector-overlay.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ const InspectorOverlay = Class(
232232
this.getJQueryData(nodeFront).then(response => {
233233
// Create jQuery data tooltip object.
234234
let dataTooltip = new DataTooltip({
235+
context: this.context,
235236
toolbox: this.toolbox,
236237
markup: this.panel.markup,
237238
target: event.target,

0 commit comments

Comments
 (0)