##// END OF EJS Templates
move utils.io.atomic_writing to contents.fileio
move utils.io.atomic_writing to contents.fileio

File last commit:

r20425:c45162aa
r21113:348b2930
Show More
main.js
97 lines | 2.6 KiB | application/javascript | JavascriptLexer
Thomas Kluyver
Basic infrastructure for new texteditor component
r19010 // Copyright (c) IPython Development Team.
// Distributed under the terms of the Modified BSD License.
require([
Jonathan Frederic
Explicitly size codemirror editor in Edit app
r20063 'jquery',
Thomas Kluyver
Refactor editor into Editor class
r19013 'base/js/namespace',
Thomas Kluyver
Basic infrastructure for new texteditor component
r19010 'base/js/utils',
'base/js/page',
Thomas Kluyver
Saving files works
r19012 'base/js/events',
Thomas Kluyver
Loading a file works
r19011 'contents',
Thomas Kluyver
Extensions config for text editor
r19082 'services/config',
Thomas Kluyver
Rename texteditor files & folders to edit
r19074 'edit/js/editor',
'edit/js/menubar',
Min RK
add save widget to text editor
r19316 'edit/js/savewidget',
Thomas Kluyver
Rename texteditor files & folders to edit
r19074 'edit/js/notificationarea',
Thomas Kluyver
Basic infrastructure for new texteditor component
r19010 'custom/custom',
], function(
Jonathan Frederic
Explicitly size codemirror editor in Edit app
r20063 $,
Thomas Kluyver
Refactor editor into Editor class
r19013 IPython,
Thomas Kluyver
Basic infrastructure for new texteditor component
r19010 utils,
page,
Thomas Kluyver
Saving files works
r19012 events,
Thomas Kluyver
Loading a file works
r19011 contents,
Thomas Kluyver
Extensions config for text editor
r19082 configmod,
Min RK
track dirty state in editor for onbeforeunload
r19304 editmod,
Thomas Kluyver
Use NotificationArea in the text editor
r19017 menubar,
Min RK
add save widget to text editor
r19316 savewidget,
Thomas Kluyver
Use NotificationArea in the text editor
r19017 notificationarea
Thomas Kluyver
Basic infrastructure for new texteditor component
r19010 ){
Matthias Bussonnier
Pass common_config to content manager.
r20425 "use strict";
Thomas Kluyver
Basic infrastructure for new texteditor component
r19010 page = new page.Page();
var base_url = utils.get_body_data('baseUrl');
Thomas Kluyver
Loading a file works
r19011 var file_path = utils.get_body_data('filePath');
Min RK
track dirty state in editor for onbeforeunload
r19304 var config = new configmod.ConfigSection('edit', {base_url: base_url});
Thomas Kluyver
Extensions config for text editor
r19082 config.load();
Thomas Kluyver
Fix instantiating config in editor and terminal
r19635 var common_config = new configmod.ConfigSection('common', {base_url: base_url});
Thomas Kluyver
Load common_config, and load extensions specified therein
r19633 common_config.load();
Matthias Bussonnier
Pass common_config to content manager.
r20425 contents = new contents.Contents({
base_url: base_url,
common_config: common_config
});
Thomas Kluyver
Refactor editor into Editor class
r19013
Min RK
track dirty state in editor for onbeforeunload
r19304 var editor = new editmod.Editor('#texteditor-container', {
Thomas Kluyver
Refactor editor into Editor class
r19013 base_url: base_url,
events: events,
contents: contents,
file_path: file_path,
Min RK
editor progress...
r19303 config: config,
Thomas Kluyver
Loading a file works
r19011 });
Thomas Kluyver
Refactor editor into Editor class
r19013
// Make it available for debugging
IPython.editor = editor;
Min RK
add File/Rename
r19317 var save_widget = new savewidget.SaveWidget('span#save_widget', {
Thomas Kluyver
Refactor editor into Editor class
r19013 editor: editor,
Min RK
editor progress...
r19303 events: events,
Thomas Kluyver
Refactor editor into Editor class
r19013 });
Thomas Kluyver
Use NotificationArea in the text editor
r19017
Min RK
add File/Rename
r19317 var menus = new menubar.MenuBar('#menubar', {
base_url: base_url,
Min RK
add save widget to text editor
r19316 editor: editor,
events: events,
Min RK
add File/Rename
r19317 save_widget: save_widget,
Min RK
add save widget to text editor
r19316 });
Thomas Kluyver
Use NotificationArea in the text editor
r19017 var notification_area = new notificationarea.EditorNotificationArea(
'#notification_area', {
events: events,
});
Bussonnier Matthias
re-hook notification area for editor....
r20149 editor.notification_area = notification_area;
Thomas Kluyver
Use NotificationArea in the text editor
r19017 notification_area.init_notification_widgets();
Thomas Kluyver
Refactor editor into Editor class
r19013
Thomas Kluyver
Load common_config, and load extensions specified therein
r19633 utils.load_extensions_from_config(config);
utils.load_extensions_from_config(common_config);
Thomas Kluyver
Refactor editor into Editor class
r19013 editor.load();
page.show();
Min RK
track dirty state in editor for onbeforeunload
r19304
window.onbeforeunload = function () {
Min RK
redirect /edit/ to /files/ if not (utf8) text
r19337 if (editor.save_enabled && !editor.codemirror.isClean(editor.generation)) {
Min RK
track dirty state in editor for onbeforeunload
r19304 return "Unsaved changes will be lost. Close anyway?";
}
};
Jonathan Frederic
Explicitly size codemirror editor in Edit app
r20063 // Make sure the codemirror editor is sized appropriatley.
var _handle_resize = function() {
Min RK
fix CodeMirror div measurement on edit page...
r20167 var backdrop = $("#texteditor-backdrop");
Jonathan Frederic
Be a little more clear about sizing logic.
r20070
Min RK
fix CodeMirror div measurement on edit page...
r20167 // account for padding on the backdrop wrapper
var padding = backdrop.outerHeight(true) - backdrop.height();
$('div.CodeMirror').height($("#site").height() - padding);
Jonathan Frederic
Explicitly size codemirror editor in Edit app
r20063 };
Min RK
don't use flexbox to size `#site`...
r20107 $(window).resize(_handle_resize);
Jonathan Frederic
Explicitly size codemirror editor in Edit app
r20063
// On document ready, resize codemirror.
Jonathan Frederic
Use longer version of document.ready
r20086 $(document).ready(_handle_resize);
Thomas Kluyver
Basic infrastructure for new texteditor component
r19010 });