Show More
@@ -1,131 +1,135 b'' | |||
|
1 | 1 | //---------------------------------------------------------------------------- |
|
2 | 2 | // Copyright (C) 2008-2011 The IPython Development Team |
|
3 | 3 | // |
|
4 | 4 | // Distributed under the terms of the BSD License. The full license is in |
|
5 | 5 | // the file COPYING, distributed as part of this software. |
|
6 | 6 | //---------------------------------------------------------------------------- |
|
7 | 7 | |
|
8 | 8 | //============================================================================ |
|
9 | 9 | // On document ready |
|
10 | 10 | //============================================================================ |
|
11 | 11 | |
|
12 | 12 | |
|
13 | 13 | $(document).ready(function () { |
|
14 | 14 | if (window.MathJax){ |
|
15 | 15 | // MathJax loaded |
|
16 | 16 | MathJax.Hub.Config({ |
|
17 | 17 | tex2jax: { |
|
18 | 18 | inlineMath: [ ['$','$'], ["\\(","\\)"] ], |
|
19 | 19 | displayMath: [ ['$$','$$'], ["\\[","\\]"] ] |
|
20 | 20 | }, |
|
21 | 21 | displayAlign: 'left', // Change this to 'center' to center equations. |
|
22 | 22 | "HTML-CSS": { |
|
23 | 23 | styles: {'.MathJax_Display': {"margin": 0}} |
|
24 | 24 | } |
|
25 | 25 | }); |
|
26 | 26 | }else if (window.mathjax_url != ""){ |
|
27 | 27 | // Don't have MathJax, but should. Show dialog. |
|
28 | 28 | var dialog = $('<div></div>') |
|
29 | 29 | .append( |
|
30 | 30 | $("<p></p>").addClass('dialog').html( |
|
31 |
"Math/LaTeX |
|
|
31 | "Math/LaTeX rendering will be disabled." | |
|
32 | 32 | ) |
|
33 | 33 | ).append( |
|
34 | 34 | $("<p></p>").addClass('dialog').html( |
|
35 | "With a working internet connection, you can install a local copy" + | |
|
36 | " of MathJax for offline use with the following command at a Python" + | |
|
37 | " or IPython prompt:" | |
|
35 | "If you have administrative access to the notebook server and" + | |
|
36 | " a working internet connection, you can install a local copy" + | |
|
37 | " of MathJax for offline use with the following command on the server" + | |
|
38 | " at a Python or IPython prompt:" | |
|
38 | 39 | ) |
|
39 | 40 | ).append( |
|
40 | 41 | $("<pre></pre>").addClass('dialog').html( |
|
41 | 42 | ">>> from IPython.external import mathjax; mathjax.install_mathjax()" |
|
42 | 43 | ) |
|
43 | 44 | ).append( |
|
44 | 45 | $("<p></p>").addClass('dialog').html( |
|
45 |
"This will try to install MathJax into the directory |
|
|
46 | " IPython. If you installed IPython to a location that requires"+ | |
|
46 | "This will try to install MathJax into the IPython source directory." | |
|
47 | ) | |
|
48 | ).append( | |
|
49 | $("<p></p>").addClass('dialog').html( | |
|
50 | "If IPython is installed to a location that requires" + | |
|
47 | 51 | " administrative privileges to write, you will need to make this call as"+ |
|
48 | 52 | " an administrator, via 'sudo'." |
|
49 | 53 | ) |
|
50 | 54 | ).append( |
|
51 | 55 | $("<p></p>").addClass('dialog').html( |
|
52 |
" |
|
|
56 | "When you start the notebook server, you can instruct it to disable MathJax support altogether:" | |
|
53 | 57 | ) |
|
54 | 58 | ).append( |
|
55 | 59 | $("<pre></pre>").addClass('dialog').html( |
|
56 | 60 | "$ ipython notebook --no-mathjax" |
|
57 | 61 | ) |
|
58 | 62 | ).append( |
|
59 | 63 | $("<p></p>").addClass('dialog').html( |
|
60 | 64 | "which will prevent this dialog from appearing." |
|
61 | 65 | ) |
|
62 | 66 | ).dialog({ |
|
63 | 67 | title: "Failed to retrieve MathJax from '" + window.mathjax_url + "'", |
|
64 | 68 | width: "70%", |
|
65 | 69 | modal: true, |
|
66 | 70 | }) |
|
67 | 71 | }else{ |
|
68 | 72 | // No MathJax, but none expected. No dialog. |
|
69 | 73 | } |
|
70 | 74 | |
|
71 | 75 | IPython.markdown_converter = new Markdown.Converter(); |
|
72 | 76 | IPython.read_only = $('meta[name=read_only]').attr("content") == 'True'; |
|
73 | 77 | |
|
74 | 78 | $('div#header').addClass('border-box-sizing'); |
|
75 | 79 | $('div#main_app').addClass('border-box-sizing ui-widget ui-widget-content'); |
|
76 | 80 | $('div#notebook_panel').addClass('border-box-sizing ui-widget'); |
|
77 | 81 | |
|
78 | 82 | IPython.layout_manager = new IPython.LayoutManager(); |
|
79 | 83 | IPython.pager = new IPython.Pager('div#pager', 'div#pager_splitter'); |
|
80 | 84 | IPython.left_panel = new IPython.LeftPanel('div#left_panel', 'div#left_panel_splitter'); |
|
81 | 85 | IPython.save_widget = new IPython.SaveWidget('span#save_widget'); |
|
82 | 86 | IPython.quick_help = new IPython.QuickHelp('span#quick_help_area'); |
|
83 | 87 | IPython.login_widget = new IPython.LoginWidget('span#login_widget'); |
|
84 | 88 | IPython.print_widget = new IPython.PrintWidget('span#print_widget'); |
|
85 | 89 | IPython.notebook = new IPython.Notebook('div#notebook'); |
|
86 | 90 | IPython.kernel_status_widget = new IPython.KernelStatusWidget('#kernel_status'); |
|
87 | 91 | IPython.kernel_status_widget.status_idle(); |
|
88 | 92 | |
|
89 | 93 | IPython.layout_manager.do_resize(); |
|
90 | 94 | |
|
91 | 95 | // These have display: none in the css file and are made visible here to prevent FLOUC. |
|
92 | 96 | $('div#header').css('display','block'); |
|
93 | 97 | |
|
94 | 98 | if(IPython.read_only){ |
|
95 | 99 | // hide various elements from read-only view |
|
96 | 100 | IPython.save_widget.element.find('button#save_notebook').addClass('hidden'); |
|
97 | 101 | IPython.quick_help.element.addClass('hidden'); // shortcuts are disabled in read_only |
|
98 | 102 | $('button#new_notebook').addClass('hidden'); |
|
99 | 103 | $('div#cell_section').addClass('hidden'); |
|
100 | 104 | $('div#config_section').addClass('hidden'); |
|
101 | 105 | $('div#kernel_section').addClass('hidden'); |
|
102 | 106 | $('span#login_widget').removeClass('hidden'); |
|
103 | 107 | // left panel starts collapsed, but the collapse must happen after |
|
104 | 108 | // elements start drawing. Don't draw contents of the panel until |
|
105 | 109 | // after they are collapsed |
|
106 | 110 | IPython.left_panel.left_panel_element.css('visibility', 'hidden'); |
|
107 | 111 | } |
|
108 | 112 | |
|
109 | 113 | $('div#main_app').css('display','block'); |
|
110 | 114 | |
|
111 | 115 | // Perform these actions after the notebook has been loaded. |
|
112 | 116 | // We wait 100 milliseconds because the notebook scrolls to the top after a load |
|
113 | 117 | // is completed and we need to wait for that to mostly finish. |
|
114 | 118 | IPython.notebook.load_notebook(function () { |
|
115 | 119 | setTimeout(function () { |
|
116 | 120 | IPython.save_widget.update_url(); |
|
117 | 121 | IPython.layout_manager.do_resize(); |
|
118 | 122 | IPython.pager.collapse(); |
|
119 | 123 | if(IPython.read_only){ |
|
120 | 124 | // collapse the left panel on read-only |
|
121 | 125 | IPython.left_panel.collapse(); |
|
122 | 126 | // and finally unhide the panel contents after collapse |
|
123 | 127 | setTimeout(function(){ |
|
124 | 128 | IPython.left_panel.left_panel_element.css('visibility', 'visible'); |
|
125 | 129 | }, 200); |
|
126 | 130 | } |
|
127 | 131 | },100); |
|
128 | 132 | }); |
|
129 | 133 | |
|
130 | 134 | }); |
|
131 | 135 |
General Comments 0
You need to be logged in to leave comments.
Login now