main.js
73 lines
| 1.9 KiB
| application/javascript
|
JavascriptLexer
|
r19010 | // Copyright (c) IPython Development Team. | ||
// Distributed under the terms of the Modified BSD License. | ||||
require([ | ||||
|
r19013 | 'base/js/namespace', | ||
|
r19010 | 'base/js/utils', | ||
'base/js/page', | ||||
|
r19012 | 'base/js/events', | ||
|
r19011 | 'contents', | ||
|
r19082 | 'services/config', | ||
|
r19074 | 'edit/js/editor', | ||
'edit/js/menubar', | ||||
'edit/js/notificationarea', | ||||
|
r19010 | 'custom/custom', | ||
], function( | ||||
|
r19013 | IPython, | ||
|
r19010 | utils, | ||
page, | ||||
|
r19012 | events, | ||
|
r19011 | contents, | ||
|
r19082 | configmod, | ||
|
r19304 | editmod, | ||
|
r19017 | menubar, | ||
notificationarea | ||||
|
r19010 | ){ | ||
page = new page.Page(); | ||||
var base_url = utils.get_body_data('baseUrl'); | ||||
|
r19011 | var file_path = utils.get_body_data('filePath'); | ||
|
r19013 | contents = new contents.Contents({base_url: base_url}); | ||
|
r19304 | var config = new configmod.ConfigSection('edit', {base_url: base_url}); | ||
|
r19082 | config.load(); | ||
|
r19013 | |||
|
r19304 | var editor = new editmod.Editor('#texteditor-container', { | ||
|
r19013 | base_url: base_url, | ||
events: events, | ||||
contents: contents, | ||||
file_path: file_path, | ||||
|
r19303 | config: config, | ||
|
r19011 | }); | ||
|
r19013 | |||
// Make it available for debugging | ||||
IPython.editor = editor; | ||||
var menus = new menubar.MenuBar('#menubar', { | ||||
base_url: base_url, | ||||
editor: editor, | ||||
|
r19303 | events: events, | ||
|
r19013 | }); | ||
|
r19017 | |||
var notification_area = new notificationarea.EditorNotificationArea( | ||||
'#notification_area', { | ||||
events: events, | ||||
}); | ||||
notification_area.init_notification_widgets(); | ||||
|
r19013 | |||
|
r19082 | config.loaded.then(function() { | ||
if (config.data.load_extensions) { | ||||
var nbextension_paths = Object.getOwnPropertyNames( | ||||
config.data.load_extensions); | ||||
IPython.load_extensions.apply(this, nbextension_paths); | ||||
} | ||||
}); | ||||
|
r19013 | editor.load(); | ||
page.show(); | ||||
|
r19304 | |||
window.onbeforeunload = function () { | ||||
if (!editor.codemirror.isClean(editor.generation)) { | ||||
return "Unsaved changes will be lost. Close anyway?"; | ||||
} | ||||
}; | ||||
|
r19010 | }); | ||