diff --git a/notebook/static/notebook/js/actions.js b/notebook/static/notebook/js/actions.js index c049aa806..7a40ec7e7 100644 --- a/notebook/static/notebook/js/actions.js +++ b/notebook/static/notebook/js/actions.js @@ -310,30 +310,20 @@ define(function(require){ help : 'toggle output of selected cells', help_index : 'gb', handler : function (env) { - var indices = env.notebook.get_selected_cells_indices(); - console.log(indices) - for(var i =0; i< indices.length; i++){ - env.notebook.toggle_output(indices[i]); - } + env.notebook.toggle_cells_outputs(); } }, 'toggle-cell-output-scrolled' : { help : 'toggle output scrolling of selected cells', help_index : 'gc', handler : function (env) { - var indices = env.notebook.get_selected_cells_indices(); - for(var i =0; i< indices.length; i++){ - env.notebook.toggle_output_scroll(indices[i]); - } + env.notebook.toggle_cells_outputs_scroll(); } }, 'clear-cell-output' : { help : 'clear output of selected cells', handler : function (env) { - var indices = env.notebook.get_selected_cells_indices(); - for(var i =0; i< indices.length; i++){ - env.notebook.clear_output(indices[i]); - } + env.notebook.clear_cells_outputs(); } }, 'move-cell-down' : { diff --git a/notebook/static/notebook/js/notebook.js b/notebook/static/notebook/js/notebook.js index 14c8b42aa..d4fb425d8 100644 --- a/notebook/static/notebook/js/notebook.js +++ b/notebook/static/notebook/js/notebook.js @@ -1600,6 +1600,20 @@ define(function (require) { } }; + /** + * Clear multiple selected CodeCells' output areas. + * + */ + Notebook.prototype.clear_cells_outputs = function(indices) { + if (!indices) { + var indices = this.get_selected_cells_indices(); + } + + for (var i = 0; i < indices.length; i++){ + this.clear_output(indices[i]); + } + } + /** * Clear each code cell's output area. */ @@ -1653,6 +1667,21 @@ define(function (require) { } }; + /** + * Toggle whether all selected cells' outputs are collapsed or expanded. + * + * @param {integer} indices - the indices of the cells to toggle + */ + Notebook.prototype.toggle_cells_outputs = function(indices) { + if (!indices) { + var indices = this.get_selected_cells_indices(); + } + + for (var i = 0; i < indices.length; i++){ + this.toggle_output(indices[i]); + } + } + /** * Toggle the output of all cells. */ @@ -1680,6 +1709,21 @@ define(function (require) { } }; + /** + * Toggle a scrollbar for selected long cells' outputs. + * + * @param {integer} indices - the indices of the cells to toggle + */ + Notebook.prototype.toggle_cells_outputs_scroll = function(indices) { + if (!indices) { + var indices = this.get_selected_cells_indices(); + } + + for (var i = 0; i < indices.length; i++){ + this.toggle_output_scroll(indices[i]); + } + } + /** * Toggle the scrolling of long output on all cells. */