@@ -12,15 +12,13 @@ const { Trace, TraceError } = require("firebug.sdk/lib/core/trace.js").get(modul
12
12
// DevTools
13
13
const { devtools } = Cu . import ( "resource://gre/modules/devtools/Loader.jsm" , { } ) ;
14
14
const { Widgets } = devtools . require ( "devtools/webconsole/console-output" ) ;
15
+ const { VariablesView } = Cu . import ( "resource:///modules/devtools/VariablesView.jsm" , { } ) ;
15
16
16
17
const XHTML_NS = "http://www.w3.org/1999/xhtml" ;
17
18
18
19
/**
19
20
* @widget This object represents a widget that is used to render
20
21
* generic jQuery object preview.
21
- *
22
- * xxxHonza: Use envelope "✉" to indicate jQuery data.
23
-
24
22
*/
25
23
var JQueryRenderer = {
26
24
byKind : "jQuery" ,
@@ -93,15 +91,34 @@ var JQueryRenderer = {
93
91
}
94
92
} ,
95
93
96
- renderCache : function ( element , parentNode ) {
97
- if ( ! element . preview . cache ) {
94
+ renderCache : function ( elementGrip , parentNode ) {
95
+ let cacheGrip = elementGrip . preview ? elementGrip . preview . cache : null ;
96
+ if ( ! cacheGrip ) {
98
97
return ;
99
98
}
100
99
101
- let cache = this . document . createElementNS ( XHTML_NS , "span" ) ;
102
- cache . className = "cache"
103
- cache . innerHTML = "✉"
104
- parentNode . appendChild ( cache ) ;
100
+ // Render a little envelop sign if the element has jQuery data
101
+ // associated. Clicking on the envelope opens the variable view
102
+ // with detailed information.
103
+ let node = this . document . createElementNS ( XHTML_NS , "span" ) ;
104
+ node . className = "cache"
105
+ node . innerHTML = "✉"
106
+ parentNode . appendChild ( node ) ;
107
+
108
+ // Click handler
109
+ let clickHandler = this . onClickCache . bind ( this , cacheGrip ) ;
110
+ this . message . _addLinkCallback ( node , clickHandler ) ;
111
+ } ,
112
+
113
+ onClickCache : function ( cacheGrip ) {
114
+ Trace . sysout ( "JQueryRenderer.onClickCache;" , cacheGrip ) ;
115
+
116
+ // Open {@link VariablesView } displaying the jQuery object (cache).
117
+ this . output . openVariablesView ( {
118
+ label : VariablesView . getString ( cacheGrip , { concise : true } ) ,
119
+ objectActor : cacheGrip ,
120
+ autofocus : true ,
121
+ } ) ;
105
122
}
106
123
} ;
107
124
0 commit comments