Show More
@@ -1,158 +1,156 b'' | |||||
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 | 'es6promise', |
|
|||
6 | 'base/js/namespace', |
|
5 | 'base/js/namespace', | |
7 | 'jquery', |
|
6 | 'jquery', | |
8 | 'notebook/js/notebook', |
|
7 | 'notebook/js/notebook', | |
9 | 'contents', |
|
8 | 'contents', | |
10 | 'base/js/utils', |
|
9 | 'base/js/utils', | |
11 | 'base/js/page', |
|
10 | 'base/js/page', | |
12 | 'notebook/js/layoutmanager', |
|
11 | 'notebook/js/layoutmanager', | |
13 | 'base/js/events', |
|
12 | 'base/js/events', | |
14 | 'auth/js/loginwidget', |
|
13 | 'auth/js/loginwidget', | |
15 | 'notebook/js/maintoolbar', |
|
14 | 'notebook/js/maintoolbar', | |
16 | 'notebook/js/pager', |
|
15 | 'notebook/js/pager', | |
17 | 'notebook/js/quickhelp', |
|
16 | 'notebook/js/quickhelp', | |
18 | 'notebook/js/menubar', |
|
17 | 'notebook/js/menubar', | |
19 | 'notebook/js/notificationarea', |
|
18 | 'notebook/js/notificationarea', | |
20 | 'notebook/js/savewidget', |
|
19 | 'notebook/js/savewidget', | |
21 | 'notebook/js/keyboardmanager', |
|
20 | 'notebook/js/keyboardmanager', | |
22 | 'notebook/js/config', |
|
21 | 'notebook/js/config', | |
23 | 'notebook/js/kernelselector', |
|
22 | 'notebook/js/kernelselector', | |
24 | 'codemirror/lib/codemirror', |
|
23 | 'codemirror/lib/codemirror', | |
25 | 'notebook/js/about', |
|
24 | 'notebook/js/about', | |
26 | // only loaded, not used, please keep sure this is loaded last |
|
25 | // only loaded, not used, please keep sure this is loaded last | |
27 | 'custom/custom' |
|
26 | 'custom/custom' | |
28 | ], function( |
|
27 | ], function( | |
29 | es6promise, |
|
|||
30 | IPython, |
|
28 | IPython, | |
31 | $, |
|
29 | $, | |
32 | notebook, |
|
30 | notebook, | |
33 | contents, |
|
31 | contents, | |
34 | utils, |
|
32 | utils, | |
35 | page, |
|
33 | page, | |
36 | layoutmanager, |
|
34 | layoutmanager, | |
37 | events, |
|
35 | events, | |
38 | loginwidget, |
|
36 | loginwidget, | |
39 | maintoolbar, |
|
37 | maintoolbar, | |
40 | pager, |
|
38 | pager, | |
41 | quickhelp, |
|
39 | quickhelp, | |
42 | menubar, |
|
40 | menubar, | |
43 | notificationarea, |
|
41 | notificationarea, | |
44 | savewidget, |
|
42 | savewidget, | |
45 | keyboardmanager, |
|
43 | keyboardmanager, | |
46 | config, |
|
44 | config, | |
47 | kernelselector, |
|
45 | kernelselector, | |
48 | CodeMirror, |
|
46 | CodeMirror, | |
49 | about, |
|
47 | about, | |
50 | // please keep sure that even if not used, this is loaded last |
|
48 | // please keep sure that even if not used, this is loaded last | |
51 | custom |
|
49 | custom | |
52 | ) { |
|
50 | ) { | |
53 | "use strict"; |
|
51 | "use strict"; | |
54 |
|
52 | |||
55 | // compat with old IPython, remove for IPython > 3.0 |
|
53 | // compat with old IPython, remove for IPython > 3.0 | |
56 | window.CodeMirror = CodeMirror; |
|
54 | window.CodeMirror = CodeMirror; | |
57 |
|
55 | |||
58 | var common_options = { |
|
56 | var common_options = { | |
59 | ws_url : utils.get_body_data("wsUrl"), |
|
57 | ws_url : utils.get_body_data("wsUrl"), | |
60 | base_url : utils.get_body_data("baseUrl"), |
|
58 | base_url : utils.get_body_data("baseUrl"), | |
61 | notebook_path : utils.get_body_data("notebookPath"), |
|
59 | notebook_path : utils.get_body_data("notebookPath"), | |
62 | notebook_name : utils.get_body_data('notebookName') |
|
60 | notebook_name : utils.get_body_data('notebookName') | |
63 | }; |
|
61 | }; | |
64 |
|
62 | |||
65 | var user_config = $.extend({}, config.default_config); |
|
63 | var user_config = $.extend({}, config.default_config); | |
66 | var page = new page.Page(); |
|
64 | var page = new page.Page(); | |
67 | var layout_manager = new layoutmanager.LayoutManager(); |
|
65 | var layout_manager = new layoutmanager.LayoutManager(); | |
68 | var pager = new pager.Pager('div#pager', 'div#pager_splitter', { |
|
66 | var pager = new pager.Pager('div#pager', 'div#pager_splitter', { | |
69 | layout_manager: layout_manager, |
|
67 | layout_manager: layout_manager, | |
70 | events: events}); |
|
68 | events: events}); | |
71 | var keyboard_manager = new keyboardmanager.KeyboardManager({ |
|
69 | var keyboard_manager = new keyboardmanager.KeyboardManager({ | |
72 | pager: pager, |
|
70 | pager: pager, | |
73 | events: events}); |
|
71 | events: events}); | |
74 | var save_widget = new savewidget.SaveWidget('span#save_widget', { |
|
72 | var save_widget = new savewidget.SaveWidget('span#save_widget', { | |
75 | events: events, |
|
73 | events: events, | |
76 | keyboard_manager: keyboard_manager}); |
|
74 | keyboard_manager: keyboard_manager}); | |
77 | var contents = new contents.Contents($.extend({ |
|
75 | var contents = new contents.Contents($.extend({ | |
78 | events: events}, |
|
76 | events: events}, | |
79 | common_options)); |
|
77 | common_options)); | |
80 | var notebook = new notebook.Notebook('div#notebook', $.extend({ |
|
78 | var notebook = new notebook.Notebook('div#notebook', $.extend({ | |
81 | events: events, |
|
79 | events: events, | |
82 | keyboard_manager: keyboard_manager, |
|
80 | keyboard_manager: keyboard_manager, | |
83 | save_widget: save_widget, |
|
81 | save_widget: save_widget, | |
84 | contents: contents, |
|
82 | contents: contents, | |
85 | config: user_config}, |
|
83 | config: user_config}, | |
86 | common_options)); |
|
84 | common_options)); | |
87 | var login_widget = new loginwidget.LoginWidget('span#login_widget', common_options); |
|
85 | var login_widget = new loginwidget.LoginWidget('span#login_widget', common_options); | |
88 | var toolbar = new maintoolbar.MainToolBar('#maintoolbar-container', { |
|
86 | var toolbar = new maintoolbar.MainToolBar('#maintoolbar-container', { | |
89 | notebook: notebook, |
|
87 | notebook: notebook, | |
90 | events: events}); |
|
88 | events: events}); | |
91 | var quick_help = new quickhelp.QuickHelp({ |
|
89 | var quick_help = new quickhelp.QuickHelp({ | |
92 | keyboard_manager: keyboard_manager, |
|
90 | keyboard_manager: keyboard_manager, | |
93 | events: events, |
|
91 | events: events, | |
94 | notebook: notebook}); |
|
92 | notebook: notebook}); | |
95 | var menubar = new menubar.MenuBar('#menubar', $.extend({ |
|
93 | var menubar = new menubar.MenuBar('#menubar', $.extend({ | |
96 | notebook: notebook, |
|
94 | notebook: notebook, | |
97 | contents: contents, |
|
95 | contents: contents, | |
98 | layout_manager: layout_manager, |
|
96 | layout_manager: layout_manager, | |
99 | events: events, |
|
97 | events: events, | |
100 | save_widget: save_widget, |
|
98 | save_widget: save_widget, | |
101 | quick_help: quick_help}, |
|
99 | quick_help: quick_help}, | |
102 | common_options)); |
|
100 | common_options)); | |
103 | var notification_area = new notificationarea.NotificationArea( |
|
101 | var notification_area = new notificationarea.NotificationArea( | |
104 | '#notification_area', { |
|
102 | '#notification_area', { | |
105 | events: events, |
|
103 | events: events, | |
106 | save_widget: save_widget, |
|
104 | save_widget: save_widget, | |
107 | notebook: notebook, |
|
105 | notebook: notebook, | |
108 | keyboard_manager: keyboard_manager}); |
|
106 | keyboard_manager: keyboard_manager}); | |
109 | notification_area.init_notification_widgets(); |
|
107 | notification_area.init_notification_widgets(); | |
110 | var kernel_selector = new kernelselector.KernelSelector( |
|
108 | var kernel_selector = new kernelselector.KernelSelector( | |
111 | '#kernel_selector_widget', notebook); |
|
109 | '#kernel_selector_widget', notebook); | |
112 |
|
110 | |||
113 | $('body').append('<div id="fonttest"><pre><span id="test1">x</span>'+ |
|
111 | $('body').append('<div id="fonttest"><pre><span id="test1">x</span>'+ | |
114 | '<span id="test2" style="font-weight: bold;">x</span>'+ |
|
112 | '<span id="test2" style="font-weight: bold;">x</span>'+ | |
115 | '<span id="test3" style="font-style: italic;">x</span></pre></div>'); |
|
113 | '<span id="test3" style="font-style: italic;">x</span></pre></div>'); | |
116 | var nh = $('#test1').innerHeight(); |
|
114 | var nh = $('#test1').innerHeight(); | |
117 | var bh = $('#test2').innerHeight(); |
|
115 | var bh = $('#test2').innerHeight(); | |
118 | var ih = $('#test3').innerHeight(); |
|
116 | var ih = $('#test3').innerHeight(); | |
119 | if(nh != bh || nh != ih) { |
|
117 | if(nh != bh || nh != ih) { | |
120 | $('head').append('<style>.CodeMirror span { vertical-align: bottom; }</style>'); |
|
118 | $('head').append('<style>.CodeMirror span { vertical-align: bottom; }</style>'); | |
121 | } |
|
119 | } | |
122 | $('#fonttest').remove(); |
|
120 | $('#fonttest').remove(); | |
123 |
|
121 | |||
124 | page.show(); |
|
122 | page.show(); | |
125 |
|
123 | |||
126 | layout_manager.do_resize(); |
|
124 | layout_manager.do_resize(); | |
127 | var first_load = function () { |
|
125 | var first_load = function () { | |
128 | layout_manager.do_resize(); |
|
126 | layout_manager.do_resize(); | |
129 | var hash = document.location.hash; |
|
127 | var hash = document.location.hash; | |
130 | if (hash) { |
|
128 | if (hash) { | |
131 | document.location.hash = ''; |
|
129 | document.location.hash = ''; | |
132 | document.location.hash = hash; |
|
130 | document.location.hash = hash; | |
133 | } |
|
131 | } | |
134 | notebook.set_autosave_interval(notebook.minimum_autosave_interval); |
|
132 | notebook.set_autosave_interval(notebook.minimum_autosave_interval); | |
135 | // only do this once |
|
133 | // only do this once | |
136 | events.off('notebook_loaded.Notebook', first_load); |
|
134 | events.off('notebook_loaded.Notebook', first_load); | |
137 | }; |
|
135 | }; | |
138 | events.on('notebook_loaded.Notebook', first_load); |
|
136 | events.on('notebook_loaded.Notebook', first_load); | |
139 |
|
137 | |||
140 | IPython.page = page; |
|
138 | IPython.page = page; | |
141 | IPython.layout_manager = layout_manager; |
|
139 | IPython.layout_manager = layout_manager; | |
142 | IPython.notebook = notebook; |
|
140 | IPython.notebook = notebook; | |
143 | IPython.contents = contents; |
|
141 | IPython.contents = contents; | |
144 | IPython.pager = pager; |
|
142 | IPython.pager = pager; | |
145 | IPython.quick_help = quick_help; |
|
143 | IPython.quick_help = quick_help; | |
146 | IPython.login_widget = login_widget; |
|
144 | IPython.login_widget = login_widget; | |
147 | IPython.menubar = menubar; |
|
145 | IPython.menubar = menubar; | |
148 | IPython.toolbar = toolbar; |
|
146 | IPython.toolbar = toolbar; | |
149 | IPython.notification_area = notification_area; |
|
147 | IPython.notification_area = notification_area; | |
150 | IPython.keyboard_manager = keyboard_manager; |
|
148 | IPython.keyboard_manager = keyboard_manager; | |
151 | IPython.save_widget = save_widget; |
|
149 | IPython.save_widget = save_widget; | |
152 | IPython.config = user_config; |
|
150 | IPython.config = user_config; | |
153 | IPython.tooltip = notebook.tooltip; |
|
151 | IPython.tooltip = notebook.tooltip; | |
154 |
|
152 | |||
155 | events.trigger('app_initialized.NotebookApp'); |
|
153 | events.trigger('app_initialized.NotebookApp'); | |
156 | notebook.load_notebook(common_options.notebook_path); |
|
154 | notebook.load_notebook(common_options.notebook_path); | |
157 |
|
155 | |||
158 | }); |
|
156 | }); |
General Comments 0
You need to be logged in to leave comments.
Login now