Make kernel dialogs be a special type of dialog

This commit is contained in:
Jessica B. Hamrick 2014-10-06 11:43:56 -07:00
parent 8f28134a89
commit 40ebe5d816
2 changed files with 14 additions and 14 deletions

View File

@ -90,6 +90,15 @@ define([
return modal.modal(options);
};
var kernel_modal = function (options) {
// only one kernel dialog should be open at a time -- but
// other modal dialogs can still be open
$('.kernel-modal').modal('hide');
var dialog = modal(options);
dialog.addClass('kernel-modal');
return dialog;
};
var edit_metadata = function (options) {
options.name = options.name || "Cell";
var error_div = $('<div/>').css('color', 'red');
@ -153,6 +162,7 @@ define([
var dialog = {
modal : modal,
kernel_modal : kernel_modal,
edit_metadata : edit_metadata,
};

View File

@ -149,10 +149,7 @@ define([
// times it tries restarting).
if (info.attempt === 1) {
// hide existing modal dialog
$(".modal").modal('hide');
dialog.modal({
dialog.kernel_modal({
notebook: that.notebook,
keyboard_manager: that.keyboard_manager,
title: "Kernel Restarting",
@ -186,15 +183,13 @@ define([
// trying to reconnect and we don't want to spam the user
// with messages
if (info.attempt === 1) {
// hide existing dialog
$(".modal").modal('hide');
var msg = "A connection to the notebook server could not be established." +
" The notebook will continue trying to reconnect, but" +
" until it does, you will NOT be able to run code. Check your" +
" network connection or notebook server configuration.";
dialog.modal({
dialog.kernel_modal({
title: "Connection failed",
body: msg,
keyboard_manager: that.keyboard_manager,
@ -215,8 +210,6 @@ define([
this.events.on('kernel_dead.Kernel', function () {
var showMsg = function () {
// hide existing dialog
$(".modal").modal('hide');
var msg = 'The kernel has died, and the automatic restart has failed.' +
' It is possible the kernel cannot be restarted.' +
@ -224,7 +217,7 @@ define([
' the notebook, but running code will no longer work until the notebook' +
' is reopened.';
dialog.modal({
dialog.kernel_modal({
title: "Dead kernel",
body : msg,
keyboard_manager: that.keyboard_manager,
@ -273,10 +266,7 @@ define([
cm_open = $.proxy(cm.refresh, cm);
}
// hide existing modal dialog
$(".modal").modal('hide');
dialog.modal({
dialog.kernel_modal({
title: "Failed to start the kernel",
body : msg,
keyboard_manager: that.keyboard_manager,