@@ -2342,7 +2342,8 @@ ExecutionVisualizer.prototype.renderDataStructures = function() {
23422342 if ( obj [ 2 ] . length > 0 ) {
23432343 superclassStr += ( '[extends ' + obj [ 2 ] . join ( ', ' ) + '] ' ) ;
23442344 }
2345- d3DomElement . append ( '<div class="typeLabel">' + typeLabelPrefix + obj [ 1 ] + ' class ' + superclassStr + '</div>' ) ;
2345+ d3DomElement . append ( '<div class="typeLabel">' + typeLabelPrefix + obj [ 1 ] + ' class ' + superclassStr +
2346+ '<br/>' + '<a href="#" id="attrToggleLink">hide attributes</a>' + '</div>' ) ;
23462347 }
23472348
23482349 // right now, let's NOT display class members, since that clutters
@@ -2382,6 +2383,29 @@ ExecutionVisualizer.prototype.renderDataStructures = function() {
23822383 renderNestedObject ( kvPair [ 1 ] , valTd ) ;
23832384 } ) ;
23842385 }
2386+
2387+ // class attributes can be displayed or hidden, so as not to
2388+ // CLUTTER UP the display with a ton of attributes, especially
2389+ // from imported modules and custom types created from, say,
2390+ // collections.namedtuple
2391+ if ( ! isInstance ) {
2392+ // super kludgy! use a global selector $ to get at the DOM
2393+ // element, which should be okay since IDs should be globally
2394+ // unique on a page, even with multiple ExecutionVisualizer
2395+ // instances ... but still feels dirty to me since it violates
2396+ // my "no using naked $(__) selectors for jQuery" convention :/
2397+ $ ( d3DomElement . selector + ' .typeLabel #attrToggleLink' ) . click ( function ( ) {
2398+ var elt = $ ( d3DomElement . selector + ' .classTbl' ) ;
2399+ elt . toggle ( ) ;
2400+ $ ( this ) . html ( ( elt . is ( ':visible' ) ? 'hide' : 'show' ) + ' attributes' ) ;
2401+
2402+ myViz . redrawConnectors ( ) ; // redraw all arrows!
2403+ return false ; // so that the <a href="#"> doesn't reload the page
2404+ } ) ;
2405+
2406+ // hide class attributes by default (or not!)
2407+ //$(d3DomElement.selector + ' .classTbl').hide();
2408+ }
23852409 }
23862410 else if ( obj [ 0 ] == 'INSTANCE_PPRINT' ) {
23872411 d3DomElement . append ( '<div class="typeLabel">' + typeLabelPrefix + obj [ 1 ] + ' instance</div>' ) ;
0 commit comments