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