mirror of
https://github.com/jupyter/notebook.git
synced 2025-01-12 11:45:38 +08:00
Merge pull request #3314 from Shels1909/1097-close-halt
#1097 Add close and halt to shortcut menu
This commit is contained in:
commit
e3981568b8
@ -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();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -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();
|
||||
|
||||
@ -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',
|
||||
@ -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',
|
||||
|
@ -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.
|
||||
*
|
||||
|
@ -124,7 +124,7 @@ data-notebook-path="{{notebook_path | urlencode}}"
|
||||
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>
|
||||
|
@ -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 () {
|
||||
|
Loading…
Reference in New Issue
Block a user