Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Menu cleanup #4662

Merged
merged 8 commits into from Jan 30, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 11 additions & 6 deletions IPython/html/static/notebook/js/codecell.js
Expand Up @@ -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();
};


Expand Down Expand Up @@ -510,6 +514,7 @@ var IPython = (function (IPython) {

CodeCell.prototype.clear_output = function (wait) {
this.output_area.clear_output(wait);
this.set_input_prompt();
};


Expand All @@ -533,9 +538,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();
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion IPython/html/static/notebook/js/keyboardmanager.js
Expand Up @@ -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();
Expand Down
8 changes: 8 additions & 0 deletions IPython/html/static/notebook/js/maintoolbar.js
Expand Up @@ -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');
};
Expand Down
26 changes: 13 additions & 13 deletions IPython/html/static/notebook/js/menubar.js
Expand Up @@ -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();
});
Expand Down Expand Up @@ -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();
Expand Down
173 changes: 116 additions & 57 deletions IPython/html/static/notebook/js/notebook.js
Expand Up @@ -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<ncells; i++) {
if (cells[i] instanceof IPython.CodeCell) {
cells[i].output_area.collapse();
Notebook.prototype.clear_all_output = function () {
$.map(this.get_cells(), function (cell, i) {
if (cell instanceof IPython.CodeCell) {
cell.clear_output();
}
};
// this should not be set if the `collapse` key is removed from nbformat
});
this.set_dirty(true);
};

/**
* Scroll the selected CodeCell's output area.
*
* @method scroll_output
* @param {Number} index A cell's numeric index
*/
Notebook.prototype.scroll_output = function (index) {
var i = this.index_or_selected(index);
var cell = this.get_cell(i);
if (cell !== null && (cell instanceof IPython.CodeCell)) {
cell.scroll_output();
this.set_dirty(true);
}
};

/**
* Expand each code cell's output area, and add a scrollbar for long output.
*
* @method scroll_all_output
*/
Notebook.prototype.scroll_all_output = function () {
var ncells = this.ncells();
var cells = this.get_cells();
for (var i=0; i<ncells; i++) {
if (cells[i] instanceof IPython.CodeCell) {
cells[i].output_area.expand();
cells[i].output_area.scroll_if_long();
$.map(this.get_cells(), function (cell, i) {
if (cell instanceof IPython.CodeCell) {
cell.scroll_output();
}
};
});
// this should not be set if the `collapse` key is removed from nbformat
this.set_dirty(true);
};

/** Toggle whether a cell's output is collapsed or expanded.
*
* @method toggle_output
* @param {Number} index A cell's numeric index
*/
Notebook.prototype.toggle_output = function (index) {
var i = this.index_or_selected(index);
var cell = this.get_cell(i);
if (cell !== null && (cell instanceof IPython.CodeCell)) {
cell.toggle_output();
this.set_dirty(true);
}
};

/**
* Expand each code cell's output area, and remove scrollbars.
* Hide/show the output of all cells.
*
* @method expand_all_output
* @method toggle_all_output
*/
Notebook.prototype.expand_all_output = function () {
var ncells = this.ncells();
var cells = this.get_cells();
for (var i=0; i<ncells; i++) {
if (cells[i] instanceof IPython.CodeCell) {
cells[i].output_area.expand();
cells[i].output_area.unscroll_area();
Notebook.prototype.toggle_all_output = function () {
$.map(this.get_cells(), function (cell, i) {
if (cell instanceof IPython.CodeCell) {
cell.toggle_output();
}
};
});
// this should not be set if the `collapse` key is removed from nbformat
this.set_dirty(true);
};

/**
* Clear each code cell's output area.
* Toggle a scrollbar for long cell outputs.
*
* @method clear_all_output
* @method toggle_output_scroll
* @param {Number} index A cell's numeric index
*/
Notebook.prototype.clear_all_output = function () {
var ncells = this.ncells();
var cells = this.get_cells();
for (var i=0; i<ncells; i++) {
if (cells[i] instanceof IPython.CodeCell) {
cells[i].clear_output();
// Make all In[] prompts blank, as well
// TODO: make this configurable (via checkbox?)
cells[i].set_input_prompt();
Notebook.prototype.toggle_output_scroll = function (index) {
var i = this.index_or_selected(index);
var cell = this.get_cell(i);
if (cell !== null && (cell instanceof IPython.CodeCell)) {
cell.toggle_output_scroll();
this.set_dirty(true);
}
};

/**
* Toggle the scrolling of long output on all cells.
*
* @method toggle_all_output_scrolling
*/
Notebook.prototype.toggle_all_output_scroll = function () {
$.map(this.get_cells(), function (cell, i) {
if (cell instanceof IPython.CodeCell) {
cell.toggle_output_scroll();
}
};
});
// this should not be set if the `collapse` key is removed from nbformat
this.set_dirty(true);
};


// Other cell functions: line numbers, ...

/**
Expand Down