Added close and halt to the action menu and exposed function

This commit is contained in:
Mac Knight 2018-02-07 11:20:26 -05:00
parent e250b0b7bf
commit 6162ca9570
3 changed files with 26 additions and 11 deletions

View File

@ -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();
}
}
};

View File

@ -232,15 +232,7 @@ 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);
that.notebook.close_and_halt();
});
// View
@ -252,7 +244,7 @@ define([
notebook: that.notebook,
keyboard_manager: that.notebook.keyboard_manager});
});
var id_actions_dict = {
'#trust_notebook' : 'trust-notebook',
'#rename_notebook' : 'rename-notebook',

View File

@ -2392,13 +2392,29 @@ define([
button.click = function () {
promise.then(click);
do_kernel_action();
};
}
});
options.dialog.buttons = buttons;
dialog.modal(options.dialog);
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.
*