##// END OF EJS Templates
Use longer version of document.ready
Jonathan Frederic -
Show More
@@ -1,97 +1,97
1 1 // Copyright (c) IPython Development Team.
2 2 // Distributed under the terms of the Modified BSD License.
3 3
4 4 require([
5 5 'jquery',
6 6 'base/js/namespace',
7 7 'base/js/utils',
8 8 'base/js/page',
9 9 'base/js/events',
10 10 'contents',
11 11 'services/config',
12 12 'edit/js/editor',
13 13 'edit/js/menubar',
14 14 'edit/js/savewidget',
15 15 'edit/js/notificationarea',
16 16 'custom/custom',
17 17 ], function(
18 18 $,
19 19 IPython,
20 20 utils,
21 21 page,
22 22 events,
23 23 contents,
24 24 configmod,
25 25 editmod,
26 26 menubar,
27 27 savewidget,
28 28 notificationarea
29 29 ){
30 30 page = new page.Page();
31 31
32 32 var base_url = utils.get_body_data('baseUrl');
33 33 var file_path = utils.get_body_data('filePath');
34 34 contents = new contents.Contents({base_url: base_url});
35 35 var config = new configmod.ConfigSection('edit', {base_url: base_url});
36 36 config.load();
37 37 var common_config = new configmod.ConfigSection('common', {base_url: base_url});
38 38 common_config.load();
39 39
40 40 var editor = new editmod.Editor('#texteditor-container', {
41 41 base_url: base_url,
42 42 events: events,
43 43 contents: contents,
44 44 file_path: file_path,
45 45 config: config,
46 46 });
47 47
48 48 // Make it available for debugging
49 49 IPython.editor = editor;
50 50
51 51 var save_widget = new savewidget.SaveWidget('span#save_widget', {
52 52 editor: editor,
53 53 events: events,
54 54 });
55 55
56 56 var menus = new menubar.MenuBar('#menubar', {
57 57 base_url: base_url,
58 58 editor: editor,
59 59 events: events,
60 60 save_widget: save_widget,
61 61 });
62 62
63 63 var notification_area = new notificationarea.EditorNotificationArea(
64 64 '#notification_area', {
65 65 events: events,
66 66 });
67 67 notification_area.init_notification_widgets();
68 68
69 69 utils.load_extensions_from_config(config);
70 70 utils.load_extensions_from_config(common_config);
71 71 editor.load();
72 72 page.show();
73 73
74 74 window.onbeforeunload = function () {
75 75 if (editor.save_enabled && !editor.codemirror.isClean(editor.generation)) {
76 76 return "Unsaved changes will be lost. Close anyway?";
77 77 }
78 78 };
79 79
80 80 // Make sure the codemirror editor is sized appropriatley.
81 81 var _handle_resize = function() {
82 82 var header = $('#header');
83 83
84 84 // The header doesn't have a margin or padding above it. Calculate
85 85 // the lower margin&padding by subtracting the innerHeight from the
86 86 // outerHeight.
87 87 var header_margin_bottom = header.outerHeight(true) - header.innerHeight();
88 88
89 89 // When scaling CodeMirror, subtract the header lower margin from the
90 90 // height twice. Once for top padding and once for bottom padding.
91 91 $('div.CodeMirror').height(window.innerHeight - header.height() - 2*header_margin_bottom);
92 92 };
93 93 window.onresize = _handle_resize;
94 94
95 95 // On document ready, resize codemirror.
96 $(_handle_resize);
96 $(document).ready(_handle_resize);
97 97 });
General Comments 0
You need to be logged in to leave comments. Login now