##// END OF EJS Templates
pass config to contentsManager
Bussonnier Matthias -
Show More
@@ -1,162 +1,162 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 5 'base/js/namespace',
6 6 'jquery',
7 7 'notebook/js/notebook',
8 8 'contents',
9 9 'services/config',
10 10 'base/js/utils',
11 11 'base/js/page',
12 12 'base/js/events',
13 13 'auth/js/loginwidget',
14 14 'notebook/js/maintoolbar',
15 15 'notebook/js/pager',
16 16 'notebook/js/quickhelp',
17 17 'notebook/js/menubar',
18 18 'notebook/js/notificationarea',
19 19 'notebook/js/savewidget',
20 20 'notebook/js/actions',
21 21 'notebook/js/keyboardmanager',
22 22 'notebook/js/kernelselector',
23 23 'codemirror/lib/codemirror',
24 24 'notebook/js/about',
25 25 // only loaded, not used, please keep sure this is loaded last
26 26 'custom/custom'
27 27 ], function(
28 28 IPython,
29 29 $,
30 30 notebook,
31 31 contents,
32 32 configmod,
33 33 utils,
34 34 page,
35 35 events,
36 36 loginwidget,
37 37 maintoolbar,
38 38 pager,
39 39 quickhelp,
40 40 menubar,
41 41 notificationarea,
42 42 savewidget,
43 43 actions,
44 44 keyboardmanager,
45 45 kernelselector,
46 46 CodeMirror,
47 47 about,
48 48 // please keep sure that even if not used, this is loaded last
49 49 custom
50 50 ) {
51 51 "use strict";
52 52
53 53 // compat with old IPython, remove for IPython > 3.0
54 54 window.CodeMirror = CodeMirror;
55 55
56 56 var common_options = {
57 57 ws_url : utils.get_body_data("wsUrl"),
58 58 base_url : utils.get_body_data("baseUrl"),
59 59 notebook_path : utils.get_body_data("notebookPath"),
60 60 notebook_name : utils.get_body_data('notebookName')
61 61 };
62 62
63 var config_section = new configmod.ConfigSection('notebook', common_options);
64 config_section.load();
63 65 var page = new page.Page();
64 66 var pager = new pager.Pager('div#pager', {
65 67 events: events});
66 68 var acts = new actions.init();
67 69 var keyboard_manager = new keyboardmanager.KeyboardManager({
68 70 pager: pager,
69 71 events: events,
70 72 actions: acts });
71 73 var save_widget = new savewidget.SaveWidget('span#save_widget', {
72 74 events: events,
73 75 keyboard_manager: keyboard_manager});
74 76 var contents = new contents.Contents($.extend({
75 events: events},
77 events: events, config:config_section},
76 78 common_options));
77 var config_section = new configmod.ConfigSection('notebook', common_options);
78 config_section.load();
79 79 var notebook = new notebook.Notebook('div#notebook', $.extend({
80 80 events: events,
81 81 keyboard_manager: keyboard_manager,
82 82 save_widget: save_widget,
83 83 contents: contents,
84 84 config: config_section},
85 85 common_options));
86 86 var login_widget = new loginwidget.LoginWidget('span#login_widget', common_options);
87 87 var toolbar = new maintoolbar.MainToolBar('#maintoolbar-container', {
88 88 notebook: notebook,
89 89 events: events,
90 90 actions: acts});
91 91 var quick_help = new quickhelp.QuickHelp({
92 92 keyboard_manager: keyboard_manager,
93 93 events: events,
94 94 notebook: notebook});
95 95 keyboard_manager.set_notebook(notebook);
96 96 keyboard_manager.set_quickhelp(quick_help);
97 97 var menubar = new menubar.MenuBar('#menubar', $.extend({
98 98 notebook: notebook,
99 99 contents: contents,
100 100 events: events,
101 101 save_widget: save_widget,
102 102 quick_help: quick_help},
103 103 common_options));
104 104 var notification_area = new notificationarea.NotebookNotificationArea(
105 105 '#notification_area', {
106 106 events: events,
107 107 save_widget: save_widget,
108 108 notebook: notebook,
109 109 keyboard_manager: keyboard_manager});
110 110 notification_area.init_notification_widgets();
111 111 var kernel_selector = new kernelselector.KernelSelector(
112 112 '#kernel_selector_widget', notebook);
113 113
114 114 $('body').append('<div id="fonttest"><pre><span id="test1">x</span>'+
115 115 '<span id="test2" style="font-weight: bold;">x</span>'+
116 116 '<span id="test3" style="font-style: italic;">x</span></pre></div>');
117 117 var nh = $('#test1').innerHeight();
118 118 var bh = $('#test2').innerHeight();
119 119 var ih = $('#test3').innerHeight();
120 120 if(nh != bh || nh != ih) {
121 121 $('head').append('<style>.CodeMirror span { vertical-align: bottom; }</style>');
122 122 }
123 123 $('#fonttest').remove();
124 124
125 125 page.show();
126 126
127 127 var first_load = function () {
128 128 var hash = document.location.hash;
129 129 if (hash) {
130 130 document.location.hash = '';
131 131 document.location.hash = hash;
132 132 }
133 133 notebook.set_autosave_interval(notebook.minimum_autosave_interval);
134 134 // only do this once
135 135 events.off('notebook_loaded.Notebook', first_load);
136 136 };
137 137 events.on('notebook_loaded.Notebook', first_load);
138 138
139 139 IPython.page = page;
140 140 IPython.notebook = notebook;
141 141 IPython.contents = contents;
142 142 IPython.pager = pager;
143 143 IPython.quick_help = quick_help;
144 144 IPython.login_widget = login_widget;
145 145 IPython.menubar = menubar;
146 146 IPython.toolbar = toolbar;
147 147 IPython.notification_area = notification_area;
148 148 IPython.keyboard_manager = keyboard_manager;
149 149 IPython.save_widget = save_widget;
150 150 IPython.tooltip = notebook.tooltip;
151 151
152 152 events.trigger('app_initialized.NotebookApp');
153 153 config_section.loaded.then(function() {
154 154 if (config_section.data.load_extensions) {
155 155 var nbextension_paths = Object.getOwnPropertyNames(
156 156 config_section.data.load_extensions);
157 157 IPython.load_extensions.apply(this, nbextension_paths);
158 158 }
159 159 });
160 160 notebook.load_notebook(common_options.notebook_path);
161 161
162 162 });
General Comments 0
You need to be logged in to leave comments. Login now