main.js
142 lines
| 4.6 KiB
| application/javascript
|
JavascriptLexer
|
r17192 | // Copyright (c) IPython Development Team. | ||
// Distributed under the terms of the Modified BSD License. | ||||
|
r4349 | |||
|
r17192 | require([ | ||
'base/js/namespace', | ||||
|
r17200 | 'jquery', | ||
|
r17192 | 'notebook/js/notebook', | ||
'base/js/utils', | ||||
'base/js/page', | ||||
'notebook/js/layoutmanager', | ||||
'base/js/events', | ||||
'auth/js/loginwidget', | ||||
'notebook/js/maintoolbar', | ||||
'notebook/js/pager', | ||||
'notebook/js/quickhelp', | ||||
'notebook/js/menubar', | ||||
'notebook/js/notificationarea', | ||||
|
r17198 | 'notebook/js/savewidget', | ||
|
r17197 | 'notebook/js/keyboardmanager', | ||
|
r17200 | 'notebook/js/config', | ||
|
r17370 | 'notebook/js/kernelselector', | ||
|
r17323 | // only loaded, not used: | ||
|
r17319 | 'custom/custom', | ||
|
r17192 | ], function( | ||
IPython, | ||||
|
r17196 | $, | ||
|
r17203 | notebook, | ||
|
r17198 | utils, | ||
|
r17203 | page, | ||
layoutmanager, | ||||
events, | ||||
loginwidget, | ||||
maintoolbar, | ||||
pager, | ||||
quickhelp, | ||||
menubar, | ||||
notificationarea, | ||||
savewidget, | ||||
keyboardmanager, | ||||
|
r17370 | config, | ||
kernelselector | ||||
|
r17192 | ) { | ||
|
r15234 | "use strict"; | ||
|
r10758 | |||
|
r9277 | $('#ipython-main-app').addClass('border-box-sizing'); | ||
$('div#notebook_panel').addClass('border-box-sizing'); | ||||
|
r4349 | |||
|
r17210 | var common_options = { | ||
|
r17198 | base_url : utils.get_body_data("baseUrl"), | ||
|
r17303 | ws_url : IPython.utils.get_body_data("wsUrl"), | ||
|
r17198 | notebook_path : utils.get_body_data("notebookPath"), | ||
notebook_name : utils.get_body_data('notebookName') | ||||
|
r15234 | }; | ||
|
r9505 | |||
|
r17200 | var user_config = $.extend({}, config.default_config); | ||
|
r17202 | var page = new page.Page(); | ||
var layout_manager = new layoutmanager.LayoutManager(); | ||||
|
r17210 | var pager = new pager.Pager('div#pager', 'div#pager_splitter', { | ||
layout_manager: layout_manager, | ||||
events: events}); | ||||
var keyboard_manager = new keyboardmanager.KeyboardManager({ | ||||
pager: pager, | ||||
events: events}); | ||||
|
r17213 | var save_widget = new savewidget.SaveWidget('span#save_widget', { | ||
events: events, | ||||
keyboard_manager: keyboard_manager}); | ||||
|
r17210 | var notebook = new notebook.Notebook('div#notebook', $.extend({ | ||
events: events, | ||||
keyboard_manager: keyboard_manager, | ||||
save_widget: save_widget, | ||||
config: user_config}, | ||||
common_options)); | ||||
var login_widget = new loginwidget.LoginWidget('span#login_widget', common_options); | ||||
var toolbar = new maintoolbar.MainToolBar('#maintoolbar-container', { | ||||
notebook: notebook, | ||||
events: events}); | ||||
var quick_help = new quickhelp.QuickHelp({ | ||||
keyboard_manager: keyboard_manager, | ||||
|
r17212 | events: events, | ||
notebook: notebook}); | ||||
|
r17210 | var menubar = new menubar.MenuBar('#menubar', $.extend({ | ||
notebook: notebook, | ||||
layout_manager: layout_manager, | ||||
events: events, | ||||
save_widget: save_widget, | ||||
quick_help: quick_help}, | ||||
common_options)); | ||||
var notification_area = new notificationarea.NotificationArea( | ||||
'#notification_area', { | ||||
events: events, | ||||
save_widget: save_widget, | ||||
|
r17212 | notebook: notebook, | ||
keyboard_manager: keyboard_manager}); | ||||
|
r17192 | notification_area.init_notification_widgets(); | ||
|
r17370 | var kernel_selector = new kernelselector.KernelSelector( | ||
'#kernel_selector_widget', notebook); | ||||
|
r17192 | |||
|
r7394 | $('body').append('<div id="fonttest"><pre><span id="test1">x</span>'+ | ||
'<span id="test2" style="font-weight: bold;">x</span>'+ | ||||
|
r15234 | '<span id="test3" style="font-style: italic;">x</span></pre></div>'); | ||
|
r7394 | var nh = $('#test1').innerHeight(); | ||
var bh = $('#test2').innerHeight(); | ||||
var ih = $('#test3').innerHeight(); | ||||
if(nh != bh || nh != ih) { | ||||
|
r7446 | $('head').append('<style>.CodeMirror span { vertical-align: bottom; }</style>'); | ||
|
r7394 | } | ||
|
r7666 | $('#fonttest').remove(); | ||
|
r7394 | |||
|
r17192 | page.show(); | ||
|
r4484 | |||
|
r17192 | layout_manager.do_resize(); | ||
|
r10505 | var first_load = function () { | ||
|
r17192 | layout_manager.do_resize(); | ||
|
r10006 | var hash = document.location.hash; | ||
if (hash) { | ||||
document.location.hash = ''; | ||||
document.location.hash = hash; | ||||
} | ||||
|
r17192 | notebook.set_autosave_interval(notebook.minimum_autosave_interval); | ||
|
r10505 | // only do this once | ||
|
r17195 | events.off('notebook_loaded.Notebook', first_load); | ||
|
r10505 | }; | ||
|
r17195 | events.on('notebook_loaded.Notebook', first_load); | ||
|
r17319 | |||
|
r17212 | IPython.page = page; | ||
IPython.layout_manager = layout_manager; | ||||
IPython.notebook = notebook; | ||||
IPython.pager = pager; | ||||
IPython.quick_help = quick_help; | ||||
IPython.login_widget = login_widget; | ||||
IPython.menubar = menubar; | ||||
IPython.toolbar = toolbar; | ||||
IPython.notification_area = notification_area; | ||||
IPython.keyboard_manager = keyboard_manager; | ||||
IPython.save_widget = save_widget; | ||||
IPython.config = user_config; | ||||
|
r17215 | IPython.tooltip = notebook.tooltip; | ||
|
r17319 | |||
events.trigger('app_initialized.NotebookApp'); | ||||
notebook.load_notebook(common_options.notebook_name, common_options.notebook_path); | ||||
|
r15234 | }); | ||