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); 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) { var edit_metadata = function (options) {
options.name = options.name || "Cell"; options.name = options.name || "Cell";
var error_div = $('<div/>').css('color', 'red'); var error_div = $('<div/>').css('color', 'red');
@ -153,6 +162,7 @@ define([
var dialog = { var dialog = {
modal : modal, modal : modal,
kernel_modal : kernel_modal,
edit_metadata : edit_metadata, edit_metadata : edit_metadata,
}; };

View File

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