main.js
81 lines
| 2.1 KiB
| application/javascript
|
JavascriptLexer
Thomas Kluyver
|
r19010 | // Copyright (c) IPython Development Team. | ||
// Distributed under the terms of the Modified BSD License. | ||||
require([ | ||||
Thomas Kluyver
|
r19013 | 'base/js/namespace', | ||
Thomas Kluyver
|
r19010 | 'base/js/utils', | ||
'base/js/page', | ||||
Thomas Kluyver
|
r19012 | 'base/js/events', | ||
Thomas Kluyver
|
r19011 | 'contents', | ||
Thomas Kluyver
|
r19082 | 'services/config', | ||
Thomas Kluyver
|
r19074 | 'edit/js/editor', | ||
'edit/js/menubar', | ||||
Min RK
|
r19316 | 'edit/js/savewidget', | ||
Thomas Kluyver
|
r19074 | 'edit/js/notificationarea', | ||
Thomas Kluyver
|
r19010 | 'custom/custom', | ||
], function( | ||||
Thomas Kluyver
|
r19013 | IPython, | ||
Thomas Kluyver
|
r19010 | utils, | ||
page, | ||||
Thomas Kluyver
|
r19012 | events, | ||
Thomas Kluyver
|
r19011 | contents, | ||
Thomas Kluyver
|
r19082 | configmod, | ||
Min RK
|
r19304 | editmod, | ||
Thomas Kluyver
|
r19017 | menubar, | ||
Min RK
|
r19316 | savewidget, | ||
Thomas Kluyver
|
r19017 | notificationarea | ||
Thomas Kluyver
|
r19010 | ){ | ||
page = new page.Page(); | ||||
var base_url = utils.get_body_data('baseUrl'); | ||||
Thomas Kluyver
|
r19011 | var file_path = utils.get_body_data('filePath'); | ||
Thomas Kluyver
|
r19013 | contents = new contents.Contents({base_url: base_url}); | ||
Min RK
|
r19304 | var config = new configmod.ConfigSection('edit', {base_url: base_url}); | ||
Thomas Kluyver
|
r19082 | config.load(); | ||
Thomas Kluyver
|
r19013 | |||
Min RK
|
r19304 | var editor = new editmod.Editor('#texteditor-container', { | ||
Thomas Kluyver
|
r19013 | base_url: base_url, | ||
events: events, | ||||
contents: contents, | ||||
file_path: file_path, | ||||
Min RK
|
r19303 | config: config, | ||
Thomas Kluyver
|
r19011 | }); | ||
Thomas Kluyver
|
r19013 | |||
// Make it available for debugging | ||||
IPython.editor = editor; | ||||
Min RK
|
r19317 | var save_widget = new savewidget.SaveWidget('span#save_widget', { | ||
Thomas Kluyver
|
r19013 | editor: editor, | ||
Min RK
|
r19303 | events: events, | ||
Thomas Kluyver
|
r19013 | }); | ||
Thomas Kluyver
|
r19017 | |||
Min RK
|
r19317 | var menus = new menubar.MenuBar('#menubar', { | ||
base_url: base_url, | ||||
Min RK
|
r19316 | editor: editor, | ||
events: events, | ||||
Min RK
|
r19317 | save_widget: save_widget, | ||
Min RK
|
r19316 | }); | ||
Thomas Kluyver
|
r19017 | var notification_area = new notificationarea.EditorNotificationArea( | ||
'#notification_area', { | ||||
events: events, | ||||
}); | ||||
notification_area.init_notification_widgets(); | ||||
Thomas Kluyver
|
r19013 | |||
Thomas Kluyver
|
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); | ||||
} | ||||
}); | ||||
Thomas Kluyver
|
r19013 | editor.load(); | ||
page.show(); | ||||
Min RK
|
r19304 | |||
window.onbeforeunload = function () { | ||||
if (!editor.codemirror.isClean(editor.generation)) { | ||||
return "Unsaved changes will be lost. Close anyway?"; | ||||
} | ||||
}; | ||||
Thomas Kluyver
|
r19010 | }); | ||