##// END OF EJS Templates
Merge branch 'htmlnotebook_publish' of https://github.com/stefanv/ipython into stefanv-htmlnotebook_publish
Brian E. Granger -
r4619:d5b4ff0a merge
parent child Browse files
Show More
@@ -0,0 +1,54 b''
1 var IPython = (function (IPython) {
2
3 var PrintWidget = function (selector) {
4 this.selector = selector;
5 if (this.selector !== undefined) {
6 this.element = $(selector);
7 this.style();
8 this.bind_events();
9 }
10 };
11
12 PrintWidget.prototype.style = function () {
13 this.element.find('button#print_notebook').button();
14 };
15
16 PrintWidget.prototype.bind_events = function () {
17 var that = this;
18 this.element.find('button#print_notebook').click(function () {
19 that.print_notebook();
20 });
21 };
22
23 PrintWidget.prototype.enable = function () {
24 this.element.find('button#print_notebook').button('enable');
25 };
26
27 PrintWidget.prototype.disable = function () {
28 this.element.find('button#print_notebook').button('disable');
29 };
30
31 PrintWidget.prototype.print_notebook = function () {
32 var w = window.open('', '_blank', 'scrollbars=1,menubar=1');
33 var html = '<html><head>' +
34 $('head').clone().html() +
35 '<style type="text/css">' +
36 '@media print { body { overflow: visible !important; } }' +
37 '.ui-widget-content { border: 0px; }' +
38 '</style>' +
39 '</head><body style="overflow: auto;">' +
40 $('#notebook').clone().html() +
41 '</body></html>';
42
43 w.document.open();
44 w.document.write(html);
45 w.document.close();
46
47 return false;
48 };
49
50 IPython.PrintWidget = PrintWidget;
51
52 return IPython;
53
54 }(IPython)); No newline at end of file
@@ -1,57 +1,58 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
15 15 MathJax.Hub.Config({
16 16 tex2jax: {
17 17 inlineMath: [ ['$','$'], ["\\(","\\)"] ],
18 18 displayMath: [ ['$$','$$'], ["\\[","\\]"] ],
19 19 },
20 20 displayAlign: 'left', // Change this to 'center' to center equations.
21 21 "HTML-CSS": {
22 22 styles: {'.MathJax_Display': {"margin": 0}}
23 23 }
24 24 });
25 25 IPython.markdown_converter = new Markdown.Converter();
26 26
27 27 $('div#header').addClass('border-box-sizing');
28 28 $('div#main_app').addClass('border-box-sizing ui-widget ui-widget-content');
29 29 $('div#notebook_panel').addClass('border-box-sizing ui-widget');
30 30
31 31 IPython.layout_manager = new IPython.LayoutManager();
32 32 IPython.pager = new IPython.Pager('div#pager', 'div#pager_splitter');
33 33 IPython.left_panel = new IPython.LeftPanel('div#left_panel', 'div#left_panel_splitter');
34 34 IPython.save_widget = new IPython.SaveWidget('span#save_widget');
35 IPython.print_widget = new IPython.PrintWidget('span#print_widget');
35 36 IPython.notebook = new IPython.Notebook('div#notebook');
36 37 IPython.kernel_status_widget = new IPython.KernelStatusWidget('#kernel_status');
37 38 IPython.kernel_status_widget.status_idle();
38 39
39 40 IPython.layout_manager.do_resize();
40 41
41 42 // These have display: none in the css file and are made visible here to prevent FLOUC.
42 43 $('div#header').css('display','block');
43 44 $('div#main_app').css('display','block');
44 45
45 46 // Perform these actions after the notebook has been loaded.
46 47 // We wait 100 milliseconds because the notebook scrolls to the top after a load
47 48 // is completed and we need to wait for that to mostly finish.
48 49 IPython.notebook.load_notebook(function () {
49 50 setTimeout(function () {
50 51 IPython.save_widget.update_url();
51 52 IPython.layout_manager.do_resize();
52 53 IPython.pager.collapse();
53 54 },100);
54 55 });
55 56
56 57 });
57 58
@@ -1,115 +1,118 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 // SaveWidget
10 10 //============================================================================
11 11
12 12 var IPython = (function (IPython) {
13 13
14 14 var utils = IPython.utils;
15 15
16 16 var SaveWidget = function (selector) {
17 17 this.selector = selector;
18 18 this.notebook_name_re = /[^/\\]+/
19 19 if (this.selector !== undefined) {
20 20 this.element = $(selector);
21 21 this.style();
22 22 this.bind_events();
23 23 }
24 24 };
25 25
26 26
27 27 SaveWidget.prototype.style = function () {
28 28 this.element.find('input#notebook_name').addClass('ui-widget ui-widget-content');
29 29 this.element.find('button#save_notebook').button();
30 30 var left_panel_width = $('div#left_panel').outerWidth();
31 31 var left_panel_splitter_width = $('div#left_panel_splitter').outerWidth();
32 32 $('span#save_widget').css({marginLeft:left_panel_width+left_panel_splitter_width});
33 33 };
34 34
35 35
36 36 SaveWidget.prototype.bind_events = function () {
37 37 var that = this;
38 38 this.element.find('button#save_notebook').click(function () {
39 39 IPython.notebook.save_notebook();
40 40 that.set_document_title();
41 41 });
42 42 };
43 43
44 44
45 45 SaveWidget.prototype.get_notebook_name = function () {
46 46 return this.element.find('input#notebook_name').attr('value');
47 47 }
48 48
49 49
50 50 SaveWidget.prototype.set_notebook_name = function (nbname) {
51 51 this.element.find('input#notebook_name').attr('value',nbname);
52 52 this.set_document_title();
53 53 }
54 54
55 55
56 56 SaveWidget.prototype.set_document_title = function () {
57 57 nbname = this.get_notebook_name();
58 58 document.title = 'IPy: ' + nbname;
59 59 };
60 60
61 61
62 62 SaveWidget.prototype.get_notebook_id = function () {
63 63 return this.element.find('span#notebook_id').text()
64 64 };
65 65
66 66
67 67 SaveWidget.prototype.update_url = function () {
68 68 var notebook_id = this.get_notebook_id();
69 69 if (notebook_id !== '') {
70 70 window.history.replaceState({}, '', notebook_id);
71 71 };
72 72 };
73 73
74 74
75 75 SaveWidget.prototype.test_notebook_name = function () {
76 76 var nbname = this.get_notebook_name();
77 77 if (this.notebook_name_re.test(nbname)) {
78 78 return true;
79 79 } else {
80 80 var bad_name = $('<div/>');
81 81 bad_name.html(
82 82 "The notebook name you entered (" +
83 83 nbname +
84 84 ") is not valid. Notebook names can contain any characters except / and \\"
85 85 );
86 86 bad_name.dialog({title: 'Invalid name', modal: true});
87 87 return false;
88 88 };
89 89 };
90 90
91 91
92 92 SaveWidget.prototype.status_save = function () {
93 this.element.find('span.ui-button-text').text('Save');
93 this.element.find('button#save_notebook').button('option', 'label', 'Save');
94 94 this.element.find('button#save_notebook').button('enable');
95 IPython.print_widget.enable();
95 96 };
96 97
97 98
98 99 SaveWidget.prototype.status_saving = function () {
99 this.element.find('span.ui-button-text').text('Saving');
100 this.element.find('button#save_notebook').button('option', 'label', 'Saving');
100 101 this.element.find('button#save_notebook').button('disable');
102 IPython.print_widget.disable();
101 103 };
102 104
103 105
104 106 SaveWidget.prototype.status_loading = function () {
105 this.element.find('span.ui-button-text').text('Loading');
107 this.element.find('button#save_notebook').button('option', 'label', 'Loading');
106 108 this.element.find('button#save_notebook').button('disable');
109 IPython.print_widget.disable();
107 110 };
108 111
109 112
110 113 IPython.SaveWidget = SaveWidget;
111 114
112 115 return IPython;
113 116
114 117 }(IPython));
115 118
@@ -1,224 +1,229 b''
1 1 <!DOCTYPE HTML>
2 2 <html>
3 3
4 4 <head>
5 5 <meta charset="utf-8">
6 6
7 7 <title>IPython Notebook</title>
8 8
9 9 <link rel="stylesheet" href="static/jquery/css/themes/aristo/jquery-wijmo.css" type="text/css" />
10 10 <!-- <link rel="stylesheet" href="static/jquery/css/themes/rocket/jquery-wijmo.css" type="text/css" /> -->
11 11 <!-- <link rel="stylesheet" href="static/jquery/css/themes/smoothness/jquery-ui-1.8.14.custom.css" type="text/css" />-->
12 12
13 13 <script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML" charset="utf-8"></script>
14 14 <!-- <script type='text/javascript' src='static/mathjax/MathJax.js?config=TeX-AMS_HTML' charset='utf-8'></script> -->
15 15 <script type="text/javascript">
16 16 if (typeof MathJax == 'undefined') {
17 17 console.log("Trying to load local copy of MathJax");
18 18 document.write(unescape("%3Cscript type='text/javascript' src='static/mathjax/MathJax.js%3Fconfig=TeX-AMS_HTML' charset='utf-8'%3E%3C/script%3E"));
19 19 }
20 20 </script>
21 21
22 22 <link rel="stylesheet" href="static/codemirror-2.12/lib/codemirror.css">
23 23 <link rel="stylesheet" href="static/codemirror-2.12/mode/rst/rst.css">
24 24 <link rel="stylesheet" href="static/codemirror-2.12/theme/ipython.css">
25 25 <link rel="stylesheet" href="static/codemirror-2.12/theme/default.css">
26 26
27 27 <link rel="stylesheet" href="static/css/boilerplate.css" type="text/css" />
28 28 <link rel="stylesheet" href="static/css/layout.css" type="text/css" />
29 29 <link rel="stylesheet" href="static/css/base.css" type="text/css" />
30 30 <link rel="stylesheet" href="static/css/notebook.css" type="text/css" />
31 31 <link rel="stylesheet" href="static/css/renderedhtml.css" type="text/css" />
32 32
33 33
34 34 </head>
35 35
36 36 <body>
37 37
38 38 <div id="header">
39 39 <span id="ipython_notebook"><h1>IPython Notebook</h1></span>
40 40 <span id="save_widget">
41 41 <input type="text" id="notebook_name" size="20"></textarea>
42 42 <span id="notebook_id" style="display:none">{{notebook_id}}</span>
43 43 <button id="save_notebook">Save</button>
44 44 </span>
45 45 <span id="kernel_status">Idle</span>
46 46 </div>
47 47
48 48 <div id="main_app">
49 49
50 50 <div id="left_panel">
51 51
52 52 <div id="notebook_section">
53 53 <h3 class="section_header">Notebook</h3>
54 54 <div class="section_content">
55 55 <div class="section_row">
56 56 <span id="new_open" class="section_row_buttons">
57 57 <button id="new_notebook">New</button>
58 58 <button id="open_notebook">Open</button>
59 59 </span>
60 60 <span class="section_row_header">Actions</span>
61 61 </div>
62 62 <div class="section_row">
63 63 <span>
64 64 <select id="download_format">
65 65 <option value="xml">xml</option>
66 66 <option value="json">json</option>
67 67 <option value="py">py</option>
68 68 </select>
69 69 </span>
70 70 <span class="section_row_buttons">
71 <span id="print_widget">
72 <button id="print_notebook">Print/HTML</button>
73 </span>
74
71 75 <button id="download_notebook">Export</button>
72 76 </span>
73 77 </div>
74 78 </div>
75 79 </div>
76 80
77 81 <div id="cell_section">
78 82 <h3 class="section_header">Cell</h3>
79 83 <div class="section_content">
80 84 <div class="section_row">
81 85 <span class="section_row_buttons">
82 86 <button id="delete_cell">Delete</button>
83 87 </span>
84 88 <span class="section_row_header">Actions</span>
85 89 </div>
86 90 <div class="section_row">
87 91 <span id="cell_type" class="section_row_buttons">
88 92 <button id="to_code">Code</button>
89 93 <!-- <button id="to_html">HTML</button>-->
90 94 <button id="to_markdown">Markdown</button>
91 95 </span>
92 96 <span class="button_label">Format</span>
93 97 </div>
94 98 <div class="section_row">
95 99 <span id="toggle_output" class="section_row_buttons">
96 100 <button id="collapse_cell">Collapse</button>
97 101 <button id="expand_cell">Expand</button>
98 102 <button id="clear_all_output">ClearAll</button>
99 103 </span>
100 104 <span class="button_label">Output</span>
101 105 </div>
102 106 <div class="section_row">
103 107 <span id="insert" class="section_row_buttons">
104 108 <button id="insert_cell_above">Above</button>
105 109 <button id="insert_cell_below">Below</button>
106 110 </span>
107 111 <span class="button_label">Insert</span>
108 112 </div>
109 113 <div class="section_row">
110 114 <span id="move" class="section_row_buttons">
111 115 <button id="move_cell_up">Up</button>
112 116 <button id="move_cell_down">Down</button>
113 117 </span>
114 118 <span class="button_label">Move</span>
115 119 </div>
116 120 <div class="section_row">
117 121 <span id="run_cells" class="section_row_buttons">
118 122 <button id="run_selected_cell">Selected</button>
119 123 <button id="run_all_cells">All</button>
120 124 </span>
121 125 <span class="button_label">Run</span>
122 126 </div>
123 127 <div class="section_row">
124 128 <span id="autoindent_span">
125 129 <input type="checkbox" id="autoindent" checked="true"></input>
126 130 </span>
127 131 <span class="checkbox_label">Autoindent:</span>
128 132 </div>
129 133 </div>
130 134 </div>
131 135
132 136 <div id="kernel_section">
133 137 <h3 class="section_header">Kernel</h3>
134 138 <div class="section_content">
135 139 <div class="section_row">
136 140 <span id="int_restart" class="section_row_buttons">
137 141 <button id="int_kernel">Interrupt</button>
138 142 <button id="restart_kernel">Restart</button>
139 143 </span>
140 144 <span class="section_row_header">Actions</span>
141 145 </div>
142 146 <div class="section_row">
143 147 <span id="kernel_persist">
144 148 <input type="checkbox" id="kill_kernel"></input>
145 149 </span>
146 150 <span class="checkbox_label">Kill kernel upon exit:</span>
147 151 </div>
148 152 </div>
149 153 </div>
150 154
151 155 <div id="help_section">
152 156 <h3 class="section_header">Help</h3>
153 157 <div class="section_content">
154 158 <div class="section_row">
155 159 <span id="help_buttons0" class="section_row_buttons">
156 160 <button id="python_help"><a href="http://docs.python.org" target="_blank">Python</a></button>
157 161 <button id="ipython_help"><a href="http://ipython.org/documentation.html" target="_blank">IPython</a></button>
158 162 <button id="numpy_help"><a href="http://docs.scipy.org/doc/numpy/reference/" target="_blank">NumPy</a></button>
159 163 </span>
160 164 <span class="section_row_header">Links</span>
161 165 </div>
162 166 <div class="section_row">
163 167 <span id="help_buttons1" class="section_row_buttons">
164 168 <button id="matplotlib_help"><a href="http://matplotlib.sourceforge.net/" target="_blank">MPL</a></button>
165 169 <button id="scipy_help"><a href="http://docs.scipy.org/doc/scipy/reference/" target="_blank">SciPy</a></button>
166 170 <button id="sympy_help"><a href="http://docs.sympy.org/dev/index.html" target="_blank">SymPy</a></button>
167 171 </span>
168 172 </div>
169 173 <div class="section_row">
170 174 <span class="help_string">run selected cell</span>
171 175 <span class="help_string_label">Shift-Enter |</span>
172 176 </div>
173 177 <div class="section_row">
174 178 <span class="help_string">run in terminal mode</span>
175 179 <span class="help_string_label">Ctrl-Enter |</span>
176 180 </div>
177 181 </div>
178 182 </div>
179 183
180 184 </div>
181 185 <div id="left_panel_splitter"></div>
182 186 <div id="notebook_panel">
183 187 <div id="notebook"></div>
184 188 <div id="pager_splitter"></div>
185 189 <div id="pager"></div>
186 190 </div>
187 191
188 192 </div>
189 193
190 194 <script src="static/jquery/js/jquery-1.6.2.min.js" type="text/javascript" charset="utf-8"></script>
191 195 <script src="static/jquery/js/jquery-ui-1.8.14.custom.min.js" type="text/javascript" charset="utf-8"></script>
192 196 <script src="static/jquery/js/jquery.autogrow.js" type="text/javascript" charset="utf-8"></script>
193 197
194 198 <script src="static/codemirror-2.12/lib/codemirror.js" charset="utf-8"></script>
195 199 <script src="static/codemirror-2.12/mode/python/python.js" charset="utf-8"></script>
196 200 <script src="static/codemirror-2.12/mode/htmlmixed/htmlmixed.js" charset="utf-8"></script>
197 201 <script src="static/codemirror-2.12/mode/xml/xml.js" charset="utf-8"></script>
198 202 <script src="static/codemirror-2.12/mode/javascript/javascript.js" charset="utf-8"></script>
199 203 <script src="static/codemirror-2.12/mode/css/css.js" charset="utf-8"></script>
200 204 <script src="static/codemirror-2.12/mode/rst/rst.js" charset="utf-8"></script>
201 205
202 206 <script src="static/pagedown/Markdown.Converter.js" charset="utf-8"></script>
203 207
204 208 <script src="static/js/namespace.js" type="text/javascript" charset="utf-8"></script>
205 209 <script src="static/js/utils.js" type="text/javascript" charset="utf-8"></script>
206 210 <script src="static/js/cell.js" type="text/javascript" charset="utf-8"></script>
207 211 <script src="static/js/codecell.js" type="text/javascript" charset="utf-8"></script>
208 212 <script src="static/js/textcell.js" type="text/javascript" charset="utf-8"></script>
209 213 <script src="static/js/kernel.js" type="text/javascript" charset="utf-8"></script>
210 214 <script src="static/js/kernelstatus.js" type="text/javascript" charset="utf-8"></script>
211 215 <script src="static/js/layout.js" type="text/javascript" charset="utf-8"></script>
212 216 <script src="static/js/savewidget.js" type="text/javascript" charset="utf-8"></script>
213 217 <script src="static/js/pager.js" type="text/javascript" charset="utf-8"></script>
214 218 <script src="static/js/panelsection.js" type="text/javascript" charset="utf-8"></script>
219 <script src="static/js/printwidget.js" type="text/javascript" charset="utf-8"></script>
215 220 <script src="static/js/leftpanel.js" type="text/javascript" charset="utf-8"></script>
216 221 <script src="static/js/notebook.js" type="text/javascript" charset="utf-8"></script>
217 222 <script src="static/js/notebook_main.js" type="text/javascript" charset="utf-8"></script>
218 223
219 224
220 225 </body>
221 226
222 227 </html>
223 228
224 229
General Comments 0
You need to be logged in to leave comments. Login now