##// END OF EJS Templates
Removing extra call to Kernel.stop_channels.
Brian Granger -
Show More
@@ -1,124 +1,123
1 //----------------------------------------------------------------------------
1 //----------------------------------------------------------------------------
2 // Copyright (C) 2008-2011 The IPython Development Team
2 // Copyright (C) 2008-2011 The IPython Development Team
3 //
3 //
4 // Distributed under the terms of the BSD License. The full license is in
4 // Distributed under the terms of the BSD License. The full license is in
5 // the file COPYING, distributed as part of this software.
5 // the file COPYING, distributed as part of this software.
6 //----------------------------------------------------------------------------
6 //----------------------------------------------------------------------------
7
7
8 //============================================================================
8 //============================================================================
9 // Notification widget
9 // Notification widget
10 //============================================================================
10 //============================================================================
11
11
12 var IPython = (function (IPython) {
12 var IPython = (function (IPython) {
13
13
14 var utils = IPython.utils;
14 var utils = IPython.utils;
15
15
16
16
17 var NotificationWidget = function (selector) {
17 var NotificationWidget = function (selector) {
18 this.selector = selector;
18 this.selector = selector;
19 this.timeout = null;
19 this.timeout = null;
20 this.busy = false;
20 this.busy = false;
21 if (this.selector !== undefined) {
21 if (this.selector !== undefined) {
22 this.element = $(selector);
22 this.element = $(selector);
23 this.style();
23 this.style();
24 this.bind_events();
24 this.bind_events();
25 }
25 }
26 };
26 };
27
27
28
28
29 NotificationWidget.prototype.style = function () {
29 NotificationWidget.prototype.style = function () {
30 this.element.addClass('ui-widget ui-widget-content ui-corner-all');
30 this.element.addClass('ui-widget ui-widget-content ui-corner-all');
31 this.element.addClass('border-box-sizing');
31 this.element.addClass('border-box-sizing');
32 };
32 };
33
33
34
34
35 NotificationWidget.prototype.bind_events = function () {
35 NotificationWidget.prototype.bind_events = function () {
36 var that = this;
36 var that = this;
37 // Kernel events
37 // Kernel events
38 $([IPython.events]).on('status_idle.Kernel',function () {
38 $([IPython.events]).on('status_idle.Kernel',function () {
39 IPython.save_widget.update_document_title();
39 IPython.save_widget.update_document_title();
40 if (that.get_message() === 'Kernel busy') {
40 if (that.get_message() === 'Kernel busy') {
41 that.element.fadeOut(100, function () {
41 that.element.fadeOut(100, function () {
42 that.element.html('');
42 that.element.html('');
43 });
43 });
44 };
44 };
45 });
45 });
46 $([IPython.events]).on('status_busy.Kernel',function () {
46 $([IPython.events]).on('status_busy.Kernel',function () {
47 window.document.title='(Busy) '+window.document.title;
47 window.document.title='(Busy) '+window.document.title;
48 that.set_message("Kernel busy");
48 that.set_message("Kernel busy");
49 });
49 });
50 $([IPython.events]).on('status_restarting.Kernel',function () {
50 $([IPython.events]).on('status_restarting.Kernel',function () {
51 IPython.save_widget.update_document_title();
51 IPython.save_widget.update_document_title();
52 that.set_message("Restarting kernel",500);
52 that.set_message("Restarting kernel",500);
53 });
53 });
54 $([IPython.events]).on('status_interrupting.Kernel',function () {
54 $([IPython.events]).on('status_interrupting.Kernel',function () {
55 that.set_message("Interrupting kernel",500);
55 that.set_message("Interrupting kernel",500);
56 });
56 });
57 $([IPython.events]).on('status_dead.Kernel',function () {
57 $([IPython.events]).on('status_dead.Kernel',function () {
58 IPython.notebook.kernel.stop_channels();
59 var dialog = $('<div/>');
58 var dialog = $('<div/>');
60 dialog.html('The kernel has died, would you like to restart it? If you do not restart the kernel, you will be able to save the notebook, but running code will not work until the notebook is reopened.');
59 dialog.html('The kernel has died, would you like to restart it? If you do not restart the kernel, you will be able to save the notebook, but running code will not work until the notebook is reopened.');
61 $(document).append(dialog);
60 $(document).append(dialog);
62 dialog.dialog({
61 dialog.dialog({
63 resizable: false,
62 resizable: false,
64 modal: true,
63 modal: true,
65 title: "Dead kernel",
64 title: "Dead kernel",
66 buttons : {
65 buttons : {
67 "Restart": function () {
66 "Restart": function () {
68 $([IPython.events]).trigger('status_restarting.Kernel');
67 $([IPython.events]).trigger('status_restarting.Kernel');
69 IPython.notebook.start_kernel();
68 IPython.notebook.start_kernel();
70 $(this).dialog('close');
69 $(this).dialog('close');
71 },
70 },
72 "Continue running": function () {
71 "Continue running": function () {
73 $(this).dialog('close');
72 $(this).dialog('close');
74 }
73 }
75 }
74 }
76 });
75 });
77 });
76 });
78 // Notebook events
77 // Notebook events
79 $([IPython.events]).on('notebook_loading.Notebook', function () {
78 $([IPython.events]).on('notebook_loading.Notebook', function () {
80 that.set_message("Loading notebook",500);
79 that.set_message("Loading notebook",500);
81 });
80 });
82 $([IPython.events]).on('notebook_loaded.Notebook', function () {
81 $([IPython.events]).on('notebook_loaded.Notebook', function () {
83 that.set_message("Notebook loaded",500);
82 that.set_message("Notebook loaded",500);
84 });
83 });
85 $([IPython.events]).on('notebook_saving.Notebook', function () {
84 $([IPython.events]).on('notebook_saving.Notebook', function () {
86 that.set_message("Saving notebook",500);
85 that.set_message("Saving notebook",500);
87 });
86 });
88 $([IPython.events]).on('notebook_saved.Notebook', function () {
87 $([IPython.events]).on('notebook_saved.Notebook', function () {
89 that.set_message("Notebook saved",500);
88 that.set_message("Notebook saved",500);
90 });
89 });
91 $([IPython.events]).on('notebook_save_failed.Notebook', function () {
90 $([IPython.events]).on('notebook_save_failed.Notebook', function () {
92 that.set_message("Notebook save failed",500);
91 that.set_message("Notebook save failed",500);
93 });
92 });
94 };
93 };
95
94
96
95
97 NotificationWidget.prototype.set_message = function (msg, timeout) {
96 NotificationWidget.prototype.set_message = function (msg, timeout) {
98 var that = this;
97 var that = this;
99 this.element.html(msg);
98 this.element.html(msg);
100 this.element.fadeIn(100);
99 this.element.fadeIn(100);
101 if (this.timeout !== null) {
100 if (this.timeout !== null) {
102 clearTimeout(this.timeout);
101 clearTimeout(this.timeout);
103 this.timeout = null;
102 this.timeout = null;
104 };
103 };
105 if (timeout !== undefined) {
104 if (timeout !== undefined) {
106 this.timeout = setTimeout(function () {
105 this.timeout = setTimeout(function () {
107 that.element.fadeOut(100, function () {that.element.html('');});
106 that.element.fadeOut(100, function () {that.element.html('');});
108 that.timeout = null;
107 that.timeout = null;
109 }, timeout)
108 }, timeout)
110 };
109 };
111 };
110 };
112
111
113
112
114 NotificationWidget.prototype.get_message = function () {
113 NotificationWidget.prototype.get_message = function () {
115 return this.element.html();
114 return this.element.html();
116 };
115 };
117
116
118
117
119 IPython.NotificationWidget = NotificationWidget;
118 IPython.NotificationWidget = NotificationWidget;
120
119
121 return IPython;
120 return IPython;
122
121
123 }(IPython));
122 }(IPython));
124
123
General Comments 0
You need to be logged in to leave comments. Login now