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