##// END OF EJS Templates
preserve backward-compatible $([IPython.events])
MinRK -
Show More
@@ -1,23 +1,23 b''
1 1 // Copyright (c) IPython Development Team.
2 2 // Distributed under the terms of the Modified BSD License.
3 3
4 4 // Give us an object to bind all events to. This object should be created
5 5 // before all other objects so it exists when others register event handlers.
6 6 // To trigger an event handler:
7 7 // require(['base/js/events'], function (events) {
8 8 // events.on("event.Namespace", function () {do_stuff(); });
9 9 // })
10 10
11 11 define(['base/js/namespace', 'jquery'], function(IPython, $) {
12 12 "use strict";
13 13
14 14 var Events = function () {};
15 15
16 var events = $([new Events()]);
16 var events = new Events();
17 17
18 18 // Backwards compatability.
19 19 IPython.Events = Events;
20 20 IPython.events = events;
21 21
22 22 return $([events]);
23 23 });
@@ -1,137 +1,136 b''
1 1 // Copyright (c) IPython Development Team.
2 2 // Distributed under the terms of the Modified BSD License.
3 3
4 4 require([
5 5 'base/js/namespace',
6 6 'jquery',
7 7 'notebook/js/notebook',
8 8 'base/js/utils',
9 9 'base/js/page',
10 10 'notebook/js/layoutmanager',
11 11 'base/js/events',
12 12 'auth/js/loginwidget',
13 13 'notebook/js/maintoolbar',
14 14 'notebook/js/pager',
15 15 'notebook/js/quickhelp',
16 16 'notebook/js/menubar',
17 17 'notebook/js/notificationarea',
18 18 'notebook/js/savewidget',
19 19 'notebook/js/keyboardmanager',
20 20 'notebook/js/config',
21 21 'custom/custom',
22 22 ], function(
23 23 IPython,
24 24 $,
25 25 notebook,
26 26 utils,
27 27 page,
28 28 layoutmanager,
29 29 events,
30 30 loginwidget,
31 31 maintoolbar,
32 32 pager,
33 33 quickhelp,
34 34 menubar,
35 35 notificationarea,
36 36 savewidget,
37 37 keyboardmanager,
38 38 config
39 39 ) {
40 40 "use strict";
41 41
42 42 $('#ipython-main-app').addClass('border-box-sizing');
43 43 $('div#notebook_panel').addClass('border-box-sizing');
44 44
45 45 var common_options = {
46 46 base_url : utils.get_body_data("baseUrl"),
47 47 notebook_path : utils.get_body_data("notebookPath"),
48 48 notebook_name : utils.get_body_data('notebookName')
49 49 };
50 50
51 51 var user_config = $.extend({}, config.default_config);
52 52 var page = new page.Page();
53 53 var layout_manager = new layoutmanager.LayoutManager();
54 54 var pager = new pager.Pager('div#pager', 'div#pager_splitter', {
55 55 layout_manager: layout_manager,
56 56 events: events});
57 57 var keyboard_manager = new keyboardmanager.KeyboardManager({
58 58 pager: pager,
59 59 events: events});
60 60 var save_widget = new savewidget.SaveWidget('span#save_widget', {
61 61 events: events,
62 62 keyboard_manager: keyboard_manager});
63 63 var notebook = new notebook.Notebook('div#notebook', $.extend({
64 64 events: events,
65 65 keyboard_manager: keyboard_manager,
66 66 save_widget: save_widget,
67 67 config: user_config},
68 68 common_options));
69 69 var login_widget = new loginwidget.LoginWidget('span#login_widget', common_options);
70 70 var toolbar = new maintoolbar.MainToolBar('#maintoolbar-container', {
71 71 notebook: notebook,
72 72 events: events});
73 73 var quick_help = new quickhelp.QuickHelp({
74 74 keyboard_manager: keyboard_manager,
75 75 events: events,
76 76 notebook: notebook});
77 77 var menubar = new menubar.MenuBar('#menubar', $.extend({
78 78 notebook: notebook,
79 79 layout_manager: layout_manager,
80 80 events: events,
81 81 save_widget: save_widget,
82 82 quick_help: quick_help},
83 83 common_options));
84 84 var notification_area = new notificationarea.NotificationArea(
85 85 '#notification_area', {
86 86 events: events,
87 87 save_widget: save_widget,
88 88 notebook: notebook,
89 89 keyboard_manager: keyboard_manager});
90 90 notification_area.init_notification_widgets();
91 91
92 92 $('body').append('<div id="fonttest"><pre><span id="test1">x</span>'+
93 93 '<span id="test2" style="font-weight: bold;">x</span>'+
94 94 '<span id="test3" style="font-style: italic;">x</span></pre></div>');
95 95 var nh = $('#test1').innerHeight();
96 96 var bh = $('#test2').innerHeight();
97 97 var ih = $('#test3').innerHeight();
98 98 if(nh != bh || nh != ih) {
99 99 $('head').append('<style>.CodeMirror span { vertical-align: bottom; }</style>');
100 100 }
101 101 $('#fonttest').remove();
102 102
103 103 page.show();
104 104
105 105 layout_manager.do_resize();
106 106 var first_load = function () {
107 107 layout_manager.do_resize();
108 108 var hash = document.location.hash;
109 109 if (hash) {
110 110 document.location.hash = '';
111 111 document.location.hash = hash;
112 112 }
113 113 notebook.set_autosave_interval(notebook.minimum_autosave_interval);
114 114 // only do this once
115 115 events.off('notebook_loaded.Notebook', first_load);
116 116 };
117 117 events.on('notebook_loaded.Notebook', first_load);
118 118
119 119 IPython.page = page;
120 120 IPython.layout_manager = layout_manager;
121 121 IPython.notebook = notebook;
122 122 IPython.pager = pager;
123 123 IPython.quick_help = quick_help;
124 124 IPython.login_widget = login_widget;
125 125 IPython.menubar = menubar;
126 126 IPython.toolbar = toolbar;
127 127 IPython.notification_area = notification_area;
128 IPython.events = events;
129 128 IPython.keyboard_manager = keyboard_manager;
130 129 IPython.save_widget = save_widget;
131 130 IPython.config = user_config;
132 131 IPython.tooltip = notebook.tooltip;
133 132
134 133 events.trigger('app_initialized.NotebookApp');
135 134 notebook.load_notebook(common_options.notebook_name, common_options.notebook_path);
136 135
137 136 });
@@ -1,121 +1,120 b''
1 1 // Copyright (c) IPython Development Team.
2 2 // Distributed under the terms of the Modified BSD License.
3 3
4 4 require([
5 5 'base/js/namespace',
6 6 'jquery',
7 7 'base/js/events',
8 8 'base/js/page',
9 9 'base/js/utils',
10 10 'tree/js/notebooklist',
11 11 'tree/js/clusterlist',
12 12 'tree/js/sessionlist',
13 13 'tree/js/kernellist',
14 14 'auth/js/loginwidget',
15 15 'jqueryui',
16 16 'bootstrap',
17 17 'custom/custom',
18 18 ], function(
19 19 IPython,
20 20 $,
21 21 events,
22 22 page,
23 23 utils,
24 24 notebooklist,
25 25 clusterlist,
26 26 sesssionlist,
27 27 kernellist,
28 28 loginwidget){
29 29
30 30 page = new page.Page();
31 31
32 32 var common_options = {
33 33 base_url: utils.get_body_data("baseUrl"),
34 34 notebook_path: utils.get_body_data("notebookPath"),
35 35 };
36 36 session_list = new sesssionlist.SesssionList($.extend({
37 37 events: events},
38 38 common_options));
39 39 notebook_list = new notebooklist.NotebookList('#notebook_list', $.extend({
40 40 session_list: session_list},
41 41 common_options));
42 42 cluster_list = new clusterlist.ClusterList('#cluster_list', common_options);
43 43 kernel_list = new kernellist.KernelList('#running_list', $.extend({
44 44 session_list: session_list},
45 45 common_options));
46 46 login_widget = new loginwidget.LoginWidget('#login_widget', common_options);
47 47
48 48 $('#new_notebook').button().click(function (e) {
49 49 notebook_list.new_notebook();
50 50 });
51 51
52 52 var interval_id=0;
53 53 // auto refresh every xx secondes, no need to be fast,
54 54 // update is done at least when page get focus
55 55 var time_refresh = 60; // in sec
56 56
57 57 var enable_autorefresh = function(){
58 58 //refresh immediately , then start interval
59 59 if($('.upload_button').length === 0)
60 60 {
61 61 session_list.load_sessions();
62 62 cluster_list.load_list();
63 63 }
64 64 if (!interval_id){
65 65 interval_id = setInterval(function(){
66 66 if($('.upload_button').length === 0)
67 67 {
68 68 session_list.load_sessions();
69 69 cluster_list.load_list();
70 70 }
71 71 }, time_refresh*1000);
72 72 }
73 73 };
74 74
75 75 var disable_autorefresh = function(){
76 76 clearInterval(interval_id);
77 77 interval_id = 0;
78 78 };
79 79
80 80 // stop autorefresh when page lose focus
81 81 $(window).blur(function() {
82 82 disable_autorefresh();
83 83 });
84 84
85 85 //re-enable when page get focus back
86 86 $(window).focus(function() {
87 87 enable_autorefresh();
88 88 });
89 89
90 90 // finally start it, it will refresh immediately
91 91 enable_autorefresh();
92 92
93 93 page.show();
94 94
95 95 // For backwards compatability.
96 96 IPython.page = page;
97 97 IPython.notebook_list = notebook_list;
98 98 IPython.cluster_list = cluster_list;
99 99 IPython.session_list = session_list;
100 100 IPython.kernel_list = kernel_list;
101 101 IPython.login_widget = login_widget;
102 IPython.events = events;
103 102
104 103 events.trigger('app_initialized.DashboardApp');
105 104
106 105 // bound the upload method to the on change of the file select list
107 106 $("#alternate_upload").change(function (event){
108 107 notebook_list.handleFilesUpload(event,'form');
109 108 });
110 109
111 110 // set hash on tab click
112 111 $("#tabs").find("a").click(function() {
113 112 window.location.hash = $(this).attr("href");
114 113 });
115 114
116 115 // load tab if url hash
117 116 if (window.location.hash) {
118 117 $("#tabs").find("a[href=" + window.location.hash + "]").click();
119 118 }
120 119
121 120 });
General Comments 0
You need to be logged in to leave comments. Login now