Show More
@@ -3,17 +3,22 b'' | |||||
3 |
|
3 | |||
4 | // Give us an object to bind all events to. This object should be created |
|
4 | // Give us an object to bind all events to. This object should be created | |
5 | // before all other objects so it exists when others register event handlers. |
|
5 | // before all other objects so it exists when others register event handlers. | |
6 |
// To |
|
6 | // To register an event handler: | |
7 | // $([IPython.events]).trigger('event.Namespace'); |
|
7 | // | |
8 | // To handle it: |
|
8 | // require(['base/js/events'], function (events) { | |
9 |
// |
|
9 | // events.on("event.Namespace", function () { do_stuff(); }); | |
10 | define(['base/js/namespace'], function(IPython) { |
|
10 | // }); | |
|
11 | ||||
|
12 | define(['base/js/namespace', 'jquery'], function(IPython, $) { | |||
11 | "use strict"; |
|
13 | "use strict"; | |
12 |
|
14 | |||
13 | var Events = function () {}; |
|
15 | var Events = function () {}; | |
14 |
|
16 | |||
|
17 | var events = new Events(); | |||
|
18 | ||||
15 | // Backwards compatability. |
|
19 | // Backwards compatability. | |
16 | IPython.Events = Events; |
|
20 | IPython.Events = Events; | |
|
21 | IPython.events = events; | |||
17 |
|
22 | |||
18 |
return |
|
23 | return $([events]); | |
19 | }); |
|
24 | }); |
@@ -18,6 +18,8 b' require([' | |||||
18 | 'notebook/js/savewidget', |
|
18 | 'notebook/js/savewidget', | |
19 | 'notebook/js/keyboardmanager', |
|
19 | 'notebook/js/keyboardmanager', | |
20 | 'notebook/js/config', |
|
20 | 'notebook/js/config', | |
|
21 | // only loaded, not used: | |||
|
22 | 'custom/custom', | |||
21 | ], function( |
|
23 | ], function( | |
22 | IPython, |
|
24 | IPython, | |
23 | $, |
|
25 | $, | |
@@ -51,7 +53,6 b' require([' | |||||
51 | var user_config = $.extend({}, config.default_config); |
|
53 | var user_config = $.extend({}, config.default_config); | |
52 | var page = new page.Page(); |
|
54 | var page = new page.Page(); | |
53 | var layout_manager = new layoutmanager.LayoutManager(); |
|
55 | var layout_manager = new layoutmanager.LayoutManager(); | |
54 | var events = $([new events.Events()]); |
|
|||
55 | var pager = new pager.Pager('div#pager', 'div#pager_splitter', { |
|
56 | var pager = new pager.Pager('div#pager', 'div#pager_splitter', { | |
56 | layout_manager: layout_manager, |
|
57 | layout_manager: layout_manager, | |
57 | events: events}); |
|
58 | events: events}); | |
@@ -115,11 +116,8 b' require([' | |||||
115 | // only do this once |
|
116 | // only do this once | |
116 | events.off('notebook_loaded.Notebook', first_load); |
|
117 | events.off('notebook_loaded.Notebook', first_load); | |
117 | }; |
|
118 | }; | |
118 |
|
||||
119 | events.on('notebook_loaded.Notebook', first_load); |
|
119 | events.on('notebook_loaded.Notebook', first_load); | |
120 | events.trigger('app_initialized.NotebookApp'); |
|
120 | ||
121 | notebook.load_notebook(common_options.notebook_name, common_options.notebook_path); |
|
|||
122 |
|
||||
123 | IPython.page = page; |
|
121 | IPython.page = page; | |
124 | IPython.layout_manager = layout_manager; |
|
122 | IPython.layout_manager = layout_manager; | |
125 | IPython.notebook = notebook; |
|
123 | IPython.notebook = notebook; | |
@@ -129,9 +127,12 b' require([' | |||||
129 | IPython.menubar = menubar; |
|
127 | IPython.menubar = menubar; | |
130 | IPython.toolbar = toolbar; |
|
128 | IPython.toolbar = toolbar; | |
131 | IPython.notification_area = notification_area; |
|
129 | IPython.notification_area = notification_area; | |
132 | IPython.events = events; |
|
|||
133 | IPython.keyboard_manager = keyboard_manager; |
|
130 | IPython.keyboard_manager = keyboard_manager; | |
134 | IPython.save_widget = save_widget; |
|
131 | IPython.save_widget = save_widget; | |
135 | IPython.config = user_config; |
|
132 | IPython.config = user_config; | |
136 | IPython.tooltip = notebook.tooltip; |
|
133 | IPython.tooltip = notebook.tooltip; | |
|
134 | ||||
|
135 | events.trigger('app_initialized.NotebookApp'); | |||
|
136 | notebook.load_notebook(common_options.notebook_name, common_options.notebook_path); | |||
|
137 | ||||
137 | }); |
|
138 | }); |
@@ -12,8 +12,10 b' require([' | |||||
12 | 'tree/js/sessionlist', |
|
12 | 'tree/js/sessionlist', | |
13 | 'tree/js/kernellist', |
|
13 | 'tree/js/kernellist', | |
14 | 'auth/js/loginwidget', |
|
14 | 'auth/js/loginwidget', | |
|
15 | // only loaded, not used: | |||
15 | 'jqueryui', |
|
16 | 'jqueryui', | |
16 | 'bootstrap', |
|
17 | 'bootstrap', | |
|
18 | 'custom/custom', | |||
17 | ], function( |
|
19 | ], function( | |
18 | IPython, |
|
20 | IPython, | |
19 | $, |
|
21 | $, | |
@@ -32,7 +34,6 b' require([' | |||||
32 | base_url: utils.get_body_data("baseUrl"), |
|
34 | base_url: utils.get_body_data("baseUrl"), | |
33 | notebook_path: utils.get_body_data("notebookPath"), |
|
35 | notebook_path: utils.get_body_data("notebookPath"), | |
34 | }; |
|
36 | }; | |
35 | events = $([new events.Events()]); |
|
|||
36 | session_list = new sesssionlist.SesssionList($.extend({ |
|
37 | session_list = new sesssionlist.SesssionList($.extend({ | |
37 | events: events}, |
|
38 | events: events}, | |
38 | common_options)); |
|
39 | common_options)); | |
@@ -91,6 +92,15 b' require([' | |||||
91 | enable_autorefresh(); |
|
92 | enable_autorefresh(); | |
92 |
|
93 | |||
93 | page.show(); |
|
94 | page.show(); | |
|
95 | ||||
|
96 | // For backwards compatability. | |||
|
97 | IPython.page = page; | |||
|
98 | IPython.notebook_list = notebook_list; | |||
|
99 | IPython.cluster_list = cluster_list; | |||
|
100 | IPython.session_list = session_list; | |||
|
101 | IPython.kernel_list = kernel_list; | |||
|
102 | IPython.login_widget = login_widget; | |||
|
103 | ||||
94 | events.trigger('app_initialized.DashboardApp'); |
|
104 | events.trigger('app_initialized.DashboardApp'); | |
95 |
|
105 | |||
96 | // bound the upload method to the on change of the file select list |
|
106 | // bound the upload method to the on change of the file select list | |
@@ -108,12 +118,4 b' require([' | |||||
108 | $("#tabs").find("a[href=" + window.location.hash + "]").click(); |
|
118 | $("#tabs").find("a[href=" + window.location.hash + "]").click(); | |
109 | } |
|
119 | } | |
110 |
|
120 | |||
111 | // For backwards compatability. |
|
|||
112 | IPython.page = page; |
|
|||
113 | IPython.notebook_list = notebook_list; |
|
|||
114 | IPython.cluster_list = cluster_list; |
|
|||
115 | IPython.session_list = session_list; |
|
|||
116 | IPython.kernel_list = kernel_list; |
|
|||
117 | IPython.login_widget = login_widget; |
|
|||
118 | IPython.events = events; |
|
|||
119 | }); |
|
121 | }); |
@@ -102,8 +102,6 b'' | |||||
102 | {% block script %} |
|
102 | {% block script %} | |
103 | {% endblock %} |
|
103 | {% endblock %} | |
104 |
|
104 | |||
105 | <script src="{{static_url("custom/custom.js") }}" type="text/javascript" charset="utf-8"></script> |
|
|||
106 |
|
||||
107 | </body> |
|
105 | </body> | |
108 |
|
106 | |||
109 | </html> |
|
107 | </html> |
@@ -9,16 +9,18 b' casper.notebook_test(function () {' | |||||
9 | var nbname = "has#hash and space and unicø∂e.ipynb"; |
|
9 | var nbname = "has#hash and space and unicø∂e.ipynb"; | |
10 |
|
10 | |||
11 | this.evaluate(function (nbname) { |
|
11 | this.evaluate(function (nbname) { | |
12 | IPython.notebook.notebook_name = nbname; |
|
12 | require(['base/js/events'], function (events) { | |
13 | IPython._save_success = IPython._save_failed = false; |
|
13 | IPython.notebook.notebook_name = nbname; | |
14 | IPython.events.on('notebook_saved.Notebook', function () { |
|
14 | IPython._save_success = IPython._save_failed = false; | |
15 | IPython._save_success = true; |
|
15 | events.on('notebook_saved.Notebook', function () { | |
16 | }); |
|
16 | IPython._save_success = true; | |
17 | IPython.events.on('notebook_save_failed.Notebook', |
|
17 | }); | |
18 | function (event, xhr, status, error) { |
|
18 | events.on('notebook_save_failed.Notebook', | |
19 | IPython._save_failed = "save failed with " + xhr.status + xhr.responseText; |
|
19 | function (event, xhr, status, error) { | |
|
20 | IPython._save_failed = "save failed with " + xhr.status + xhr.responseText; | |||
|
21 | }); | |||
|
22 | IPython.notebook.save_notebook(); | |||
20 | }); |
|
23 | }); | |
21 | IPython.notebook.save_notebook(); |
|
|||
22 | }, {nbname:nbname}); |
|
24 | }, {nbname:nbname}); | |
23 |
|
25 | |||
24 | this.waitFor(function () { |
|
26 | this.waitFor(function () { | |
@@ -41,10 +43,12 b' casper.notebook_test(function () {' | |||||
41 | }); |
|
43 | }); | |
42 |
|
44 | |||
43 | this.thenEvaluate(function(){ |
|
45 | this.thenEvaluate(function(){ | |
44 | IPython.events.on('checkpoint_created.Notebook', function (evt, data) { |
|
|||
45 | IPython._checkpoint_created = true; |
|
|||
46 | }); |
|
|||
47 | IPython._checkpoint_created = false; |
|
46 | IPython._checkpoint_created = false; | |
|
47 | require(['base/js/events'], function (events) { | |||
|
48 | events.on('checkpoint_created.Notebook', function (evt, data) { | |||
|
49 | IPython._checkpoint_created = true; | |||
|
50 | }); | |||
|
51 | }); | |||
48 | IPython.notebook.save_checkpoint(); |
|
52 | IPython.notebook.save_checkpoint(); | |
49 | }); |
|
53 | }); | |
50 |
|
54 | |||
@@ -71,7 +75,7 b' casper.notebook_test(function () {' | |||||
71 | this.then(function(){ |
|
75 | this.then(function(){ | |
72 | var notebook_url = this.evaluate(function(nbname){ |
|
76 | var notebook_url = this.evaluate(function(nbname){ | |
73 | var escaped_name = encodeURIComponent(nbname); |
|
77 | var escaped_name = encodeURIComponent(nbname); | |
74 | var return_this_thing; |
|
78 | var return_this_thing = null; | |
75 | $("a.item_link").map(function (i,a) { |
|
79 | $("a.item_link").map(function (i,a) { | |
76 | if (a.href.indexOf(escaped_name) >= 0) { |
|
80 | if (a.href.indexOf(escaped_name) >= 0) { | |
77 | return_this_thing = a.href; |
|
81 | return_this_thing = a.href; |
@@ -26,11 +26,14 b' casper.open_new_notebook = function () {' | |||||
26 | this.waitFor(this.kernel_running); |
|
26 | this.waitFor(this.kernel_running); | |
27 | // track the IPython busy/idle state |
|
27 | // track the IPython busy/idle state | |
28 | this.thenEvaluate(function () { |
|
28 | this.thenEvaluate(function () { | |
29 | IPython.events.on('status_idle.Kernel',function () { |
|
29 | require(['base/js/namespace', 'base/js/events'], function (IPython, events) { | |
30 | IPython._status = 'idle'; |
|
30 | ||
31 | }); |
|
31 | events.on('status_idle.Kernel',function () { | |
32 | IPython.events.on('status_busy.Kernel',function () { |
|
32 | IPython._status = 'idle'; | |
33 | IPython._status = 'busy'; |
|
33 | }); | |
|
34 | events.on('status_busy.Kernel',function () { | |||
|
35 | IPython._status = 'busy'; | |||
|
36 | }); | |||
34 | }); |
|
37 | }); | |
35 | }); |
|
38 | }); | |
36 |
|
39 | |||
@@ -47,9 +50,8 b' casper.open_new_notebook = function () {' | |||||
47 | casper.page_loaded = function() { |
|
50 | casper.page_loaded = function() { | |
48 | // Return whether or not the kernel is running. |
|
51 | // Return whether or not the kernel is running. | |
49 | return this.evaluate(function() { |
|
52 | return this.evaluate(function() { | |
50 |
return IPython !== undefined && |
|
53 | return IPython !== undefined && | |
51 |
IPython.page !== undefined |
|
54 | IPython.page !== undefined; | |
52 | IPython.events !== undefined; |
|
|||
53 | }); |
|
55 | }); | |
54 | }; |
|
56 | }; | |
55 |
|
57 |
General Comments 0
You need to be logged in to leave comments.
Login now