notebookmain.js
85 lines
| 3.7 KiB
| application/javascript
|
JavascriptLexer
Brian E. Granger
|
r4609 | //---------------------------------------------------------------------------- | ||
// Copyright (C) 2008-2011 The IPython Development Team | ||||
// | ||||
// Distributed under the terms of the BSD License. The full license is in | ||||
// the file COPYING, distributed as part of this software. | ||||
//---------------------------------------------------------------------------- | ||||
Brian E. Granger
|
r4349 | |||
//============================================================================ | ||||
// On document ready | ||||
//============================================================================ | ||||
$(document).ready(function () { | ||||
MathJax.Hub.Config({ | ||||
tex2jax: { | ||||
inlineMath: [ ['$','$'], ["\\(","\\)"] ], | ||||
displayMath: [ ['$$','$$'], ["\\[","\\]"] ], | ||||
}, | ||||
displayAlign: 'left', // Change this to 'center' to center equations. | ||||
"HTML-CSS": { | ||||
styles: {'.MathJax_Display': {"margin": 0}} | ||||
} | ||||
}); | ||||
Brian E. Granger
|
r4507 | IPython.markdown_converter = new Markdown.Converter(); | ||
MinRK
|
r5213 | IPython.read_only = $('meta[name=read_only]').attr("content") == 'True'; | ||
Brian E. Granger
|
r4349 | |||
Brian E. Granger
|
r4372 | $('div#header').addClass('border-box-sizing'); | ||
Brian E. Granger
|
r4488 | $('div#main_app').addClass('border-box-sizing ui-widget ui-widget-content'); | ||
Brian E. Granger
|
r4363 | $('div#notebook_panel').addClass('border-box-sizing ui-widget'); | ||
Brian E. Granger
|
r4349 | |||
Brian E. Granger
|
r4363 | IPython.layout_manager = new IPython.LayoutManager(); | ||
Brian E. Granger
|
r4357 | IPython.pager = new IPython.Pager('div#pager', 'div#pager_splitter'); | ||
Brian E. Granger
|
r4363 | IPython.left_panel = new IPython.LeftPanel('div#left_panel', 'div#left_panel_splitter'); | ||
Brian E. Granger
|
r4372 | IPython.save_widget = new IPython.SaveWidget('span#save_widget'); | ||
MinRK
|
r5066 | IPython.quick_help = new IPython.QuickHelp('span#quick_help_area'); | ||
MinRK
|
r5200 | IPython.login_widget = new IPython.LoginWidget('span#login_widget'); | ||
Stefan van der Walt
|
r4615 | IPython.print_widget = new IPython.PrintWidget('span#print_widget'); | ||
Brian E. Granger
|
r4363 | IPython.notebook = new IPython.Notebook('div#notebook'); | ||
Brian E. Granger
|
r4372 | IPython.kernel_status_widget = new IPython.KernelStatusWidget('#kernel_status'); | ||
IPython.kernel_status_widget.status_idle(); | ||||
Brian E. Granger
|
r4357 | |||
Brian E. Granger
|
r4379 | IPython.layout_manager.do_resize(); | ||
Brian E. Granger
|
r4395 | |||
// These have display: none in the css file and are made visible here to prevent FLOUC. | ||||
$('div#header').css('display','block'); | ||||
MinRK
|
r5213 | |||
if(IPython.read_only){ | ||||
// hide various elements from read-only view | ||||
IPython.save_widget.element.find('button#save_notebook').addClass('hidden'); | ||||
IPython.quick_help.element.addClass('hidden'); // shortcuts are disabled in read_only | ||||
$('button#new_notebook').addClass('hidden'); | ||||
$('div#cell_section').addClass('hidden'); | ||||
Matthias BUSSONNIER
|
r5399 | $('div#config_section').addClass('hidden'); | ||
MinRK
|
r5213 | $('div#kernel_section').addClass('hidden'); | ||
$('span#login_widget').removeClass('hidden'); | ||||
// left panel starts collapsed, but the collapse must happen after | ||||
// elements start drawing. Don't draw contents of the panel until | ||||
// after they are collapsed | ||||
IPython.left_panel.left_panel_element.css('visibility', 'hidden'); | ||||
} | ||||
Brian E. Granger
|
r4488 | $('div#main_app').css('display','block'); | ||
Brian E. Granger
|
r4484 | |||
// Perform these actions after the notebook has been loaded. | ||||
Brian E. Granger
|
r4488 | // We wait 100 milliseconds because the notebook scrolls to the top after a load | ||
// is completed and we need to wait for that to mostly finish. | ||||
IPython.notebook.load_notebook(function () { | ||||
setTimeout(function () { | ||||
IPython.save_widget.update_url(); | ||||
IPython.layout_manager.do_resize(); | ||||
IPython.pager.collapse(); | ||||
MinRK
|
r5213 | if(IPython.read_only){ | ||
// collapse the left panel on read-only | ||||
IPython.left_panel.collapse(); | ||||
// and finally unhide the panel contents after collapse | ||||
setTimeout(function(){ | ||||
IPython.left_panel.left_panel_element.css('visibility', 'visible'); | ||||
}, 200) | ||||
} | ||||
Brian E. Granger
|
r4488 | },100); | ||
}); | ||||
Brian E. Granger
|
r4349 | }); | ||