Merge pull request #3314 from Shels1909/1097-close-halt

#1097 Add close and halt to shortcut menu
This commit is contained in:
Thomas Kluyver 2018-02-08 11:26:22 +00:00 committed by GitHub
commit e3981568b8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 27 additions and 15 deletions

View File

@ -694,6 +694,13 @@ define([
// Execute a CM command // Execute a CM command
selected_cell.code_mirror.execCommand('indentAuto'); 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();
}
} }
}; };

View File

@ -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 // View
this._add_celltoolbar_list(); this._add_celltoolbar_list();
@ -252,7 +240,7 @@ define([
notebook: that.notebook, notebook: that.notebook,
keyboard_manager: that.notebook.keyboard_manager}); keyboard_manager: that.notebook.keyboard_manager});
}); });
var id_actions_dict = { var id_actions_dict = {
'#trust_notebook' : 'trust-notebook', '#trust_notebook' : 'trust-notebook',
'#rename_notebook' : 'rename-notebook', '#rename_notebook' : 'rename-notebook',
@ -262,6 +250,7 @@ define([
'#restart_kernel': 'confirm-restart-kernel', '#restart_kernel': 'confirm-restart-kernel',
'#restart_clear_output': 'confirm-restart-kernel-and-clear-output', '#restart_clear_output': 'confirm-restart-kernel-and-clear-output',
'#restart_run_all': 'confirm-restart-kernel-and-run-all-cells', '#restart_run_all': 'confirm-restart-kernel-and-run-all-cells',
'#close_and_halt': 'close-and-halt',
'#int_kernel': 'interrupt-kernel', '#int_kernel': 'interrupt-kernel',
'#cut_cell': 'cut-cell', '#cut_cell': 'cut-cell',
'#copy_cell': 'copy-cell', '#copy_cell': 'copy-cell',

View File

@ -2399,6 +2399,22 @@ define([
return promise; 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. * Execute cells corresponding to the given indices.
* *

View File

@ -124,7 +124,7 @@ data-notebook-path="{{notebook_path | urlencode}}"
title="{% trans %}Trust the output of this notebook{% endtrans %}"> title="{% trans %}Trust the output of this notebook{% endtrans %}">
<a href="#" >{% trans %}Trust Notebook{% endtrans %}</a></li> <a href="#" >{% trans %}Trust Notebook{% endtrans %}</a></li>
<li class="divider"></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 %}"> title="{% trans %}Shutdown this notebook's kernel, and close this window{% endtrans %}">
<a href="#" >{% trans %}Close and Halt{% endtrans %}</a></li> <a href="#" >{% trans %}Close and Halt{% endtrans %}</a></li>
</ul> </ul>

View File

@ -25,7 +25,7 @@ casper.notebook_test(function () {
this.waitForPopup(''); this.waitForPopup('');
this.withPopup('', function () { this.withPopup('', function () {
this.thenEvaluate(function () { this.thenEvaluate(function () {
$('#kill_and_exit').click(); $('#close_and_halt').click();
}); });
this.thenEvaluate(function () { this.thenEvaluate(function () {