##// END OF EJS Templates
Merge pull request #4662 from ellisonbg/menu-cleanup...
Min RK -
r14935:85e85ef6 merge
parent child Browse files
Show More
@@ -418,26 +418,30 b' var IPython = (function (IPython) {'
418 };
418 };
419
419
420
420
421 CodeCell.prototype.collapse = function () {
421 CodeCell.prototype.collapse_output = function () {
422 this.collapsed = true;
422 this.collapsed = true;
423 this.output_area.collapse();
423 this.output_area.collapse();
424 };
424 };
425
425
426
426
427 CodeCell.prototype.expand = function () {
427 CodeCell.prototype.expand_output = function () {
428 this.collapsed = false;
428 this.collapsed = false;
429 this.output_area.expand();
429 this.output_area.expand();
430 this.output_area.unscroll_area();
430 };
431 };
431
432
433 CodeCell.prototype.scroll_output = function () {
434 this.output_area.expand();
435 this.output_area.scroll_if_long();
436 };
432
437
433 CodeCell.prototype.toggle_output = function () {
438 CodeCell.prototype.toggle_output = function () {
434 this.collapsed = Boolean(1 - this.collapsed);
439 this.collapsed = Boolean(1 - this.collapsed);
435 this.output_area.toggle_output();
440 this.output_area.toggle_output();
436 };
441 };
437
442
438
439 CodeCell.prototype.toggle_output_scroll = function () {
443 CodeCell.prototype.toggle_output_scroll = function () {
440 this.output_area.toggle_scroll();
444 this.output_area.toggle_scroll();
441 };
445 };
442
446
443
447
@@ -510,6 +514,7 b' var IPython = (function (IPython) {'
510
514
511 CodeCell.prototype.clear_output = function (wait) {
515 CodeCell.prototype.clear_output = function (wait) {
512 this.output_area.clear_output(wait);
516 this.output_area.clear_output(wait);
517 this.set_input_prompt();
513 };
518 };
514
519
515
520
@@ -534,9 +539,9 b' var IPython = (function (IPython) {'
534 this.output_area.fromJSON(data.outputs);
539 this.output_area.fromJSON(data.outputs);
535 if (data.collapsed !== undefined) {
540 if (data.collapsed !== undefined) {
536 if (data.collapsed) {
541 if (data.collapsed) {
537 this.collapse();
542 this.collapse_output();
538 } else {
543 } else {
539 this.expand();
544 this.expand_output();
540 }
545 }
541 }
546 }
542 }
547 }
@@ -451,7 +451,7 b' var IPython = (function (IPython) {'
451 }
451 }
452 },
452 },
453 'shift+o' : {
453 'shift+o' : {
454 help : 'toggle output scroll',
454 help : 'toggle output scrolling',
455 help_index : 'gc',
455 help_index : 'gc',
456 handler : function (event) {
456 handler : function (event) {
457 IPython.notebook.toggle_output_scroll();
457 IPython.notebook.toggle_output_scroll();
@@ -110,6 +110,14 b' var IPython = (function (IPython) {'
110 callback : function () {
110 callback : function () {
111 IPython.notebook.session.interrupt_kernel();
111 IPython.notebook.session.interrupt_kernel();
112 }
112 }
113 },
114 {
115 id : 'repeat_b',
116 label : 'Restart Kernel',
117 icon : 'icon-repeat',
118 callback : function () {
119 IPython.notebook.restart_kernel();
120 }
113 }
121 }
114 ],'run_int');
122 ],'run_int');
115 };
123 };
@@ -178,12 +178,6 b' var IPython = (function (IPython) {'
178 this.element.find('#move_cell_down').click(function () {
178 this.element.find('#move_cell_down').click(function () {
179 IPython.notebook.move_cell_down();
179 IPython.notebook.move_cell_down();
180 });
180 });
181 this.element.find('#select_previous').click(function () {
182 IPython.notebook.select_prev();
183 });
184 this.element.find('#select_next').click(function () {
185 IPython.notebook.select_next();
186 });
187 this.element.find('#edit_nb_metadata').click(function () {
181 this.element.find('#edit_nb_metadata').click(function () {
188 IPython.notebook.edit_metadata();
182 IPython.notebook.edit_metadata();
189 });
183 });
@@ -252,21 +246,27 b' var IPython = (function (IPython) {'
252 this.element.find('#to_heading6').click(function () {
246 this.element.find('#to_heading6').click(function () {
253 IPython.notebook.to_heading(undefined, 6);
247 IPython.notebook.to_heading(undefined, 6);
254 });
248 });
255 this.element.find('#toggle_output').click(function () {
249
250 this.element.find('#toggle_current_output').click(function () {
256 IPython.notebook.toggle_output();
251 IPython.notebook.toggle_output();
257 });
252 });
258 this.element.find('#collapse_all_output').click(function () {
253 this.element.find('#toggle_current_output_scroll').click(function () {
259 IPython.notebook.collapse_all_output();
254 IPython.notebook.toggle_output_scroll();
255 });
256 this.element.find('#clear_current_output').click(function () {
257 IPython.notebook.clear_output();
260 });
258 });
261 this.element.find('#scroll_all_output').click(function () {
259
262 IPython.notebook.scroll_all_output();
260 this.element.find('#toggle_all_output').click(function () {
261 IPython.notebook.toggle_all_output();
263 });
262 });
264 this.element.find('#expand_all_output').click(function () {
263 this.element.find('#toggle_all_output_scroll').click(function () {
265 IPython.notebook.expand_all_output();
264 IPython.notebook.toggle_all_output_scroll();
266 });
265 });
267 this.element.find('#clear_all_output').click(function () {
266 this.element.find('#clear_all_output').click(function () {
268 IPython.notebook.clear_all_output();
267 IPython.notebook.clear_all_output();
269 });
268 });
269
270 // Kernel
270 // Kernel
271 this.element.find('#int_kernel').click(function () {
271 this.element.find('#int_kernel').click(function () {
272 IPython.notebook.session.interrupt_kernel();
272 IPython.notebook.session.interrupt_kernel();
@@ -1165,122 +1165,181 b' var IPython = (function (IPython) {'
1165 /**
1165 /**
1166 * Hide a cell's output.
1166 * Hide a cell's output.
1167 *
1167 *
1168 * @method collapse
1168 * @method collapse_output
1169 * @param {Number} index A cell's numeric index
1169 * @param {Number} index A cell's numeric index
1170 */
1170 */
1171 Notebook.prototype.collapse = function (index) {
1171 Notebook.prototype.collapse_output = function (index) {
1172 var i = this.index_or_selected(index);
1172 var i = this.index_or_selected(index);
1173 this.get_cell(i).collapse();
1173 var cell = this.get_cell(i);
1174 if (cell !== null && (cell instanceof IPython.CodeCell)) {
1175 cell.collapse_output();
1176 this.set_dirty(true);
1177 }
1178 };
1179
1180 /**
1181 * Hide each code cell's output area.
1182 *
1183 * @method collapse_all_output
1184 */
1185 Notebook.prototype.collapse_all_output = function () {
1186 $.map(this.get_cells(), function (cell, i) {
1187 if (cell instanceof IPython.CodeCell) {
1188 cell.collapse_output();
1189 }
1190 });
1191 // this should not be set if the `collapse` key is removed from nbformat
1174 this.set_dirty(true);
1192 this.set_dirty(true);
1175 };
1193 };
1176
1194
1177 /**
1195 /**
1178 * Show a cell's output.
1196 * Show a cell's output.
1179 *
1197 *
1180 * @method expand
1198 * @method expand_output
1181 * @param {Number} index A cell's numeric index
1199 * @param {Number} index A cell's numeric index
1182 */
1200 */
1183 Notebook.prototype.expand = function (index) {
1201 Notebook.prototype.expand_output = function (index) {
1184 var i = this.index_or_selected(index);
1202 var i = this.index_or_selected(index);
1185 this.get_cell(i).expand();
1203 var cell = this.get_cell(i);
1186 this.set_dirty(true);
1204 if (cell !== null && (cell instanceof IPython.CodeCell)) {
1205 cell.expand_output();
1206 this.set_dirty(true);
1207 }
1187 };
1208 };
1188
1209
1189 /** Toggle whether a cell's output is collapsed or expanded.
1210 /**
1211 * Expand each code cell's output area, and remove scrollbars.
1190 *
1212 *
1191 * @method toggle_output
1213 * @method expand_all_output
1192 * @param {Number} index A cell's numeric index
1193 */
1214 */
1194 Notebook.prototype.toggle_output = function (index) {
1215 Notebook.prototype.expand_all_output = function () {
1195 var i = this.index_or_selected(index);
1216 $.map(this.get_cells(), function (cell, i) {
1196 this.get_cell(i).toggle_output();
1217 if (cell instanceof IPython.CodeCell) {
1218 cell.expand_output();
1219 }
1220 });
1221 // this should not be set if the `collapse` key is removed from nbformat
1197 this.set_dirty(true);
1222 this.set_dirty(true);
1198 };
1223 };
1199
1224
1200 /**
1225 /**
1201 * Toggle a scrollbar for long cell outputs.
1226 * Clear the selected CodeCell's output area.
1202 *
1227 *
1203 * @method toggle_output_scroll
1228 * @method clear_output
1204 * @param {Number} index A cell's numeric index
1229 * @param {Number} index A cell's numeric index
1205 */
1230 */
1206 Notebook.prototype.toggle_output_scroll = function (index) {
1231 Notebook.prototype.clear_output = function (index) {
1207 var i = this.index_or_selected(index);
1232 var i = this.index_or_selected(index);
1208 this.get_cell(i).toggle_output_scroll();
1233 var cell = this.get_cell(i);
1234 if (cell !== null && (cell instanceof IPython.CodeCell)) {
1235 cell.clear_output();
1236 this.set_dirty(true);
1237 }
1209 };
1238 };
1210
1239
1211 /**
1240 /**
1212 * Hide each code cell's output area.
1241 * Clear each code cell's output area.
1213 *
1242 *
1214 * @method collapse_all_output
1243 * @method clear_all_output
1215 */
1244 */
1216 Notebook.prototype.collapse_all_output = function () {
1245 Notebook.prototype.clear_all_output = function () {
1217 var ncells = this.ncells();
1246 $.map(this.get_cells(), function (cell, i) {
1218 var cells = this.get_cells();
1247 if (cell instanceof IPython.CodeCell) {
1219 for (var i=0; i<ncells; i++) {
1248 cell.clear_output();
1220 if (cells[i] instanceof IPython.CodeCell) {
1221 cells[i].output_area.collapse();
1222 }
1249 }
1223 };
1250 });
1224 // this should not be set if the `collapse` key is removed from nbformat
1225 this.set_dirty(true);
1251 this.set_dirty(true);
1226 };
1252 };
1227
1253
1228 /**
1254 /**
1255 * Scroll the selected CodeCell's output area.
1256 *
1257 * @method scroll_output
1258 * @param {Number} index A cell's numeric index
1259 */
1260 Notebook.prototype.scroll_output = function (index) {
1261 var i = this.index_or_selected(index);
1262 var cell = this.get_cell(i);
1263 if (cell !== null && (cell instanceof IPython.CodeCell)) {
1264 cell.scroll_output();
1265 this.set_dirty(true);
1266 }
1267 };
1268
1269 /**
1229 * Expand each code cell's output area, and add a scrollbar for long output.
1270 * Expand each code cell's output area, and add a scrollbar for long output.
1230 *
1271 *
1231 * @method scroll_all_output
1272 * @method scroll_all_output
1232 */
1273 */
1233 Notebook.prototype.scroll_all_output = function () {
1274 Notebook.prototype.scroll_all_output = function () {
1234 var ncells = this.ncells();
1275 $.map(this.get_cells(), function (cell, i) {
1235 var cells = this.get_cells();
1276 if (cell instanceof IPython.CodeCell) {
1236 for (var i=0; i<ncells; i++) {
1277 cell.scroll_output();
1237 if (cells[i] instanceof IPython.CodeCell) {
1238 cells[i].output_area.expand();
1239 cells[i].output_area.scroll_if_long();
1240 }
1278 }
1241 };
1279 });
1242 // this should not be set if the `collapse` key is removed from nbformat
1280 // this should not be set if the `collapse` key is removed from nbformat
1243 this.set_dirty(true);
1281 this.set_dirty(true);
1244 };
1282 };
1245
1283
1284 /** Toggle whether a cell's output is collapsed or expanded.
1285 *
1286 * @method toggle_output
1287 * @param {Number} index A cell's numeric index
1288 */
1289 Notebook.prototype.toggle_output = function (index) {
1290 var i = this.index_or_selected(index);
1291 var cell = this.get_cell(i);
1292 if (cell !== null && (cell instanceof IPython.CodeCell)) {
1293 cell.toggle_output();
1294 this.set_dirty(true);
1295 }
1296 };
1297
1246 /**
1298 /**
1247 * Expand each code cell's output area, and remove scrollbars.
1299 * Hide/show the output of all cells.
1248 *
1300 *
1249 * @method expand_all_output
1301 * @method toggle_all_output
1250 */
1302 */
1251 Notebook.prototype.expand_all_output = function () {
1303 Notebook.prototype.toggle_all_output = function () {
1252 var ncells = this.ncells();
1304 $.map(this.get_cells(), function (cell, i) {
1253 var cells = this.get_cells();
1305 if (cell instanceof IPython.CodeCell) {
1254 for (var i=0; i<ncells; i++) {
1306 cell.toggle_output();
1255 if (cells[i] instanceof IPython.CodeCell) {
1256 cells[i].output_area.expand();
1257 cells[i].output_area.unscroll_area();
1258 }
1307 }
1259 };
1308 });
1260 // this should not be set if the `collapse` key is removed from nbformat
1309 // this should not be set if the `collapse` key is removed from nbformat
1261 this.set_dirty(true);
1310 this.set_dirty(true);
1262 };
1311 };
1263
1312
1264 /**
1313 /**
1265 * Clear each code cell's output area.
1314 * Toggle a scrollbar for long cell outputs.
1266 *
1315 *
1267 * @method clear_all_output
1316 * @method toggle_output_scroll
1317 * @param {Number} index A cell's numeric index
1268 */
1318 */
1269 Notebook.prototype.clear_all_output = function () {
1319 Notebook.prototype.toggle_output_scroll = function (index) {
1270 var ncells = this.ncells();
1320 var i = this.index_or_selected(index);
1271 var cells = this.get_cells();
1321 var cell = this.get_cell(i);
1272 for (var i=0; i<ncells; i++) {
1322 if (cell !== null && (cell instanceof IPython.CodeCell)) {
1273 if (cells[i] instanceof IPython.CodeCell) {
1323 cell.toggle_output_scroll();
1274 cells[i].clear_output();
1324 this.set_dirty(true);
1275 // Make all In[] prompts blank, as well
1325 }
1276 // TODO: make this configurable (via checkbox?)
1326 };
1277 cells[i].set_input_prompt();
1327
1328 /**
1329 * Toggle the scrolling of long output on all cells.
1330 *
1331 * @method toggle_all_output_scrolling
1332 */
1333 Notebook.prototype.toggle_all_output_scroll = function () {
1334 $.map(this.get_cells(), function (cell, i) {
1335 if (cell instanceof IPython.CodeCell) {
1336 cell.toggle_output_scroll();
1278 }
1337 }
1279 };
1338 });
1339 // this should not be set if the `collapse` key is removed from nbformat
1280 this.set_dirty(true);
1340 this.set_dirty(true);
1281 };
1341 };
1282
1342
1283
1284 // Other cell functions: line numbers, ...
1343 // Other cell functions: line numbers, ...
1285
1344
1286 /**
1345 /**
@@ -51,7 +51,7 b' class="notebook_app"'
51 <div class="container">
51 <div class="container">
52 <ul id="menus" class="nav">
52 <ul id="menus" class="nav">
53 <li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown">File</a>
53 <li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown">File</a>
54 <ul class="dropdown-menu">
54 <ul id="file_menu" class="dropdown-menu">
55 <li id="new_notebook"
55 <li id="new_notebook"
56 title="Make a new notebook (Opens a new window)">
56 title="Make a new notebook (Opens a new window)">
57 <a href="#">New</a></li>
57 <a href="#">New</a></li>
@@ -94,7 +94,7 b' class="notebook_app"'
94 </ul>
94 </ul>
95 </li>
95 </li>
96 <li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown">Edit</a>
96 <li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown">Edit</a>
97 <ul class="dropdown-menu">
97 <ul id="edit_menu" class="dropdown-menu">
98 <li id="cut_cell"><a href="#">Cut Cell</a></li>
98 <li id="cut_cell"><a href="#">Cut Cell</a></li>
99 <li id="copy_cell"><a href="#">Copy Cell</a></li>
99 <li id="copy_cell"><a href="#">Copy Cell</a></li>
100 <li id="paste_cell_above" class="disabled"><a href="#">Paste Cell Above</a></li>
100 <li id="paste_cell_above" class="disabled"><a href="#">Paste Cell Above</a></li>
@@ -110,14 +110,11 b' class="notebook_app"'
110 <li id="move_cell_up"><a href="#">Move Cell Up</a></li>
110 <li id="move_cell_up"><a href="#">Move Cell Up</a></li>
111 <li id="move_cell_down"><a href="#">Move Cell Down</a></li>
111 <li id="move_cell_down"><a href="#">Move Cell Down</a></li>
112 <li class="divider"></li>
112 <li class="divider"></li>
113 <li id="select_previous"><a href="#">Select Previous Cell</a></li>
114 <li id="select_next"><a href="#">Select Next Cell</a></li>
115 <li class="divider"></li>
116 <li id="edit_nb_metadata"><a href="#">Edit Notebook Metadata</a></li>
113 <li id="edit_nb_metadata"><a href="#">Edit Notebook Metadata</a></li>
117 </ul>
114 </ul>
118 </li>
115 </li>
119 <li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown">View</a>
116 <li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown">View</a>
120 <ul class="dropdown-menu">
117 <ul id="view_menu" class="dropdown-menu">
121 <li id="toggle_header"
118 <li id="toggle_header"
122 title="Show/Hide the IPython Notebook logo and notebook title (above menu bar)">
119 title="Show/Hide the IPython Notebook logo and notebook title (above menu bar)">
123 <a href="#">Toggle Header</a></li>
120 <a href="#">Toggle Header</a></li>
@@ -127,7 +124,7 b' class="notebook_app"'
127 </ul>
124 </ul>
128 </li>
125 </li>
129 <li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown">Insert</a>
126 <li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown">Insert</a>
130 <ul class="dropdown-menu">
127 <ul id="insert_menu" class="dropdown-menu">
131 <li id="insert_cell_above"
128 <li id="insert_cell_above"
132 title="Insert an empty Code cell above the currently active cell">
129 title="Insert an empty Code cell above the currently active cell">
133 <a href="#">Insert Cell Above</a></li>
130 <a href="#">Insert Cell Above</a></li>
@@ -137,7 +134,7 b' class="notebook_app"'
137 </ul>
134 </ul>
138 </li>
135 </li>
139 <li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown">Cell</a>
136 <li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown">Cell</a>
140 <ul class="dropdown-menu">
137 <ul id="cell_menu" class="dropdown-menu">
141 <li id="run_cell" title="Run this cell, and move cursor to the next one">
138 <li id="run_cell" title="Run this cell, and move cursor to the next one">
142 <a href="#">Run</a></li>
139 <a href="#">Run</a></li>
143 <li id="run_cell_select_below" title="Run this cell, select below">
140 <li id="run_cell_select_below" title="Run this cell, select below">
@@ -173,23 +170,42 b' class="notebook_app"'
173 </ul>
170 </ul>
174 </li>
171 </li>
175 <li class="divider"></li>
172 <li class="divider"></li>
176 <li id="toggle_output"
173 <li id="current_outputs" class="dropdown-submenu"><a href="#">Current Output</a>
177 title="Show/Hide the output portion of a Code cell">
174 <ul class="dropdown-menu">
178 <a href="#">Toggle Current Output</a></li>
175 <li id="toggle_current_output"
176 title="Hide/Show the output of the current cell">
177 <a href="#">Toggle</a>
178 </li>
179 <li id="toggle_current_output_scroll"
180 title="Scroll the output of the current cell">
181 <a href="#">Toggle Scrolling</a>
182 </li>
183 <li id="clear_current_output"
184 title="Clear the output of the current cell">
185 <a href="#">Clear</a>
186 </li>
187 </ul>
188 </li>
179 <li id="all_outputs" class="dropdown-submenu"><a href="#">All Output</a>
189 <li id="all_outputs" class="dropdown-submenu"><a href="#">All Output</a>
180 <ul class="dropdown-menu">
190 <ul class="dropdown-menu">
181 <li id="expand_all_output"><a href="#">Expand</a></li>
191 <li id="toggle_all_output"
182 <li id="scroll_all_output"><a href="#">Scroll Long</a></li>
192 title="Hide/Show the output of all cells">
183 <li id="collapse_all_output"><a href="#">Collapse</a></li>
193 <a href="#">Toggle</a>
194 </li>
195 <li id="toggle_all_output_scroll"
196 title="Scroll the output of all cells">
197 <a href="#">Toggle Scrolling</a>
198 </li>
184 <li id="clear_all_output"
199 <li id="clear_all_output"
185 title="Remove the output portion of all Code cells">
200 title="Clear the output of all cells">
186 <a href="#">Clear</a></li>
201 <a href="#">Clear</a>
202 </li>
187 </ul>
203 </ul>
188 </li>
204 </li>
189 </ul>
205 </ul>
190 </li>
206 </li>
191 <li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown">Kernel</a>
207 <li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown">Kernel</a>
192 <ul class="dropdown-menu">
208 <ul id="kernel_menu" class="dropdown-menu">
193 <li id="int_kernel"
209 <li id="int_kernel"
194 title="Send KeyboardInterrupt (CTRL-C) to the Kernel">
210 title="Send KeyboardInterrupt (CTRL-C) to the Kernel">
195 <a href="#">Interrupt</a></li>
211 <a href="#">Interrupt</a></li>
@@ -199,7 +215,7 b' class="notebook_app"'
199 </ul>
215 </ul>
200 </li>
216 </li>
201 <li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown">Help</a>
217 <li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown">Help</a>
202 <ul class="dropdown-menu" title="Opens in a new window">
218 <ul id="help_menu" class="dropdown-menu">
203 <li><a href="http://ipython.org/documentation.html" target="_blank">IPython Help</a></li>
219 <li><a href="http://ipython.org/documentation.html" target="_blank">IPython Help</a></li>
204 <li><a href="http://ipython.org/ipython-doc/stable/interactive/notebook.html" target="_blank">Notebook Help</a></li>
220 <li><a href="http://ipython.org/ipython-doc/stable/interactive/notebook.html" target="_blank">Notebook Help</a></li>
205 <li id="keyboard_shortcuts" title="Opens a tooltip with all keyboard shortcuts"><a href="#">Keyboard Shortcuts</a></li>
221 <li id="keyboard_shortcuts" title="Opens a tooltip with all keyboard shortcuts"><a href="#">Keyboard Shortcuts</a></li>
General Comments 0
You need to be logged in to leave comments. Login now