Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Avatar for KuCalc : devops.
Download
50654 views
1
// Copyright (c) IPython Development Team.
2
// Distributed under the terms of the Modified BSD License.
3
4
require([
5
'base/js/namespace',
6
'jquery',
7
'notebook/js/notebook',
8
'contents',
9
'services/config',
10
'base/js/utils',
11
'base/js/page',
12
'base/js/events',
13
'auth/js/loginwidget',
14
'notebook/js/maintoolbar',
15
'notebook/js/pager',
16
'notebook/js/quickhelp',
17
'notebook/js/menubar',
18
'notebook/js/notificationarea',
19
'notebook/js/savewidget',
20
'notebook/js/actions',
21
'notebook/js/keyboardmanager',
22
'notebook/js/kernelselector',
23
'codemirror/lib/codemirror',
24
'notebook/js/about',
25
// only loaded, not used, please keep sure this is loaded last
26
'custom/custom'
27
], function(
28
IPython,
29
$,
30
notebook,
31
contents,
32
configmod,
33
utils,
34
page,
35
events,
36
loginwidget,
37
maintoolbar,
38
pager,
39
quickhelp,
40
menubar,
41
notificationarea,
42
savewidget,
43
actions,
44
keyboardmanager,
45
kernelselector,
46
CodeMirror,
47
about,
48
// please keep sure that even if not used, this is loaded last
49
custom
50
) {
51
"use strict";
52
53
// compat with old IPython, remove for IPython > 3.0
54
window.CodeMirror = CodeMirror;
55
56
var common_options = {
57
ws_url : utils.get_body_data("wsUrl"),
58
base_url : utils.get_body_data("baseUrl"),
59
notebook_path : utils.get_body_data("notebookPath"),
60
notebook_name : utils.get_body_data('notebookName')
61
};
62
63
var config_section = new configmod.ConfigSection('notebook', common_options);
64
config_section.load();
65
var common_config = new configmod.ConfigSection('common', common_options);
66
common_config.load();
67
var page = new page.Page();
68
var pager = new pager.Pager('div#pager', {
69
events: events});
70
var acts = new actions.init();
71
var keyboard_manager = new keyboardmanager.KeyboardManager({
72
pager: pager,
73
events: events,
74
actions: acts });
75
var save_widget = new savewidget.SaveWidget('span#save_widget', {
76
events: events,
77
keyboard_manager: keyboard_manager});
78
var contents = new contents.Contents({
79
base_url: common_options.base_url,
80
common_config: common_config
81
});
82
var notebook = new notebook.Notebook('div#notebook', $.extend({
83
events: events,
84
keyboard_manager: keyboard_manager,
85
save_widget: save_widget,
86
contents: contents,
87
config: config_section},
88
common_options));
89
var login_widget = new loginwidget.LoginWidget('span#login_widget', common_options);
90
var toolbar = new maintoolbar.MainToolBar('#maintoolbar-container', {
91
notebook: notebook,
92
events: events,
93
actions: acts});
94
var quick_help = new quickhelp.QuickHelp({
95
keyboard_manager: keyboard_manager,
96
events: events,
97
notebook: notebook});
98
keyboard_manager.set_notebook(notebook);
99
keyboard_manager.set_quickhelp(quick_help);
100
var menubar = new menubar.MenuBar('#menubar', $.extend({
101
notebook: notebook,
102
contents: contents,
103
events: events,
104
save_widget: save_widget,
105
quick_help: quick_help},
106
common_options));
107
var notification_area = new notificationarea.NotebookNotificationArea(
108
'#notification_area', {
109
events: events,
110
save_widget: save_widget,
111
notebook: notebook,
112
keyboard_manager: keyboard_manager});
113
notification_area.init_notification_widgets();
114
var kernel_selector = new kernelselector.KernelSelector(
115
'#kernel_logo_widget', notebook);
116
117
$('body').append('<div id="fonttest"><pre><span id="test1">x</span>'+
118
'<span id="test2" style="font-weight: bold;">x</span>'+
119
'<span id="test3" style="font-style: italic;">x</span></pre></div>');
120
var nh = $('#test1').innerHeight();
121
var bh = $('#test2').innerHeight();
122
var ih = $('#test3').innerHeight();
123
if(nh != bh || nh != ih) {
124
$('head').append('<style>.CodeMirror span { vertical-align: bottom; }</style>');
125
}
126
$('#fonttest').remove();
127
128
page.show();
129
130
var first_load = function () {
131
var hash = document.location.hash;
132
if (hash) {
133
document.location.hash = '';
134
document.location.hash = hash;
135
}
136
notebook.set_autosave_interval(notebook.minimum_autosave_interval);
137
// only do this once
138
events.off('notebook_loaded.Notebook', first_load);
139
};
140
events.on('notebook_loaded.Notebook', first_load);
141
142
IPython.page = page;
143
IPython.notebook = notebook;
144
IPython.contents = contents;
145
IPython.pager = pager;
146
IPython.quick_help = quick_help;
147
IPython.login_widget = login_widget;
148
IPython.menubar = menubar;
149
IPython.toolbar = toolbar;
150
IPython.notification_area = notification_area;
151
IPython.keyboard_manager = keyboard_manager;
152
IPython.save_widget = save_widget;
153
IPython.tooltip = notebook.tooltip;
154
155
events.trigger('app_initialized.NotebookApp');
156
utils.load_extensions_from_config(config_section);
157
utils.load_extensions_from_config(common_config);
158
notebook.load_notebook(common_options.notebook_path);
159
160
});
161
162