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

#1097 Add close and halt to shortcut menu #3314

Merged
merged 4 commits into from Feb 8, 2018
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
7 changes: 7 additions & 0 deletions notebook/static/notebook/js/actions.js
Expand Up @@ -694,6 +694,13 @@ define([
// Execute a CM command
selected_cell.code_mirror.execCommand('indentAuto');
}
},
'close-and-halt': {
cmd: i18n.msg._('shutdown kernel and close window'),
help : i18n.msg._('shutdown kernel and close window'),
handler : function(env) {
env.notebook.close_and_halt();
}
}
};

Expand Down
15 changes: 2 additions & 13 deletions notebook/static/notebook/js/menubar.js
Expand Up @@ -231,18 +231,6 @@ define([
}
});

this.element.find('#kill_and_exit').click(function () {
var close_window = function () {
/**
* allow closing of new tabs in Chromium, impossible in FF
*/
window.open('', '_self', '');
window.close();
};
// finish with close on success or failure
that.notebook.session.delete(close_window, close_window);
});

// View
this._add_celltoolbar_list();

Expand All @@ -252,7 +240,7 @@ define([
notebook: that.notebook,
keyboard_manager: that.notebook.keyboard_manager});
});

var id_actions_dict = {
'#trust_notebook' : 'trust-notebook',
'#rename_notebook' : 'rename-notebook',
Expand All @@ -262,6 +250,7 @@ define([
'#restart_kernel': 'confirm-restart-kernel',
'#restart_clear_output': 'confirm-restart-kernel-and-clear-output',
'#restart_run_all': 'confirm-restart-kernel-and-run-all-cells',
'#close_and_halt': 'close-and-halt',
'#int_kernel': 'interrupt-kernel',
'#cut_cell': 'cut-cell',
'#copy_cell': 'copy-cell',
Expand Down
16 changes: 16 additions & 0 deletions notebook/static/notebook/js/notebook.js
Expand Up @@ -2399,6 +2399,22 @@ define([
return promise;
};

/**
*
* Halt the kernel and close the notebook window
*/
Notebook.prototype.close_and_halt = function () {
var close_window = function () {
/**
* allow closing of new tabs in Chromium, impossible in FF
*/
window.open('', '_self', '');
window.close();
};
// finish with close on success or failure
this.session.delete(close_window, close_window);
};

/**
* Execute cells corresponding to the given indices.
*
Expand Down
2 changes: 1 addition & 1 deletion notebook/templates/notebook.html
Expand Up @@ -124,7 +124,7 @@
title="{% trans %}Trust the output of this notebook{% endtrans %}">
<a href="#" >{% trans %}Trust Notebook{% endtrans %}</a></li>
<li class="divider"></li>
<li id="kill_and_exit"
<li id="close_and_halt"
title="{% trans %}Shutdown this notebook's kernel, and close this window{% endtrans %}">
<a href="#" >{% trans %}Close and Halt{% endtrans %}</a></li>
</ul>
Expand Down
2 changes: 1 addition & 1 deletion notebook/tests/notebook/shutdown.js
Expand Up @@ -25,7 +25,7 @@ casper.notebook_test(function () {
this.waitForPopup('');
this.withPopup('', function () {
this.thenEvaluate(function () {
$('#kill_and_exit').click();
$('#close_and_halt').click();
});

this.thenEvaluate(function () {
Expand Down