Show More
@@ -1,371 +1,375 | |||||
1 | /** |
|
1 | /** | |
2 | * HTML5 ✰ Boilerplate |
|
2 | * HTML5 ✰ Boilerplate | |
3 | * |
|
3 | * | |
4 | * style.css contains a reset, font normalization and some base styles. |
|
4 | * style.css contains a reset, font normalization and some base styles. | |
5 | * |
|
5 | * | |
6 | * Credit is left where credit is due. |
|
6 | * Credit is left where credit is due. | |
7 | * Much inspiration was taken from these projects: |
|
7 | * Much inspiration was taken from these projects: | |
8 | * - yui.yahooapis.com/2.8.1/build/base/base.css |
|
8 | * - yui.yahooapis.com/2.8.1/build/base/base.css | |
9 | * - camendesign.com/design/ |
|
9 | * - camendesign.com/design/ | |
10 | * - praegnanz.de/weblog/htmlcssjs-kickstart |
|
10 | * - praegnanz.de/weblog/htmlcssjs-kickstart | |
11 | */ |
|
11 | */ | |
12 |
|
12 | |||
13 |
|
13 | |||
14 | /** |
|
14 | /** | |
15 | * html5doctor.com Reset Stylesheet (Eric Meyer's Reset Reloaded + HTML5 baseline) |
|
15 | * html5doctor.com Reset Stylesheet (Eric Meyer's Reset Reloaded + HTML5 baseline) | |
16 | * v1.6.1 2010-09-17 | Authors: Eric Meyer & Richard Clark |
|
16 | * v1.6.1 2010-09-17 | Authors: Eric Meyer & Richard Clark | |
17 | * html5doctor.com/html-5-reset-stylesheet/ |
|
17 | * html5doctor.com/html-5-reset-stylesheet/ | |
18 | */ |
|
18 | */ | |
19 |
|
19 | |||
20 | html, body, div, span, object, iframe, |
|
20 | html, body, div, span, object, iframe, | |
21 | h1, h2, h3, h4, h5, h6, p, blockquote, pre, |
|
21 | h1, h2, h3, h4, h5, h6, p, blockquote, pre, | |
22 | abbr, address, cite, code, del, dfn, em, img, ins, kbd, q, samp, |
|
22 | abbr, address, cite, code, del, dfn, em, img, ins, kbd, q, samp, | |
23 | small, strong, sub, sup, var, b, i, dl, dt, dd, ol, ul, li, |
|
23 | small, strong, sub, sup, var, b, i, dl, dt, dd, ol, ul, li, | |
24 | fieldset, form, label, legend, |
|
24 | fieldset, form, label, legend, | |
25 | table, caption, tbody, tfoot, thead, tr, th, td, |
|
25 | table, caption, tbody, tfoot, thead, tr, th, td, | |
26 | article, aside, canvas, details, figcaption, figure, |
|
26 | article, aside, canvas, details, figcaption, figure, | |
27 | footer, header, hgroup, menu, nav, section, summary, |
|
27 | footer, header, hgroup, menu, nav, section, summary, | |
28 | time, mark, audio, video { |
|
28 | time, mark, audio, video { | |
29 | margin: 0; |
|
29 | margin: 0; | |
30 | padding: 0; |
|
30 | padding: 0; | |
31 | border: 0; |
|
31 | border: 0; | |
32 | font-size: 100%; |
|
32 | font-size: 100%; | |
33 | font: inherit; |
|
33 | font: inherit; | |
34 | vertical-align: baseline; |
|
34 | vertical-align: baseline; | |
35 | } |
|
35 | } | |
36 |
|
36 | |||
37 | article, aside, details, figcaption, figure, |
|
37 | article, aside, details, figcaption, figure, | |
38 | footer, header, hgroup, menu, nav, section { |
|
38 | footer, header, hgroup, menu, nav, section { | |
39 | display: block; |
|
39 | display: block; | |
40 | } |
|
40 | } | |
41 |
|
41 | |||
42 | blockquote, q { quotes: none; } |
|
42 | blockquote, q { quotes: none; } | |
43 |
|
43 | |||
44 | blockquote:before, blockquote:after, |
|
44 | blockquote:before, blockquote:after, | |
45 | q:before, q:after { content: ""; content: none; } |
|
45 | q:before, q:after { content: ""; content: none; } | |
46 |
|
46 | |||
47 | ins { background-color: #ff9; color: #000; text-decoration: none; } |
|
47 | ins { background-color: #ff9; color: #000; text-decoration: none; } | |
48 |
|
48 | |||
49 | mark { background-color: #ff9; color: #000; font-style: italic; font-weight: bold; } |
|
49 | mark { background-color: #ff9; color: #000; font-style: italic; font-weight: bold; } | |
50 |
|
50 | |||
51 | del { text-decoration: line-through; } |
|
51 | del { text-decoration: line-through; } | |
52 |
|
52 | |||
53 | abbr[title], dfn[title] { border-bottom: 1px dotted; cursor: help; } |
|
53 | abbr[title], dfn[title] { border-bottom: 1px dotted; cursor: help; } | |
54 |
|
54 | |||
55 | table { border-collapse: collapse; border-spacing: 0; } |
|
55 | table { border-collapse: collapse; border-spacing: 0; } | |
56 |
|
56 | |||
57 | hr { display: block; height: 1px; border: 0; border-top: 1px solid #ccc; margin: 1em 0; padding: 0; } |
|
57 | hr { display: block; height: 1px; border: 0; border-top: 1px solid #ccc; margin: 1em 0; padding: 0; } | |
58 |
|
58 | |||
59 | input, select { vertical-align: middle; } |
|
59 | input, select { vertical-align: middle; } | |
60 |
|
60 | |||
61 |
|
61 | |||
62 | /** |
|
62 | /** | |
63 | * Font normalization inspired by YUI Library's fonts.css: developer.yahoo.com/yui/ |
|
63 | * Font normalization inspired by YUI Library's fonts.css: developer.yahoo.com/yui/ | |
64 | */ |
|
64 | */ | |
65 |
|
65 | |||
66 | body { font:13px/1.231 sans-serif; *font-size:small; } /* Hack retained to preserve specificity */ |
|
66 | body { font:13px/1.231 sans-serif; *font-size:small; } /* Hack retained to preserve specificity */ | |
67 | select, input, textarea, button { font:99% sans-serif; } |
|
67 | select, input, textarea, button { font:99% sans-serif; } | |
68 |
|
68 | |||
69 | /* Normalize monospace sizing: |
|
69 | /* Normalize monospace sizing: | |
70 | en.wikipedia.org/wiki/MediaWiki_talk:Common.css/Archive_11#Teletype_style_fix_for_Chrome */ |
|
70 | en.wikipedia.org/wiki/MediaWiki_talk:Common.css/Archive_11#Teletype_style_fix_for_Chrome */ | |
71 | pre, code, kbd, samp { font-family: monospace, sans-serif; } |
|
71 | pre, code, kbd, samp { font-family: monospace, sans-serif; } | |
72 |
|
72 | |||
73 |
|
73 | |||
74 | /** |
|
74 | /** | |
75 | * Primary styles |
|
75 | * Primary styles | |
76 | * |
|
76 | * | |
77 | * Author: IPython Development Team |
|
77 | * Author: IPython Development Team | |
78 | */ |
|
78 | */ | |
79 |
|
79 | |||
80 |
|
80 | |||
81 | body { |
|
81 | body { | |
82 | background-color: white; |
|
82 | background-color: white; | |
83 | /* This makes sure that the body covers the entire window and needs to |
|
83 | /* This makes sure that the body covers the entire window and needs to | |
84 | be in a different element than the display: box in wrapper below */ |
|
84 | be in a different element than the display: box in wrapper below */ | |
85 | position: absolute; |
|
85 | position: absolute; | |
86 | left: 0px; |
|
86 | left: 0px; | |
87 | right: 0px; |
|
87 | right: 0px; | |
88 | top: 0px; |
|
88 | top: 0px; | |
89 | bottom: 0px; |
|
89 | bottom: 0px; | |
90 | overflow: hidden; |
|
90 | overflow: hidden; | |
91 | } |
|
91 | } | |
92 |
|
92 | |||
93 |
|
93 | |||
94 | div#header { |
|
94 | div#header { | |
|
95 | /* Initially hidden to prevent FLOUC */ | |||
|
96 | display: none; | |||
95 | position: relative; |
|
97 | position: relative; | |
96 | height: 45px; |
|
98 | height: 45px; | |
97 | padding: 5px; |
|
99 | padding: 5px; | |
98 | margin: 0px; |
|
100 | margin: 0px; | |
99 | width: 100% |
|
101 | width: 100%; | |
100 | } |
|
102 | } | |
101 |
|
103 | |||
102 | span#ipython_notebook { |
|
104 | span#ipython_notebook { | |
103 | position: absolute; |
|
105 | position: absolute; | |
104 | padding: 2px; |
|
106 | padding: 2px; | |
105 | } |
|
107 | } | |
106 |
|
108 | |||
107 | span#ipython_notebook h1 { |
|
109 | span#ipython_notebook h1 { | |
108 | font-family: Verdana, "Helvetica Neue", Arial, Helvetica, Geneva, sans-serif; |
|
110 | font-family: Verdana, "Helvetica Neue", Arial, Helvetica, Geneva, sans-serif; | |
109 | font-size: 197%; |
|
111 | font-size: 197%; | |
110 | display: inline; |
|
112 | display: inline; | |
111 | } |
|
113 | } | |
112 |
|
114 | |||
113 | span#save_widget { |
|
115 | span#save_widget { | |
114 | position: absolute; |
|
116 | position: absolute; | |
115 | left: 0px; |
|
117 | left: 0px; | |
116 | padding: 5px 0px; |
|
118 | padding: 5px 0px; | |
117 | margin: 0px 0px 0px 0px; |
|
119 | margin: 0px 0px 0px 0px; | |
118 | } |
|
120 | } | |
119 |
|
121 | |||
120 | input#notebook_name { |
|
122 | input#notebook_name { | |
121 | height: 1em; |
|
123 | height: 1em; | |
122 | line-height: 1em; |
|
124 | line-height: 1em; | |
123 | padding: 5px; |
|
125 | padding: 5px; | |
124 | } |
|
126 | } | |
125 |
|
127 | |||
126 | span#kernel_status { |
|
128 | span#kernel_status { | |
127 | position: absolute; |
|
129 | position: absolute; | |
128 | padding: 8px 5px 5px 5px; |
|
130 | padding: 8px 5px 5px 5px; | |
129 | right: 10px; |
|
131 | right: 10px; | |
130 | font-weight: bold; |
|
132 | font-weight: bold; | |
131 | } |
|
133 | } | |
132 |
|
134 | |||
133 | .status_idle { |
|
135 | .status_idle { | |
134 | color: gray; |
|
136 | color: gray; | |
135 | } |
|
137 | } | |
136 |
|
138 | |||
137 | .status_busy { |
|
139 | .status_busy { | |
138 | color: red; |
|
140 | color: red; | |
139 | } |
|
141 | } | |
140 |
|
142 | |||
141 | .status_restarting { |
|
143 | .status_restarting { | |
142 | color: black; |
|
144 | color: black; | |
143 | } |
|
145 | } | |
144 |
|
146 | |||
145 | div#notebook_app { |
|
147 | div#notebook_app { | |
|
148 | /* Initially hidden to prevent FLOUC */ | |||
|
149 | display: none; | |||
146 | width: 100%; |
|
150 | width: 100%; | |
147 | position: relative; |
|
151 | position: relative; | |
148 | } |
|
152 | } | |
149 |
|
153 | |||
150 | div#left_panel { |
|
154 | div#left_panel { | |
151 | overflow-y: auto; |
|
155 | overflow-y: auto; | |
152 | top: 0px; |
|
156 | top: 0px; | |
153 | left: 0px; |
|
157 | left: 0px; | |
154 | margin: 0px; |
|
158 | margin: 0px; | |
155 | padding: 0px; |
|
159 | padding: 0px; | |
156 | position: absolute; |
|
160 | position: absolute; | |
157 | } |
|
161 | } | |
158 |
|
162 | |||
159 | h3.section_header { |
|
163 | h3.section_header { | |
160 | padding: 5px; |
|
164 | padding: 5px; | |
161 | } |
|
165 | } | |
162 |
|
166 | |||
163 | div.section_content { |
|
167 | div.section_content { | |
164 | padding: 5px; |
|
168 | padding: 5px; | |
165 | } |
|
169 | } | |
166 |
|
170 | |||
167 |
|
171 | |||
168 | span.section_row_buttons > button { |
|
172 | span.section_row_buttons > button { | |
169 | width: 60px; |
|
173 | width: 60px; | |
170 | } |
|
174 | } | |
171 |
|
175 | |||
172 | .section_row { |
|
176 | .section_row { | |
173 | margin: 5px 0px; |
|
177 | margin: 5px 0px; | |
174 | } |
|
178 | } | |
175 |
|
179 | |||
176 | .section_row_buttons { |
|
180 | .section_row_buttons { | |
177 | float: right; |
|
181 | float: right; | |
178 | } |
|
182 | } | |
179 |
|
183 | |||
180 | .section_row_header { |
|
184 | .section_row_header { | |
181 | float: left; |
|
185 | float: left; | |
182 | font-size: 85%; |
|
186 | font-size: 85%; | |
183 | padding: 0.2em 0em; |
|
187 | padding: 0.2em 0em; | |
184 | font-weight: bold; |
|
188 | font-weight: bold; | |
185 | } |
|
189 | } | |
186 |
|
190 | |||
187 | span.button_label { |
|
191 | span.button_label { | |
188 | padding: 0.2em 1em; |
|
192 | padding: 0.2em 1em; | |
189 | font-size: 77%; |
|
193 | font-size: 77%; | |
190 | float: right; |
|
194 | float: right; | |
191 | } |
|
195 | } | |
192 |
|
196 | |||
193 | /* This is needed because FF was adding a 2px margin top and bottom. */ |
|
197 | /* This is needed because FF was adding a 2px margin top and bottom. */ | |
194 | .section_row .ui-button { |
|
198 | .section_row .ui-button { | |
195 | margin-top: 0px; |
|
199 | margin-top: 0px; | |
196 | margin-bottom: 0px; |
|
200 | margin-bottom: 0px; | |
197 | } |
|
201 | } | |
198 |
|
202 | |||
199 |
|
203 | |||
200 | .ui-button .ui-button-text { |
|
204 | .ui-button .ui-button-text { | |
201 | padding: 0.2em 0.8em; |
|
205 | padding: 0.2em 0.8em; | |
202 | font-size: 77%; |
|
206 | font-size: 77%; | |
203 | } |
|
207 | } | |
204 |
|
208 | |||
205 | div#left_panel_splitter { |
|
209 | div#left_panel_splitter { | |
206 | width: 8px; |
|
210 | width: 8px; | |
207 | top: 0px; |
|
211 | top: 0px; | |
208 | left: 202px; |
|
212 | left: 202px; | |
209 | margin: 0px; |
|
213 | margin: 0px; | |
210 | padding: 0px; |
|
214 | padding: 0px; | |
211 | position: absolute; |
|
215 | position: absolute; | |
212 | } |
|
216 | } | |
213 |
|
217 | |||
214 | div#notebook_panel { |
|
218 | div#notebook_panel { | |
215 | /* The L margin will be set in the Javascript code*/ |
|
219 | /* The L margin will be set in the Javascript code*/ | |
216 | margin: 0px 0px 0px 0px; |
|
220 | margin: 0px 0px 0px 0px; | |
217 | padding: 0px; |
|
221 | padding: 0px; | |
218 | } |
|
222 | } | |
219 |
|
223 | |||
220 | div#notebook { |
|
224 | div#notebook { | |
221 | overflow-y: scroll; |
|
225 | overflow-y: scroll; | |
222 | overflow-x: auto; |
|
226 | overflow-x: auto; | |
223 | width: 100%; |
|
227 | width: 100%; | |
224 | padding: 0px 15px 0px 15px; |
|
228 | padding: 0px 15px 0px 15px; | |
225 | margin: 0px |
|
229 | margin: 0px | |
226 | background-color: white; |
|
230 | background-color: white; | |
227 | } |
|
231 | } | |
228 |
|
232 | |||
229 | div#pager_splitter { |
|
233 | div#pager_splitter { | |
230 | height: 8px; |
|
234 | height: 8px; | |
231 | } |
|
235 | } | |
232 |
|
236 | |||
233 | div#pager { |
|
237 | div#pager { | |
234 | padding: 15px; |
|
238 | padding: 15px; | |
235 | overflow: auto; |
|
239 | overflow: auto; | |
236 | } |
|
240 | } | |
237 |
|
241 | |||
238 | div.cell { |
|
242 | div.cell { | |
239 | width: 100%; |
|
243 | width: 100%; | |
240 | padding: 5px; |
|
244 | padding: 5px; | |
241 | /* This acts as a spacer between cells, that is outside the border */ |
|
245 | /* This acts as a spacer between cells, that is outside the border */ | |
242 | margin: 15px 0px 15px 0px; |
|
246 | margin: 15px 0px 15px 0px; | |
243 | } |
|
247 | } | |
244 |
|
248 | |||
245 | div.code_cell { |
|
249 | div.code_cell { | |
246 | background-color: white; |
|
250 | background-color: white; | |
247 | } |
|
251 | } | |
248 |
|
252 | |||
249 | div.prompt { |
|
253 | div.prompt { | |
250 | width: 80px; |
|
254 | width: 80px; | |
251 | padding: 0.4em; |
|
255 | padding: 0.4em; | |
252 | margin: 0px; |
|
256 | margin: 0px; | |
253 | font-family: monospace; |
|
257 | font-family: monospace; | |
254 | } |
|
258 | } | |
255 |
|
259 | |||
256 | div.input_prompt { |
|
260 | div.input_prompt { | |
257 | color: navy; |
|
261 | color: navy; | |
258 | } |
|
262 | } | |
259 |
|
263 | |||
260 | div.output { |
|
264 | div.output { | |
261 | /* This is a spacer between the input and output of each cell */ |
|
265 | /* This is a spacer between the input and output of each cell */ | |
262 | margin-top: 15px; |
|
266 | margin-top: 15px; | |
263 | } |
|
267 | } | |
264 |
|
268 | |||
265 | div.output_prompt { |
|
269 | div.output_prompt { | |
266 | color: darkred; |
|
270 | color: darkred; | |
267 | } |
|
271 | } | |
268 |
|
272 | |||
269 | div.output_area { |
|
273 | div.output_area { | |
270 | text-align: left; |
|
274 | text-align: left; | |
271 | color: black; |
|
275 | color: black; | |
272 | font-family: monospace; |
|
276 | font-family: monospace; | |
273 | } |
|
277 | } | |
274 |
|
278 | |||
275 | div.output_stream { |
|
279 | div.output_stream { | |
276 | padding: 0.4em; |
|
280 | padding: 0.4em; | |
277 | } |
|
281 | } | |
278 |
|
282 | |||
279 | div.output_latex { |
|
283 | div.output_latex { | |
280 | /* Slightly bigger than the rest of the notebook */ |
|
284 | /* Slightly bigger than the rest of the notebook */ | |
281 | font-size: 116%; |
|
285 | font-size: 116%; | |
282 | } |
|
286 | } | |
283 |
|
287 | |||
284 | div.output_png { |
|
288 | div.output_png { | |
285 | } |
|
289 | } | |
286 |
|
290 | |||
287 | div.text_cell { |
|
291 | div.text_cell { | |
288 | background-color: white; |
|
292 | background-color: white; | |
289 | } |
|
293 | } | |
290 |
|
294 | |||
291 | textarea.text_cell_input { |
|
295 | textarea.text_cell_input { | |
292 | /* Slightly bigger than the rest of the notebook */ |
|
296 | /* Slightly bigger than the rest of the notebook */ | |
293 | font-size: 116%; |
|
297 | font-size: 116%; | |
294 | font-family: monospace; |
|
298 | font-family: monospace; | |
295 | outline: none; |
|
299 | outline: none; | |
296 | resize: none; |
|
300 | resize: none; | |
297 | width: inherit; |
|
301 | width: inherit; | |
298 | border-style: none; |
|
302 | border-style: none; | |
299 | padding: 0px; |
|
303 | padding: 0px; | |
300 | margin: 0px; |
|
304 | margin: 0px; | |
301 | color: black; |
|
305 | color: black; | |
302 | } |
|
306 | } | |
303 |
|
307 | |||
304 | div.text_cell_render { |
|
308 | div.text_cell_render { | |
305 | font-family: "Helvetica Neue", Arial, Helvetica, Geneva, sans-serif; |
|
309 | font-family: "Helvetica Neue", Arial, Helvetica, Geneva, sans-serif; | |
306 | /* Slightly bigger than the rest of the notebook */ |
|
310 | /* Slightly bigger than the rest of the notebook */ | |
307 | font-size: 116%; |
|
311 | font-size: 116%; | |
308 | outline: none; |
|
312 | outline: none; | |
309 | resize: none; |
|
313 | resize: none; | |
310 | width: inherit; |
|
314 | width: inherit; | |
311 | border-style: none; |
|
315 | border-style: none; | |
312 | padding: 5px; |
|
316 | padding: 5px; | |
313 | color: black; |
|
317 | color: black; | |
314 | } |
|
318 | } | |
315 |
|
319 | |||
316 | div.text_cell_render em {font-style: italic;} |
|
320 | div.text_cell_render em {font-style: italic;} | |
317 | div.text_cell_render strong {font-weight: bold;} |
|
321 | div.text_cell_render strong {font-weight: bold;} | |
318 | div.text_cell_render u {text-decoration: underline;} |
|
322 | div.text_cell_render u {text-decoration: underline;} | |
319 | div.text_cell_render :link { text-decoration: underline } |
|
323 | div.text_cell_render :link { text-decoration: underline } | |
320 | div.text_cell_render :visited { text-decoration: underline } |
|
324 | div.text_cell_render :visited { text-decoration: underline } | |
321 | div.text_cell_render h1 {font-size: 197%; margin: .67em 0; font-weight: bold;} |
|
325 | div.text_cell_render h1 {font-size: 197%; margin: .67em 0; font-weight: bold;} | |
322 | div.text_cell_render h2 {font-size: 153.9%; margin: .75em 0; font-weight: bold;} |
|
326 | div.text_cell_render h2 {font-size: 153.9%; margin: .75em 0; font-weight: bold;} | |
323 | div.text_cell_render h3 {font-size: 116%; margin: .83em 0; font-weight: bold;} |
|
327 | div.text_cell_render h3 {font-size: 116%; margin: .83em 0; font-weight: bold;} | |
324 | div.text_cell_render h4 {margin: 1.12em 0; font-weight: bold;} |
|
328 | div.text_cell_render h4 {margin: 1.12em 0; font-weight: bold;} | |
325 | div.text_cell_render h5 {font-size: 85%.; margin: 1.5em 0; font-weight: bold;} |
|
329 | div.text_cell_render h5 {font-size: 85%.; margin: 1.5em 0; font-weight: bold;} | |
326 | div.text_cell_render h6 {font-size: 77%; margin: 1.67em 0; font-weight: bold;} |
|
330 | div.text_cell_render h6 {font-size: 77%; margin: 1.67em 0; font-weight: bold;} | |
327 | div.text_cell_render ul {list-style:disc; margin-left: 40px;} |
|
331 | div.text_cell_render ul {list-style:disc; margin-left: 40px;} | |
328 | div.text_cell_render ul ul {list-style:square; margin-left: 40px;} |
|
332 | div.text_cell_render ul ul {list-style:square; margin-left: 40px;} | |
329 | div.text_cell_render ul ul ul {list-style:circle; margin-left: 40px;} |
|
333 | div.text_cell_render ul ul ul {list-style:circle; margin-left: 40px;} | |
330 | div.text_cell_render ol {list-style:upper-roman; margin-left: 40px;} |
|
334 | div.text_cell_render ol {list-style:upper-roman; margin-left: 40px;} | |
331 | div.text_cell_render ol ol {list-style:upper-alpha;} |
|
335 | div.text_cell_render ol ol {list-style:upper-alpha;} | |
332 | div.text_cell_render ol ol ol {list-style:decimal;} |
|
336 | div.text_cell_render ol ol ol {list-style:decimal;} | |
333 | div.text_cell_render ol ol ol ol {list-style:lower-alpha;} |
|
337 | div.text_cell_render ol ol ol ol {list-style:lower-alpha;} | |
334 | div.text_cell_render ol ol ol ol ol {list-style:lower-roman;} |
|
338 | div.text_cell_render ol ol ol ol ol {list-style:lower-roman;} | |
335 |
|
339 | |||
336 |
|
340 | |||
337 | .CodeMirror { |
|
341 | .CodeMirror { | |
338 | overflow: hidden; /* Changed from auto to remove scrollbar */ |
|
342 | overflow: hidden; /* Changed from auto to remove scrollbar */ | |
339 | height: auto; /* Changed to auto to autogrow */ |
|
343 | height: auto; /* Changed to auto to autogrow */ | |
340 | line-height: 1.231; /* Changed from 1em to our global default */ |
|
344 | line-height: 1.231; /* Changed from 1em to our global default */ | |
341 | } |
|
345 | } | |
342 |
|
346 | |||
343 | /* CSS font colors for translated ANSI colors. */ |
|
347 | /* CSS font colors for translated ANSI colors. */ | |
344 |
|
348 | |||
345 |
|
349 | |||
346 | .ansiblack {color: black;} |
|
350 | .ansiblack {color: black;} | |
347 | .ansired {color: darkred;} |
|
351 | .ansired {color: darkred;} | |
348 | .ansigreen {color: darkgreen;} |
|
352 | .ansigreen {color: darkgreen;} | |
349 | .ansiyellow {color: brown;} |
|
353 | .ansiyellow {color: brown;} | |
350 | .ansiblue {color: darkblue;} |
|
354 | .ansiblue {color: darkblue;} | |
351 | .ansipurple {color: darkviolet;} |
|
355 | .ansipurple {color: darkviolet;} | |
352 | .ansicyan {color: steelblue;} |
|
356 | .ansicyan {color: steelblue;} | |
353 | .ansigrey {color: grey;} |
|
357 | .ansigrey {color: grey;} | |
354 | .ansibold {font-weight: bold;} |
|
358 | .ansibold {font-weight: bold;} | |
355 |
|
359 | |||
356 | .completions { |
|
360 | .completions { | |
357 | position: absolute; |
|
361 | position: absolute; | |
358 | z-index: 10; |
|
362 | z-index: 10; | |
359 | overflow: auto; |
|
363 | overflow: auto; | |
360 | border: 1px solid black; |
|
364 | border: 1px solid black; | |
361 | } |
|
365 | } | |
362 |
|
366 | |||
363 | .completions select { |
|
367 | .completions select { | |
364 | background: white; |
|
368 | background: white; | |
365 | outline: none; |
|
369 | outline: none; | |
366 | border: none; |
|
370 | border: none; | |
367 | padding: 0px; |
|
371 | padding: 0px; | |
368 | margin: 0px; |
|
372 | margin: 0px; | |
369 | font-family: monospace; |
|
373 | font-family: monospace; | |
370 | } |
|
374 | } | |
371 |
|
375 |
@@ -1,624 +1,624 | |||||
1 |
|
1 | |||
2 | //============================================================================ |
|
2 | //============================================================================ | |
3 | // Notebook |
|
3 | // Notebook | |
4 | //============================================================================ |
|
4 | //============================================================================ | |
5 |
|
5 | |||
6 | var IPython = (function (IPython) { |
|
6 | var IPython = (function (IPython) { | |
7 |
|
7 | |||
8 | var utils = IPython.utils; |
|
8 | var utils = IPython.utils; | |
9 |
|
9 | |||
10 | var Notebook = function (selector) { |
|
10 | var Notebook = function (selector) { | |
11 | this.element = $(selector); |
|
11 | this.element = $(selector); | |
12 | this.element.scroll(); |
|
12 | this.element.scroll(); | |
13 | this.element.data("notebook", this); |
|
13 | this.element.data("notebook", this); | |
14 | this.next_prompt_number = 1; |
|
14 | this.next_prompt_number = 1; | |
15 | this.kernel = null; |
|
15 | this.kernel = null; | |
16 | this.msg_cell_map = {}; |
|
16 | this.msg_cell_map = {}; | |
17 | this.filename = null; |
|
17 | this.filename = null; | |
18 | this.notebook_load_re = /%notebook load/ |
|
18 | this.notebook_load_re = /%notebook load/ | |
19 | this.notebook_save_re = /%notebook save/ |
|
19 | this.notebook_save_re = /%notebook save/ | |
20 | this.notebook_filename_re = /(\w)+.ipynb/ |
|
20 | this.notebook_filename_re = /(\w)+.ipynb/ | |
21 | this.style(); |
|
21 | this.style(); | |
22 | this.create_elements(); |
|
22 | this.create_elements(); | |
23 | this.bind_events(); |
|
23 | this.bind_events(); | |
24 | this.start_kernel(); |
|
24 | this.start_kernel(); | |
25 | }; |
|
25 | }; | |
26 |
|
26 | |||
27 |
|
27 | |||
28 | Notebook.prototype.style = function () { |
|
28 | Notebook.prototype.style = function () { | |
29 | $('div#notebook').addClass('border-box-sizing'); |
|
29 | $('div#notebook').addClass('border-box-sizing'); | |
30 | }; |
|
30 | }; | |
31 |
|
31 | |||
32 |
|
32 | |||
33 | Notebook.prototype.create_elements = function () { |
|
33 | Notebook.prototype.create_elements = function () { | |
34 | // We add this end_space div to the end of the notebook div to: |
|
34 | // We add this end_space div to the end of the notebook div to: | |
35 | // i) provide a margin between the last cell and the end of the notebook |
|
35 | // i) provide a margin between the last cell and the end of the notebook | |
36 | // ii) to prevent the div from scrolling up when the last cell is being |
|
36 | // ii) to prevent the div from scrolling up when the last cell is being | |
37 | // edited, but is too low on the page, which browsers will do automatically. |
|
37 | // edited, but is too low on the page, which browsers will do automatically. | |
38 | this.element.append($('<div class="end_space"></div>').height(50)); |
|
38 | this.element.append($('<div class="end_space"></div>').height(50)); | |
39 | $('div#notebook').addClass('border-box-sizing'); |
|
39 | $('div#notebook').addClass('border-box-sizing'); | |
40 | }; |
|
40 | }; | |
41 |
|
41 | |||
42 |
|
42 | |||
43 | Notebook.prototype.bind_events = function () { |
|
43 | Notebook.prototype.bind_events = function () { | |
44 | var that = this; |
|
44 | var that = this; | |
45 | $(document).keydown(function (event) { |
|
45 | $(document).keydown(function (event) { | |
46 | // console.log(event); |
|
46 | // console.log(event); | |
47 | if (event.which === 38) { |
|
47 | if (event.which === 38) { | |
48 | var cell = that.selected_cell(); |
|
48 | var cell = that.selected_cell(); | |
49 | if (cell.at_top()) { |
|
49 | if (cell.at_top()) { | |
50 | event.preventDefault(); |
|
50 | event.preventDefault(); | |
51 | that.select_prev(); |
|
51 | that.select_prev(); | |
52 | }; |
|
52 | }; | |
53 | } else if (event.which === 40) { |
|
53 | } else if (event.which === 40) { | |
54 | var cell = that.selected_cell(); |
|
54 | var cell = that.selected_cell(); | |
55 | if (cell.at_bottom()) { |
|
55 | if (cell.at_bottom()) { | |
56 | event.preventDefault(); |
|
56 | event.preventDefault(); | |
57 | that.select_next(); |
|
57 | that.select_next(); | |
58 | }; |
|
58 | }; | |
59 | } else if (event.which === 13 && event.shiftKey) { |
|
59 | } else if (event.which === 13 && event.shiftKey) { | |
60 | that.execute_selected_cell(); |
|
60 | that.execute_selected_cell(); | |
61 | return false; |
|
61 | return false; | |
62 | } else if (event.which === 13 && event.ctrlKey) { |
|
62 | } else if (event.which === 13 && event.ctrlKey) { | |
63 | that.execute_selected_cell({terminal:true}); |
|
63 | that.execute_selected_cell({terminal:true}); | |
64 | return false; |
|
64 | return false; | |
65 | }; |
|
65 | }; | |
66 | }); |
|
66 | }); | |
67 |
|
67 | |||
68 | this.element.bind('collapse_pager', function () { |
|
68 | this.element.bind('collapse_pager', function () { | |
69 | var app_height = $('div#notebook_app').height(); // content height |
|
69 | var app_height = $('div#notebook_app').height(); // content height | |
70 | var splitter_height = $('div#pager_splitter').outerHeight(true); |
|
70 | var splitter_height = $('div#pager_splitter').outerHeight(true); | |
71 | var new_height = app_height - splitter_height; |
|
71 | var new_height = app_height - splitter_height; | |
72 | that.element.animate({height : new_height + 'px'}, 'fast'); |
|
72 | that.element.animate({height : new_height + 'px'}, 'fast'); | |
73 | }); |
|
73 | }); | |
74 |
|
74 | |||
75 | this.element.bind('expand_pager', function () { |
|
75 | this.element.bind('expand_pager', function () { | |
76 | var app_height = $('div#notebook_app').height(); // content height |
|
76 | var app_height = $('div#notebook_app').height(); // content height | |
77 | var splitter_height = $('div#pager_splitter').outerHeight(true); |
|
77 | var splitter_height = $('div#pager_splitter').outerHeight(true); | |
78 | var pager_height = $('div#pager').outerHeight(true); |
|
78 | var pager_height = $('div#pager').outerHeight(true); | |
79 | var new_height = app_height - pager_height - splitter_height; |
|
79 | var new_height = app_height - pager_height - splitter_height; | |
80 | that.element.animate({height : new_height + 'px'}, 'fast'); |
|
80 | that.element.animate({height : new_height + 'px'}, 'fast'); | |
81 | }); |
|
81 | }); | |
82 |
|
82 | |||
83 | this.element.bind('collapse_left_panel', function () { |
|
83 | this.element.bind('collapse_left_panel', function () { | |
84 | var splitter_width = $('div#left_panel_splitter').outerWidth(true); |
|
84 | var splitter_width = $('div#left_panel_splitter').outerWidth(true); | |
85 | var new_margin = splitter_width; |
|
85 | var new_margin = splitter_width; | |
86 | $('div#notebook_panel').animate({marginLeft : new_margin + 'px'}, 'fast'); |
|
86 | $('div#notebook_panel').animate({marginLeft : new_margin + 'px'}, 'fast'); | |
87 | }); |
|
87 | }); | |
88 |
|
88 | |||
89 | this.element.bind('expand_left_panel', function () { |
|
89 | this.element.bind('expand_left_panel', function () { | |
90 | var splitter_width = $('div#left_panel_splitter').outerWidth(true); |
|
90 | var splitter_width = $('div#left_panel_splitter').outerWidth(true); | |
91 | var left_panel_width = IPython.left_panel.width; |
|
91 | var left_panel_width = IPython.left_panel.width; | |
92 | var new_margin = splitter_width + left_panel_width; |
|
92 | var new_margin = splitter_width + left_panel_width; | |
93 | $('div#notebook_panel').animate({marginLeft : new_margin + 'px'}, 'fast'); |
|
93 | $('div#notebook_panel').animate({marginLeft : new_margin + 'px'}, 'fast'); | |
94 | }); |
|
94 | }); | |
95 | }; |
|
95 | }; | |
96 |
|
96 | |||
97 |
|
97 | |||
98 | Notebook.prototype.scroll_to_bottom = function () { |
|
98 | Notebook.prototype.scroll_to_bottom = function () { | |
99 | this.element.animate({scrollTop:this.element.get(0).scrollHeight}, 0); |
|
99 | this.element.animate({scrollTop:this.element.get(0).scrollHeight}, 0); | |
100 | }; |
|
100 | }; | |
101 |
|
101 | |||
102 | // Cell indexing, retrieval, etc. |
|
102 | // Cell indexing, retrieval, etc. | |
103 |
|
103 | |||
104 |
|
104 | |||
105 | Notebook.prototype.cell_elements = function () { |
|
105 | Notebook.prototype.cell_elements = function () { | |
106 | return this.element.children("div.cell"); |
|
106 | return this.element.children("div.cell"); | |
107 | } |
|
107 | } | |
108 |
|
108 | |||
109 |
|
109 | |||
110 | Notebook.prototype.ncells = function (cell) { |
|
110 | Notebook.prototype.ncells = function (cell) { | |
111 | return this.cell_elements().length; |
|
111 | return this.cell_elements().length; | |
112 | } |
|
112 | } | |
113 |
|
113 | |||
114 |
|
114 | |||
115 | // TODO: we are often calling cells as cells()[i], which we should optimize |
|
115 | // TODO: we are often calling cells as cells()[i], which we should optimize | |
116 | // to cells(i) or a new method. |
|
116 | // to cells(i) or a new method. | |
117 | Notebook.prototype.cells = function () { |
|
117 | Notebook.prototype.cells = function () { | |
118 | return this.cell_elements().toArray().map(function (e) { |
|
118 | return this.cell_elements().toArray().map(function (e) { | |
119 | return $(e).data("cell"); |
|
119 | return $(e).data("cell"); | |
120 | }); |
|
120 | }); | |
121 | } |
|
121 | } | |
122 |
|
122 | |||
123 |
|
123 | |||
124 | Notebook.prototype.find_cell_index = function (cell) { |
|
124 | Notebook.prototype.find_cell_index = function (cell) { | |
125 | var result = null; |
|
125 | var result = null; | |
126 | this.cell_elements().filter(function (index) { |
|
126 | this.cell_elements().filter(function (index) { | |
127 | if ($(this).data("cell") === cell) { |
|
127 | if ($(this).data("cell") === cell) { | |
128 | result = index; |
|
128 | result = index; | |
129 | }; |
|
129 | }; | |
130 | }); |
|
130 | }); | |
131 | return result; |
|
131 | return result; | |
132 | }; |
|
132 | }; | |
133 |
|
133 | |||
134 |
|
134 | |||
135 | Notebook.prototype.index_or_selected = function (index) { |
|
135 | Notebook.prototype.index_or_selected = function (index) { | |
136 | return index || this.selected_index() || 0; |
|
136 | return index || this.selected_index() || 0; | |
137 | } |
|
137 | } | |
138 |
|
138 | |||
139 |
|
139 | |||
140 | Notebook.prototype.select = function (index) { |
|
140 | Notebook.prototype.select = function (index) { | |
141 | if (index !== undefined && index >= 0 && index < this.ncells()) { |
|
141 | if (index !== undefined && index >= 0 && index < this.ncells()) { | |
142 | if (this.selected_index() !== null) { |
|
142 | if (this.selected_index() !== null) { | |
143 | this.selected_cell().unselect(); |
|
143 | this.selected_cell().unselect(); | |
144 | }; |
|
144 | }; | |
145 | this.cells()[index].select(); |
|
145 | this.cells()[index].select(); | |
146 | if (index === (this.ncells()-1)) { |
|
146 | if (index === (this.ncells()-1)) { | |
147 | this.scroll_to_bottom(); |
|
147 | this.scroll_to_bottom(); | |
148 | }; |
|
148 | }; | |
149 | }; |
|
149 | }; | |
150 | return this; |
|
150 | return this; | |
151 | }; |
|
151 | }; | |
152 |
|
152 | |||
153 |
|
153 | |||
154 | Notebook.prototype.select_next = function () { |
|
154 | Notebook.prototype.select_next = function () { | |
155 | var index = this.selected_index(); |
|
155 | var index = this.selected_index(); | |
156 | if (index !== null && index >= 0 && (index+1) < this.ncells()) { |
|
156 | if (index !== null && index >= 0 && (index+1) < this.ncells()) { | |
157 | this.select(index+1); |
|
157 | this.select(index+1); | |
158 | }; |
|
158 | }; | |
159 | return this; |
|
159 | return this; | |
160 | }; |
|
160 | }; | |
161 |
|
161 | |||
162 |
|
162 | |||
163 | Notebook.prototype.select_prev = function () { |
|
163 | Notebook.prototype.select_prev = function () { | |
164 | var index = this.selected_index(); |
|
164 | var index = this.selected_index(); | |
165 | if (index !== null && index >= 0 && (index-1) < this.ncells()) { |
|
165 | if (index !== null && index >= 0 && (index-1) < this.ncells()) { | |
166 | this.select(index-1); |
|
166 | this.select(index-1); | |
167 | }; |
|
167 | }; | |
168 | return this; |
|
168 | return this; | |
169 | }; |
|
169 | }; | |
170 |
|
170 | |||
171 |
|
171 | |||
172 | Notebook.prototype.selected_index = function () { |
|
172 | Notebook.prototype.selected_index = function () { | |
173 | var result = null; |
|
173 | var result = null; | |
174 | this.cell_elements().filter(function (index) { |
|
174 | this.cell_elements().filter(function (index) { | |
175 | if ($(this).data("cell").selected === true) { |
|
175 | if ($(this).data("cell").selected === true) { | |
176 | result = index; |
|
176 | result = index; | |
177 | }; |
|
177 | }; | |
178 | }); |
|
178 | }); | |
179 | return result; |
|
179 | return result; | |
180 | }; |
|
180 | }; | |
181 |
|
181 | |||
182 |
|
182 | |||
183 | Notebook.prototype.cell_for_msg = function (msg_id) { |
|
183 | Notebook.prototype.cell_for_msg = function (msg_id) { | |
184 | var cell_id = this.msg_cell_map[msg_id]; |
|
184 | var cell_id = this.msg_cell_map[msg_id]; | |
185 | var result = null; |
|
185 | var result = null; | |
186 | this.cell_elements().filter(function (index) { |
|
186 | this.cell_elements().filter(function (index) { | |
187 | cell = $(this).data("cell"); |
|
187 | cell = $(this).data("cell"); | |
188 | if (cell.cell_id === cell_id) { |
|
188 | if (cell.cell_id === cell_id) { | |
189 | result = cell; |
|
189 | result = cell; | |
190 | }; |
|
190 | }; | |
191 | }); |
|
191 | }); | |
192 | return result; |
|
192 | return result; | |
193 | }; |
|
193 | }; | |
194 |
|
194 | |||
195 |
|
195 | |||
196 | Notebook.prototype.selected_cell = function () { |
|
196 | Notebook.prototype.selected_cell = function () { | |
197 | return this.cell_elements().eq(this.selected_index()).data("cell"); |
|
197 | return this.cell_elements().eq(this.selected_index()).data("cell"); | |
198 | } |
|
198 | } | |
199 |
|
199 | |||
200 |
|
200 | |||
201 | // Cell insertion, deletion and moving. |
|
201 | // Cell insertion, deletion and moving. | |
202 |
|
202 | |||
203 |
|
203 | |||
204 | Notebook.prototype.delete_cell = function (index) { |
|
204 | Notebook.prototype.delete_cell = function (index) { | |
205 | var i = index || this.selected_index(); |
|
205 | var i = index || this.selected_index(); | |
206 | if (i !== null && i >= 0 && i < this.ncells()) { |
|
206 | if (i !== null && i >= 0 && i < this.ncells()) { | |
207 | this.cell_elements().eq(i).remove(); |
|
207 | this.cell_elements().eq(i).remove(); | |
208 | if (i === (this.ncells())) { |
|
208 | if (i === (this.ncells())) { | |
209 | this.select(i-1); |
|
209 | this.select(i-1); | |
210 | } else { |
|
210 | } else { | |
211 | this.select(i); |
|
211 | this.select(i); | |
212 | }; |
|
212 | }; | |
213 | }; |
|
213 | }; | |
214 | return this; |
|
214 | return this; | |
215 | }; |
|
215 | }; | |
216 |
|
216 | |||
217 |
|
217 | |||
218 | Notebook.prototype.append_cell = function (cell) { |
|
218 | Notebook.prototype.append_cell = function (cell) { | |
219 | this.element.find('div.end_space').before(cell.element); |
|
219 | this.element.find('div.end_space').before(cell.element); | |
220 | return this; |
|
220 | return this; | |
221 | }; |
|
221 | }; | |
222 |
|
222 | |||
223 |
|
223 | |||
224 | Notebook.prototype.insert_cell_after = function (cell, index) { |
|
224 | Notebook.prototype.insert_cell_after = function (cell, index) { | |
225 | var ncells = this.ncells(); |
|
225 | var ncells = this.ncells(); | |
226 | if (ncells === 0) { |
|
226 | if (ncells === 0) { | |
227 | this.append_cell(cell); |
|
227 | this.append_cell(cell); | |
228 | return this; |
|
228 | return this; | |
229 | }; |
|
229 | }; | |
230 | if (index >= 0 && index < ncells) { |
|
230 | if (index >= 0 && index < ncells) { | |
231 | this.cell_elements().eq(index).after(cell.element); |
|
231 | this.cell_elements().eq(index).after(cell.element); | |
232 | }; |
|
232 | }; | |
233 | return this |
|
233 | return this | |
234 | }; |
|
234 | }; | |
235 |
|
235 | |||
236 |
|
236 | |||
237 | Notebook.prototype.insert_cell_before = function (cell, index) { |
|
237 | Notebook.prototype.insert_cell_before = function (cell, index) { | |
238 | var ncells = this.ncells(); |
|
238 | var ncells = this.ncells(); | |
239 | if (ncells === 0) { |
|
239 | if (ncells === 0) { | |
240 | this.append_cell(cell); |
|
240 | this.append_cell(cell); | |
241 | return this; |
|
241 | return this; | |
242 | }; |
|
242 | }; | |
243 | if (index >= 0 && index < ncells) { |
|
243 | if (index >= 0 && index < ncells) { | |
244 | this.cell_elements().eq(index).before(cell.element); |
|
244 | this.cell_elements().eq(index).before(cell.element); | |
245 | }; |
|
245 | }; | |
246 | return this; |
|
246 | return this; | |
247 | }; |
|
247 | }; | |
248 |
|
248 | |||
249 |
|
249 | |||
250 | Notebook.prototype.move_cell_up = function (index) { |
|
250 | Notebook.prototype.move_cell_up = function (index) { | |
251 | var i = index || this.selected_index(); |
|
251 | var i = index || this.selected_index(); | |
252 | if (i !== null && i < this.ncells() && i > 0) { |
|
252 | if (i !== null && i < this.ncells() && i > 0) { | |
253 | var pivot = this.cell_elements().eq(i-1); |
|
253 | var pivot = this.cell_elements().eq(i-1); | |
254 | var tomove = this.cell_elements().eq(i); |
|
254 | var tomove = this.cell_elements().eq(i); | |
255 | if (pivot !== null && tomove !== null) { |
|
255 | if (pivot !== null && tomove !== null) { | |
256 | tomove.detach(); |
|
256 | tomove.detach(); | |
257 | pivot.before(tomove); |
|
257 | pivot.before(tomove); | |
258 | this.select(i-1); |
|
258 | this.select(i-1); | |
259 | }; |
|
259 | }; | |
260 | }; |
|
260 | }; | |
261 | return this; |
|
261 | return this; | |
262 | } |
|
262 | } | |
263 |
|
263 | |||
264 |
|
264 | |||
265 | Notebook.prototype.move_cell_down = function (index) { |
|
265 | Notebook.prototype.move_cell_down = function (index) { | |
266 | var i = index || this.selected_index(); |
|
266 | var i = index || this.selected_index(); | |
267 | if (i !== null && i < (this.ncells()-1) && i >= 0) { |
|
267 | if (i !== null && i < (this.ncells()-1) && i >= 0) { | |
268 | var pivot = this.cell_elements().eq(i+1) |
|
268 | var pivot = this.cell_elements().eq(i+1) | |
269 | var tomove = this.cell_elements().eq(i) |
|
269 | var tomove = this.cell_elements().eq(i) | |
270 | if (pivot !== null && tomove !== null) { |
|
270 | if (pivot !== null && tomove !== null) { | |
271 | tomove.detach(); |
|
271 | tomove.detach(); | |
272 | pivot.after(tomove); |
|
272 | pivot.after(tomove); | |
273 | this.select(i+1); |
|
273 | this.select(i+1); | |
274 | }; |
|
274 | }; | |
275 | }; |
|
275 | }; | |
276 | return this; |
|
276 | return this; | |
277 | } |
|
277 | } | |
278 |
|
278 | |||
279 |
|
279 | |||
280 | Notebook.prototype.sort_cells = function () { |
|
280 | Notebook.prototype.sort_cells = function () { | |
281 | var ncells = this.ncells(); |
|
281 | var ncells = this.ncells(); | |
282 | var sindex = this.selected_index(); |
|
282 | var sindex = this.selected_index(); | |
283 | var swapped; |
|
283 | var swapped; | |
284 | do { |
|
284 | do { | |
285 | swapped = false |
|
285 | swapped = false | |
286 | for (var i=1; i<ncells; i++) { |
|
286 | for (var i=1; i<ncells; i++) { | |
287 | current = this.cell_elements().eq(i).data("cell"); |
|
287 | current = this.cell_elements().eq(i).data("cell"); | |
288 | previous = this.cell_elements().eq(i-1).data("cell"); |
|
288 | previous = this.cell_elements().eq(i-1).data("cell"); | |
289 | if (previous.input_prompt_number > current.input_prompt_number) { |
|
289 | if (previous.input_prompt_number > current.input_prompt_number) { | |
290 | this.move_cell_up(i); |
|
290 | this.move_cell_up(i); | |
291 | swapped = true; |
|
291 | swapped = true; | |
292 | }; |
|
292 | }; | |
293 | }; |
|
293 | }; | |
294 | } while (swapped); |
|
294 | } while (swapped); | |
295 | this.select(sindex); |
|
295 | this.select(sindex); | |
296 | return this; |
|
296 | return this; | |
297 | }; |
|
297 | }; | |
298 |
|
298 | |||
299 |
|
299 | |||
300 | Notebook.prototype.insert_code_cell_before = function (index) { |
|
300 | Notebook.prototype.insert_code_cell_before = function (index) { | |
301 | // TODO: Bounds check for i |
|
301 | // TODO: Bounds check for i | |
302 | var i = this.index_or_selected(index); |
|
302 | var i = this.index_or_selected(index); | |
303 | var cell = new IPython.CodeCell(this); |
|
303 | var cell = new IPython.CodeCell(this); | |
304 | // cell.set_input_prompt(this.next_prompt_number); |
|
304 | // cell.set_input_prompt(this.next_prompt_number); | |
305 | cell.set_input_prompt(); |
|
305 | cell.set_input_prompt(); | |
306 | this.next_prompt_number = this.next_prompt_number + 1; |
|
306 | this.next_prompt_number = this.next_prompt_number + 1; | |
307 | this.insert_cell_before(cell, i); |
|
307 | this.insert_cell_before(cell, i); | |
308 | this.select(this.find_cell_index(cell)); |
|
308 | this.select(this.find_cell_index(cell)); | |
309 | return this; |
|
309 | return this; | |
310 | } |
|
310 | } | |
311 |
|
311 | |||
312 |
|
312 | |||
313 | Notebook.prototype.insert_code_cell_after = function (index) { |
|
313 | Notebook.prototype.insert_code_cell_after = function (index) { | |
314 | // TODO: Bounds check for i |
|
314 | // TODO: Bounds check for i | |
315 | var i = this.index_or_selected(index); |
|
315 | var i = this.index_or_selected(index); | |
316 | var cell = new IPython.CodeCell(this); |
|
316 | var cell = new IPython.CodeCell(this); | |
317 | // cell.set_input_prompt(this.next_prompt_number); |
|
317 | // cell.set_input_prompt(this.next_prompt_number); | |
318 | cell.set_input_prompt(); |
|
318 | cell.set_input_prompt(); | |
319 | this.next_prompt_number = this.next_prompt_number + 1; |
|
319 | this.next_prompt_number = this.next_prompt_number + 1; | |
320 | this.insert_cell_after(cell, i); |
|
320 | this.insert_cell_after(cell, i); | |
321 | this.select(this.find_cell_index(cell)); |
|
321 | this.select(this.find_cell_index(cell)); | |
322 | return this; |
|
322 | return this; | |
323 | } |
|
323 | } | |
324 |
|
324 | |||
325 |
|
325 | |||
326 | Notebook.prototype.insert_text_cell_before = function (index) { |
|
326 | Notebook.prototype.insert_text_cell_before = function (index) { | |
327 | // TODO: Bounds check for i |
|
327 | // TODO: Bounds check for i | |
328 | var i = this.index_or_selected(index); |
|
328 | var i = this.index_or_selected(index); | |
329 | var cell = new IPython.TextCell(this); |
|
329 | var cell = new IPython.TextCell(this); | |
330 | cell.config_mathjax(); |
|
330 | cell.config_mathjax(); | |
331 | this.insert_cell_before(cell, i); |
|
331 | this.insert_cell_before(cell, i); | |
332 | this.select(this.find_cell_index(cell)); |
|
332 | this.select(this.find_cell_index(cell)); | |
333 | return this; |
|
333 | return this; | |
334 | } |
|
334 | } | |
335 |
|
335 | |||
336 |
|
336 | |||
337 | Notebook.prototype.insert_text_cell_after = function (index) { |
|
337 | Notebook.prototype.insert_text_cell_after = function (index) { | |
338 | // TODO: Bounds check for i |
|
338 | // TODO: Bounds check for i | |
339 | var i = this.index_or_selected(index); |
|
339 | var i = this.index_or_selected(index); | |
340 | var cell = new IPython.TextCell(this); |
|
340 | var cell = new IPython.TextCell(this); | |
341 | cell.config_mathjax(); |
|
341 | cell.config_mathjax(); | |
342 | this.insert_cell_after(cell, i); |
|
342 | this.insert_cell_after(cell, i); | |
343 | this.select(this.find_cell_index(cell)); |
|
343 | this.select(this.find_cell_index(cell)); | |
344 | return this; |
|
344 | return this; | |
345 | } |
|
345 | } | |
346 |
|
346 | |||
347 |
|
347 | |||
348 | Notebook.prototype.text_to_code = function (index) { |
|
348 | Notebook.prototype.text_to_code = function (index) { | |
349 | // TODO: Bounds check for i |
|
349 | // TODO: Bounds check for i | |
350 | var i = this.index_or_selected(index); |
|
350 | var i = this.index_or_selected(index); | |
351 | var source_element = this.cell_elements().eq(i); |
|
351 | var source_element = this.cell_elements().eq(i); | |
352 | var source_cell = source_element.data("cell"); |
|
352 | var source_cell = source_element.data("cell"); | |
353 | if (source_cell instanceof IPython.TextCell) { |
|
353 | if (source_cell instanceof IPython.TextCell) { | |
354 | this.insert_code_cell_after(i); |
|
354 | this.insert_code_cell_after(i); | |
355 | var target_cell = this.cells()[i+1]; |
|
355 | var target_cell = this.cells()[i+1]; | |
356 | target_cell.set_code(source_cell.get_text()); |
|
356 | target_cell.set_code(source_cell.get_text()); | |
357 | source_element.remove(); |
|
357 | source_element.remove(); | |
358 | }; |
|
358 | }; | |
359 | }; |
|
359 | }; | |
360 |
|
360 | |||
361 |
|
361 | |||
362 | Notebook.prototype.code_to_text = function (index) { |
|
362 | Notebook.prototype.code_to_text = function (index) { | |
363 | // TODO: Bounds check for i |
|
363 | // TODO: Bounds check for i | |
364 | var i = this.index_or_selected(index); |
|
364 | var i = this.index_or_selected(index); | |
365 | var source_element = this.cell_elements().eq(i); |
|
365 | var source_element = this.cell_elements().eq(i); | |
366 | var source_cell = source_element.data("cell"); |
|
366 | var source_cell = source_element.data("cell"); | |
367 | if (source_cell instanceof IPython.CodeCell) { |
|
367 | if (source_cell instanceof IPython.CodeCell) { | |
368 | this.insert_text_cell_after(i); |
|
368 | this.insert_text_cell_after(i); | |
369 | var target_cell = this.cells()[i+1]; |
|
369 | var target_cell = this.cells()[i+1]; | |
370 | var text = source_cell.get_code(); |
|
370 | var text = source_cell.get_code(); | |
371 | if (text === "") {text = target_cell.placeholder;}; |
|
371 | if (text === "") {text = target_cell.placeholder;}; | |
372 | target_cell.set_text(text); |
|
372 | target_cell.set_text(text); | |
373 | source_element.remove(); |
|
373 | source_element.remove(); | |
374 | target_cell.edit(); |
|
374 | target_cell.edit(); | |
375 | }; |
|
375 | }; | |
376 | }; |
|
376 | }; | |
377 |
|
377 | |||
378 |
|
378 | |||
379 | // Cell collapsing |
|
379 | // Cell collapsing | |
380 |
|
380 | |||
381 | Notebook.prototype.collapse = function (index) { |
|
381 | Notebook.prototype.collapse = function (index) { | |
382 | var i = this.index_or_selected(index); |
|
382 | var i = this.index_or_selected(index); | |
383 | this.cells()[i].collapse(); |
|
383 | this.cells()[i].collapse(); | |
384 | }; |
|
384 | }; | |
385 |
|
385 | |||
386 |
|
386 | |||
387 | Notebook.prototype.expand = function (index) { |
|
387 | Notebook.prototype.expand = function (index) { | |
388 | var i = this.index_or_selected(index); |
|
388 | var i = this.index_or_selected(index); | |
389 | this.cells()[i].expand(); |
|
389 | this.cells()[i].expand(); | |
390 | }; |
|
390 | }; | |
391 |
|
391 | |||
392 |
|
392 | |||
393 | // Kernel related things |
|
393 | // Kernel related things | |
394 |
|
394 | |||
395 | Notebook.prototype.start_kernel = function () { |
|
395 | Notebook.prototype.start_kernel = function () { | |
396 | this.kernel = new IPython.Kernel(); |
|
396 | this.kernel = new IPython.Kernel(); | |
397 | this.kernel.start_kernel($.proxy(this.kernel_started, this)); |
|
397 | this.kernel.start_kernel($.proxy(this.kernel_started, this)); | |
398 | }; |
|
398 | }; | |
399 |
|
399 | |||
400 |
|
400 | |||
401 | Notebook.prototype.handle_shell_reply = function (e) { |
|
401 | Notebook.prototype.handle_shell_reply = function (e) { | |
402 | reply = $.parseJSON(e.data); |
|
402 | reply = $.parseJSON(e.data); | |
403 | var header = reply.header; |
|
403 | var header = reply.header; | |
404 | var content = reply.content; |
|
404 | var content = reply.content; | |
405 | var msg_type = header.msg_type; |
|
405 | var msg_type = header.msg_type; | |
406 | // console.log(reply); |
|
406 | // console.log(reply); | |
407 | var cell = this.cell_for_msg(reply.parent_header.msg_id); |
|
407 | var cell = this.cell_for_msg(reply.parent_header.msg_id); | |
408 | if (msg_type === "execute_reply") { |
|
408 | if (msg_type === "execute_reply") { | |
409 | cell.set_input_prompt(content.execution_count); |
|
409 | cell.set_input_prompt(content.execution_count); | |
410 | } else if (msg_type === "complete_reply") { |
|
410 | } else if (msg_type === "complete_reply") { | |
411 | cell.finish_completing(content.matched_text, content.matches); |
|
411 | cell.finish_completing(content.matched_text, content.matches); | |
412 | }; |
|
412 | }; | |
413 | var payload = content.payload || []; |
|
413 | var payload = content.payload || []; | |
414 | this.handle_payload(payload); |
|
414 | this.handle_payload(payload); | |
415 | }; |
|
415 | }; | |
416 |
|
416 | |||
417 |
|
417 | |||
418 | Notebook.prototype.handle_payload = function (payload) { |
|
418 | Notebook.prototype.handle_payload = function (payload) { | |
419 | var l = payload.length; |
|
419 | var l = payload.length; | |
420 | if (l > 0) { |
|
420 | if (l > 0) { | |
421 | IPython.pager.clear(); |
|
421 | IPython.pager.clear(); | |
422 | IPython.pager.expand(); |
|
422 | IPython.pager.expand(); | |
423 | }; |
|
423 | }; | |
424 | for (var i=0; i<l; i++) { |
|
424 | for (var i=0; i<l; i++) { | |
425 | IPython.pager.append_text(payload[i].text); |
|
425 | IPython.pager.append_text(payload[i].text); | |
426 | }; |
|
426 | }; | |
427 | }; |
|
427 | }; | |
428 |
|
428 | |||
429 |
|
429 | |||
430 | Notebook.prototype.handle_iopub_reply = function (e) { |
|
430 | Notebook.prototype.handle_iopub_reply = function (e) { | |
431 | reply = $.parseJSON(e.data); |
|
431 | reply = $.parseJSON(e.data); | |
432 | var content = reply.content; |
|
432 | var content = reply.content; | |
433 | // console.log(reply); |
|
433 | // console.log(reply); | |
434 | var msg_type = reply.header.msg_type; |
|
434 | var msg_type = reply.header.msg_type; | |
435 | var cell = this.cell_for_msg(reply.parent_header.msg_id); |
|
435 | var cell = this.cell_for_msg(reply.parent_header.msg_id); | |
436 | if (msg_type === "stream") { |
|
436 | if (msg_type === "stream") { | |
437 | cell.expand(); |
|
437 | cell.expand(); | |
438 | cell.append_stream(content.data + "\n"); |
|
438 | cell.append_stream(content.data + "\n"); | |
439 | } else if (msg_type === "display_data") { |
|
439 | } else if (msg_type === "display_data") { | |
440 | cell.expand(); |
|
440 | cell.expand(); | |
441 | cell.append_display_data(content.data); |
|
441 | cell.append_display_data(content.data); | |
442 | } else if (msg_type === "pyout") { |
|
442 | } else if (msg_type === "pyout") { | |
443 | cell.expand(); |
|
443 | cell.expand(); | |
444 | cell.append_pyout(content.data, content.execution_count) |
|
444 | cell.append_pyout(content.data, content.execution_count) | |
445 | } else if (msg_type === "pyerr") { |
|
445 | } else if (msg_type === "pyerr") { | |
446 | cell.expand(); |
|
446 | cell.expand(); | |
447 | cell.append_pyerr(content.ename, content.evalue, content.traceback); |
|
447 | cell.append_pyerr(content.ename, content.evalue, content.traceback); | |
448 | } else if (msg_type === "status") { |
|
448 | } else if (msg_type === "status") { | |
449 | if (content.execution_state === "busy") { |
|
449 | if (content.execution_state === "busy") { | |
450 | IPython.kernel_status_widget.status_busy(); |
|
450 | IPython.kernel_status_widget.status_busy(); | |
451 | } else if (content.execution_state === "idle") { |
|
451 | } else if (content.execution_state === "idle") { | |
452 | IPython.kernel_status_widget.status_idle(); |
|
452 | IPython.kernel_status_widget.status_idle(); | |
453 | }; |
|
453 | }; | |
454 | } |
|
454 | } | |
455 | }; |
|
455 | }; | |
456 |
|
456 | |||
457 |
|
457 | |||
458 | Notebook.prototype.kernel_started = function () { |
|
458 | Notebook.prototype.kernel_started = function () { | |
459 | console.log("Kernel started: ", this.kernel.kernel_id); |
|
459 | console.log("Kernel started: ", this.kernel.kernel_id); | |
460 | this.kernel.shell_channel.onmessage = $.proxy(this.handle_shell_reply,this); |
|
460 | this.kernel.shell_channel.onmessage = $.proxy(this.handle_shell_reply,this); | |
461 | this.kernel.iopub_channel.onmessage = $.proxy(this.handle_iopub_reply,this); |
|
461 | this.kernel.iopub_channel.onmessage = $.proxy(this.handle_iopub_reply,this); | |
462 | }; |
|
462 | }; | |
463 |
|
463 | |||
464 |
|
464 | |||
465 | Notebook.prototype.execute_selected_cell = function (options) { |
|
465 | Notebook.prototype.execute_selected_cell = function (options) { | |
466 | // add_new: should a new cell be added if we are at the end of the nb |
|
466 | // add_new: should a new cell be added if we are at the end of the nb | |
467 | // terminal: execute in terminal mode, which stays in the current cell |
|
467 | // terminal: execute in terminal mode, which stays in the current cell | |
468 | default_options = {terminal: false, add_new: true} |
|
468 | default_options = {terminal: false, add_new: true} | |
469 | $.extend(default_options, options) |
|
469 | $.extend(default_options, options) | |
470 | var that = this; |
|
470 | var that = this; | |
471 | var cell = that.selected_cell(); |
|
471 | var cell = that.selected_cell(); | |
472 | var cell_index = that.find_cell_index(cell); |
|
472 | var cell_index = that.find_cell_index(cell); | |
473 | // TODO: the logic here needs to be moved into appropriate |
|
|||
474 | // methods of Notebook. |
|
|||
475 | if (cell instanceof IPython.CodeCell) { |
|
473 | if (cell instanceof IPython.CodeCell) { | |
476 | cell.clear_output(); |
|
474 | cell.clear_output(); | |
477 | var code = cell.get_code(); |
|
475 | var code = cell.get_code(); | |
478 | if (that.notebook_load_re.test(code)) { |
|
476 | if (that.notebook_load_re.test(code)) { | |
|
477 | // %notebook load | |||
479 | var code_parts = code.split(' '); |
|
478 | var code_parts = code.split(' '); | |
480 | if (code_parts.length === 3) { |
|
479 | if (code_parts.length === 3) { | |
481 | that.load_notebook(code_parts[2]); |
|
480 | that.load_notebook(code_parts[2]); | |
482 | }; |
|
481 | }; | |
483 | } else if (that.notebook_save_re.test(code)) { |
|
482 | } else if (that.notebook_save_re.test(code)) { | |
|
483 | // %notebook save | |||
484 | var code_parts = code.split(' '); |
|
484 | var code_parts = code.split(' '); | |
485 | if (code_parts.length === 3) { |
|
485 | if (code_parts.length === 3) { | |
486 | that.save_notebook(code_parts[2]); |
|
486 | that.save_notebook(code_parts[2]); | |
487 | } else { |
|
487 | } else { | |
488 | that.save_notebook() |
|
488 | that.save_notebook() | |
489 | }; |
|
489 | }; | |
490 | } else { |
|
490 | } else { | |
491 | var msg_id = that.kernel.execute(cell.get_code()); |
|
491 | var msg_id = that.kernel.execute(cell.get_code()); | |
492 | that.msg_cell_map[msg_id] = cell.cell_id; |
|
492 | that.msg_cell_map[msg_id] = cell.cell_id; | |
493 | }; |
|
493 | }; | |
494 | } else if (cell instanceof IPython.TextCell) { |
|
494 | } else if (cell instanceof IPython.TextCell) { | |
495 | cell.render(); |
|
495 | cell.render(); | |
496 | } |
|
496 | } | |
497 | if (default_options.terminal) { |
|
497 | if (default_options.terminal) { | |
498 | cell.clear_input(); |
|
498 | cell.clear_input(); | |
499 | } else { |
|
499 | } else { | |
500 | if ((cell_index === (that.ncells()-1)) && default_options.add_new) { |
|
500 | if ((cell_index === (that.ncells()-1)) && default_options.add_new) { | |
501 | that.insert_code_cell_after(); |
|
501 | that.insert_code_cell_after(); | |
502 | // If we are adding a new cell at the end, scroll down to show it. |
|
502 | // If we are adding a new cell at the end, scroll down to show it. | |
503 | that.scroll_to_bottom(); |
|
503 | that.scroll_to_bottom(); | |
504 | } else { |
|
504 | } else { | |
505 | that.select(cell_index+1); |
|
505 | that.select(cell_index+1); | |
506 | }; |
|
506 | }; | |
507 | }; |
|
507 | }; | |
508 | }; |
|
508 | }; | |
509 |
|
509 | |||
510 |
|
510 | |||
511 | Notebook.prototype.execute_all_cells = function () { |
|
511 | Notebook.prototype.execute_all_cells = function () { | |
512 | var ncells = this.ncells(); |
|
512 | var ncells = this.ncells(); | |
513 | for (var i=0; i<ncells; i++) { |
|
513 | for (var i=0; i<ncells; i++) { | |
514 | this.select(i); |
|
514 | this.select(i); | |
515 | this.execute_selected_cell({add_new:false}); |
|
515 | this.execute_selected_cell({add_new:false}); | |
516 | }; |
|
516 | }; | |
517 | this.scroll_to_bottom(); |
|
517 | this.scroll_to_bottom(); | |
518 | }; |
|
518 | }; | |
519 |
|
519 | |||
520 |
|
520 | |||
521 | Notebook.prototype.complete_cell = function (cell, line, cursor_pos) { |
|
521 | Notebook.prototype.complete_cell = function (cell, line, cursor_pos) { | |
522 | var msg_id = this.kernel.complete(line, cursor_pos); |
|
522 | var msg_id = this.kernel.complete(line, cursor_pos); | |
523 | this.msg_cell_map[msg_id] = cell.cell_id; |
|
523 | this.msg_cell_map[msg_id] = cell.cell_id; | |
524 | }; |
|
524 | }; | |
525 |
|
525 | |||
526 | // Persistance and loading |
|
526 | // Persistance and loading | |
527 |
|
527 | |||
528 |
|
528 | |||
529 | Notebook.prototype.fromJSON = function (data) { |
|
529 | Notebook.prototype.fromJSON = function (data) { | |
530 | var ncells = this.ncells(); |
|
530 | var ncells = this.ncells(); | |
531 | for (var i=0; i<ncells; i++) { |
|
531 | for (var i=0; i<ncells; i++) { | |
532 | // Always delete cell 0 as they get renumbered as they are deleted. |
|
532 | // Always delete cell 0 as they get renumbered as they are deleted. | |
533 | this.delete_cell(0); |
|
533 | this.delete_cell(0); | |
534 | }; |
|
534 | }; | |
535 | var new_cells = data.cells; |
|
535 | var new_cells = data.cells; | |
536 | ncells = new_cells.length; |
|
536 | ncells = new_cells.length; | |
537 | var cell_data = null; |
|
537 | var cell_data = null; | |
538 | for (var i=0; i<ncells; i++) { |
|
538 | for (var i=0; i<ncells; i++) { | |
539 | cell_data = new_cells[i]; |
|
539 | cell_data = new_cells[i]; | |
540 | if (cell_data.cell_type == 'code') { |
|
540 | if (cell_data.cell_type == 'code') { | |
541 | this.insert_code_cell_after(); |
|
541 | this.insert_code_cell_after(); | |
542 | this.selected_cell().fromJSON(cell_data); |
|
542 | this.selected_cell().fromJSON(cell_data); | |
543 | } else if (cell_data.cell_type === 'text') { |
|
543 | } else if (cell_data.cell_type === 'text') { | |
544 | this.insert_text_cell_after(); |
|
544 | this.insert_text_cell_after(); | |
545 | this.selected_cell().fromJSON(cell_data); |
|
545 | this.selected_cell().fromJSON(cell_data); | |
546 | }; |
|
546 | }; | |
547 | }; |
|
547 | }; | |
548 | }; |
|
548 | }; | |
549 |
|
549 | |||
550 |
|
550 | |||
551 | Notebook.prototype.toJSON = function () { |
|
551 | Notebook.prototype.toJSON = function () { | |
552 | var cells = this.cells(); |
|
552 | var cells = this.cells(); | |
553 | var ncells = cells.length; |
|
553 | var ncells = cells.length; | |
554 | cell_array = new Array(ncells); |
|
554 | cell_array = new Array(ncells); | |
555 | for (var i=0; i<ncells; i++) { |
|
555 | for (var i=0; i<ncells; i++) { | |
556 | cell_array[i] = cells[i].toJSON(); |
|
556 | cell_array[i] = cells[i].toJSON(); | |
557 | }; |
|
557 | }; | |
558 | json = { |
|
558 | json = { | |
559 | cells : cell_array |
|
559 | cells : cell_array | |
560 | }; |
|
560 | }; | |
561 | return json |
|
561 | return json | |
562 | }; |
|
562 | }; | |
563 |
|
563 | |||
564 |
|
564 | |||
565 | Notebook.prototype.test_filename = function (filename) { |
|
565 | Notebook.prototype.test_filename = function (filename) { | |
566 | if (this.notebook_filename_re.test(filename)) { |
|
566 | if (this.notebook_filename_re.test(filename)) { | |
567 | return true; |
|
567 | return true; | |
568 | } else { |
|
568 | } else { | |
569 | var bad_filename = $('<div/>'); |
|
569 | var bad_filename = $('<div/>'); | |
570 | bad_filename.html( |
|
570 | bad_filename.html( | |
571 | "The filename you entered (" + filename + ") is not valid. Notebook filenames must have the following form: foo.ipynb" |
|
571 | "The filename you entered (" + filename + ") is not valid. Notebook filenames must have the following form: foo.ipynb" | |
572 | ); |
|
572 | ); | |
573 | bad_filename.dialog({title: 'Invalid filename', modal: true}); |
|
573 | bad_filename.dialog({title: 'Invalid filename', modal: true}); | |
574 | return false; |
|
574 | return false; | |
575 | }; |
|
575 | }; | |
576 | }; |
|
576 | }; | |
577 |
|
577 | |||
578 | Notebook.prototype.save_notebook = function (filename) { |
|
578 | Notebook.prototype.save_notebook = function (filename) { | |
579 | this.filename = filename || this.filename || ''; |
|
579 | this.filename = filename || this.filename || ''; | |
580 | if (this.filename === '') { |
|
580 | if (this.filename === '') { | |
581 | var no_filename = $('<div/>'); |
|
581 | var no_filename = $('<div/>'); | |
582 | no_filename.html( |
|
582 | no_filename.html( | |
583 | "This notebook has no filename, please specify a filename of the form: foo.ipynb" |
|
583 | "This notebook has no filename, please specify a filename of the form: foo.ipynb" | |
584 | ); |
|
584 | ); | |
585 | no_filename.dialog({title: 'Missing filename', modal: true}); |
|
585 | no_filename.dialog({title: 'Missing filename', modal: true}); | |
586 | return; |
|
586 | return; | |
587 | } |
|
587 | } | |
588 | if (!this.test_filename(this.filename)) {return;} |
|
588 | if (!this.test_filename(this.filename)) {return;} | |
589 | var thedata = this.toJSON(); |
|
589 | var thedata = this.toJSON(); | |
590 | var settings = { |
|
590 | var settings = { | |
591 | processData : false, |
|
591 | processData : false, | |
592 | cache : false, |
|
592 | cache : false, | |
593 | type : "PUT", |
|
593 | type : "PUT", | |
594 | data : JSON.stringify(thedata), |
|
594 | data : JSON.stringify(thedata), | |
595 | success : function (data, status, xhr) {console.log(data);} |
|
595 | success : function (data, status, xhr) {console.log(data);} | |
596 | }; |
|
596 | }; | |
597 | $.ajax("/notebooks/" + this.filename, settings); |
|
597 | $.ajax("/notebooks/" + this.filename, settings); | |
598 | }; |
|
598 | }; | |
599 |
|
599 | |||
600 |
|
600 | |||
601 | Notebook.prototype.load_notebook = function (filename) { |
|
601 | Notebook.prototype.load_notebook = function (filename) { | |
602 | if (!this.test_filename(filename)) {return;} |
|
602 | if (!this.test_filename(filename)) {return;} | |
603 | var that = this; |
|
603 | var that = this; | |
604 | // We do the call with settings so we can set cache to false. |
|
604 | // We do the call with settings so we can set cache to false. | |
605 | var settings = { |
|
605 | var settings = { | |
606 | processData : false, |
|
606 | processData : false, | |
607 | cache : false, |
|
607 | cache : false, | |
608 | type : "GET", |
|
608 | type : "GET", | |
609 | dataType : "json", |
|
609 | dataType : "json", | |
610 | success : function (data, status, xhr) { |
|
610 | success : function (data, status, xhr) { | |
611 | that.fromJSON(data); |
|
611 | that.fromJSON(data); | |
612 | that.filename = filename; |
|
612 | that.filename = filename; | |
613 | that.kernel.restart(); |
|
613 | that.kernel.restart(); | |
614 | } |
|
614 | } | |
615 | }; |
|
615 | }; | |
616 | $.ajax("/notebooks/" + filename, settings); |
|
616 | $.ajax("/notebooks/" + filename, settings); | |
617 | } |
|
617 | } | |
618 |
|
618 | |||
619 | IPython.Notebook = Notebook; |
|
619 | IPython.Notebook = Notebook; | |
620 |
|
620 | |||
621 | return IPython; |
|
621 | return IPython; | |
622 |
|
622 | |||
623 | }(IPython)); |
|
623 | }(IPython)); | |
624 |
|
624 |
@@ -1,38 +1,42 | |||||
1 |
|
1 | |||
2 | //============================================================================ |
|
2 | //============================================================================ | |
3 | // On document ready |
|
3 | // On document ready | |
4 | //============================================================================ |
|
4 | //============================================================================ | |
5 |
|
5 | |||
6 |
|
6 | |||
7 | $(document).ready(function () { |
|
7 | $(document).ready(function () { | |
8 |
|
8 | |||
9 | MathJax.Hub.Config({ |
|
9 | MathJax.Hub.Config({ | |
10 | tex2jax: { |
|
10 | tex2jax: { | |
11 | inlineMath: [ ['$','$'], ["\\(","\\)"] ], |
|
11 | inlineMath: [ ['$','$'], ["\\(","\\)"] ], | |
12 | displayMath: [ ['$$','$$'], ["\\[","\\]"] ], |
|
12 | displayMath: [ ['$$','$$'], ["\\[","\\]"] ], | |
13 | }, |
|
13 | }, | |
14 | displayAlign: 'left', // Change this to 'center' to center equations. |
|
14 | displayAlign: 'left', // Change this to 'center' to center equations. | |
15 | "HTML-CSS": { |
|
15 | "HTML-CSS": { | |
16 | styles: {'.MathJax_Display': {"margin": 0}} |
|
16 | styles: {'.MathJax_Display': {"margin": 0}} | |
17 | } |
|
17 | } | |
18 | }); |
|
18 | }); | |
19 |
|
19 | |||
20 | $('div#header').addClass('border-box-sizing'); |
|
20 | $('div#header').addClass('border-box-sizing'); | |
21 | $('div#notebook_app').addClass('border-box-sizing ui-widget ui-widget-content'); |
|
21 | $('div#notebook_app').addClass('border-box-sizing ui-widget ui-widget-content'); | |
22 | $('div#notebook_panel').addClass('border-box-sizing ui-widget'); |
|
22 | $('div#notebook_panel').addClass('border-box-sizing ui-widget'); | |
23 |
|
23 | |||
24 | IPython.layout_manager = new IPython.LayoutManager(); |
|
24 | IPython.layout_manager = new IPython.LayoutManager(); | |
25 | IPython.pager = new IPython.Pager('div#pager', 'div#pager_splitter'); |
|
25 | IPython.pager = new IPython.Pager('div#pager', 'div#pager_splitter'); | |
26 | IPython.left_panel = new IPython.LeftPanel('div#left_panel', 'div#left_panel_splitter'); |
|
26 | IPython.left_panel = new IPython.LeftPanel('div#left_panel', 'div#left_panel_splitter'); | |
27 | IPython.save_widget = new IPython.SaveWidget('span#save_widget'); |
|
27 | IPython.save_widget = new IPython.SaveWidget('span#save_widget'); | |
28 | IPython.notebook = new IPython.Notebook('div#notebook'); |
|
28 | IPython.notebook = new IPython.Notebook('div#notebook'); | |
29 | IPython.kernel_status_widget = new IPython.KernelStatusWidget('#kernel_status'); |
|
29 | IPython.kernel_status_widget = new IPython.KernelStatusWidget('#kernel_status'); | |
30 | IPython.kernel_status_widget.status_idle(); |
|
30 | IPython.kernel_status_widget.status_idle(); | |
31 |
|
31 | |||
32 | IPython.layout_manager.do_resize(); |
|
32 | IPython.layout_manager.do_resize(); | |
33 | IPython.notebook.insert_code_cell_after(); |
|
33 | IPython.notebook.insert_code_cell_after(); | |
34 | IPython.layout_manager.do_resize(); |
|
34 | IPython.layout_manager.do_resize(); | |
35 | IPython.pager.collapse(); |
|
35 | IPython.pager.collapse(); | |
36 | IPython.layout_manager.do_resize(); |
|
36 | IPython.layout_manager.do_resize(); | |
|
37 | ||||
|
38 | // These have display: none in the css file and are made visible here to prevent FLOUC. | |||
|
39 | $('div#header').css('display','block'); | |||
|
40 | $('div#notebook_app').css('display','block'); | |||
37 | }); |
|
41 | }); | |
38 |
|
42 |
General Comments 0
You need to be logged in to leave comments.
Login now