notebookmain.js
117 lines
| 4.8 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 () { | ||||
MinRK
|
r5557 | if (window.MathJax){ | ||
// MathJax loaded | ||||
MinRK
|
r5547 | MathJax.Hub.Config({ | ||
tex2jax: { | ||||
inlineMath: [ ['$','$'], ["\\(","\\)"] ], | ||||
displayMath: [ ['$$','$$'], ["\\[","\\]"] ] | ||||
}, | ||||
displayAlign: 'left', // Change this to 'center' to center equations. | ||||
"HTML-CSS": { | ||||
styles: {'.MathJax_Display': {"margin": 0}} | ||||
} | ||||
}); | ||||
MinRK
|
r5557 | }else if (window.mathjax_url != ""){ | ||
// Don't have MathJax, but should. Show dialog. | ||||
var dialog = $('<div></div>') | ||||
.append( | ||||
$("<p></p>").addClass('dialog').html( | ||||
MinRK
|
r5568 | "Math/LaTeX rendering will be disabled." | ||
MinRK
|
r5557 | ) | ||
).append( | ||||
$("<p></p>").addClass('dialog').html( | ||||
MinRK
|
r5568 | "If you have administrative access to the notebook server and" + | ||
" a working internet connection, you can install a local copy" + | ||||
" of MathJax for offline use with the following command on the server" + | ||||
" at a Python or IPython prompt:" | ||||
MinRK
|
r5557 | ) | ||
).append( | ||||
$("<pre></pre>").addClass('dialog').html( | ||||
">>> from IPython.external import mathjax; mathjax.install_mathjax()" | ||||
) | ||||
).append( | ||||
$("<p></p>").addClass('dialog').html( | ||||
MinRK
|
r5568 | "This will try to install MathJax into the IPython source directory." | ||
) | ||||
).append( | ||||
$("<p></p>").addClass('dialog').html( | ||||
"If IPython is installed to a location that requires" + | ||||
" administrative privileges to write, you will need to make this call as" + | ||||
MinRK
|
r5557 | " an administrator, via 'sudo'." | ||
) | ||||
).append( | ||||
$("<p></p>").addClass('dialog').html( | ||||
MinRK
|
r5568 | "When you start the notebook server, you can instruct it to disable MathJax support altogether:" | ||
MinRK
|
r5557 | ) | ||
).append( | ||||
$("<pre></pre>").addClass('dialog').html( | ||||
"$ ipython notebook --no-mathjax" | ||||
) | ||||
).append( | ||||
$("<p></p>").addClass('dialog').html( | ||||
"which will prevent this dialog from appearing." | ||||
) | ||||
).dialog({ | ||||
title: "Failed to retrieve MathJax from '" + window.mathjax_url + "'", | ||||
width: "70%", | ||||
modal: true, | ||||
}) | ||||
MinRK
|
r5547 | }else{ | ||
MinRK
|
r5557 | // No MathJax, but none expected. No dialog. | ||
MinRK
|
r5547 | } | ||
Brian Granger
|
r5904 | |||
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
|
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'); | ||
Brian E. Granger
|
r4363 | IPython.notebook = new IPython.Notebook('div#notebook'); | ||
Brian E. Granger
|
r4372 | IPython.kernel_status_widget = new IPython.KernelStatusWidget('#kernel_status'); | ||
Brian Granger
|
r5857 | IPython.menubar = new IPython.MenuBar('#menubar') | ||
Brian Granger
|
r5993 | IPython.toolbar = new IPython.ToolBar('#toolbar') | ||
Brian E. Granger
|
r4372 | 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 | ||||
Matthias BUSSONNIER
|
r5655 | $('div#pager').remove(); | ||
$('div#pager_splitter').remove(); | ||||
MinRK
|
r5213 | $('span#login_widget').removeClass('hidden'); | ||
Matthias BUSSONNIER
|
r5659 | |||
// set the notebook name field as not modifiable | ||||
$('#notebook_name').attr('disabled','disabled') | ||||
MinRK
|
r5213 | } | ||
Brian Granger
|
r5904 | $('div#menubar').css('display','block'); | ||
Brian Granger
|
r5993 | $('div#toolbar').css('display','block'); | ||
Brian E. Granger
|
r4488 | $('div#main_app').css('display','block'); | ||
Brian E. Granger
|
r4484 | |||
Brian Granger
|
r5949 | IPython.layout_manager.do_resize(); | ||
IPython.notebook.load_notebook(); | ||||
Brian E. Granger
|
r4488 | |||
Brian E. Granger
|
r4349 | }); | ||