Show More
@@ -1,78 +1,90 b'' | |||||
1 | // Copyright (c) IPython Development Team. |
|
1 | // Copyright (c) IPython Development Team. | |
2 | // Distributed under the terms of the Modified BSD License. |
|
2 | // Distributed under the terms of the Modified BSD License. | |
3 |
|
3 | |||
4 | require([ |
|
4 | require([ | |
|
5 | 'jquery', | |||
5 | 'base/js/namespace', |
|
6 | 'base/js/namespace', | |
6 | 'base/js/utils', |
|
7 | 'base/js/utils', | |
7 | 'base/js/page', |
|
8 | 'base/js/page', | |
8 | 'base/js/events', |
|
9 | 'base/js/events', | |
9 | 'contents', |
|
10 | 'contents', | |
10 | 'services/config', |
|
11 | 'services/config', | |
11 | 'edit/js/editor', |
|
12 | 'edit/js/editor', | |
12 | 'edit/js/menubar', |
|
13 | 'edit/js/menubar', | |
13 | 'edit/js/savewidget', |
|
14 | 'edit/js/savewidget', | |
14 | 'edit/js/notificationarea', |
|
15 | 'edit/js/notificationarea', | |
15 | 'custom/custom', |
|
16 | 'custom/custom', | |
16 | ], function( |
|
17 | ], function( | |
|
18 | $, | |||
17 | IPython, |
|
19 | IPython, | |
18 | utils, |
|
20 | utils, | |
19 | page, |
|
21 | page, | |
20 | events, |
|
22 | events, | |
21 | contents, |
|
23 | contents, | |
22 | configmod, |
|
24 | configmod, | |
23 | editmod, |
|
25 | editmod, | |
24 | menubar, |
|
26 | menubar, | |
25 | savewidget, |
|
27 | savewidget, | |
26 | notificationarea |
|
28 | notificationarea | |
27 | ){ |
|
29 | ){ | |
28 | page = new page.Page(); |
|
30 | page = new page.Page(); | |
29 |
|
31 | |||
30 | var base_url = utils.get_body_data('baseUrl'); |
|
32 | var base_url = utils.get_body_data('baseUrl'); | |
31 | var file_path = utils.get_body_data('filePath'); |
|
33 | var file_path = utils.get_body_data('filePath'); | |
32 | contents = new contents.Contents({base_url: base_url}); |
|
34 | contents = new contents.Contents({base_url: base_url}); | |
33 | var config = new configmod.ConfigSection('edit', {base_url: base_url}); |
|
35 | var config = new configmod.ConfigSection('edit', {base_url: base_url}); | |
34 | config.load(); |
|
36 | config.load(); | |
35 | var common_config = new configmod.ConfigSection('common', {base_url: base_url}); |
|
37 | var common_config = new configmod.ConfigSection('common', {base_url: base_url}); | |
36 | common_config.load(); |
|
38 | common_config.load(); | |
37 |
|
39 | |||
38 | var editor = new editmod.Editor('#texteditor-container', { |
|
40 | var editor = new editmod.Editor('#texteditor-container', { | |
39 | base_url: base_url, |
|
41 | base_url: base_url, | |
40 | events: events, |
|
42 | events: events, | |
41 | contents: contents, |
|
43 | contents: contents, | |
42 | file_path: file_path, |
|
44 | file_path: file_path, | |
43 | config: config, |
|
45 | config: config, | |
44 | }); |
|
46 | }); | |
45 |
|
47 | |||
46 | // Make it available for debugging |
|
48 | // Make it available for debugging | |
47 | IPython.editor = editor; |
|
49 | IPython.editor = editor; | |
48 |
|
50 | |||
49 | var save_widget = new savewidget.SaveWidget('span#save_widget', { |
|
51 | var save_widget = new savewidget.SaveWidget('span#save_widget', { | |
50 | editor: editor, |
|
52 | editor: editor, | |
51 | events: events, |
|
53 | events: events, | |
52 | }); |
|
54 | }); | |
53 |
|
55 | |||
54 | var menus = new menubar.MenuBar('#menubar', { |
|
56 | var menus = new menubar.MenuBar('#menubar', { | |
55 | base_url: base_url, |
|
57 | base_url: base_url, | |
56 | editor: editor, |
|
58 | editor: editor, | |
57 | events: events, |
|
59 | events: events, | |
58 | save_widget: save_widget, |
|
60 | save_widget: save_widget, | |
59 | }); |
|
61 | }); | |
60 |
|
62 | |||
61 | var notification_area = new notificationarea.EditorNotificationArea( |
|
63 | var notification_area = new notificationarea.EditorNotificationArea( | |
62 | '#notification_area', { |
|
64 | '#notification_area', { | |
63 | events: events, |
|
65 | events: events, | |
64 | }); |
|
66 | }); | |
65 | notification_area.init_notification_widgets(); |
|
67 | notification_area.init_notification_widgets(); | |
66 |
|
68 | |||
67 | utils.load_extensions_from_config(config); |
|
69 | utils.load_extensions_from_config(config); | |
68 | utils.load_extensions_from_config(common_config); |
|
70 | utils.load_extensions_from_config(common_config); | |
69 | editor.load(); |
|
71 | editor.load(); | |
70 | page.show(); |
|
72 | page.show(); | |
71 |
|
73 | |||
72 | window.onbeforeunload = function () { |
|
74 | window.onbeforeunload = function () { | |
73 | if (editor.save_enabled && !editor.codemirror.isClean(editor.generation)) { |
|
75 | if (editor.save_enabled && !editor.codemirror.isClean(editor.generation)) { | |
74 | return "Unsaved changes will be lost. Close anyway?"; |
|
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