Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Avatar for KuCalc : devops.
Download
50650 views
1
// Copyright (c) IPython Development Team.
2
// Distributed under the terms of the Modified BSD License.
3
4
require([
5
'jquery',
6
'base/js/namespace',
7
'base/js/utils',
8
'base/js/page',
9
'base/js/events',
10
'contents',
11
'services/config',
12
'edit/js/editor',
13
'edit/js/menubar',
14
'edit/js/savewidget',
15
'edit/js/notificationarea',
16
'custom/custom',
17
], function(
18
$,
19
IPython,
20
utils,
21
page,
22
events,
23
contents,
24
configmod,
25
editmod,
26
menubar,
27
savewidget,
28
notificationarea
29
){
30
"use strict";
31
page = new page.Page();
32
33
var base_url = utils.get_body_data('baseUrl');
34
var file_path = utils.get_body_data('filePath');
35
var config = new configmod.ConfigSection('edit', {base_url: base_url});
36
config.load();
37
var common_config = new configmod.ConfigSection('common', {base_url: base_url});
38
common_config.load();
39
contents = new contents.Contents({
40
base_url: base_url,
41
common_config: common_config
42
});
43
44
var editor = new editmod.Editor('#texteditor-container', {
45
base_url: base_url,
46
events: events,
47
contents: contents,
48
file_path: file_path,
49
config: config,
50
});
51
52
// Make it available for debugging
53
IPython.editor = editor;
54
55
var save_widget = new savewidget.SaveWidget('span#save_widget', {
56
editor: editor,
57
events: events,
58
});
59
60
var menus = new menubar.MenuBar('#menubar', {
61
base_url: base_url,
62
editor: editor,
63
events: events,
64
save_widget: save_widget,
65
});
66
67
var notification_area = new notificationarea.EditorNotificationArea(
68
'#notification_area', {
69
events: events,
70
});
71
editor.notification_area = notification_area;
72
notification_area.init_notification_widgets();
73
74
utils.load_extensions_from_config(config);
75
utils.load_extensions_from_config(common_config);
76
editor.load();
77
page.show();
78
79
window.onbeforeunload = function () {
80
if (editor.save_enabled && !editor.codemirror.isClean(editor.generation)) {
81
return "Unsaved changes will be lost. Close anyway?";
82
}
83
};
84
85
// Make sure the codemirror editor is sized appropriatley.
86
var _handle_resize = function() {
87
var backdrop = $("#texteditor-backdrop");
88
89
// account for padding on the backdrop wrapper
90
var padding = backdrop.outerHeight(true) - backdrop.height();
91
$('div.CodeMirror').height($("#site").height() - padding);
92
};
93
$(window).resize(_handle_resize);
94
95
// On document ready, resize codemirror.
96
$(document).ready(_handle_resize);
97
});
98
99