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