##// END OF EJS Templates
[notebook] read-only: disable name field
Matthias BUSSONNIER -
Show More
@@ -1,137 +1,141 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 rendering will be disabled."
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 "If you have administrative access to the notebook server and" +
35 "If you have administrative access to the notebook server and" +
36 " a working internet connection, you can install a local copy" +
36 " a working internet connection, you can install a local copy" +
37 " of MathJax for offline use with the following command on the server" +
37 " of MathJax for offline use with the following command on the server" +
38 " at a Python or IPython prompt:"
38 " at a Python or IPython prompt:"
39 )
39 )
40 ).append(
40 ).append(
41 $("<pre></pre>").addClass('dialog').html(
41 $("<pre></pre>").addClass('dialog').html(
42 ">>> from IPython.external import mathjax; mathjax.install_mathjax()"
42 ">>> from IPython.external import mathjax; mathjax.install_mathjax()"
43 )
43 )
44 ).append(
44 ).append(
45 $("<p></p>").addClass('dialog').html(
45 $("<p></p>").addClass('dialog').html(
46 "This will try to install MathJax into the IPython source directory."
46 "This will try to install MathJax into the IPython source directory."
47 )
47 )
48 ).append(
48 ).append(
49 $("<p></p>").addClass('dialog').html(
49 $("<p></p>").addClass('dialog').html(
50 "If IPython is installed to a location that requires" +
50 "If IPython is installed to a location that requires" +
51 " 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" +
52 " an administrator, via 'sudo'."
52 " an administrator, via 'sudo'."
53 )
53 )
54 ).append(
54 ).append(
55 $("<p></p>").addClass('dialog').html(
55 $("<p></p>").addClass('dialog').html(
56 "When you start the notebook server, you can instruct it to disable MathJax support altogether:"
56 "When you start the notebook server, you can instruct it to disable MathJax support altogether:"
57 )
57 )
58 ).append(
58 ).append(
59 $("<pre></pre>").addClass('dialog').html(
59 $("<pre></pre>").addClass('dialog').html(
60 "$ ipython notebook --no-mathjax"
60 "$ ipython notebook --no-mathjax"
61 )
61 )
62 ).append(
62 ).append(
63 $("<p></p>").addClass('dialog').html(
63 $("<p></p>").addClass('dialog').html(
64 "which will prevent this dialog from appearing."
64 "which will prevent this dialog from appearing."
65 )
65 )
66 ).dialog({
66 ).dialog({
67 title: "Failed to retrieve MathJax from '" + window.mathjax_url + "'",
67 title: "Failed to retrieve MathJax from '" + window.mathjax_url + "'",
68 width: "70%",
68 width: "70%",
69 modal: true,
69 modal: true,
70 })
70 })
71 }else{
71 }else{
72 // No MathJax, but none expected. No dialog.
72 // No MathJax, but none expected. No dialog.
73 }
73 }
74
74
75 IPython.markdown_converter = new Markdown.Converter();
75 IPython.markdown_converter = new Markdown.Converter();
76 IPython.read_only = $('meta[name=read_only]').attr("content") == 'True';
76 IPython.read_only = $('meta[name=read_only]').attr("content") == 'True';
77
77
78 $('div#header').addClass('border-box-sizing');
78 $('div#header').addClass('border-box-sizing');
79 $('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');
80 $('div#notebook_panel').addClass('border-box-sizing ui-widget');
80 $('div#notebook_panel').addClass('border-box-sizing ui-widget');
81
81
82 IPython.layout_manager = new IPython.LayoutManager();
82 IPython.layout_manager = new IPython.LayoutManager();
83 IPython.pager = new IPython.Pager('div#pager', 'div#pager_splitter');
83 IPython.pager = new IPython.Pager('div#pager', 'div#pager_splitter');
84 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');
85 IPython.save_widget = new IPython.SaveWidget('span#save_widget');
85 IPython.save_widget = new IPython.SaveWidget('span#save_widget');
86 IPython.quick_help = new IPython.QuickHelp('span#quick_help_area');
86 IPython.quick_help = new IPython.QuickHelp('span#quick_help_area');
87 IPython.login_widget = new IPython.LoginWidget('span#login_widget');
87 IPython.login_widget = new IPython.LoginWidget('span#login_widget');
88 IPython.print_widget = new IPython.PrintWidget('span#print_widget');
88 IPython.print_widget = new IPython.PrintWidget('span#print_widget');
89 IPython.notebook = new IPython.Notebook('div#notebook');
89 IPython.notebook = new IPython.Notebook('div#notebook');
90 IPython.kernel_status_widget = new IPython.KernelStatusWidget('#kernel_status');
90 IPython.kernel_status_widget = new IPython.KernelStatusWidget('#kernel_status');
91 IPython.kernel_status_widget.status_idle();
91 IPython.kernel_status_widget.status_idle();
92
92
93 IPython.layout_manager.do_resize();
93 IPython.layout_manager.do_resize();
94
94
95 // 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.
96 $('div#header').css('display','block');
96 $('div#header').css('display','block');
97
97
98 if(IPython.read_only){
98 if(IPython.read_only){
99 // hide various elements from read-only view
99 // hide various elements from read-only view
100 IPython.save_widget.element.find('button#save_notebook').addClass('hidden');
100 IPython.save_widget.element.find('button#save_notebook').addClass('hidden');
101 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
102 $('div#pager').remove();
102 $('div#pager').remove();
103 $('div#pager_splitter').remove();
103 $('div#pager_splitter').remove();
104 $('button#new_notebook').addClass('hidden');
104 $('button#new_notebook').addClass('hidden');
105 $('div#cell_section').addClass('hidden');
105 $('div#cell_section').addClass('hidden');
106 $('div#config_section').addClass('hidden');
106 $('div#config_section').addClass('hidden');
107 $('div#kernel_section').addClass('hidden');
107 $('div#kernel_section').addClass('hidden');
108 $('span#login_widget').removeClass('hidden');
108 $('span#login_widget').removeClass('hidden');
109
110 // set the notebook name field as not modifiable
111 $('#notebook_name').attr('disabled','disabled')
112
109 // left panel starts collapsed, but the collapse must happen after
113 // left panel starts collapsed, but the collapse must happen after
110 // elements start drawing. Don't draw contents of the panel until
114 // elements start drawing. Don't draw contents of the panel until
111 // after they are collapsed
115 // after they are collapsed
112 IPython.left_panel.left_panel_element.css('visibility', 'hidden');
116 IPython.left_panel.left_panel_element.css('visibility', 'hidden');
113 }
117 }
114
118
115 $('div#main_app').css('display','block');
119 $('div#main_app').css('display','block');
116
120
117 // Perform these actions after the notebook has been loaded.
121 // Perform these actions after the notebook has been loaded.
118 // We wait 100 milliseconds because the notebook scrolls to the top after a load
122 // We wait 100 milliseconds because the notebook scrolls to the top after a load
119 // is completed and we need to wait for that to mostly finish.
123 // is completed and we need to wait for that to mostly finish.
120 IPython.notebook.load_notebook(function () {
124 IPython.notebook.load_notebook(function () {
121 setTimeout(function () {
125 setTimeout(function () {
122 IPython.save_widget.update_url();
126 IPython.save_widget.update_url();
123 IPython.layout_manager.do_resize();
127 IPython.layout_manager.do_resize();
124 IPython.pager.collapse();
128 IPython.pager.collapse();
125 if(IPython.read_only){
129 if(IPython.read_only){
126 // collapse the left panel on read-only
130 // collapse the left panel on read-only
127 IPython.left_panel.collapse();
131 IPython.left_panel.collapse();
128 // and finally unhide the panel contents after collapse
132 // and finally unhide the panel contents after collapse
129 setTimeout(function(){
133 setTimeout(function(){
130 IPython.left_panel.left_panel_element.css('visibility', 'visible');
134 IPython.left_panel.left_panel_element.css('visibility', 'visible');
131 }, 200);
135 }, 200);
132 }
136 }
133 },100);
137 },100);
134 });
138 });
135
139
136 });
140 });
137
141
General Comments 0
You need to be logged in to leave comments. Login now