Skip to content

Commit 6e852f0

Browse files
committed
preserve shown/hidden state for class attributes
1 parent 72d5395 commit 6e852f0

1 file changed

Lines changed: 17 additions & 2 deletions

File tree

v3/js/pytutor.js

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,7 @@ function ExecutionVisualizer(domRootID, dat, params) {
236236

237237
this.enableTransitions = false; // EXPERIMENTAL - enable transition effects
238238

239+
this.classAttrsHidden = {}; // kludgy hack for 'show/hide attributes' for class objects
239240

240241
this.hasRendered = false;
241242

@@ -2399,12 +2400,26 @@ ExecutionVisualizer.prototype.renderDataStructures = function() {
23992400
elt.toggle();
24002401
$(this).html((elt.is(':visible') ? 'hide' : 'show') + ' attributes');
24012402

2403+
if (elt.is(':visible')) {
2404+
myViz.classAttrsHidden[d3DomElement.selector] = false;
2405+
$(this).html('hide attributes');
2406+
}
2407+
else {
2408+
myViz.classAttrsHidden[d3DomElement.selector] = true;
2409+
$(this).html('show attributes');
2410+
}
2411+
24022412
myViz.redrawConnectors(); // redraw all arrows!
2413+
24032414
return false; // so that the <a href="#"> doesn't reload the page
24042415
});
24052416

2406-
// hide class attributes by default (or not!)
2407-
//$(d3DomElement.selector + ' .classTbl').hide();
2417+
// "remember" whether this was hidden earlier during this
2418+
// visualization session
2419+
if (myViz.classAttrsHidden[d3DomElement.selector]) {
2420+
$(d3DomElement.selector + ' .classTbl').hide();
2421+
$(d3DomElement.selector + ' .typeLabel #attrToggleLink').html('show attributes');
2422+
}
24082423
}
24092424
}
24102425
else if (obj[0] == 'INSTANCE_PPRINT') {

0 commit comments

Comments
 (0)