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