@@ -141,25 +141,15 @@ const InspectorOverlay = Class(
141
141
} ,
142
142
143
143
onMarkupViewContainerCreated : function ( eventId , container ) {
144
- Trace . sysout ( "InspectorOverlay.onMarkupViewContainerCreated; " , arguments ) ;
144
+ // Trace.sysout("InspectorOverlay.onMarkupViewContainerCreated;" );
145
145
146
+ // Create a little data-icon indicating that the rendered element
147
+ // has jQuery.data associated. Clickin on the icon opens a tooltip
148
+ // with more details.
146
149
let nodeFront = container . node ;
147
- let hasJQueryData = false ;
148
-
149
- // nodeFront.getFormProperty has been introduced in Bug 1036949
150
- // xxxHonza: Checking existence of the method can be removed
151
- // as soon as Fx42 is the minimum required version.
152
- if ( nodeFront . getFormProperty ) {
153
- hasJQueryData = nodeFront . getFormProperty ( "hasJQueryData" ) ;
154
- } else if ( nodeFront . _form . props ) {
155
- hasJQueryData = nodeFront . _form . props . hasJQueryData ;
156
- }
157
-
158
- if ( ! hasJQueryData ) {
159
- return ;
150
+ if ( this . hasJQueryData ( nodeFront ) ) {
151
+ this . createDataIcon ( container . elt ) ;
160
152
}
161
-
162
- this . createDataIcon ( container . elt ) ;
163
153
} ,
164
154
165
155
createDataIcon : function ( element ) {
@@ -208,17 +198,7 @@ const InspectorOverlay = Class(
208
198
209
199
// Get node front for the clicked element.
210
200
let nodeFront = this . panel . selection . nodeFront ;
211
-
212
- // Use jQuery actor front to get fresh jQuery data
213
- // for the clicked node (for the selection).
214
- let toolboxOverlay = this . context . getOverlay ( ToolboxOverlayId ) ;
215
- if ( ! toolboxOverlay ) {
216
- TraceError . sysout ( "InspectorOverlay.onClickTooltip; ERROR no " +
217
- "toolbox overlay!" , this . context ) ;
218
- return ;
219
- }
220
-
221
- toolboxOverlay . front . getJQueryData ( nodeFront ) . then ( response => {
201
+ this . getJQueryData ( nodeFront ) . then ( response => {
222
202
// Create jQuery data tooltip object.
223
203
let dataTooltip = new DataTooltip ( {
224
204
toolbox : this . toolbox ,
@@ -235,31 +215,36 @@ const InspectorOverlay = Class(
235
215
showDOMProperties : function ( ) {
236
216
let original = this . showDOMPropertiesOriginal ;
237
217
238
- // The user needs to click on the jQueryData element (an envelope)
218
+ // The user needs to click on a little icon indicating
219
+ // jQuery.data in the element in order to show properties
220
+ // for the jQuery.data
239
221
let target = this . panel . panelDoc . popupNode ;
240
222
if ( ! target . classList . contains ( "fireQueryData" ) ) {
241
223
return original . apply ( this . panel , arguments ) ;
242
224
}
243
225
244
- // There must be jQuery data associated with the node.
226
+ // Make sure there are jQuery data associated with the node.
245
227
let nodeFront = this . panel . selection . nodeFront ;
246
- let jQueryData = nodeFront . _form . jQueryData ;
247
- if ( ! jQueryData ) {
228
+ if ( ! this . hasJQueryData ( nodeFront ) ) {
248
229
return original . apply ( this . panel , arguments ) ;
249
230
}
250
231
251
- Trace . sysout ( "InspectorOverlay.showDOMProperties;" , jQueryData ) ;
252
-
253
- // Display clicked jQuery data instead of element properties.
254
- this . toolbox . openSplitConsole ( ) . then ( ( ) => {
255
- let panel = this . toolbox . getPanel ( "webconsole" ) ;
256
- let output = panel . hud . ui . output ;
257
-
258
- output . openVariablesView ( {
259
- label : "jQuery.data" ,
260
- //objectActor: dataGrip,
261
- rawObject : jQueryData ,
262
- autofocus : true ,
232
+ // Alright, get jQuery.data from the backend and display
233
+ // them in the VariablesView (Console panel's side panel).
234
+ this . getJQueryData ( nodeFront ) . then ( response => {
235
+ this . toolbox . openSplitConsole ( ) . then ( ( ) => {
236
+ Trace . sysout ( "InspectorOverlay.showDOMProperties;" , response ) ;
237
+
238
+ let panel = this . toolbox . getPanel ( "webconsole" ) ;
239
+ let output = panel . hud . ui . output ;
240
+
241
+ // Retrieved 'response.jQueryData' is a grip object.
242
+ output . openVariablesView ( {
243
+ label : "jQuery.data" ,
244
+ objectActor : response . jQueryData ,
245
+ //rawObject: raw e.g. JSON object, would go here,
246
+ autofocus : true ,
247
+ } ) ;
263
248
} ) ;
264
249
} ) ;
265
250
} ,
@@ -310,6 +295,28 @@ const InspectorOverlay = Class(
310
295
this . createDataIcon ( element ) ;
311
296
}
312
297
} ,
298
+
299
+ // Helpers for jQuery.data
300
+
301
+ hasJQueryData : function ( nodeFront ) {
302
+ let hasJQueryData ;
303
+
304
+ // nodeFront.getFormProperty has been introduced in Bug 1036949
305
+ // xxxHonza: Checking existence of the method can be removed
306
+ // as soon as Fx42 is the minimum required version.
307
+ if ( nodeFront . getFormProperty ) {
308
+ hasJQueryData = nodeFront . getFormProperty ( "hasJQueryData" ) ;
309
+ } else if ( nodeFront . _form . props ) {
310
+ hasJQueryData = nodeFront . _form . props . hasJQueryData ;
311
+ }
312
+
313
+ return hasJQueryData ;
314
+ } ,
315
+
316
+ getJQueryData : function ( nodeFront ) {
317
+ let toolboxOverlay = this . context . getOverlay ( ToolboxOverlayId ) ;
318
+ return toolboxOverlay . front . getJQueryData ( nodeFront ) ;
319
+ }
313
320
} ) ;
314
321
315
322
// Patching MarkupView (fire a new "container-created" event)
0 commit comments