Show More
@@ -1242,7 +1242,7 b' var IPython = (function (IPython) {' | |||||
1242 | for (var i=0; i<ncells; i++) { |
|
1242 | for (var i=0; i<ncells; i++) { | |
1243 | if (cells[i] instanceof IPython.CodeCell) { |
|
1243 | if (cells[i] instanceof IPython.CodeCell) { | |
1244 | cells[i].output_area.expand(); |
|
1244 | cells[i].output_area.expand(); | |
1245 |
cells[i].output_area.scroll_if_long( |
|
1245 | cells[i].output_area.scroll_if_long(); | |
1246 | } |
|
1246 | } | |
1247 | }; |
|
1247 | }; | |
1248 | // this should not be set if the `collapse` key is removed from nbformat |
|
1248 | // this should not be set if the `collapse` key is removed from nbformat |
@@ -1,5 +1,5 b'' | |||||
1 | //---------------------------------------------------------------------------- |
|
1 | //---------------------------------------------------------------------------- | |
2 |
// Copyright (C) 2008 |
|
2 | // Copyright (C) 2008 The IPython Development Team | |
3 | // |
|
3 | // | |
4 | // Distributed under the terms of the BSD License. The full license is in |
|
4 | // Distributed under the terms of the BSD License. The full license is in | |
5 | // the file COPYING, distributed as part of this software. |
|
5 | // the file COPYING, distributed as part of this software. | |
@@ -9,11 +9,22 b'' | |||||
9 | // OutputArea |
|
9 | // OutputArea | |
10 | //============================================================================ |
|
10 | //============================================================================ | |
11 |
|
11 | |||
|
12 | /** | |||
|
13 | * @module IPython | |||
|
14 | * @namespace IPython | |||
|
15 | * @submodule OutputArea | |||
|
16 | */ | |||
12 | var IPython = (function (IPython) { |
|
17 | var IPython = (function (IPython) { | |
13 | "use strict"; |
|
18 | "use strict"; | |
14 |
|
19 | |||
15 | var utils = IPython.utils; |
|
20 | var utils = IPython.utils; | |
16 |
|
21 | |||
|
22 | /** | |||
|
23 | * @class OutputArea | |||
|
24 | * | |||
|
25 | * @constructor | |||
|
26 | */ | |||
|
27 | ||||
17 | var OutputArea = function (selector, prompt_area) { |
|
28 | var OutputArea = function (selector, prompt_area) { | |
18 | this.selector = selector; |
|
29 | this.selector = selector; | |
19 | this.wrapper = $(selector); |
|
30 | this.wrapper = $(selector); | |
@@ -59,8 +70,18 b' var IPython = (function (IPython) {' | |||||
59 | this.collapse(); |
|
70 | this.collapse(); | |
60 | }; |
|
71 | }; | |
61 |
|
72 | |||
62 |
|
73 | /** | ||
|
74 | * Should the OutputArea scroll? | |||
|
75 | * Returns whether the height (in lines) exceeds a threshold. | |||
|
76 | * | |||
|
77 | * @private | |||
|
78 | * @method _should_scroll | |||
|
79 | * @param [lines=100]{Integer} | |||
|
80 | * @return {Bool} | |||
|
81 | * | |||
|
82 | */ | |||
63 | OutputArea.prototype._should_scroll = function (lines) { |
|
83 | OutputArea.prototype._should_scroll = function (lines) { | |
|
84 | if (lines <=0 ){ return } | |||
64 | if (!lines) { |
|
85 | if (!lines) { | |
65 | lines = 100; |
|
86 | lines = 100; | |
66 | } |
|
87 | } | |
@@ -84,7 +105,7 b' var IPython = (function (IPython) {' | |||||
84 | } |
|
105 | } | |
85 | // maybe scroll output, |
|
106 | // maybe scroll output, | |
86 | // if it's grown large enough and hasn't already been scrolled. |
|
107 | // if it's grown large enough and hasn't already been scrolled. | |
87 | if ( !that.scrolled && that._should_scroll()) { |
|
108 | if ( !that.scrolled && that._should_scroll(OutputArea.auto_scroll_threshold)) { | |
88 | that.scroll_area(); |
|
109 | that.scroll_area(); | |
89 | } |
|
110 | } | |
90 | }); |
|
111 | }); | |
@@ -143,9 +164,51 b' var IPython = (function (IPython) {' | |||||
143 | this.scrolled = false; |
|
164 | this.scrolled = false; | |
144 | }; |
|
165 | }; | |
145 |
|
166 | |||
146 |
|
167 | /** | ||
|
168 | * Threshold to trigger autoscroll when the OutputArea is resized, | |||
|
169 | * typically when new outputs are added. | |||
|
170 | * | |||
|
171 | * Behavior is undefined if autoscroll is lower than scroll_threshold, | |||
|
172 | * unless it is < 0 then autoscroll will never be triggerd | |||
|
173 | * | |||
|
174 | * @property auto_scroll_threshold | |||
|
175 | * @type Number | |||
|
176 | * @default 20 | |||
|
177 | * | |||
|
178 | **/ | |||
|
179 | OutputArea.auto_scroll_threshold = 20; | |||
|
180 | ||||
|
181 | ||||
|
182 | /** | |||
|
183 | * Defautl value for minimal length for output are to be able to switch to | |||
|
184 | * scroll mode | |||
|
185 | * | |||
|
186 | * @property scroll_threshold | |||
|
187 | * @type Number | |||
|
188 | * @default 20 | |||
|
189 | * | |||
|
190 | **/ | |||
|
191 | OutputArea.scroll_threshold = 20; | |||
|
192 | ||||
|
193 | ||||
|
194 | /** | |||
|
195 | * Scroll OutputArea if height supperior than a threshold. | |||
|
196 | * | |||
|
197 | * Treshold is exprimed as a number of lines, fallback to a (configurable) default. | |||
|
198 | * | |||
|
199 | * Negative or null (0) threshold will prevent the OutputArea ever to scroll. | |||
|
200 | * | |||
|
201 | * @method scroll_if_long | |||
|
202 | * @param [lines=20,configurable]{Number} | |||
|
203 | * | |||
|
204 | **/ | |||
147 | OutputArea.prototype.scroll_if_long = function (lines) { |
|
205 | OutputArea.prototype.scroll_if_long = function (lines) { | |
148 | if (this._should_scroll(lines)) { |
|
206 | var n = lines | OutputArea.scroll_threshold; | |
|
207 | if(n <= 0){ | |||
|
208 | return | |||
|
209 | } | |||
|
210 | ||||
|
211 | if (this._should_scroll(n)) { | |||
149 | // only allow scrolling long-enough output |
|
212 | // only allow scrolling long-enough output | |
150 | this.scroll_area(); |
|
213 | this.scroll_area(); | |
151 | } |
|
214 | } | |
@@ -157,7 +220,7 b' var IPython = (function (IPython) {' | |||||
157 | this.unscroll_area(); |
|
220 | this.unscroll_area(); | |
158 | } else { |
|
221 | } else { | |
159 | // only allow scrolling long-enough output |
|
222 | // only allow scrolling long-enough output | |
160 |
this.scroll_if_long( |
|
223 | this.scroll_if_long(); | |
161 | } |
|
224 | } | |
162 | }; |
|
225 | }; | |
163 |
|
226 | |||
@@ -466,7 +529,7 b' var IPython = (function (IPython) {' | |||||
466 | toinsert.append(latex); |
|
529 | toinsert.append(latex); | |
467 | element.append(toinsert); |
|
530 | element.append(toinsert); | |
468 | }; |
|
531 | }; | |
469 |
|
532 | |||
470 | OutputArea.prototype.append_raw_input = function (content) { |
|
533 | OutputArea.prototype.append_raw_input = function (content) { | |
471 | var that = this; |
|
534 | var that = this; | |
472 | this.expand(); |
|
535 | this.expand(); |
General Comments 0
You need to be logged in to leave comments.
Login now