mirror of
https://github.com/jupyter/notebook.git
synced 2025-02-05 12:19:58 +08:00
Merge pull request #2527 from ivanov/run-fine-grained
Notebook, add Run All Above and Run All Below action in Menu
This commit is contained in:
commit
095d8c85d0
@ -128,7 +128,13 @@ var IPython = (function (IPython) {
|
||||
});
|
||||
this.element.find('#run_all_cells').click(function () {
|
||||
IPython.notebook.execute_all_cells();
|
||||
});
|
||||
}).attr('title', 'Run all cells in the notebook');
|
||||
this.element.find('#run_all_cells_above').click(function () {
|
||||
IPython.notebook.execute_cells_above();
|
||||
}).attr('title', 'Run all cells above (but not including) this cell');
|
||||
this.element.find('#run_all_cells_below').click(function () {
|
||||
IPython.notebook.execute_cells_below();
|
||||
}).attr('title', 'Run this cell and all cells below it');
|
||||
this.element.find('#to_code').click(function () {
|
||||
IPython.notebook.to_code();
|
||||
});
|
||||
|
@ -1049,13 +1049,25 @@ var IPython = (function (IPython) {
|
||||
};
|
||||
|
||||
|
||||
Notebook.prototype.execute_cells_below = function () {
|
||||
this.execute_cell_range(this.get_selected_index(), this.ncells());
|
||||
that.scroll_to_bottom();
|
||||
};
|
||||
|
||||
Notebook.prototype.execute_cells_above = function () {
|
||||
this.execute_cell_range(0, this.get_selected_index());
|
||||
};
|
||||
|
||||
Notebook.prototype.execute_all_cells = function () {
|
||||
var ncells = this.ncells();
|
||||
for (var i=0; i<ncells; i++) {
|
||||
this.execute_cell_range(0, this.ncells());
|
||||
that.scroll_to_bottom();
|
||||
};
|
||||
|
||||
Notebook.prototype.execute_cell_range = function (start, end) {
|
||||
for (var i=start; i<end; i++) {
|
||||
this.select(i);
|
||||
this.execute_selected_cell({add_new:false});
|
||||
};
|
||||
this.scroll_to_bottom();
|
||||
};
|
||||
|
||||
// Persistance and loading
|
||||
|
@ -108,6 +108,8 @@ data-notebook-id={{notebook_id}}
|
||||
<li id="run_cell"><a href="#">Run</a></li>
|
||||
<li id="run_cell_in_place"><a href="#">Run in Place</a></li>
|
||||
<li id="run_all_cells"><a href="#">Run All</a></li>
|
||||
<li id="run_all_cells_above"><a href="#">Run All Above</a></li>
|
||||
<li id="run_all_cells_below"><a href="#">Run All Below</a></li>
|
||||
<hr/>
|
||||
<li id="to_code"><a href="#">Code</a></li>
|
||||
<li id="to_markdown"><a href="#">Markdown </a></li>
|
||||
|
Loading…
Reference in New Issue
Block a user