##// END OF EJS Templates
Merge pull request #1825 from minrk/elide2...
Min RK -
r7614:ef57f6e2 merge
parent child Browse files
Show More
@@ -104,7 +104,7 b' div#notebook {'
104 width: 100%;
104 width: 100%;
105 /* This spaces the cell away from the edge of the notebook area */
105 /* This spaces the cell away from the edge of the notebook area */
106 padding: 5px 5px 15px 5px;
106 padding: 5px 5px 15px 5px;
107 margin: 0px
107 margin: 0px;
108 background-color: white;
108 background-color: white;
109 }
109 }
110
110
@@ -137,6 +137,7 b' div.cell {'
137 div.code_cell {
137 div.code_cell {
138 background-color: white;
138 background-color: white;
139 }
139 }
140
140 /* any special styling for code cells that are currently running goes here */
141 /* any special styling for code cells that are currently running goes here */
141 div.code_cell.running {
142 div.code_cell.running {
142 }
143 }
@@ -168,13 +169,50 b' div.input_prompt {'
168 border-top: 1px solid transparent;
169 border-top: 1px solid transparent;
169 }
170 }
170
171
171 div.output {
172 div.output_wrapper {
172 /* This is a spacer between the input and output of each cell */
173 /* This is a spacer between the input and output of each cell */
173 margin-top: 5px;
174 margin-top: 5px;
175 margin-left: 5px;
176 /* FF needs explicit width to stretch */
177 width: 100%;
178 /* this position must be relative to enable descendents to be absolute within it */
179 position: relative;
180 }
181
182 /* class for the output area when it should be height-limited */
183 div.output_scroll {
184 /* ideally, this would be max-height, but FF barfs all over that */
185 height: 24em;
186 /* FF needs this *and the wrapper* to specify full width, or it will shrinkwrap */
187 width: 100%;
188
189 overflow: auto;
190 border-radius: 3px;
191 box-shadow: inset 0 2px 8px rgba(0, 0, 0, .8);
192 }
193
194 /* output div while it is collapsed */
195 div.output_collapsed {
196 margin-right: 5px;
197 }
198
199 div.out_prompt_overlay {
200 height: 100%;
201 padding: 0px;
202 position: absolute;
203 border-radius: 3px;
204 }
205
206 div.out_prompt_overlay:hover {
207 /* use inner shadow to get border that is computed the same on WebKit/FF */
208 box-shadow: inset 0 0 1px #000;
209 background: rgba(240, 240, 240, 0.5);
174 }
210 }
175
211
176 div.output_prompt {
212 div.output_prompt {
177 color: darkred;
213 color: darkred;
214 /* 5px right shift to account for margin in parent container */
215 margin: 0 5px 0 -5px;
178 }
216 }
179
217
180 /* This class is the outer container of all output sections. */
218 /* This class is the outer container of all output sections. */
@@ -218,6 +218,11 b' var IPython = (function (IPython) {'
218 };
218 };
219
219
220
220
221 CodeCell.prototype.toggle_output_scroll = function () {
222 this.output_area.toggle_scroll();
223 };
224
225
221 CodeCell.prototype.set_input_prompt = function (number) {
226 CodeCell.prototype.set_input_prompt = function (number) {
222 this.input_prompt_number = number;
227 this.input_prompt_number = number;
223 var ns = number || " ";
228 var ns = number || " ";
@@ -158,6 +158,15 b' var IPython = (function (IPython) {'
158 this.element.find('#toggle_output').click(function () {
158 this.element.find('#toggle_output').click(function () {
159 IPython.notebook.toggle_output();
159 IPython.notebook.toggle_output();
160 });
160 });
161 this.element.find('#collapse_all_output').click(function () {
162 IPython.notebook.collapse_all_output();
163 });
164 this.element.find('#scroll_all_output').click(function () {
165 IPython.notebook.scroll_all_output();
166 });
167 this.element.find('#expand_all_output').click(function () {
168 IPython.notebook.expand_all_output();
169 });
161 this.element.find('#clear_all_output').click(function () {
170 this.element.find('#clear_all_output').click(function () {
162 IPython.notebook.clear_all_output();
171 IPython.notebook.clear_all_output();
163 });
172 });
@@ -194,7 +194,11 b' var IPython = (function (IPython) {'
194 return false;
194 return false;
195 } else if (event.which === 79 && that.control_key_active) {
195 } else if (event.which === 79 && that.control_key_active) {
196 // Toggle output = o
196 // Toggle output = o
197 that.toggle_output();
197 if (event.shiftKey){
198 that.toggle_output_scroll();
199 } else {
200 that.toggle_output();
201 }
198 that.control_key_active = false;
202 that.control_key_active = false;
199 return false;
203 return false;
200 } else if (event.which === 83 && that.control_key_active) {
204 } else if (event.which === 83 && that.control_key_active) {
@@ -883,6 +887,53 b' var IPython = (function (IPython) {'
883 };
887 };
884
888
885
889
890 Notebook.prototype.toggle_output_scroll = function (index) {
891 var i = this.index_or_selected(index);
892 this.get_cell(i).toggle_output_scroll();
893 };
894
895
896 Notebook.prototype.collapse_all_output = function () {
897 var ncells = this.ncells();
898 var cells = this.get_cells();
899 for (var i=0; i<ncells; i++) {
900 if (cells[i] instanceof IPython.CodeCell) {
901 cells[i].output_area.collapse();
902 }
903 };
904 // this should not be set if the `collapse` key is removed from nbformat
905 this.dirty = true;
906 };
907
908
909 Notebook.prototype.scroll_all_output = function () {
910 var ncells = this.ncells();
911 var cells = this.get_cells();
912 for (var i=0; i<ncells; i++) {
913 if (cells[i] instanceof IPython.CodeCell) {
914 cells[i].output_area.expand();
915 cells[i].output_area.scroll_if_long(20);
916 }
917 };
918 // this should not be set if the `collapse` key is removed from nbformat
919 this.dirty = true;
920 };
921
922
923 Notebook.prototype.expand_all_output = function () {
924 var ncells = this.ncells();
925 var cells = this.get_cells();
926 for (var i=0; i<ncells; i++) {
927 if (cells[i] instanceof IPython.CodeCell) {
928 cells[i].output_area.expand();
929 cells[i].output_area.unscroll_area();
930 }
931 };
932 // this should not be set if the `collapse` key is removed from nbformat
933 this.dirty = true;
934 };
935
936
886 Notebook.prototype.clear_all_output = function () {
937 Notebook.prototype.clear_all_output = function () {
887 var ncells = this.ncells();
938 var ncells = this.ncells();
888 var cells = this.get_cells();
939 var cells = this.get_cells();
@@ -16,28 +16,92 b' var IPython = (function (IPython) {'
16
16
17 var OutputArea = function (selector, prompt_area) {
17 var OutputArea = function (selector, prompt_area) {
18 this.selector = selector;
18 this.selector = selector;
19 this.element = $(selector);
19 this.wrapper = $(selector);
20 this.outputs = [];
20 this.outputs = [];
21 this.collapsed = false;
21 this.collapsed = false;
22 this.scrolled = false;
22 this.clear_out_timeout = null;
23 this.clear_out_timeout = null;
23 if (prompt_area === undefined) {
24 if (prompt_area === undefined) {
24 this.prompt_area = true;
25 this.prompt_area = true;
25 } else {
26 } else {
26 this.prompt_area = prompt_area;
27 this.prompt_area = prompt_area;
27 };
28 };
29 this.create_elements();
28 this.style();
30 this.style();
31 this.bind_events();
32 };
33
34 OutputArea.prototype.create_elements = function () {
35 this.element = $("<div/>");
36 this.collapse_button = $("<div/>");
37 this.prompt_overlay = $("<div/>");
38 this.wrapper.append(this.prompt_overlay);
39 this.wrapper.append(this.element);
40 this.wrapper.append(this.collapse_button);
29 };
41 };
30
42
31
43
32 OutputArea.prototype.style = function () {
44 OutputArea.prototype.style = function () {
45 this.collapse_button.hide();
46 this.prompt_overlay.hide();
47
48 this.wrapper.addClass('output_wrapper');
33 this.element.addClass('output vbox');
49 this.element.addClass('output vbox');
50
51 this.collapse_button.button();
52 this.collapse_button.addClass('output_collapsed vbox');
53 this.collapse_button.attr('title', 'click to expand outout');
54 this.collapse_button.html('. . .');
55
56 this.prompt_overlay.addClass('out_prompt_overlay prompt');
57 this.prompt_overlay.attr('title', 'click to expand outout; double click to hide output');
58
34 this.collapse();
59 this.collapse();
35 };
60 };
36
61
37
62
63 OutputArea.prototype._should_scroll = function (lines) {
64 if (!lines) {
65 lines = 50;
66 }
67 // line-height from http://stackoverflow.com/questions/1185151
68 var fontSize = this.element.css('font-size');
69 var lineHeight = Math.floor(parseInt(fontSize.replace('px','')) * 1.5);
70
71 return (this.element.height() > lines * lineHeight);
72 };
73
74
75 OutputArea.prototype.bind_events = function () {
76 var that = this;
77 this.prompt_overlay.dblclick(function () { that.toggle_output(); });
78 this.prompt_overlay.click(function () { that.toggle_scroll(); });
79
80 this.element.resize(function () {
81 // maybe scroll output,
82 // if it's grown large enough and hasn't already been scrolled.
83 if ( !that.scrolled && that._should_scroll()) {
84 that.scroll_area();
85 }
86 });
87 this.collapse_button.click(function () {
88 that.expand();
89 });
90 this.collapse_button.hover(function () {
91 $(this).addClass("ui-state-hover");
92 }, function () {
93 $(this).removeClass("ui-state-hover");
94 });
95 };
96
97
38 OutputArea.prototype.collapse = function () {
98 OutputArea.prototype.collapse = function () {
39 if (!this.collapsed) {
99 if (!this.collapsed) {
40 this.element.hide();
100 this.element.hide();
101 this.prompt_overlay.hide();
102 if (this.element.html()){
103 this.collapse_button.show();
104 }
41 this.collapsed = true;
105 this.collapsed = true;
42 };
106 };
43 };
107 };
@@ -45,7 +109,9 b' var IPython = (function (IPython) {'
45
109
46 OutputArea.prototype.expand = function () {
110 OutputArea.prototype.expand = function () {
47 if (this.collapsed) {
111 if (this.collapsed) {
112 this.collapse_button.hide();
48 this.element.show();
113 this.element.show();
114 this.prompt_overlay.show();
49 this.collapsed = false;
115 this.collapsed = false;
50 };
116 };
51 };
117 };
@@ -60,6 +126,38 b' var IPython = (function (IPython) {'
60 };
126 };
61
127
62
128
129 OutputArea.prototype.scroll_area = function () {
130 this.element.addClass('output_scroll');
131 this.prompt_overlay.attr('title', 'click to unscroll output; double click to hide');
132 this.scrolled = true;
133 };
134
135
136 OutputArea.prototype.unscroll_area = function () {
137 this.element.removeClass('output_scroll');
138 this.prompt_overlay.attr('title', 'click to scroll output; double click to hide');
139 this.scrolled = false;
140 };
141
142
143 OutputArea.prototype.scroll_if_long = function (lines) {
144 if (this._should_scroll(lines)) {
145 // only allow scrolling long-enough output
146 this.scroll_area();
147 };
148 };
149
150
151 OutputArea.prototype.toggle_scroll = function () {
152 if (this.scrolled) {
153 this.unscroll_area();
154 } else {
155 // only allow scrolling long-enough output
156 this.scroll_if_long(20);
157 };
158 };
159
160
63 // typeset with MathJax if MathJax is available
161 // typeset with MathJax if MathJax is available
64 OutputArea.prototype.typeset = function () {
162 OutputArea.prototype.typeset = function () {
65 if (window.MathJax){
163 if (window.MathJax){
@@ -132,6 +230,8 b' var IPython = (function (IPython) {'
132 this.append_stream(json);
230 this.append_stream(json);
133 };
231 };
134 this.outputs.push(json);
232 this.outputs.push(json);
233 var that = this;
234 setTimeout(function(){that.element.trigger('resize');}, 100);
135 };
235 };
136
236
137
237
@@ -346,6 +446,7 b' var IPython = (function (IPython) {'
346 // clear all, no need for logic
446 // clear all, no need for logic
347 output_div.html("");
447 output_div.html("");
348 this.outputs = [];
448 this.outputs = [];
449 this.unscroll_area();
349 return;
450 return;
350 }
451 }
351 // remove html output
452 // remove html output
@@ -360,7 +461,8 b' var IPython = (function (IPython) {'
360 if (other) {
461 if (other) {
361 output_div.find("div.output_subarea").not("div.output_stderr").not("div.output_stdout").parent().remove();
462 output_div.find("div.output_subarea").not("div.output_stderr").not("div.output_stdout").parent().remove();
362 }
463 }
363
464 this.unscroll_area();
465
364 // remove cleared outputs from JSON list:
466 // remove cleared outputs from JSON list:
365 for (var i = this.outputs.length - 1; i >= 0; i--) {
467 for (var i = this.outputs.length - 1; i >= 0; i--) {
366 var out = this.outputs[i];
468 var out = this.outputs[i];
@@ -35,6 +35,7 b' var IPython = (function (IPython) {'
35 {key: 'Ctrl-m a', help: 'insert cell above'},
35 {key: 'Ctrl-m a', help: 'insert cell above'},
36 {key: 'Ctrl-m b', help: 'insert cell below'},
36 {key: 'Ctrl-m b', help: 'insert cell below'},
37 {key: 'Ctrl-m o', help: 'toggle output'},
37 {key: 'Ctrl-m o', help: 'toggle output'},
38 {key: 'Ctrl-m O', help: 'toggle output scroll'},
38 {key: 'Ctrl-m l', help: 'toggle line numbers'},
39 {key: 'Ctrl-m l', help: 'toggle line numbers'},
39 {key: 'Ctrl-m s', help: 'save notebook'},
40 {key: 'Ctrl-m s', help: 'save notebook'},
40 {key: 'Ctrl-m j', help: 'move cell down'},
41 {key: 'Ctrl-m j', help: 'move cell down'},
@@ -117,8 +117,15 b' data-notebook-id={{notebook_id}}'
117 <li id="to_heading5"><a href="#">Heading 5</a></li>
117 <li id="to_heading5"><a href="#">Heading 5</a></li>
118 <li id="to_heading6"><a href="#">Heading 6</a></li>
118 <li id="to_heading6"><a href="#">Heading 6</a></li>
119 <hr/>
119 <hr/>
120 <li id="toggle_output"><a href="#">Toggle Output</a></li>
120 <li id="toggle_output"><a href="#">Toggle Current Output</a></li>
121 <li id="clear_all_output"><a href="#">Clear All Output</a></li>
121 <li id="all_outputs"><a href="#">All Output</a>
122 <ul>
123 <li id="expand_all_output"><a href="#">Expand</a></li>
124 <li id="scroll_all_output"><a href="#">Scroll Long</a></li>
125 <li id="collapse_all_output"><a href="#">Collapse</a></li>
126 <li id="clear_all_output"><a href="#">Clear</a></li>
127 </ul>
128 </li>
122 </ul>
129 </ul>
123 </li>
130 </li>
124 <li><a href="#">Kernel</a>
131 <li><a href="#">Kernel</a>
General Comments 0
You need to be logged in to leave comments. Login now