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