Show More
@@ -61,7 +61,7 b' span#notebook_name {' | |||||
61 | z-index: 10; |
|
61 | z-index: 10; | |
62 | } |
|
62 | } | |
63 |
|
63 | |||
64 | .notification{ |
|
64 | .notification_widget{ | |
65 | float : right; |
|
65 | float : right; | |
66 | right: 0px; |
|
66 | right: 0px; | |
67 | top: 1px; |
|
67 | top: 1px; |
@@ -99,7 +99,7 b' var IPython = (function (IPython) {' | |||||
99 | " or if the url does not look right, there could be an error in the" + |
|
99 | " or if the url does not look right, there could be an error in the" + | |
100 | " server's configuration."; |
|
100 | " server's configuration."; | |
101 | } else { |
|
101 | } else { | |
102 | IPython.notification_widget.set_message('Reconnecting Websockets', 1000); |
|
102 | IPython.notification_area.widget('kernel').set_message('Reconnecting Websockets', 1000); | |
103 | this.start_channels(); |
|
103 | this.start_channels(); | |
104 | return; |
|
104 | return; | |
105 | } |
|
105 | } |
@@ -32,7 +32,7 b' $(document).ready(function () {' | |||||
32 | IPython.toolbar = new IPython.ToolBar('#toolbar') |
|
32 | IPython.toolbar = new IPython.ToolBar('#toolbar') | |
33 | IPython.tooltip = new IPython.Tooltip() |
|
33 | IPython.tooltip = new IPython.Tooltip() | |
34 | IPython.notification_area = new IPython.NotificationArea('#notification_area') |
|
34 | IPython.notification_area = new IPython.NotificationArea('#notification_area') | |
35 |
IPython. |
|
35 | IPython.notification_area.init_notification_widgets(); | |
36 |
|
36 | |||
37 | IPython.layout_manager.do_resize(); |
|
37 | IPython.layout_manager.do_resize(); | |
38 |
|
38 |
@@ -19,6 +19,7 b' var IPython = (function (IPython) {' | |||||
19 | if (this.selector !== undefined) { |
|
19 | if (this.selector !== undefined) { | |
20 | this.element = $(selector); |
|
20 | this.element = $(selector); | |
21 | } |
|
21 | } | |
|
22 | this.widget_dict = {}; | |||
22 | }; |
|
23 | }; | |
23 |
|
24 | |||
24 | NotificationArea.prototype.temp_message = function (msg, timeout, css_class) { |
|
25 | NotificationArea.prototype.temp_message = function (msg, timeout, css_class) { | |
@@ -27,7 +28,7 b' var IPython = (function (IPython) {' | |||||
27 | if( css_class == 'warning'){css_class = 'ui-state-highlight'} |
|
28 | if( css_class == 'warning'){css_class = 'ui-state-highlight'} | |
28 | var tdiv = $('<div>') |
|
29 | var tdiv = $('<div>') | |
29 | .attr('id',uuid) |
|
30 | .attr('id',uuid) | |
30 | .addClass('notification ui-widget ui-widget-content ui-corner-all') |
|
31 | .addClass('notification_widget ui-widget ui-widget-content ui-corner-all') | |
31 | .addClass('border-box-sizing') |
|
32 | .addClass('border-box-sizing') | |
32 | .addClass(css_class) |
|
33 | .addClass(css_class) | |
33 | .hide() |
|
34 | .hide() | |
@@ -42,10 +43,94 b' var IPython = (function (IPython) {' | |||||
42 | }, tmout) |
|
43 | }, tmout) | |
43 | }; |
|
44 | }; | |
44 |
|
45 | |||
|
46 | NotificationArea.prototype.widget = function(name){ | |||
|
47 | if(this.widget_dict[name] == undefined){ | |||
|
48 | return this.new_notification_widget(name) | |||
|
49 | } | |||
|
50 | return this.get_widget(name) | |||
|
51 | } | |||
|
52 | ||||
|
53 | NotificationArea.prototype.get_widget = function(name) { | |||
|
54 | if(this.widget_dict[name] == undefined){ | |||
|
55 | throw('no widgets with this name'); | |||
|
56 | } | |||
|
57 | return this.widget_dict[name]; | |||
|
58 | } | |||
|
59 | ||||
45 | NotificationArea.prototype.new_notification_widget = function(name) { |
|
60 | NotificationArea.prototype.new_notification_widget = function(name) { | |
|
61 | if(this.widget_dict[name] != undefined){ | |||
|
62 | throw('widget with that name already exists ! '); | |||
|
63 | } | |||
46 | var div = $('<div/>').attr('id','notification_'+name); |
|
64 | var div = $('<div/>').attr('id','notification_'+name); | |
47 | $(this.selector).append(div) |
|
65 | $(this.selector).append(div) | |
48 |
|
|
66 | this.widget_dict[name] = new IPython.NotificationWidget('#notification_'+name) | |
|
67 | return this.widget_dict[name]; | |||
|
68 | } | |||
|
69 | ||||
|
70 | NotificationArea.prototype.init_notification_widgets = function() { | |||
|
71 | var knw = this.new_notification_widget('kernel'); | |||
|
72 | ||||
|
73 | // Kernel events | |||
|
74 | $([IPython.events]).on('status_idle.Kernel',function () { | |||
|
75 | IPython.save_widget.update_document_title(); | |||
|
76 | knw.set_message('Kernel Idle',200); | |||
|
77 | } | |||
|
78 | ); | |||
|
79 | ||||
|
80 | $([IPython.events]).on('status_busy.Kernel',function () { | |||
|
81 | window.document.title='(Busy) '+window.document.title; | |||
|
82 | knw.set_message("Kernel busy"); | |||
|
83 | }); | |||
|
84 | ||||
|
85 | $([IPython.events]).on('status_restarting.Kernel',function () { | |||
|
86 | IPython.save_widget.update_document_title(); | |||
|
87 | knw.set_message("Restarting kernel",1000); | |||
|
88 | }); | |||
|
89 | ||||
|
90 | $([IPython.events]).on('status_interrupting.Kernel',function () { | |||
|
91 | knw.set_message("Interrupting kernel"); | |||
|
92 | }); | |||
|
93 | ||||
|
94 | $([IPython.events]).on('status_dead.Kernel',function () { | |||
|
95 | var dialog = $('<div/>'); | |||
|
96 | 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.'); | |||
|
97 | $(document).append(dialog); | |||
|
98 | dialog.dialog({ | |||
|
99 | resizable: false, | |||
|
100 | modal: true, | |||
|
101 | title: "Dead kernel", | |||
|
102 | buttons : { | |||
|
103 | "Restart": function () { | |||
|
104 | $([IPython.events]).trigger('status_restarting.Kernel'); | |||
|
105 | IPython.notebook.start_kernel(); | |||
|
106 | $(this).dialog('close'); | |||
|
107 | }, | |||
|
108 | "Continue running": function () { | |||
|
109 | $(this).dialog('close'); | |||
|
110 | } | |||
|
111 | } | |||
|
112 | }); | |||
|
113 | }); | |||
|
114 | ||||
|
115 | var nnw = this.new_notification_widget('notebook'); | |||
|
116 | ||||
|
117 | // Notebook events | |||
|
118 | $([IPython.events]).on('notebook_loading.Notebook', function () { | |||
|
119 | nnw.set_message("Loading notebook",500); | |||
|
120 | }); | |||
|
121 | $([IPython.events]).on('notebook_loaded.Notebook', function () { | |||
|
122 | nnw.set_message("Notebook loaded",500); | |||
|
123 | }); | |||
|
124 | $([IPython.events]).on('notebook_saving.Notebook', function () { | |||
|
125 | nnw.set_message("Saving notebook",500); | |||
|
126 | }); | |||
|
127 | $([IPython.events]).on('notebook_saved.Notebook', function () { | |||
|
128 | nnw.set_message("Notebook saved",2000); | |||
|
129 | }); | |||
|
130 | $([IPython.events]).on('notebook_save_failed.Notebook', function () { | |||
|
131 | nnw.set_message("Notebook save failed"); | |||
|
132 | }); | |||
|
133 | ||||
49 | } |
|
134 | } | |
50 |
|
135 | |||
51 | IPython.NotificationArea = NotificationArea; |
|
136 | IPython.NotificationArea = NotificationArea; |
@@ -21,28 +21,27 b' var IPython = (function (IPython) {' | |||||
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(); |
|
|||
25 | } |
|
24 | } | |
26 | this.element.button(); |
|
25 | this.element.button(); | |
27 | this.element.hide(); |
|
26 | this.element.hide(); | |
28 | var that = this; |
|
27 | var that = this; | |
29 | this.element.click(function(){ |
|
28 | ||
30 | that.element.fadeOut(100, function () {that.element.html('');}); |
|
|||
31 | if (that.timeout !== undefined) { |
|
|||
32 | that.timeout = undefined |
|
|||
33 | clearTimeout(that.timeout); |
|
|||
34 | } |
|
|||
35 | }); |
|
|||
36 | }; |
|
29 | }; | |
37 |
|
30 | |||
38 |
|
31 | |||
39 | NotificationWidget.prototype.style = function () { |
|
32 | NotificationWidget.prototype.style = function () { | |
40 | this.element.addClass('notification ui-widget ui-widget-content ui-corner-all'); |
|
33 | this.element.addClass('notification_widget ui-widget ui-widget-content ui-corner-all'); | |
41 | this.element.addClass('border-box-sizing'); |
|
34 | this.element.addClass('border-box-sizing'); | |
42 | }; |
|
35 | }; | |
43 |
|
36 | |||
44 |
|
37 | // msg : message to display | ||
45 | NotificationWidget.prototype.set_message = function (msg, timeout) { |
|
38 | // timeout : time in ms before diseapearing | |
|
39 | // | |||
|
40 | // if timeout <= 0 | |||
|
41 | // click_callback : function called if user click on notification | |||
|
42 | // could return false to prevent the notification to be dismissed | |||
|
43 | NotificationWidget.prototype.set_message = function (msg, timeout, click_callback) { | |||
|
44 | var callback = click_callback || function(){return false}; | |||
46 | var that = this; |
|
45 | var that = this; | |
47 | this.element.html(msg); |
|
46 | this.element.html(msg); | |
48 | this.element.fadeIn(100); |
|
47 | this.element.fadeIn(100); | |
@@ -55,7 +54,18 b' var IPython = (function (IPython) {' | |||||
55 | that.element.fadeOut(100, function () {that.element.html('');}); |
|
54 | that.element.fadeOut(100, function () {that.element.html('');}); | |
56 | that.timeout = null; |
|
55 | that.timeout = null; | |
57 | }, timeout); |
|
56 | }, timeout); | |
58 |
} |
|
57 | } else { | |
|
58 | this.element.click(function(){ | |||
|
59 | if( callback() != false){ | |||
|
60 | that.element.fadeOut(100, function () {that.element.html('');}); | |||
|
61 | } | |||
|
62 | if (that.timeout !== undefined) { | |||
|
63 | that.timeout = undefined | |||
|
64 | clearTimeout(that.timeout); | |||
|
65 | } | |||
|
66 | that.element.unbind('click') | |||
|
67 | }); | |||
|
68 | } | |||
59 | }; |
|
69 | }; | |
60 |
|
70 | |||
61 |
|
71 |
@@ -244,7 +244,6 b' data-notebook-id={{notebook_id}}' | |||||
244 | <script src="{{ static_url("js/notebook.js") }}" type="text/javascript" charset="utf-8"></script> |
|
244 | <script src="{{ static_url("js/notebook.js") }}" type="text/javascript" charset="utf-8"></script> | |
245 | <script src="{{ static_url("js/notificationwidget.js") }}" type="text/javascript" charset="utf-8"></script> |
|
245 | <script src="{{ static_url("js/notificationwidget.js") }}" type="text/javascript" charset="utf-8"></script> | |
246 | <script src="{{ static_url("js/notificationarea.js") }}" type="text/javascript" charset="utf-8"></script> |
|
246 | <script src="{{ static_url("js/notificationarea.js") }}" type="text/javascript" charset="utf-8"></script> | |
247 | <script src="{{ static_url("js/initnotificationwidgets.js") }}" type="text/javascript" charset="utf-8"></script> |
|
|||
248 | <script src="{{ static_url("js/tooltip.js") }}" type="text/javascript" charset="utf-8"></script> |
|
247 | <script src="{{ static_url("js/tooltip.js") }}" type="text/javascript" charset="utf-8"></script> | |
249 | <script src="{{ static_url("js/notebookmain.js") }}" type="text/javascript" charset="utf-8"></script> |
|
248 | <script src="{{ static_url("js/notebookmain.js") }}" type="text/javascript" charset="utf-8"></script> | |
250 |
|
249 |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
General Comments 0
You need to be logged in to leave comments.
Login now