From 85e85ef6ee2c6115a56690ebc86272e56cde9dc8 2014-01-30 04:23:12 From: Min RK Date: 2014-01-30 04:23:12 Subject: [PATCH] Merge pull request #4662 from ellisonbg/menu-cleanup Menu cleanup --- diff --git a/IPython/html/static/notebook/js/codecell.js b/IPython/html/static/notebook/js/codecell.js index a36e82a..6a12f98 100644 --- a/IPython/html/static/notebook/js/codecell.js +++ b/IPython/html/static/notebook/js/codecell.js @@ -418,26 +418,30 @@ var IPython = (function (IPython) { }; - CodeCell.prototype.collapse = function () { + CodeCell.prototype.collapse_output = function () { this.collapsed = true; this.output_area.collapse(); }; - CodeCell.prototype.expand = function () { + CodeCell.prototype.expand_output = function () { this.collapsed = false; this.output_area.expand(); + this.output_area.unscroll_area(); }; + CodeCell.prototype.scroll_output = function () { + this.output_area.expand(); + this.output_area.scroll_if_long(); + }; CodeCell.prototype.toggle_output = function () { this.collapsed = Boolean(1 - this.collapsed); this.output_area.toggle_output(); }; - CodeCell.prototype.toggle_output_scroll = function () { - this.output_area.toggle_scroll(); + this.output_area.toggle_scroll(); }; @@ -510,6 +514,7 @@ var IPython = (function (IPython) { CodeCell.prototype.clear_output = function (wait) { this.output_area.clear_output(wait); + this.set_input_prompt(); }; @@ -534,9 +539,9 @@ var IPython = (function (IPython) { this.output_area.fromJSON(data.outputs); if (data.collapsed !== undefined) { if (data.collapsed) { - this.collapse(); + this.collapse_output(); } else { - this.expand(); + this.expand_output(); } } } diff --git a/IPython/html/static/notebook/js/keyboardmanager.js b/IPython/html/static/notebook/js/keyboardmanager.js index 42db5eb..1e6a50c 100644 --- a/IPython/html/static/notebook/js/keyboardmanager.js +++ b/IPython/html/static/notebook/js/keyboardmanager.js @@ -451,7 +451,7 @@ var IPython = (function (IPython) { } }, 'shift+o' : { - help : 'toggle output scroll', + help : 'toggle output scrolling', help_index : 'gc', handler : function (event) { IPython.notebook.toggle_output_scroll(); diff --git a/IPython/html/static/notebook/js/maintoolbar.js b/IPython/html/static/notebook/js/maintoolbar.js index 9c09e37..ec00315 100644 --- a/IPython/html/static/notebook/js/maintoolbar.js +++ b/IPython/html/static/notebook/js/maintoolbar.js @@ -110,6 +110,14 @@ var IPython = (function (IPython) { callback : function () { IPython.notebook.session.interrupt_kernel(); } + }, + { + id : 'repeat_b', + label : 'Restart Kernel', + icon : 'icon-repeat', + callback : function () { + IPython.notebook.restart_kernel(); + } } ],'run_int'); }; diff --git a/IPython/html/static/notebook/js/menubar.js b/IPython/html/static/notebook/js/menubar.js index e531eef..622d76e 100644 --- a/IPython/html/static/notebook/js/menubar.js +++ b/IPython/html/static/notebook/js/menubar.js @@ -178,12 +178,6 @@ var IPython = (function (IPython) { this.element.find('#move_cell_down').click(function () { IPython.notebook.move_cell_down(); }); - this.element.find('#select_previous').click(function () { - IPython.notebook.select_prev(); - }); - this.element.find('#select_next').click(function () { - IPython.notebook.select_next(); - }); this.element.find('#edit_nb_metadata').click(function () { IPython.notebook.edit_metadata(); }); @@ -252,21 +246,27 @@ var IPython = (function (IPython) { this.element.find('#to_heading6').click(function () { IPython.notebook.to_heading(undefined, 6); }); - this.element.find('#toggle_output').click(function () { + + this.element.find('#toggle_current_output').click(function () { IPython.notebook.toggle_output(); }); - this.element.find('#collapse_all_output').click(function () { - IPython.notebook.collapse_all_output(); + this.element.find('#toggle_current_output_scroll').click(function () { + IPython.notebook.toggle_output_scroll(); + }); + this.element.find('#clear_current_output').click(function () { + IPython.notebook.clear_output(); }); - this.element.find('#scroll_all_output').click(function () { - IPython.notebook.scroll_all_output(); + + this.element.find('#toggle_all_output').click(function () { + IPython.notebook.toggle_all_output(); }); - this.element.find('#expand_all_output').click(function () { - IPython.notebook.expand_all_output(); + this.element.find('#toggle_all_output_scroll').click(function () { + IPython.notebook.toggle_all_output_scroll(); }); this.element.find('#clear_all_output').click(function () { IPython.notebook.clear_all_output(); }); + // Kernel this.element.find('#int_kernel').click(function () { IPython.notebook.session.interrupt_kernel(); diff --git a/IPython/html/static/notebook/js/notebook.js b/IPython/html/static/notebook/js/notebook.js index 345fc14..61c80e9 100644 --- a/IPython/html/static/notebook/js/notebook.js +++ b/IPython/html/static/notebook/js/notebook.js @@ -1165,122 +1165,181 @@ var IPython = (function (IPython) { /** * Hide a cell's output. * - * @method collapse + * @method collapse_output * @param {Number} index A cell's numeric index */ - Notebook.prototype.collapse = function (index) { + Notebook.prototype.collapse_output = function (index) { var i = this.index_or_selected(index); - this.get_cell(i).collapse(); + var cell = this.get_cell(i); + if (cell !== null && (cell instanceof IPython.CodeCell)) { + cell.collapse_output(); + this.set_dirty(true); + } + }; + + /** + * Hide each code cell's output area. + * + * @method collapse_all_output + */ + Notebook.prototype.collapse_all_output = function () { + $.map(this.get_cells(), function (cell, i) { + if (cell instanceof IPython.CodeCell) { + cell.collapse_output(); + } + }); + // this should not be set if the `collapse` key is removed from nbformat this.set_dirty(true); }; /** * Show a cell's output. * - * @method expand + * @method expand_output * @param {Number} index A cell's numeric index */ - Notebook.prototype.expand = function (index) { + Notebook.prototype.expand_output = function (index) { var i = this.index_or_selected(index); - this.get_cell(i).expand(); - this.set_dirty(true); + var cell = this.get_cell(i); + if (cell !== null && (cell instanceof IPython.CodeCell)) { + cell.expand_output(); + this.set_dirty(true); + } }; - /** Toggle whether a cell's output is collapsed or expanded. + /** + * Expand each code cell's output area, and remove scrollbars. * - * @method toggle_output - * @param {Number} index A cell's numeric index + * @method expand_all_output */ - Notebook.prototype.toggle_output = function (index) { - var i = this.index_or_selected(index); - this.get_cell(i).toggle_output(); + Notebook.prototype.expand_all_output = function () { + $.map(this.get_cells(), function (cell, i) { + if (cell instanceof IPython.CodeCell) { + cell.expand_output(); + } + }); + // this should not be set if the `collapse` key is removed from nbformat this.set_dirty(true); }; /** - * Toggle a scrollbar for long cell outputs. + * Clear the selected CodeCell's output area. * - * @method toggle_output_scroll + * @method clear_output * @param {Number} index A cell's numeric index */ - Notebook.prototype.toggle_output_scroll = function (index) { + Notebook.prototype.clear_output = function (index) { var i = this.index_or_selected(index); - this.get_cell(i).toggle_output_scroll(); + var cell = this.get_cell(i); + if (cell !== null && (cell instanceof IPython.CodeCell)) { + cell.clear_output(); + this.set_dirty(true); + } }; /** - * Hide each code cell's output area. + * Clear each code cell's output area. * - * @method collapse_all_output + * @method clear_all_output */ - Notebook.prototype.collapse_all_output = function () { - var ncells = this.ncells(); - var cells = this.get_cells(); - for (var i=0; i