@@ -65,6 +65,8 @@ function AnnotationBubble(type, domID) {
6565 this . domID = domID ;
6666 this . hashID = '#' + domID ;
6767
68+ this . type = type ;
69+
6870 if ( type == 'codeline' ) {
6971 this . my = 'left center' ;
7072 this . at = 'right center' ;
@@ -256,13 +258,23 @@ AnnotationBubble.prototype.qTipID = function() {
256258
257259
258260AnnotationBubble . prototype . enterEditMode = function ( ) {
261+ // punt if you're a codeline annotation and your line of code is hidden
262+ if ( this . type == 'codeline' && ! isOutputLineVisible ( this . domID ) ) {
263+ return ;
264+ }
265+
259266 assert ( globalAnnotationMode == 'edit' ) ;
260267 if ( this . state == 'hidden' ) {
261268 this . showStub ( ) ;
262269 }
263270}
264271
265272AnnotationBubble . prototype . enterViewMode = function ( ) {
273+ // punt if you're a codeline annotation and your line of code is hidden
274+ if ( this . type == 'codeline' && ! isOutputLineVisible ( this . domID ) ) {
275+ return ;
276+ }
277+
266278 assert ( globalAnnotationMode == 'view' ) ;
267279 if ( this . state == 'stub' ) {
268280 this . hide ( ) ;
@@ -286,10 +298,27 @@ globalAnnotationMode = 'view';
286298
287299allBubbles = [ ] ;
288300
289- $ ( document ) . ready ( function ( ) {
290- $ . fn . qtip . styles = { } ;
291- $ . fn . qtip . styles . stubStyle = { border : { color : '#999' } } ;
292301
302+ // returns True iff lineNo is visible in pyCodeOutputDiv
303+ // NB: copied, pasted, and modified from isOutputLineVisible in js/pytutor.js
304+ function isOutputLineVisible ( lineDivID ) {
305+ var pcod = $ ( '#pyCodeOutputDiv' ) ;
306+
307+ var lineNoTd = $ ( '#' + lineDivID ) ;
308+ var LO = lineNoTd . offset ( ) . top ;
309+
310+ var PO = pcod . offset ( ) . top ;
311+ var ST = pcod . scrollTop ( ) ;
312+ var H = pcod . height ( ) ;
313+
314+ // add a few pixels of fudge factor on the bottom end due to bottom scrollbar
315+ return ( PO <= LO ) && ( LO < ( PO + H - 30 ) ) ;
316+ }
317+
318+
319+ $ ( document ) . ready ( function ( ) {
320+ // force vertical code scrolling
321+ $ ( '#pyCodeOutputDiv' ) . css ( 'max-height' , '120px' ) ;
293322
294323 /*
295324 var listSumVisualizer = new ExecutionVisualizer('listSumDiv', listSumTrace,
0 commit comments