Show More
@@ -0,0 +1,20 b'' | |||||
|
1 | .rendered_html {color: black;} | |||
|
2 | .rendered_html em {font-style: italic;} | |||
|
3 | .rendered_html strong {font-weight: bold;} | |||
|
4 | .rendered_html u {text-decoration: underline;} | |||
|
5 | .rendered_html :link { text-decoration: underline } | |||
|
6 | .rendered_html :visited { text-decoration: underline } | |||
|
7 | .rendered_html h1 {font-size: 197%; margin: .67em 0; font-weight: bold;} | |||
|
8 | .rendered_html h2 {font-size: 153.9%; margin: .75em 0; font-weight: bold;} | |||
|
9 | .rendered_html h3 {font-size: 116%; margin: .83em 0; font-weight: bold;} | |||
|
10 | .rendered_html h4 {margin: 1.12em 0; font-weight: bold;} | |||
|
11 | .rendered_html h5 {font-size: 85%.; margin: 1.5em 0; font-weight: bold;} | |||
|
12 | .rendered_html h6 {font-size: 77%; margin: 1.67em 0; font-weight: bold;} | |||
|
13 | .rendered_html ul {list-style:disc; margin-left: 40px;} | |||
|
14 | .rendered_html ul ul {list-style:square; margin-left: 40px;} | |||
|
15 | .rendered_html ul ul ul {list-style:circle; margin-left: 40px;} | |||
|
16 | .rendered_html ol {list-style:upper-roman; margin-left: 40px;} | |||
|
17 | .rendered_html ol ol {list-style:upper-alpha;} | |||
|
18 | .rendered_html ol ol ol {list-style:decimal;} | |||
|
19 | .rendered_html ol ol ol ol {list-style:lower-alpha;} | |||
|
20 | .rendered_html ol ol ol ol ol {list-style:lower-roman;} No newline at end of file |
@@ -1,303 +1,266 b'' | |||||
1 |
|
1 | |||
2 | /** |
|
2 | /** | |
3 | * Primary styles |
|
3 | * Primary styles | |
4 | * |
|
4 | * | |
5 | * Author: IPython Development Team |
|
5 | * Author: IPython Development Team | |
6 | */ |
|
6 | */ | |
7 |
|
7 | |||
8 |
|
8 | |||
9 | body { |
|
9 | body { | |
10 | background-color: white; |
|
10 | background-color: white; | |
11 | /* This makes sure that the body covers the entire window and needs to |
|
11 | /* This makes sure that the body covers the entire window and needs to | |
12 | be in a different element than the display: box in wrapper below */ |
|
12 | be in a different element than the display: box in wrapper below */ | |
13 | position: absolute; |
|
13 | position: absolute; | |
14 | left: 0px; |
|
14 | left: 0px; | |
15 | right: 0px; |
|
15 | right: 0px; | |
16 | top: 0px; |
|
16 | top: 0px; | |
17 | bottom: 0px; |
|
17 | bottom: 0px; | |
18 | overflow: hidden; |
|
18 | overflow: hidden; | |
19 | } |
|
19 | } | |
20 |
|
20 | |||
21 | span#save_widget { |
|
21 | span#save_widget { | |
22 | position: absolute; |
|
22 | position: absolute; | |
23 | left: 0px; |
|
23 | left: 0px; | |
24 | padding: 5px 0px; |
|
24 | padding: 5px 0px; | |
25 | margin: 0px 0px 0px 0px; |
|
25 | margin: 0px 0px 0px 0px; | |
26 | } |
|
26 | } | |
27 |
|
27 | |||
28 | input#notebook_name { |
|
28 | input#notebook_name { | |
29 | height: 1em; |
|
29 | height: 1em; | |
30 | line-height: 1em; |
|
30 | line-height: 1em; | |
31 | padding: 5px; |
|
31 | padding: 5px; | |
32 | } |
|
32 | } | |
33 |
|
33 | |||
34 | span#kernel_status { |
|
34 | span#kernel_status { | |
35 | position: absolute; |
|
35 | position: absolute; | |
36 | padding: 8px 5px 5px 5px; |
|
36 | padding: 8px 5px 5px 5px; | |
37 | right: 10px; |
|
37 | right: 10px; | |
38 | font-weight: bold; |
|
38 | font-weight: bold; | |
39 | } |
|
39 | } | |
40 |
|
40 | |||
41 | .status_idle { |
|
41 | .status_idle { | |
42 | color: gray; |
|
42 | color: gray; | |
43 | } |
|
43 | } | |
44 |
|
44 | |||
45 | .status_busy { |
|
45 | .status_busy { | |
46 | color: red; |
|
46 | color: red; | |
47 | } |
|
47 | } | |
48 |
|
48 | |||
49 | .status_restarting { |
|
49 | .status_restarting { | |
50 | color: black; |
|
50 | color: black; | |
51 | } |
|
51 | } | |
52 |
|
52 | |||
53 | div#left_panel { |
|
53 | div#left_panel { | |
54 | overflow-y: auto; |
|
54 | overflow-y: auto; | |
55 | top: 0px; |
|
55 | top: 0px; | |
56 | left: 0px; |
|
56 | left: 0px; | |
57 | margin: 0px; |
|
57 | margin: 0px; | |
58 | padding: 0px; |
|
58 | padding: 0px; | |
59 | position: absolute; |
|
59 | position: absolute; | |
60 | } |
|
60 | } | |
61 |
|
61 | |||
62 | h3.section_header { |
|
62 | h3.section_header { | |
63 | padding: 5px; |
|
63 | padding: 5px; | |
64 | } |
|
64 | } | |
65 |
|
65 | |||
66 | div.section_content { |
|
66 | div.section_content { | |
67 | padding: 5px; |
|
67 | padding: 5px; | |
68 | } |
|
68 | } | |
69 |
|
69 | |||
70 |
|
70 | |||
71 | span.section_row_buttons > button { |
|
71 | span.section_row_buttons > button { | |
72 |
width: |
|
72 | width: 70px; | |
73 | } |
|
73 | } | |
74 |
|
74 | |||
75 | .section_row { |
|
75 | .section_row { | |
76 | margin: 5px 0px; |
|
76 | margin: 5px 0px; | |
77 | } |
|
77 | } | |
78 |
|
78 | |||
79 | .section_row_buttons { |
|
79 | .section_row_buttons { | |
80 | float: right; |
|
80 | float: right; | |
81 | } |
|
81 | } | |
82 |
|
82 | |||
83 | #kernel_persist { |
|
83 | #kernel_persist { | |
84 | float: right; |
|
84 | float: right; | |
85 | } |
|
85 | } | |
86 |
|
86 | |||
87 | .checkbox_label { |
|
87 | .checkbox_label { | |
88 | font-size: 85%; |
|
88 | font-size: 85%; | |
89 | float: right; |
|
89 | float: right; | |
90 | padding: 0.3em; |
|
90 | padding: 0.3em; | |
91 | } |
|
91 | } | |
92 |
|
92 | |||
93 | .section_row_header { |
|
93 | .section_row_header { | |
94 | float: left; |
|
94 | float: left; | |
95 | font-size: 85%; |
|
95 | font-size: 85%; | |
96 | padding: 0.4em 0em; |
|
96 | padding: 0.4em 0em; | |
97 | font-weight: bold; |
|
97 | font-weight: bold; | |
98 | } |
|
98 | } | |
99 |
|
99 | |||
100 | span.button_label { |
|
100 | span.button_label { | |
101 | padding: 0.2em 1em; |
|
101 | padding: 0.2em 1em; | |
102 | font-size: 77%; |
|
102 | font-size: 77%; | |
103 | float: right; |
|
103 | float: right; | |
104 | } |
|
104 | } | |
105 |
|
105 | |||
106 | /* This is needed because FF was adding a 2px margin top and bottom. */ |
|
106 | /* This is needed because FF was adding a 2px margin top and bottom. */ | |
107 | .section_row .ui-button { |
|
107 | .section_row .ui-button { | |
108 | margin-top: 0px; |
|
108 | margin-top: 0px; | |
109 | margin-bottom: 0px; |
|
109 | margin-bottom: 0px; | |
110 | } |
|
110 | } | |
111 |
|
111 | |||
112 | #download_format { |
|
112 | #download_format { | |
113 | float: right; |
|
113 | float: right; | |
114 | font-size: 85%; |
|
114 | font-size: 85%; | |
115 | width: 60px; |
|
115 | width: 60px; | |
116 | margin: 1px 5px; |
|
116 | margin: 1px 5px; | |
117 | } |
|
117 | } | |
118 |
|
118 | |||
119 | div#left_panel_splitter { |
|
119 | div#left_panel_splitter { | |
120 | width: 8px; |
|
120 | width: 8px; | |
121 | top: 0px; |
|
121 | top: 0px; | |
122 | left: 202px; |
|
122 | left: 202px; | |
123 | margin: 0px; |
|
123 | margin: 0px; | |
124 | padding: 0px; |
|
124 | padding: 0px; | |
125 | position: absolute; |
|
125 | position: absolute; | |
126 | } |
|
126 | } | |
127 |
|
127 | |||
128 | div#notebook_panel { |
|
128 | div#notebook_panel { | |
129 | /* The L margin will be set in the Javascript code*/ |
|
129 | /* The L margin will be set in the Javascript code*/ | |
130 | margin: 0px 0px 0px 0px; |
|
130 | margin: 0px 0px 0px 0px; | |
131 | padding: 0px; |
|
131 | padding: 0px; | |
132 | } |
|
132 | } | |
133 |
|
133 | |||
134 | div#notebook { |
|
134 | div#notebook { | |
135 | overflow-y: scroll; |
|
135 | overflow-y: scroll; | |
136 | overflow-x: auto; |
|
136 | overflow-x: auto; | |
137 | width: 100%; |
|
137 | width: 100%; | |
138 | padding: 0px 15px 0px 15px; |
|
138 | padding: 0px 15px 0px 15px; | |
139 | margin: 0px |
|
139 | margin: 0px | |
140 | background-color: white; |
|
140 | background-color: white; | |
141 | } |
|
141 | } | |
142 |
|
142 | |||
143 | div#pager_splitter { |
|
143 | div#pager_splitter { | |
144 | height: 8px; |
|
144 | height: 8px; | |
145 | } |
|
145 | } | |
146 |
|
146 | |||
147 | div#pager { |
|
147 | div#pager { | |
148 | padding: 15px; |
|
148 | padding: 15px; | |
149 | overflow: auto; |
|
149 | overflow: auto; | |
150 | } |
|
150 | } | |
151 |
|
151 | |||
152 | div.cell { |
|
152 | div.cell { | |
153 | width: 100%; |
|
153 | width: 100%; | |
154 | padding: 5px; |
|
154 | padding: 5px; | |
155 | /* This acts as a spacer between cells, that is outside the border */ |
|
155 | /* This acts as a spacer between cells, that is outside the border */ | |
156 | margin: 15px 0px 15px 0px; |
|
156 | margin: 15px 0px 15px 0px; | |
157 | } |
|
157 | } | |
158 |
|
158 | |||
159 | div.code_cell { |
|
159 | div.code_cell { | |
160 | background-color: white; |
|
160 | background-color: white; | |
161 | } |
|
161 | } | |
162 |
|
162 | |||
163 | div.prompt { |
|
163 | div.prompt { | |
164 | width: 80px; |
|
164 | width: 80px; | |
165 | padding: 0.4em; |
|
165 | padding: 0.4em; | |
166 | margin: 0px; |
|
166 | margin: 0px; | |
167 | font-family: monospace; |
|
167 | font-family: monospace; | |
168 | } |
|
168 | } | |
169 |
|
169 | |||
170 | div.input_prompt { |
|
170 | div.input_prompt { | |
171 | color: navy; |
|
171 | color: navy; | |
172 | } |
|
172 | } | |
173 |
|
173 | |||
174 | div.output { |
|
174 | div.output { | |
175 | /* This is a spacer between the input and output of each cell */ |
|
175 | /* This is a spacer between the input and output of each cell */ | |
176 | margin-top: 15px; |
|
176 | margin-top: 15px; | |
177 | } |
|
177 | } | |
178 |
|
178 | |||
179 | div.output_prompt { |
|
179 | div.output_prompt { | |
180 | color: darkred; |
|
180 | color: darkred; | |
181 | } |
|
181 | } | |
182 |
|
182 | |||
183 | div.input_area { |
|
183 | div.input_area { | |
184 | color: black; |
|
184 | color: black; | |
185 | } |
|
185 | } | |
186 |
|
186 | |||
187 | div.output_area { |
|
187 | div.output_area { | |
188 | text-align: left; |
|
188 | text-align: left; | |
189 | color: black; |
|
189 | color: black; | |
190 | font-family: monospace; |
|
190 | font-family: monospace; | |
191 | } |
|
191 | } | |
192 |
|
192 | |||
193 | div.output_stream { |
|
193 | div.output_stream { | |
194 | padding: 0.4em; |
|
194 | padding: 0.4em; | |
195 | } |
|
195 | } | |
196 |
|
196 | |||
197 | div.output_latex { |
|
197 | div.output_latex { | |
198 | /* Slightly bigger than the rest of the notebook */ |
|
198 | /* Slightly bigger than the rest of the notebook */ | |
199 | font-size: 116%; |
|
199 | font-size: 116%; | |
200 | } |
|
200 | } | |
201 |
|
201 | |||
202 | div.output_html { |
|
202 | div.output_html { | |
203 | } |
|
203 | } | |
204 |
|
204 | |||
205 | div.output_png { |
|
205 | div.output_png { | |
206 | } |
|
206 | } | |
207 |
|
207 | |||
208 |
div. |
|
208 | div.text_cell { | |
209 | background-color: white; |
|
209 | background-color: white; | |
210 | } |
|
210 | } | |
211 |
|
211 | |||
212 |
div. |
|
212 | div.text_cell_input { | |
213 | color: black; |
|
|||
214 | } |
|
|||
215 |
|
||||
216 | div.html_cell_render { |
|
|||
217 | font-family: "Helvetica Neue", Arial, Helvetica, Geneva, sans-serif; |
|
|||
218 | /* Slightly bigger than the rest of the notebook */ |
|
|||
219 | font-size: 116%; |
|
|||
220 | outline: none; |
|
|||
221 | resize: none; |
|
|||
222 | width: inherit; |
|
|||
223 | border-style: none; |
|
|||
224 | padding: 5px; |
|
|||
225 | color: black; |
|
|||
226 | } |
|
|||
227 |
|
||||
228 | div.rst_cell_input { |
|
|||
229 | color: black; |
|
213 | color: black; | |
230 | } |
|
214 | } | |
231 |
|
215 | |||
232 |
div. |
|
216 | div.text_cell_render { | |
233 | font-family: "Helvetica Neue", Arial, Helvetica, Geneva, sans-serif; |
|
217 | font-family: "Helvetica Neue", Arial, Helvetica, Geneva, sans-serif; | |
234 | /* Slightly bigger than the rest of the notebook */ |
|
218 | /* Slightly bigger than the rest of the notebook */ | |
235 | font-size: 116%; |
|
219 | font-size: 116%; | |
236 | outline: none; |
|
220 | outline: none; | |
237 | resize: none; |
|
221 | resize: none; | |
238 | width: inherit; |
|
222 | width: inherit; | |
239 | border-style: none; |
|
223 | border-style: none; | |
240 | padding: 5px; |
|
224 | padding: 5px; | |
241 | color: black; |
|
225 | color: black; | |
242 | } |
|
226 | } | |
243 |
|
227 | |||
244 | .rendered_html {color: black;} |
|
|||
245 | .rendered_html em {font-style: italic;} |
|
|||
246 | .rendered_html strong {font-weight: bold;} |
|
|||
247 | .rendered_html u {text-decoration: underline;} |
|
|||
248 | .rendered_html :link { text-decoration: underline } |
|
|||
249 | .rendered_html :visited { text-decoration: underline } |
|
|||
250 | .rendered_html h1 {font-size: 197%; margin: .67em 0; font-weight: bold;} |
|
|||
251 | .rendered_html h2 {font-size: 153.9%; margin: .75em 0; font-weight: bold;} |
|
|||
252 | .rendered_html h3 {font-size: 116%; margin: .83em 0; font-weight: bold;} |
|
|||
253 | .rendered_html h4 {margin: 1.12em 0; font-weight: bold;} |
|
|||
254 | .rendered_html h5 {font-size: 85%.; margin: 1.5em 0; font-weight: bold;} |
|
|||
255 | .rendered_html h6 {font-size: 77%; margin: 1.67em 0; font-weight: bold;} |
|
|||
256 | .rendered_html ul {list-style:disc; margin-left: 40px;} |
|
|||
257 | .rendered_html ul ul {list-style:square; margin-left: 40px;} |
|
|||
258 | .rendered_html ul ul ul {list-style:circle; margin-left: 40px;} |
|
|||
259 | .rendered_html ol {list-style:upper-roman; margin-left: 40px;} |
|
|||
260 | .rendered_html ol ol {list-style:upper-alpha;} |
|
|||
261 | .rendered_html ol ol ol {list-style:decimal;} |
|
|||
262 | .rendered_html ol ol ol ol {list-style:lower-alpha;} |
|
|||
263 | .rendered_html ol ol ol ol ol {list-style:lower-roman;} |
|
|||
264 |
|
||||
265 | .CodeMirror { |
|
228 | .CodeMirror { | |
266 | line-height: 1.231; /* Changed from 1em to our global default */ |
|
229 | line-height: 1.231; /* Changed from 1em to our global default */ | |
267 | } |
|
230 | } | |
268 |
|
231 | |||
269 | .CodeMirror-scroll { |
|
232 | .CodeMirror-scroll { | |
270 | height: auto; /* Changed to auto to autogrow */ |
|
233 | height: auto; /* Changed to auto to autogrow */ | |
271 | overflow-y: visible; /* Changed from auto to remove scrollbar */ |
|
234 | overflow-y: visible; /* Changed from auto to remove scrollbar */ | |
272 | overflow-x: auto; /* Changed from auto to remove scrollbar */ |
|
235 | overflow-x: auto; /* Changed from auto to remove scrollbar */ | |
273 | } |
|
236 | } | |
274 |
|
237 | |||
275 | /* CSS font colors for translated ANSI colors. */ |
|
238 | /* CSS font colors for translated ANSI colors. */ | |
276 |
|
239 | |||
277 |
|
240 | |||
278 | .ansiblack {color: black;} |
|
241 | .ansiblack {color: black;} | |
279 | .ansired {color: darkred;} |
|
242 | .ansired {color: darkred;} | |
280 | .ansigreen {color: darkgreen;} |
|
243 | .ansigreen {color: darkgreen;} | |
281 | .ansiyellow {color: brown;} |
|
244 | .ansiyellow {color: brown;} | |
282 | .ansiblue {color: darkblue;} |
|
245 | .ansiblue {color: darkblue;} | |
283 | .ansipurple {color: darkviolet;} |
|
246 | .ansipurple {color: darkviolet;} | |
284 | .ansicyan {color: steelblue;} |
|
247 | .ansicyan {color: steelblue;} | |
285 | .ansigrey {color: grey;} |
|
248 | .ansigrey {color: grey;} | |
286 | .ansibold {font-weight: bold;} |
|
249 | .ansibold {font-weight: bold;} | |
287 |
|
250 | |||
288 | .completions { |
|
251 | .completions { | |
289 | position: absolute; |
|
252 | position: absolute; | |
290 | z-index: 10; |
|
253 | z-index: 10; | |
291 | overflow: auto; |
|
254 | overflow: auto; | |
292 | border: 1px solid black; |
|
255 | border: 1px solid black; | |
293 | } |
|
256 | } | |
294 |
|
257 | |||
295 | .completions select { |
|
258 | .completions select { | |
296 | background: white; |
|
259 | background: white; | |
297 | outline: none; |
|
260 | outline: none; | |
298 | border: none; |
|
261 | border: none; | |
299 | padding: 0px; |
|
262 | padding: 0px; | |
300 | margin: 0px; |
|
263 | margin: 0px; | |
301 | font-family: monospace; |
|
264 | font-family: monospace; | |
302 | } |
|
265 | } | |
303 |
|
266 |
@@ -1,79 +1,79 b'' | |||||
1 |
|
1 | |||
2 | //============================================================================ |
|
2 | //============================================================================ | |
3 | // Cell |
|
3 | // Cell | |
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 Cell = function (notebook) { |
|
10 | var Cell = function (notebook) { | |
11 | this.notebook = notebook; |
|
11 | this.notebook = notebook; | |
12 | this.selected = false; |
|
12 | this.selected = false; | |
13 | this.element; |
|
13 | this.element; | |
14 | this.create_element(); |
|
14 | this.create_element(); | |
15 | if (this.element !== undefined) { |
|
15 | if (this.element !== undefined) { | |
16 | this.element.data("cell", this); |
|
16 | this.element.data("cell", this); | |
17 | this.bind_events(); |
|
17 | this.bind_events(); | |
18 | } |
|
18 | } | |
19 | this.cell_id = utils.uuid(); |
|
19 | this.cell_id = utils.uuid(); | |
20 | }; |
|
20 | }; | |
21 |
|
21 | |||
22 |
|
22 | |||
23 | Cell.prototype.select = function () { |
|
23 | Cell.prototype.select = function () { | |
24 | this.element.addClass('ui-widget-content ui-corner-all'); |
|
24 | this.element.addClass('ui-widget-content ui-corner-all'); | |
25 | this.selected = true; |
|
25 | this.selected = true; | |
26 | // TODO: we need t test across browsers to see if both of these are needed. |
|
26 | // TODO: we need to test across browsers to see if both of these are needed. | |
27 | // In the meantime, there should not be any harm in having them both. |
|
27 | // In the meantime, there should not be any harm in having them both. | |
28 | this.element.find('textarea').trigger('focusin'); |
|
28 | this.element.find('textarea').trigger('focusin'); | |
29 | this.element.find('textarea').trigger('focus'); |
|
29 | this.element.find('textarea').trigger('focus'); | |
30 | }; |
|
30 | }; | |
31 |
|
31 | |||
32 |
|
32 | |||
33 | Cell.prototype.unselect = function () { |
|
33 | Cell.prototype.unselect = function () { | |
34 | this.element.removeClass('ui-widget-content ui-corner-all'); |
|
34 | this.element.removeClass('ui-widget-content ui-corner-all'); | |
35 | this.selected = false; |
|
35 | this.selected = false; | |
36 | }; |
|
36 | }; | |
37 |
|
37 | |||
38 |
|
38 | |||
39 | Cell.prototype.bind_events = function () { |
|
39 | Cell.prototype.bind_events = function () { | |
40 | var that = this; |
|
40 | var that = this; | |
41 | var nb = that.notebook |
|
41 | var nb = that.notebook | |
42 | that.element.click(function (event) { |
|
42 | that.element.click(function (event) { | |
43 | if (that.selected === false) { |
|
43 | if (that.selected === false) { | |
44 | nb.select(nb.find_cell_index(that)); |
|
44 | nb.select(nb.find_cell_index(that)); | |
45 | }; |
|
45 | }; | |
46 | }); |
|
46 | }); | |
47 | that.element.focusin(function (event) { |
|
47 | that.element.focusin(function (event) { | |
48 | if (that.selected === false) { |
|
48 | if (that.selected === false) { | |
49 | nb.select(nb.find_cell_index(that)); |
|
49 | nb.select(nb.find_cell_index(that)); | |
50 | }; |
|
50 | }; | |
51 | }); |
|
51 | }); | |
52 | }; |
|
52 | }; | |
53 |
|
53 | |||
54 | Cell.prototype.grow = function(element) { |
|
54 | Cell.prototype.grow = function(element) { | |
55 | // Grow the cell by hand. This is used upon reloading from JSON, when the |
|
55 | // Grow the cell by hand. This is used upon reloading from JSON, when the | |
56 | // autogrow handler is not called. |
|
56 | // autogrow handler is not called. | |
57 | var dom = element.get(0); |
|
57 | var dom = element.get(0); | |
58 | var lines_count = 0; |
|
58 | var lines_count = 0; | |
59 | // modified split rule from |
|
59 | // modified split rule from | |
60 | // http://stackoverflow.com/questions/2035910/how-to-get-the-number-of-lines-in-a-textarea/2036424#2036424 |
|
60 | // http://stackoverflow.com/questions/2035910/how-to-get-the-number-of-lines-in-a-textarea/2036424#2036424 | |
61 | var lines = dom.value.split(/\r|\r\n|\n/); |
|
61 | var lines = dom.value.split(/\r|\r\n|\n/); | |
62 | lines_count = lines.length; |
|
62 | lines_count = lines.length; | |
63 | if (lines_count >= 1) { |
|
63 | if (lines_count >= 1) { | |
64 | dom.rows = lines_count; |
|
64 | dom.rows = lines_count; | |
65 | } else { |
|
65 | } else { | |
66 | dom.rows = 1; |
|
66 | dom.rows = 1; | |
67 | } |
|
67 | } | |
68 | }; |
|
68 | }; | |
69 |
|
69 | |||
70 |
|
70 | |||
71 | // Subclasses must implement create_element. |
|
71 | // Subclasses must implement create_element. | |
72 | Cell.prototype.create_element = function () {}; |
|
72 | Cell.prototype.create_element = function () {}; | |
73 |
|
73 | |||
74 | IPython.Cell = Cell; |
|
74 | IPython.Cell = Cell; | |
75 |
|
75 | |||
76 | return IPython; |
|
76 | return IPython; | |
77 |
|
77 | |||
78 | }(IPython)); |
|
78 | }(IPython)); | |
79 |
|
79 |
@@ -1,95 +1,95 b'' | |||||
1 |
|
1 | |||
2 | //============================================================================ |
|
2 | //============================================================================ | |
3 | // LeftPanel |
|
3 | // LeftPanel | |
4 | //============================================================================ |
|
4 | //============================================================================ | |
5 |
|
5 | |||
6 |
|
6 | |||
7 | var IPython = (function (IPython) { |
|
7 | var IPython = (function (IPython) { | |
8 |
|
8 | |||
9 | var utils = IPython.utils; |
|
9 | var utils = IPython.utils; | |
10 |
|
10 | |||
11 | var LeftPanel = function (left_panel_selector, left_panel_splitter_selector) { |
|
11 | var LeftPanel = function (left_panel_selector, left_panel_splitter_selector) { | |
12 | this.left_panel_element = $(left_panel_selector); |
|
12 | this.left_panel_element = $(left_panel_selector); | |
13 | this.left_panel_splitter_element = $(left_panel_splitter_selector); |
|
13 | this.left_panel_splitter_element = $(left_panel_splitter_selector); | |
14 | this.expanded = true; |
|
14 | this.expanded = true; | |
15 |
this.width = |
|
15 | this.width = 300; | |
16 | this.style(); |
|
16 | this.style(); | |
17 | this.bind_events(); |
|
17 | this.bind_events(); | |
18 | this.create_children(); |
|
18 | this.create_children(); | |
19 | }; |
|
19 | }; | |
20 |
|
20 | |||
21 |
|
21 | |||
22 | LeftPanel.prototype.style = function () { |
|
22 | LeftPanel.prototype.style = function () { | |
23 | this.left_panel_splitter_element.addClass('border-box-sizing ui-widget ui-state-default'); |
|
23 | this.left_panel_splitter_element.addClass('border-box-sizing ui-widget ui-state-default'); | |
24 | this.left_panel_element.addClass('border-box-sizing ui-widget'); |
|
24 | this.left_panel_element.addClass('border-box-sizing ui-widget'); | |
25 | this.left_panel_element.width(this.width); |
|
25 | this.left_panel_element.width(this.width); | |
26 | this.left_panel_splitter_element.css({left : this.width}); |
|
26 | this.left_panel_splitter_element.css({left : this.width}); | |
27 | }; |
|
27 | }; | |
28 |
|
28 | |||
29 |
|
29 | |||
30 | LeftPanel.prototype.bind_events = function () { |
|
30 | LeftPanel.prototype.bind_events = function () { | |
31 | var that = this; |
|
31 | var that = this; | |
32 |
|
32 | |||
33 | this.left_panel_element.bind('collapse_left_panel', function () { |
|
33 | this.left_panel_element.bind('collapse_left_panel', function () { | |
34 | that.left_panel_element.hide('fast'); |
|
34 | that.left_panel_element.hide('fast'); | |
35 | that.left_panel_splitter_element.animate({left : 0}, 'fast'); |
|
35 | that.left_panel_splitter_element.animate({left : 0}, 'fast'); | |
36 | }); |
|
36 | }); | |
37 |
|
37 | |||
38 | this.left_panel_element.bind('expand_left_panel', function () { |
|
38 | this.left_panel_element.bind('expand_left_panel', function () { | |
39 | that.left_panel_element.show('fast'); |
|
39 | that.left_panel_element.show('fast'); | |
40 | that.left_panel_splitter_element.animate({left : that.width}, 'fast'); |
|
40 | that.left_panel_splitter_element.animate({left : that.width}, 'fast'); | |
41 | }); |
|
41 | }); | |
42 |
|
42 | |||
43 | this.left_panel_splitter_element.hover( |
|
43 | this.left_panel_splitter_element.hover( | |
44 | function () { |
|
44 | function () { | |
45 | that.left_panel_splitter_element.addClass('ui-state-hover'); |
|
45 | that.left_panel_splitter_element.addClass('ui-state-hover'); | |
46 | }, |
|
46 | }, | |
47 | function () { |
|
47 | function () { | |
48 | that.left_panel_splitter_element.removeClass('ui-state-hover'); |
|
48 | that.left_panel_splitter_element.removeClass('ui-state-hover'); | |
49 | } |
|
49 | } | |
50 | ); |
|
50 | ); | |
51 |
|
51 | |||
52 | this.left_panel_splitter_element.click(function () { |
|
52 | this.left_panel_splitter_element.click(function () { | |
53 | that.toggle(); |
|
53 | that.toggle(); | |
54 | }); |
|
54 | }); | |
55 |
|
55 | |||
56 | }; |
|
56 | }; | |
57 |
|
57 | |||
58 |
|
58 | |||
59 | LeftPanel.prototype.create_children = function () { |
|
59 | LeftPanel.prototype.create_children = function () { | |
60 | this.notebook_section = new IPython.NotebookSection('div#notebook_section'); |
|
60 | this.notebook_section = new IPython.NotebookSection('div#notebook_section'); | |
61 | this.cell_section = new IPython.CellSection('div#cell_section'); |
|
61 | this.cell_section = new IPython.CellSection('div#cell_section'); | |
62 | this.kernel_section = new IPython.KernelSection('div#kernel_section'); |
|
62 | this.kernel_section = new IPython.KernelSection('div#kernel_section'); | |
63 | this.help_section = new IPython.HelpSection('div#help_section'); |
|
63 | this.help_section = new IPython.HelpSection('div#help_section'); | |
64 | } |
|
64 | } | |
65 |
|
65 | |||
66 | LeftPanel.prototype.collapse = function () { |
|
66 | LeftPanel.prototype.collapse = function () { | |
67 | if (this.expanded === true) { |
|
67 | if (this.expanded === true) { | |
68 | this.left_panel_element.add($('div#notebook')).trigger('collapse_left_panel'); |
|
68 | this.left_panel_element.add($('div#notebook')).trigger('collapse_left_panel'); | |
69 | this.expanded = false; |
|
69 | this.expanded = false; | |
70 | }; |
|
70 | }; | |
71 | }; |
|
71 | }; | |
72 |
|
72 | |||
73 |
|
73 | |||
74 | LeftPanel.prototype.expand = function () { |
|
74 | LeftPanel.prototype.expand = function () { | |
75 | if (this.expanded !== true) { |
|
75 | if (this.expanded !== true) { | |
76 | this.left_panel_element.add($('div#notebook')).trigger('expand_left_panel'); |
|
76 | this.left_panel_element.add($('div#notebook')).trigger('expand_left_panel'); | |
77 | this.expanded = true; |
|
77 | this.expanded = true; | |
78 | }; |
|
78 | }; | |
79 | }; |
|
79 | }; | |
80 |
|
80 | |||
81 |
|
81 | |||
82 | LeftPanel.prototype.toggle = function () { |
|
82 | LeftPanel.prototype.toggle = function () { | |
83 | if (this.expanded === true) { |
|
83 | if (this.expanded === true) { | |
84 | this.collapse(); |
|
84 | this.collapse(); | |
85 | } else { |
|
85 | } else { | |
86 | this.expand(); |
|
86 | this.expand(); | |
87 | }; |
|
87 | }; | |
88 | }; |
|
88 | }; | |
89 |
|
89 | |||
90 | IPython.LeftPanel = LeftPanel; |
|
90 | IPython.LeftPanel = LeftPanel; | |
91 |
|
91 | |||
92 | return IPython; |
|
92 | return IPython; | |
93 |
|
93 | |||
94 | }(IPython)); |
|
94 | }(IPython)); | |
95 |
|
95 |
@@ -1,711 +1,718 b'' | |||||
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.style(); |
|
17 | this.style(); | |
18 | this.create_elements(); |
|
18 | this.create_elements(); | |
19 | this.bind_events(); |
|
19 | this.bind_events(); | |
20 | }; |
|
20 | }; | |
21 |
|
21 | |||
22 |
|
22 | |||
23 | Notebook.prototype.style = function () { |
|
23 | Notebook.prototype.style = function () { | |
24 | $('div#notebook').addClass('border-box-sizing'); |
|
24 | $('div#notebook').addClass('border-box-sizing'); | |
25 | }; |
|
25 | }; | |
26 |
|
26 | |||
27 |
|
27 | |||
28 | Notebook.prototype.create_elements = function () { |
|
28 | Notebook.prototype.create_elements = function () { | |
29 | // We add this end_space div to the end of the notebook div to: |
|
29 | // We add this end_space div to the end of the notebook div to: | |
30 | // i) provide a margin between the last cell and the end of the notebook |
|
30 | // i) provide a margin between the last cell and the end of the notebook | |
31 | // ii) to prevent the div from scrolling up when the last cell is being |
|
31 | // ii) to prevent the div from scrolling up when the last cell is being | |
32 | // edited, but is too low on the page, which browsers will do automatically. |
|
32 | // edited, but is too low on the page, which browsers will do automatically. | |
33 | this.element.append($('<div class="end_space"></div>').height(50)); |
|
33 | this.element.append($('<div class="end_space"></div>').height(50)); | |
34 | $('div#notebook').addClass('border-box-sizing'); |
|
34 | $('div#notebook').addClass('border-box-sizing'); | |
35 | }; |
|
35 | }; | |
36 |
|
36 | |||
37 |
|
37 | |||
38 | Notebook.prototype.bind_events = function () { |
|
38 | Notebook.prototype.bind_events = function () { | |
39 | var that = this; |
|
39 | var that = this; | |
40 | $(document).keydown(function (event) { |
|
40 | $(document).keydown(function (event) { | |
41 | // console.log(event); |
|
41 | // console.log(event); | |
42 | if (event.which === 38) { |
|
42 | if (event.which === 38) { | |
43 | var cell = that.selected_cell(); |
|
43 | var cell = that.selected_cell(); | |
44 | if (cell.at_top()) { |
|
44 | if (cell.at_top()) { | |
45 | event.preventDefault(); |
|
45 | event.preventDefault(); | |
46 | that.select_prev(); |
|
46 | that.select_prev(); | |
47 | }; |
|
47 | }; | |
48 | } else if (event.which === 40) { |
|
48 | } else if (event.which === 40) { | |
49 | var cell = that.selected_cell(); |
|
49 | var cell = that.selected_cell(); | |
50 | if (cell.at_bottom()) { |
|
50 | if (cell.at_bottom()) { | |
51 | event.preventDefault(); |
|
51 | event.preventDefault(); | |
52 | that.select_next(); |
|
52 | that.select_next(); | |
53 | }; |
|
53 | }; | |
54 | } else if (event.which === 13 && event.shiftKey) { |
|
54 | } else if (event.which === 13 && event.shiftKey) { | |
55 | that.execute_selected_cell(); |
|
55 | that.execute_selected_cell(); | |
56 | return false; |
|
56 | return false; | |
57 | } else if (event.which === 13 && event.ctrlKey) { |
|
57 | } else if (event.which === 13 && event.ctrlKey) { | |
58 | that.execute_selected_cell({terminal:true}); |
|
58 | that.execute_selected_cell({terminal:true}); | |
59 | return false; |
|
59 | return false; | |
60 | }; |
|
60 | }; | |
61 | }); |
|
61 | }); | |
62 |
|
62 | |||
63 | this.element.bind('collapse_pager', function () { |
|
63 | this.element.bind('collapse_pager', function () { | |
64 | var app_height = $('div#main_app').height(); // content height |
|
64 | var app_height = $('div#main_app').height(); // content height | |
65 | var splitter_height = $('div#pager_splitter').outerHeight(true); |
|
65 | var splitter_height = $('div#pager_splitter').outerHeight(true); | |
66 | var new_height = app_height - splitter_height; |
|
66 | var new_height = app_height - splitter_height; | |
67 | that.element.animate({height : new_height + 'px'}, 'fast'); |
|
67 | that.element.animate({height : new_height + 'px'}, 'fast'); | |
68 | }); |
|
68 | }); | |
69 |
|
69 | |||
70 | this.element.bind('expand_pager', function () { |
|
70 | this.element.bind('expand_pager', function () { | |
71 | var app_height = $('div#main_app').height(); // content height |
|
71 | var app_height = $('div#main_app').height(); // content height | |
72 | var splitter_height = $('div#pager_splitter').outerHeight(true); |
|
72 | var splitter_height = $('div#pager_splitter').outerHeight(true); | |
73 | var pager_height = $('div#pager').outerHeight(true); |
|
73 | var pager_height = $('div#pager').outerHeight(true); | |
74 | var new_height = app_height - pager_height - splitter_height; |
|
74 | var new_height = app_height - pager_height - splitter_height; | |
75 | that.element.animate({height : new_height + 'px'}, 'fast'); |
|
75 | that.element.animate({height : new_height + 'px'}, 'fast'); | |
76 | }); |
|
76 | }); | |
77 |
|
77 | |||
78 | this.element.bind('collapse_left_panel', function () { |
|
78 | this.element.bind('collapse_left_panel', function () { | |
79 | var splitter_width = $('div#left_panel_splitter').outerWidth(true); |
|
79 | var splitter_width = $('div#left_panel_splitter').outerWidth(true); | |
80 | var new_margin = splitter_width; |
|
80 | var new_margin = splitter_width; | |
81 | $('div#notebook_panel').animate({marginLeft : new_margin + 'px'}, 'fast'); |
|
81 | $('div#notebook_panel').animate({marginLeft : new_margin + 'px'}, 'fast'); | |
82 | }); |
|
82 | }); | |
83 |
|
83 | |||
84 | this.element.bind('expand_left_panel', function () { |
|
84 | this.element.bind('expand_left_panel', function () { | |
85 | var splitter_width = $('div#left_panel_splitter').outerWidth(true); |
|
85 | var splitter_width = $('div#left_panel_splitter').outerWidth(true); | |
86 | var left_panel_width = IPython.left_panel.width; |
|
86 | var left_panel_width = IPython.left_panel.width; | |
87 | var new_margin = splitter_width + left_panel_width; |
|
87 | var new_margin = splitter_width + left_panel_width; | |
88 | $('div#notebook_panel').animate({marginLeft : new_margin + 'px'}, 'fast'); |
|
88 | $('div#notebook_panel').animate({marginLeft : new_margin + 'px'}, 'fast'); | |
89 | }); |
|
89 | }); | |
90 | }; |
|
90 | }; | |
91 |
|
91 | |||
92 |
|
92 | |||
93 | Notebook.prototype.scroll_to_bottom = function () { |
|
93 | Notebook.prototype.scroll_to_bottom = function () { | |
94 | this.element.animate({scrollTop:this.element.get(0).scrollHeight}, 0); |
|
94 | this.element.animate({scrollTop:this.element.get(0).scrollHeight}, 0); | |
95 | }; |
|
95 | }; | |
96 |
|
96 | |||
97 |
|
97 | |||
98 | Notebook.prototype.scroll_to_top = function () { |
|
98 | Notebook.prototype.scroll_to_top = function () { | |
99 | this.element.animate({scrollTop:0}, 0); |
|
99 | this.element.animate({scrollTop:0}, 0); | |
100 | }; |
|
100 | }; | |
101 |
|
101 | |||
102 |
|
102 | |||
103 | // Cell indexing, retrieval, etc. |
|
103 | // Cell indexing, retrieval, etc. | |
104 |
|
104 | |||
105 |
|
105 | |||
106 | Notebook.prototype.cell_elements = function () { |
|
106 | Notebook.prototype.cell_elements = function () { | |
107 | return this.element.children("div.cell"); |
|
107 | return this.element.children("div.cell"); | |
108 | } |
|
108 | } | |
109 |
|
109 | |||
110 |
|
110 | |||
111 | Notebook.prototype.ncells = function (cell) { |
|
111 | Notebook.prototype.ncells = function (cell) { | |
112 | return this.cell_elements().length; |
|
112 | return this.cell_elements().length; | |
113 | } |
|
113 | } | |
114 |
|
114 | |||
115 |
|
115 | |||
116 | // TODO: we are often calling cells as cells()[i], which we should optimize |
|
116 | // TODO: we are often calling cells as cells()[i], which we should optimize | |
117 | // to cells(i) or a new method. |
|
117 | // to cells(i) or a new method. | |
118 | Notebook.prototype.cells = function () { |
|
118 | Notebook.prototype.cells = function () { | |
119 | return this.cell_elements().toArray().map(function (e) { |
|
119 | return this.cell_elements().toArray().map(function (e) { | |
120 | return $(e).data("cell"); |
|
120 | return $(e).data("cell"); | |
121 | }); |
|
121 | }); | |
122 | } |
|
122 | } | |
123 |
|
123 | |||
124 |
|
124 | |||
125 | Notebook.prototype.find_cell_index = function (cell) { |
|
125 | Notebook.prototype.find_cell_index = function (cell) { | |
126 | var result = null; |
|
126 | var result = null; | |
127 | this.cell_elements().filter(function (index) { |
|
127 | this.cell_elements().filter(function (index) { | |
128 | if ($(this).data("cell") === cell) { |
|
128 | if ($(this).data("cell") === cell) { | |
129 | result = index; |
|
129 | result = index; | |
130 | }; |
|
130 | }; | |
131 | }); |
|
131 | }); | |
132 | return result; |
|
132 | return result; | |
133 | }; |
|
133 | }; | |
134 |
|
134 | |||
135 |
|
135 | |||
136 | Notebook.prototype.index_or_selected = function (index) { |
|
136 | Notebook.prototype.index_or_selected = function (index) { | |
137 | return index || this.selected_index() || 0; |
|
137 | return index || this.selected_index() || 0; | |
138 | } |
|
138 | } | |
139 |
|
139 | |||
140 |
|
140 | |||
141 | Notebook.prototype.select = function (index) { |
|
141 | Notebook.prototype.select = function (index) { | |
142 | if (index !== undefined && index >= 0 && index < this.ncells()) { |
|
142 | if (index !== undefined && index >= 0 && index < this.ncells()) { | |
143 | if (this.selected_index() !== null) { |
|
143 | if (this.selected_index() !== null) { | |
144 | this.selected_cell().unselect(); |
|
144 | this.selected_cell().unselect(); | |
145 | }; |
|
145 | }; | |
146 | this.cells()[index].select(); |
|
146 | this.cells()[index].select(); | |
147 | if (index === (this.ncells()-1)) { |
|
147 | if (index === (this.ncells()-1)) { | |
148 | this.scroll_to_bottom(); |
|
148 | this.scroll_to_bottom(); | |
149 | }; |
|
149 | }; | |
150 | }; |
|
150 | }; | |
151 | return this; |
|
151 | return this; | |
152 | }; |
|
152 | }; | |
153 |
|
153 | |||
154 |
|
154 | |||
155 | Notebook.prototype.select_next = function () { |
|
155 | Notebook.prototype.select_next = function () { | |
156 | var index = this.selected_index(); |
|
156 | var index = this.selected_index(); | |
157 | if (index !== null && index >= 0 && (index+1) < this.ncells()) { |
|
157 | if (index !== null && index >= 0 && (index+1) < this.ncells()) { | |
158 | this.select(index+1); |
|
158 | this.select(index+1); | |
159 | }; |
|
159 | }; | |
160 | return this; |
|
160 | return this; | |
161 | }; |
|
161 | }; | |
162 |
|
162 | |||
163 |
|
163 | |||
164 | Notebook.prototype.select_prev = function () { |
|
164 | Notebook.prototype.select_prev = function () { | |
165 | var index = this.selected_index(); |
|
165 | var index = this.selected_index(); | |
166 | if (index !== null && index >= 0 && (index-1) < this.ncells()) { |
|
166 | if (index !== null && index >= 0 && (index-1) < this.ncells()) { | |
167 | this.select(index-1); |
|
167 | this.select(index-1); | |
168 | }; |
|
168 | }; | |
169 | return this; |
|
169 | return this; | |
170 | }; |
|
170 | }; | |
171 |
|
171 | |||
172 |
|
172 | |||
173 | Notebook.prototype.selected_index = function () { |
|
173 | Notebook.prototype.selected_index = function () { | |
174 | var result = null; |
|
174 | var result = null; | |
175 | this.cell_elements().filter(function (index) { |
|
175 | this.cell_elements().filter(function (index) { | |
176 | if ($(this).data("cell").selected === true) { |
|
176 | if ($(this).data("cell").selected === true) { | |
177 | result = index; |
|
177 | result = index; | |
178 | }; |
|
178 | }; | |
179 | }); |
|
179 | }); | |
180 | return result; |
|
180 | return result; | |
181 | }; |
|
181 | }; | |
182 |
|
182 | |||
183 |
|
183 | |||
184 | Notebook.prototype.cell_for_msg = function (msg_id) { |
|
184 | Notebook.prototype.cell_for_msg = function (msg_id) { | |
185 | var cell_id = this.msg_cell_map[msg_id]; |
|
185 | var cell_id = this.msg_cell_map[msg_id]; | |
186 | var result = null; |
|
186 | var result = null; | |
187 | this.cell_elements().filter(function (index) { |
|
187 | this.cell_elements().filter(function (index) { | |
188 | cell = $(this).data("cell"); |
|
188 | cell = $(this).data("cell"); | |
189 | if (cell.cell_id === cell_id) { |
|
189 | if (cell.cell_id === cell_id) { | |
190 | result = cell; |
|
190 | result = cell; | |
191 | }; |
|
191 | }; | |
192 | }); |
|
192 | }); | |
193 | return result; |
|
193 | return result; | |
194 | }; |
|
194 | }; | |
195 |
|
195 | |||
196 |
|
196 | |||
197 | Notebook.prototype.selected_cell = function () { |
|
197 | Notebook.prototype.selected_cell = function () { | |
198 | return this.cell_elements().eq(this.selected_index()).data("cell"); |
|
198 | return this.cell_elements().eq(this.selected_index()).data("cell"); | |
199 | } |
|
199 | } | |
200 |
|
200 | |||
201 |
|
201 | |||
202 | // Cell insertion, deletion and moving. |
|
202 | // Cell insertion, deletion and moving. | |
203 |
|
203 | |||
204 |
|
204 | |||
205 | Notebook.prototype.delete_cell = function (index) { |
|
205 | Notebook.prototype.delete_cell = function (index) { | |
206 | var i = index || this.selected_index(); |
|
206 | var i = index || this.selected_index(); | |
207 | if (i !== null && i >= 0 && i < this.ncells()) { |
|
207 | if (i !== null && i >= 0 && i < this.ncells()) { | |
208 | this.cell_elements().eq(i).remove(); |
|
208 | this.cell_elements().eq(i).remove(); | |
209 | if (i === (this.ncells())) { |
|
209 | if (i === (this.ncells())) { | |
210 | this.select(i-1); |
|
210 | this.select(i-1); | |
211 | } else { |
|
211 | } else { | |
212 | this.select(i); |
|
212 | this.select(i); | |
213 | }; |
|
213 | }; | |
214 | }; |
|
214 | }; | |
215 | return this; |
|
215 | return this; | |
216 | }; |
|
216 | }; | |
217 |
|
217 | |||
218 |
|
218 | |||
219 | Notebook.prototype.append_cell = function (cell) { |
|
219 | Notebook.prototype.append_cell = function (cell) { | |
220 | this.element.find('div.end_space').before(cell.element); |
|
220 | this.element.find('div.end_space').before(cell.element); | |
221 | return this; |
|
221 | return this; | |
222 | }; |
|
222 | }; | |
223 |
|
223 | |||
224 |
|
224 | |||
225 | Notebook.prototype.insert_cell_after = function (cell, index) { |
|
225 | Notebook.prototype.insert_cell_after = function (cell, index) { | |
226 | var ncells = this.ncells(); |
|
226 | var ncells = this.ncells(); | |
227 | if (ncells === 0) { |
|
227 | if (ncells === 0) { | |
228 | this.append_cell(cell); |
|
228 | this.append_cell(cell); | |
229 | return this; |
|
229 | return this; | |
230 | }; |
|
230 | }; | |
231 | if (index >= 0 && index < ncells) { |
|
231 | if (index >= 0 && index < ncells) { | |
232 | this.cell_elements().eq(index).after(cell.element); |
|
232 | this.cell_elements().eq(index).after(cell.element); | |
233 | }; |
|
233 | }; | |
234 | return this |
|
234 | return this | |
235 | }; |
|
235 | }; | |
236 |
|
236 | |||
237 |
|
237 | |||
238 | Notebook.prototype.insert_cell_before = function (cell, index) { |
|
238 | Notebook.prototype.insert_cell_before = function (cell, index) { | |
239 | var ncells = this.ncells(); |
|
239 | var ncells = this.ncells(); | |
240 | if (ncells === 0) { |
|
240 | if (ncells === 0) { | |
241 | this.append_cell(cell); |
|
241 | this.append_cell(cell); | |
242 | return this; |
|
242 | return this; | |
243 | }; |
|
243 | }; | |
244 | if (index >= 0 && index < ncells) { |
|
244 | if (index >= 0 && index < ncells) { | |
245 | this.cell_elements().eq(index).before(cell.element); |
|
245 | this.cell_elements().eq(index).before(cell.element); | |
246 | }; |
|
246 | }; | |
247 | return this; |
|
247 | return this; | |
248 | }; |
|
248 | }; | |
249 |
|
249 | |||
250 |
|
250 | |||
251 | Notebook.prototype.move_cell_up = function (index) { |
|
251 | Notebook.prototype.move_cell_up = function (index) { | |
252 | var i = index || this.selected_index(); |
|
252 | var i = index || this.selected_index(); | |
253 | if (i !== null && i < this.ncells() && i > 0) { |
|
253 | if (i !== null && i < this.ncells() && i > 0) { | |
254 | var pivot = this.cell_elements().eq(i-1); |
|
254 | var pivot = this.cell_elements().eq(i-1); | |
255 | var tomove = this.cell_elements().eq(i); |
|
255 | var tomove = this.cell_elements().eq(i); | |
256 | if (pivot !== null && tomove !== null) { |
|
256 | if (pivot !== null && tomove !== null) { | |
257 | tomove.detach(); |
|
257 | tomove.detach(); | |
258 | pivot.before(tomove); |
|
258 | pivot.before(tomove); | |
259 | this.select(i-1); |
|
259 | this.select(i-1); | |
260 | }; |
|
260 | }; | |
261 | }; |
|
261 | }; | |
262 | return this; |
|
262 | return this; | |
263 | } |
|
263 | } | |
264 |
|
264 | |||
265 |
|
265 | |||
266 | Notebook.prototype.move_cell_down = function (index) { |
|
266 | Notebook.prototype.move_cell_down = function (index) { | |
267 | var i = index || this.selected_index(); |
|
267 | var i = index || this.selected_index(); | |
268 | if (i !== null && i < (this.ncells()-1) && i >= 0) { |
|
268 | if (i !== null && i < (this.ncells()-1) && i >= 0) { | |
269 | var pivot = this.cell_elements().eq(i+1) |
|
269 | var pivot = this.cell_elements().eq(i+1) | |
270 | var tomove = this.cell_elements().eq(i) |
|
270 | var tomove = this.cell_elements().eq(i) | |
271 | if (pivot !== null && tomove !== null) { |
|
271 | if (pivot !== null && tomove !== null) { | |
272 | tomove.detach(); |
|
272 | tomove.detach(); | |
273 | pivot.after(tomove); |
|
273 | pivot.after(tomove); | |
274 | this.select(i+1); |
|
274 | this.select(i+1); | |
275 | }; |
|
275 | }; | |
276 | }; |
|
276 | }; | |
277 | return this; |
|
277 | return this; | |
278 | } |
|
278 | } | |
279 |
|
279 | |||
280 |
|
280 | |||
281 | Notebook.prototype.sort_cells = function () { |
|
281 | Notebook.prototype.sort_cells = function () { | |
282 | var ncells = this.ncells(); |
|
282 | var ncells = this.ncells(); | |
283 | var sindex = this.selected_index(); |
|
283 | var sindex = this.selected_index(); | |
284 | var swapped; |
|
284 | var swapped; | |
285 | do { |
|
285 | do { | |
286 | swapped = false |
|
286 | swapped = false | |
287 | for (var i=1; i<ncells; i++) { |
|
287 | for (var i=1; i<ncells; i++) { | |
288 | current = this.cell_elements().eq(i).data("cell"); |
|
288 | current = this.cell_elements().eq(i).data("cell"); | |
289 | previous = this.cell_elements().eq(i-1).data("cell"); |
|
289 | previous = this.cell_elements().eq(i-1).data("cell"); | |
290 | if (previous.input_prompt_number > current.input_prompt_number) { |
|
290 | if (previous.input_prompt_number > current.input_prompt_number) { | |
291 | this.move_cell_up(i); |
|
291 | this.move_cell_up(i); | |
292 | swapped = true; |
|
292 | swapped = true; | |
293 | }; |
|
293 | }; | |
294 | }; |
|
294 | }; | |
295 | } while (swapped); |
|
295 | } while (swapped); | |
296 | this.select(sindex); |
|
296 | this.select(sindex); | |
297 | return this; |
|
297 | return this; | |
298 | }; |
|
298 | }; | |
299 |
|
299 | |||
300 |
|
300 | |||
301 | Notebook.prototype.insert_code_cell_before = function (index) { |
|
301 | Notebook.prototype.insert_code_cell_before = function (index) { | |
302 | // TODO: Bounds check for i |
|
302 | // TODO: Bounds check for i | |
303 | var i = this.index_or_selected(index); |
|
303 | var i = this.index_or_selected(index); | |
304 | var cell = new IPython.CodeCell(this); |
|
304 | var cell = new IPython.CodeCell(this); | |
305 | cell.set_input_prompt(); |
|
305 | cell.set_input_prompt(); | |
306 | this.insert_cell_before(cell, i); |
|
306 | this.insert_cell_before(cell, i); | |
307 | this.select(this.find_cell_index(cell)); |
|
307 | this.select(this.find_cell_index(cell)); | |
308 | return cell; |
|
308 | return cell; | |
309 | } |
|
309 | } | |
310 |
|
310 | |||
311 |
|
311 | |||
312 | Notebook.prototype.insert_code_cell_after = function (index) { |
|
312 | Notebook.prototype.insert_code_cell_after = function (index) { | |
313 | // TODO: Bounds check for i |
|
313 | // TODO: Bounds check for i | |
314 | var i = this.index_or_selected(index); |
|
314 | var i = this.index_or_selected(index); | |
315 | var cell = new IPython.CodeCell(this); |
|
315 | var cell = new IPython.CodeCell(this); | |
316 | cell.set_input_prompt(); |
|
316 | cell.set_input_prompt(); | |
317 | this.insert_cell_after(cell, i); |
|
317 | this.insert_cell_after(cell, i); | |
318 | this.select(this.find_cell_index(cell)); |
|
318 | this.select(this.find_cell_index(cell)); | |
319 | return cell; |
|
319 | return cell; | |
320 | } |
|
320 | } | |
321 |
|
321 | |||
322 |
|
322 | |||
323 | Notebook.prototype.insert_html_cell_before = function (index) { |
|
323 | Notebook.prototype.insert_html_cell_before = function (index) { | |
324 | // TODO: Bounds check for i |
|
324 | // TODO: Bounds check for i | |
325 | var i = this.index_or_selected(index); |
|
325 | var i = this.index_or_selected(index); | |
326 | var cell = new IPython.HTMLCell(this); |
|
326 | var cell = new IPython.HTMLCell(this); | |
327 | cell.config_mathjax(); |
|
327 | cell.config_mathjax(); | |
328 | this.insert_cell_before(cell, i); |
|
328 | this.insert_cell_before(cell, i); | |
329 | this.select(this.find_cell_index(cell)); |
|
329 | this.select(this.find_cell_index(cell)); | |
330 | return cell; |
|
330 | return cell; | |
331 | } |
|
331 | } | |
332 |
|
332 | |||
333 |
|
333 | |||
334 | Notebook.prototype.insert_html_cell_after = function (index) { |
|
334 | Notebook.prototype.insert_html_cell_after = function (index) { | |
335 | // TODO: Bounds check for i |
|
335 | // TODO: Bounds check for i | |
336 | var i = this.index_or_selected(index); |
|
336 | var i = this.index_or_selected(index); | |
337 | var cell = new IPython.HTMLCell(this); |
|
337 | var cell = new IPython.HTMLCell(this); | |
338 | cell.config_mathjax(); |
|
338 | cell.config_mathjax(); | |
339 | this.insert_cell_after(cell, i); |
|
339 | this.insert_cell_after(cell, i); | |
340 | this.select(this.find_cell_index(cell)); |
|
340 | this.select(this.find_cell_index(cell)); | |
341 | return cell; |
|
341 | return cell; | |
342 | } |
|
342 | } | |
343 |
|
343 | |||
344 |
|
344 | |||
345 |
Notebook.prototype.insert_ |
|
345 | Notebook.prototype.insert_markdown_cell_before = function (index) { | |
346 | // TODO: Bounds check for i |
|
346 | // TODO: Bounds check for i | |
347 | var i = this.index_or_selected(index); |
|
347 | var i = this.index_or_selected(index); | |
348 |
var cell = new IPython. |
|
348 | var cell = new IPython.MarkdownCell(this); | |
349 | cell.config_mathjax(); |
|
349 | cell.config_mathjax(); | |
350 | this.insert_cell_before(cell, i); |
|
350 | this.insert_cell_before(cell, i); | |
351 | this.select(this.find_cell_index(cell)); |
|
351 | this.select(this.find_cell_index(cell)); | |
352 | return cell; |
|
352 | return cell; | |
353 | } |
|
353 | } | |
354 |
|
354 | |||
355 |
|
355 | |||
356 |
Notebook.prototype.insert_ |
|
356 | Notebook.prototype.insert_markdown_cell_after = function (index) { | |
357 | // TODO: Bounds check for i |
|
357 | // TODO: Bounds check for i | |
358 | var i = this.index_or_selected(index); |
|
358 | var i = this.index_or_selected(index); | |
359 |
var cell = new IPython. |
|
359 | var cell = new IPython.MarkdownCell(this); | |
360 | cell.config_mathjax(); |
|
360 | cell.config_mathjax(); | |
361 | this.insert_cell_after(cell, i); |
|
361 | this.insert_cell_after(cell, i); | |
362 | this.select(this.find_cell_index(cell)); |
|
362 | this.select(this.find_cell_index(cell)); | |
363 | return cell; |
|
363 | return cell; | |
364 | } |
|
364 | } | |
365 |
|
365 | |||
366 |
|
366 | |||
367 | Notebook.prototype.to_code = function (index) { |
|
367 | Notebook.prototype.to_code = function (index) { | |
368 | // TODO: Bounds check for i |
|
368 | // TODO: Bounds check for i | |
369 | var i = this.index_or_selected(index); |
|
369 | var i = this.index_or_selected(index); | |
370 | var source_element = this.cell_elements().eq(i); |
|
370 | var source_element = this.cell_elements().eq(i); | |
371 | var source_cell = source_element.data("cell"); |
|
371 | var source_cell = source_element.data("cell"); | |
372 |
if (source_cell instanceof IPython.HTMLCell || |
|
372 | if (source_cell instanceof IPython.HTMLCell || | |
|
373 | source_cell instanceof IPython.MarkdownCell) { | |||
373 | this.insert_code_cell_after(i); |
|
374 | this.insert_code_cell_after(i); | |
374 | var target_cell = this.cells()[i+1]; |
|
375 | var target_cell = this.cells()[i+1]; | |
375 | target_cell.set_code(source_cell.get_source()); |
|
376 | target_cell.set_code(source_cell.get_source()); | |
376 | source_element.remove(); |
|
377 | source_element.remove(); | |
377 | }; |
|
378 | }; | |
378 | }; |
|
379 | }; | |
379 |
|
380 | |||
380 |
|
381 | |||
381 |
Notebook.prototype.to_ |
|
382 | Notebook.prototype.to_markdown = function (index) { | |
382 | // TODO: Bounds check for i |
|
383 | // TODO: Bounds check for i | |
383 | var i = this.index_or_selected(index); |
|
384 | var i = this.index_or_selected(index); | |
384 | var source_element = this.cell_elements().eq(i); |
|
385 | var source_element = this.cell_elements().eq(i); | |
385 | var source_cell = source_element.data("cell"); |
|
386 | var source_cell = source_element.data("cell"); | |
386 | var target_cell = null; |
|
387 | var target_cell = null; | |
387 | if (source_cell instanceof IPython.CodeCell) { |
|
388 | if (source_cell instanceof IPython.CodeCell) { | |
388 |
this.insert_ |
|
389 | this.insert_markdown_cell_after(i); | |
389 | var target_cell = this.cells()[i+1]; |
|
390 | var target_cell = this.cells()[i+1]; | |
390 | var text = source_cell.get_code(); |
|
391 | var text = source_cell.get_code(); | |
391 | } else if (source_cell instanceof IPython.HTMLCell) { |
|
392 | } else if (source_cell instanceof IPython.HTMLCell) { | |
392 |
this.insert_ |
|
393 | this.insert_markdown_cell_after(i); | |
393 | var target_cell = this.cells()[i+1]; |
|
394 | var target_cell = this.cells()[i+1]; | |
394 | var text = source_cell.get_source(); |
|
395 | var text = source_cell.get_source(); | |
|
396 | if (text === source_cell.placeholder) { | |||
|
397 | text = target_cell.placeholder; | |||
|
398 | } | |||
395 | } |
|
399 | } | |
396 | if (target_cell !== null) { |
|
400 | if (target_cell !== null) { | |
397 | if (text === "") {text = target_cell.placeholder;}; |
|
401 | if (text === "") {text = target_cell.placeholder;}; | |
398 | target_cell.set_source(text); |
|
402 | target_cell.set_source(text); | |
399 | source_element.remove(); |
|
403 | source_element.remove(); | |
400 | target_cell.edit(); |
|
404 | target_cell.edit(); | |
401 | } |
|
405 | } | |
402 | }; |
|
406 | }; | |
403 |
|
407 | |||
404 |
|
408 | |||
405 | Notebook.prototype.to_html = function (index) { |
|
409 | Notebook.prototype.to_html = function (index) { | |
406 | // TODO: Bounds check for i |
|
410 | // TODO: Bounds check for i | |
407 | var i = this.index_or_selected(index); |
|
411 | var i = this.index_or_selected(index); | |
408 | var source_element = this.cell_elements().eq(i); |
|
412 | var source_element = this.cell_elements().eq(i); | |
409 | var source_cell = source_element.data("cell"); |
|
413 | var source_cell = source_element.data("cell"); | |
410 | var target_cell = null; |
|
414 | var target_cell = null; | |
411 | if (source_cell instanceof IPython.CodeCell) { |
|
415 | if (source_cell instanceof IPython.CodeCell) { | |
412 | this.insert_html_cell_after(i); |
|
416 | this.insert_html_cell_after(i); | |
413 | var target_cell = this.cells()[i+1]; |
|
417 | var target_cell = this.cells()[i+1]; | |
414 | var text = source_cell.get_code(); |
|
418 | var text = source_cell.get_code(); | |
415 |
} else if (source_cell instanceof IPython. |
|
419 | } else if (source_cell instanceof IPython.MarkdownCell) { | |
416 | this.insert_html_cell_after(i); |
|
420 | this.insert_html_cell_after(i); | |
417 | var target_cell = this.cells()[i+1]; |
|
421 | var target_cell = this.cells()[i+1]; | |
418 | var text = source_cell.get_source(); |
|
422 | var text = source_cell.get_source(); | |
|
423 | if (text === source_cell.placeholder) { | |||
|
424 | text = target_cell.placeholder; | |||
|
425 | } | |||
419 | } |
|
426 | } | |
420 | if (target_cell !== null) { |
|
427 | if (target_cell !== null) { | |
421 | if (text === "") {text = target_cell.placeholder;}; |
|
428 | if (text === "") {text = target_cell.placeholder;}; | |
422 | target_cell.set_source(text); |
|
429 | target_cell.set_source(text); | |
423 | source_element.remove(); |
|
430 | source_element.remove(); | |
424 | target_cell.edit(); |
|
431 | target_cell.edit(); | |
425 | } |
|
432 | } | |
426 | }; |
|
433 | }; | |
427 |
|
434 | |||
428 |
|
435 | |||
429 | // Cell collapsing |
|
436 | // Cell collapsing | |
430 |
|
437 | |||
431 | Notebook.prototype.collapse = function (index) { |
|
438 | Notebook.prototype.collapse = function (index) { | |
432 | var i = this.index_or_selected(index); |
|
439 | var i = this.index_or_selected(index); | |
433 | this.cells()[i].collapse(); |
|
440 | this.cells()[i].collapse(); | |
434 | }; |
|
441 | }; | |
435 |
|
442 | |||
436 |
|
443 | |||
437 | Notebook.prototype.expand = function (index) { |
|
444 | Notebook.prototype.expand = function (index) { | |
438 | var i = this.index_or_selected(index); |
|
445 | var i = this.index_or_selected(index); | |
439 | this.cells()[i].expand(); |
|
446 | this.cells()[i].expand(); | |
440 | }; |
|
447 | }; | |
441 |
|
448 | |||
442 |
|
449 | |||
443 | // Kernel related things |
|
450 | // Kernel related things | |
444 |
|
451 | |||
445 | Notebook.prototype.start_kernel = function () { |
|
452 | Notebook.prototype.start_kernel = function () { | |
446 | this.kernel = new IPython.Kernel(); |
|
453 | this.kernel = new IPython.Kernel(); | |
447 | var notebook_id = IPython.save_widget.get_notebook_id(); |
|
454 | var notebook_id = IPython.save_widget.get_notebook_id(); | |
448 | this.kernel.start_kernel(notebook_id, $.proxy(this.kernel_started, this)); |
|
455 | this.kernel.start_kernel(notebook_id, $.proxy(this.kernel_started, this)); | |
449 | }; |
|
456 | }; | |
450 |
|
457 | |||
451 |
|
458 | |||
452 | Notebook.prototype.handle_shell_reply = function (e) { |
|
459 | Notebook.prototype.handle_shell_reply = function (e) { | |
453 | reply = $.parseJSON(e.data); |
|
460 | reply = $.parseJSON(e.data); | |
454 | var header = reply.header; |
|
461 | var header = reply.header; | |
455 | var content = reply.content; |
|
462 | var content = reply.content; | |
456 | var msg_type = header.msg_type; |
|
463 | var msg_type = header.msg_type; | |
457 | // console.log(reply); |
|
464 | // console.log(reply); | |
458 | var cell = this.cell_for_msg(reply.parent_header.msg_id); |
|
465 | var cell = this.cell_for_msg(reply.parent_header.msg_id); | |
459 | if (msg_type === "execute_reply") { |
|
466 | if (msg_type === "execute_reply") { | |
460 | cell.set_input_prompt(content.execution_count); |
|
467 | cell.set_input_prompt(content.execution_count); | |
461 | } else if (msg_type === "complete_reply") { |
|
468 | } else if (msg_type === "complete_reply") { | |
462 | cell.finish_completing(content.matched_text, content.matches); |
|
469 | cell.finish_completing(content.matched_text, content.matches); | |
463 | }; |
|
470 | }; | |
464 | var payload = content.payload || []; |
|
471 | var payload = content.payload || []; | |
465 | this.handle_payload(payload); |
|
472 | this.handle_payload(payload); | |
466 | }; |
|
473 | }; | |
467 |
|
474 | |||
468 |
|
475 | |||
469 | Notebook.prototype.handle_payload = function (payload) { |
|
476 | Notebook.prototype.handle_payload = function (payload) { | |
470 | var l = payload.length; |
|
477 | var l = payload.length; | |
471 | if (l > 0) { |
|
478 | if (l > 0) { | |
472 | IPython.pager.clear(); |
|
479 | IPython.pager.clear(); | |
473 | IPython.pager.expand(); |
|
480 | IPython.pager.expand(); | |
474 | }; |
|
481 | }; | |
475 | for (var i=0; i<l; i++) { |
|
482 | for (var i=0; i<l; i++) { | |
476 | IPython.pager.append_text(payload[i].text); |
|
483 | IPython.pager.append_text(payload[i].text); | |
477 | }; |
|
484 | }; | |
478 | }; |
|
485 | }; | |
479 |
|
486 | |||
480 |
|
487 | |||
481 | Notebook.prototype.handle_iopub_reply = function (e) { |
|
488 | Notebook.prototype.handle_iopub_reply = function (e) { | |
482 | reply = $.parseJSON(e.data); |
|
489 | reply = $.parseJSON(e.data); | |
483 | var content = reply.content; |
|
490 | var content = reply.content; | |
484 | // console.log(reply); |
|
491 | // console.log(reply); | |
485 | var msg_type = reply.header.msg_type; |
|
492 | var msg_type = reply.header.msg_type; | |
486 | var cell = this.cell_for_msg(reply.parent_header.msg_id); |
|
493 | var cell = this.cell_for_msg(reply.parent_header.msg_id); | |
487 | var output_types = ['stream','display_data','pyout','pyerr']; |
|
494 | var output_types = ['stream','display_data','pyout','pyerr']; | |
488 | if (output_types.indexOf(msg_type) >= 0) { |
|
495 | if (output_types.indexOf(msg_type) >= 0) { | |
489 | this.handle_output(cell, msg_type, content); |
|
496 | this.handle_output(cell, msg_type, content); | |
490 | } else if (msg_type === "status") { |
|
497 | } else if (msg_type === "status") { | |
491 | if (content.execution_state === "busy") { |
|
498 | if (content.execution_state === "busy") { | |
492 | IPython.kernel_status_widget.status_busy(); |
|
499 | IPython.kernel_status_widget.status_busy(); | |
493 | } else if (content.execution_state === "idle") { |
|
500 | } else if (content.execution_state === "idle") { | |
494 | IPython.kernel_status_widget.status_idle(); |
|
501 | IPython.kernel_status_widget.status_idle(); | |
495 | }; |
|
502 | }; | |
496 | } |
|
503 | } | |
497 | }; |
|
504 | }; | |
498 |
|
505 | |||
499 |
|
506 | |||
500 | Notebook.prototype.handle_output = function (cell, msg_type, content) { |
|
507 | Notebook.prototype.handle_output = function (cell, msg_type, content) { | |
501 | var json = {}; |
|
508 | var json = {}; | |
502 | json.output_type = msg_type; |
|
509 | json.output_type = msg_type; | |
503 | if (msg_type === "stream") { |
|
510 | if (msg_type === "stream") { | |
504 | json.text = content.data + '\n'; |
|
511 | json.text = content.data + '\n'; | |
505 | } else if (msg_type === "display_data") { |
|
512 | } else if (msg_type === "display_data") { | |
506 | json = this.convert_mime_types(json, content.data); |
|
513 | json = this.convert_mime_types(json, content.data); | |
507 | } else if (msg_type === "pyout") { |
|
514 | } else if (msg_type === "pyout") { | |
508 | json.prompt_number = content.execution_count; |
|
515 | json.prompt_number = content.execution_count; | |
509 | json = this.convert_mime_types(json, content.data); |
|
516 | json = this.convert_mime_types(json, content.data); | |
510 | } else if (msg_type === "pyerr") { |
|
517 | } else if (msg_type === "pyerr") { | |
511 | json.ename = content.ename; |
|
518 | json.ename = content.ename; | |
512 | json.evalue = content.evalue; |
|
519 | json.evalue = content.evalue; | |
513 | json.traceback = content.traceback; |
|
520 | json.traceback = content.traceback; | |
514 | }; |
|
521 | }; | |
515 | cell.append_output(json); |
|
522 | cell.append_output(json); | |
516 | }; |
|
523 | }; | |
517 |
|
524 | |||
518 |
|
525 | |||
519 | Notebook.prototype.convert_mime_types = function (json, data) { |
|
526 | Notebook.prototype.convert_mime_types = function (json, data) { | |
520 | if (data['text/plain'] !== undefined) { |
|
527 | if (data['text/plain'] !== undefined) { | |
521 | json.text = data['text/plain']; |
|
528 | json.text = data['text/plain']; | |
522 | }; |
|
529 | }; | |
523 | if (data['text/html'] !== undefined) { |
|
530 | if (data['text/html'] !== undefined) { | |
524 | json.html = data['text/html']; |
|
531 | json.html = data['text/html']; | |
525 | }; |
|
532 | }; | |
526 | if (data['image/svg+xml'] !== undefined) { |
|
533 | if (data['image/svg+xml'] !== undefined) { | |
527 | json.svg = data['image/svg+xml']; |
|
534 | json.svg = data['image/svg+xml']; | |
528 | }; |
|
535 | }; | |
529 | if (data['image/png'] !== undefined) { |
|
536 | if (data['image/png'] !== undefined) { | |
530 | json.png = data['image/png']; |
|
537 | json.png = data['image/png']; | |
531 | }; |
|
538 | }; | |
532 | if (data['text/latex'] !== undefined) { |
|
539 | if (data['text/latex'] !== undefined) { | |
533 | json.latex = data['text/latex']; |
|
540 | json.latex = data['text/latex']; | |
534 | }; |
|
541 | }; | |
535 | if (data['application/json'] !== undefined) { |
|
542 | if (data['application/json'] !== undefined) { | |
536 | json.json = data['application/json']; |
|
543 | json.json = data['application/json']; | |
537 | }; |
|
544 | }; | |
538 | if (data['application/javascript'] !== undefined) { |
|
545 | if (data['application/javascript'] !== undefined) { | |
539 | json.javascript = data['application/javascript']; |
|
546 | json.javascript = data['application/javascript']; | |
540 | } |
|
547 | } | |
541 | return json; |
|
548 | return json; | |
542 | }; |
|
549 | }; | |
543 |
|
550 | |||
544 | Notebook.prototype.kernel_started = function () { |
|
551 | Notebook.prototype.kernel_started = function () { | |
545 | console.log("Kernel started: ", this.kernel.kernel_id); |
|
552 | console.log("Kernel started: ", this.kernel.kernel_id); | |
546 | this.kernel.shell_channel.onmessage = $.proxy(this.handle_shell_reply,this); |
|
553 | this.kernel.shell_channel.onmessage = $.proxy(this.handle_shell_reply,this); | |
547 | this.kernel.iopub_channel.onmessage = $.proxy(this.handle_iopub_reply,this); |
|
554 | this.kernel.iopub_channel.onmessage = $.proxy(this.handle_iopub_reply,this); | |
548 | }; |
|
555 | }; | |
549 |
|
556 | |||
550 |
|
557 | |||
551 | Notebook.prototype.execute_selected_cell = function (options) { |
|
558 | Notebook.prototype.execute_selected_cell = function (options) { | |
552 | // add_new: should a new cell be added if we are at the end of the nb |
|
559 | // add_new: should a new cell be added if we are at the end of the nb | |
553 | // terminal: execute in terminal mode, which stays in the current cell |
|
560 | // terminal: execute in terminal mode, which stays in the current cell | |
554 | default_options = {terminal: false, add_new: true} |
|
561 | default_options = {terminal: false, add_new: true} | |
555 | $.extend(default_options, options) |
|
562 | $.extend(default_options, options) | |
556 | var that = this; |
|
563 | var that = this; | |
557 | var cell = that.selected_cell(); |
|
564 | var cell = that.selected_cell(); | |
558 | var cell_index = that.find_cell_index(cell); |
|
565 | var cell_index = that.find_cell_index(cell); | |
559 | if (cell instanceof IPython.CodeCell) { |
|
566 | if (cell instanceof IPython.CodeCell) { | |
560 | cell.clear_output(); |
|
567 | cell.clear_output(); | |
561 | var code = cell.get_code(); |
|
568 | var code = cell.get_code(); | |
562 | var msg_id = that.kernel.execute(cell.get_code()); |
|
569 | var msg_id = that.kernel.execute(cell.get_code()); | |
563 | that.msg_cell_map[msg_id] = cell.cell_id; |
|
570 | that.msg_cell_map[msg_id] = cell.cell_id; | |
564 | } else if (cell instanceof IPython.HTMLCell) { |
|
571 | } else if (cell instanceof IPython.HTMLCell) { | |
565 | cell.render(); |
|
572 | cell.render(); | |
566 | } |
|
573 | } | |
567 | if (default_options.terminal) { |
|
574 | if (default_options.terminal) { | |
568 | cell.clear_input(); |
|
575 | cell.clear_input(); | |
569 | } else { |
|
576 | } else { | |
570 | if ((cell_index === (that.ncells()-1)) && default_options.add_new) { |
|
577 | if ((cell_index === (that.ncells()-1)) && default_options.add_new) { | |
571 | that.insert_code_cell_after(); |
|
578 | that.insert_code_cell_after(); | |
572 | // If we are adding a new cell at the end, scroll down to show it. |
|
579 | // If we are adding a new cell at the end, scroll down to show it. | |
573 | that.scroll_to_bottom(); |
|
580 | that.scroll_to_bottom(); | |
574 | } else { |
|
581 | } else { | |
575 | that.select(cell_index+1); |
|
582 | that.select(cell_index+1); | |
576 | }; |
|
583 | }; | |
577 | }; |
|
584 | }; | |
578 | }; |
|
585 | }; | |
579 |
|
586 | |||
580 |
|
587 | |||
581 | Notebook.prototype.execute_all_cells = function () { |
|
588 | Notebook.prototype.execute_all_cells = function () { | |
582 | var ncells = this.ncells(); |
|
589 | var ncells = this.ncells(); | |
583 | for (var i=0; i<ncells; i++) { |
|
590 | for (var i=0; i<ncells; i++) { | |
584 | this.select(i); |
|
591 | this.select(i); | |
585 | this.execute_selected_cell({add_new:false}); |
|
592 | this.execute_selected_cell({add_new:false}); | |
586 | }; |
|
593 | }; | |
587 | this.scroll_to_bottom(); |
|
594 | this.scroll_to_bottom(); | |
588 | }; |
|
595 | }; | |
589 |
|
596 | |||
590 |
|
597 | |||
591 | Notebook.prototype.complete_cell = function (cell, line, cursor_pos) { |
|
598 | Notebook.prototype.complete_cell = function (cell, line, cursor_pos) { | |
592 | var msg_id = this.kernel.complete(line, cursor_pos); |
|
599 | var msg_id = this.kernel.complete(line, cursor_pos); | |
593 | this.msg_cell_map[msg_id] = cell.cell_id; |
|
600 | this.msg_cell_map[msg_id] = cell.cell_id; | |
594 | }; |
|
601 | }; | |
595 |
|
602 | |||
596 | // Persistance and loading |
|
603 | // Persistance and loading | |
597 |
|
604 | |||
598 |
|
605 | |||
599 | Notebook.prototype.fromJSON = function (data) { |
|
606 | Notebook.prototype.fromJSON = function (data) { | |
600 | var ncells = this.ncells(); |
|
607 | var ncells = this.ncells(); | |
601 | for (var i=0; i<ncells; i++) { |
|
608 | for (var i=0; i<ncells; i++) { | |
602 | // Always delete cell 0 as they get renumbered as they are deleted. |
|
609 | // Always delete cell 0 as they get renumbered as they are deleted. | |
603 | this.delete_cell(0); |
|
610 | this.delete_cell(0); | |
604 | }; |
|
611 | }; | |
605 | // Only handle 1 worksheet for now. |
|
612 | // Only handle 1 worksheet for now. | |
606 | var worksheet = data.worksheets[0]; |
|
613 | var worksheet = data.worksheets[0]; | |
607 | if (worksheet !== undefined) { |
|
614 | if (worksheet !== undefined) { | |
608 | var new_cells = worksheet.cells; |
|
615 | var new_cells = worksheet.cells; | |
609 | ncells = new_cells.length; |
|
616 | ncells = new_cells.length; | |
610 | var cell_data = null; |
|
617 | var cell_data = null; | |
611 | var new_cell = null; |
|
618 | var new_cell = null; | |
612 | for (var i=0; i<ncells; i++) { |
|
619 | for (var i=0; i<ncells; i++) { | |
613 | cell_data = new_cells[i]; |
|
620 | cell_data = new_cells[i]; | |
614 | if (cell_data.cell_type == 'code') { |
|
621 | if (cell_data.cell_type == 'code') { | |
615 | new_cell = this.insert_code_cell_after(); |
|
622 | new_cell = this.insert_code_cell_after(); | |
616 | new_cell.fromJSON(cell_data); |
|
623 | new_cell.fromJSON(cell_data); | |
617 | } else if (cell_data.cell_type === 'html') { |
|
624 | } else if (cell_data.cell_type === 'html') { | |
618 | new_cell = this.insert_html_cell_after(); |
|
625 | new_cell = this.insert_html_cell_after(); | |
619 | new_cell.fromJSON(cell_data); |
|
626 | new_cell.fromJSON(cell_data); | |
620 | }; |
|
627 | }; | |
621 | }; |
|
628 | }; | |
622 | }; |
|
629 | }; | |
623 | }; |
|
630 | }; | |
624 |
|
631 | |||
625 |
|
632 | |||
626 | Notebook.prototype.toJSON = function () { |
|
633 | Notebook.prototype.toJSON = function () { | |
627 | var cells = this.cells(); |
|
634 | var cells = this.cells(); | |
628 | var ncells = cells.length; |
|
635 | var ncells = cells.length; | |
629 | cell_array = new Array(ncells); |
|
636 | cell_array = new Array(ncells); | |
630 | for (var i=0; i<ncells; i++) { |
|
637 | for (var i=0; i<ncells; i++) { | |
631 | cell_array[i] = cells[i].toJSON(); |
|
638 | cell_array[i] = cells[i].toJSON(); | |
632 | }; |
|
639 | }; | |
633 | data = { |
|
640 | data = { | |
634 | // Only handle 1 worksheet for now. |
|
641 | // Only handle 1 worksheet for now. | |
635 | worksheets : [{cells:cell_array}] |
|
642 | worksheets : [{cells:cell_array}] | |
636 | } |
|
643 | } | |
637 | return data |
|
644 | return data | |
638 | }; |
|
645 | }; | |
639 |
|
646 | |||
640 | Notebook.prototype.save_notebook = function () { |
|
647 | Notebook.prototype.save_notebook = function () { | |
641 | if (IPython.save_widget.test_notebook_name()) { |
|
648 | if (IPython.save_widget.test_notebook_name()) { | |
642 | var notebook_id = IPython.save_widget.get_notebook_id(); |
|
649 | var notebook_id = IPython.save_widget.get_notebook_id(); | |
643 | var nbname = IPython.save_widget.get_notebook_name(); |
|
650 | var nbname = IPython.save_widget.get_notebook_name(); | |
644 | // We may want to move the name/id/nbformat logic inside toJSON? |
|
651 | // We may want to move the name/id/nbformat logic inside toJSON? | |
645 | var data = this.toJSON(); |
|
652 | var data = this.toJSON(); | |
646 | data.name = nbname; |
|
653 | data.name = nbname; | |
647 | data.nbformat = 2; |
|
654 | data.nbformat = 2; | |
648 | data.id = notebook_id |
|
655 | data.id = notebook_id | |
649 | // We do the call with settings so we can set cache to false. |
|
656 | // We do the call with settings so we can set cache to false. | |
650 | var settings = { |
|
657 | var settings = { | |
651 | processData : false, |
|
658 | processData : false, | |
652 | cache : false, |
|
659 | cache : false, | |
653 | type : "PUT", |
|
660 | type : "PUT", | |
654 | data : JSON.stringify(data), |
|
661 | data : JSON.stringify(data), | |
655 | headers : {'Content-Type': 'application/json'}, |
|
662 | headers : {'Content-Type': 'application/json'}, | |
656 | success : $.proxy(this.notebook_saved,this) |
|
663 | success : $.proxy(this.notebook_saved,this) | |
657 | }; |
|
664 | }; | |
658 | IPython.save_widget.status_saving(); |
|
665 | IPython.save_widget.status_saving(); | |
659 | $.ajax("/notebooks/" + notebook_id, settings); |
|
666 | $.ajax("/notebooks/" + notebook_id, settings); | |
660 | }; |
|
667 | }; | |
661 | }; |
|
668 | }; | |
662 |
|
669 | |||
663 |
|
670 | |||
664 | Notebook.prototype.notebook_saved = function (data, status, xhr) { |
|
671 | Notebook.prototype.notebook_saved = function (data, status, xhr) { | |
665 | IPython.save_widget.status_save(); |
|
672 | IPython.save_widget.status_save(); | |
666 | } |
|
673 | } | |
667 |
|
674 | |||
668 |
|
675 | |||
669 | Notebook.prototype.load_notebook = function (callback) { |
|
676 | Notebook.prototype.load_notebook = function (callback) { | |
670 | var that = this; |
|
677 | var that = this; | |
671 | var notebook_id = IPython.save_widget.get_notebook_id(); |
|
678 | var notebook_id = IPython.save_widget.get_notebook_id(); | |
672 | // We do the call with settings so we can set cache to false. |
|
679 | // We do the call with settings so we can set cache to false. | |
673 | var settings = { |
|
680 | var settings = { | |
674 | processData : false, |
|
681 | processData : false, | |
675 | cache : false, |
|
682 | cache : false, | |
676 | type : "GET", |
|
683 | type : "GET", | |
677 | dataType : "json", |
|
684 | dataType : "json", | |
678 | success : function (data, status, xhr) { |
|
685 | success : function (data, status, xhr) { | |
679 | that.notebook_loaded(data, status, xhr); |
|
686 | that.notebook_loaded(data, status, xhr); | |
680 | if (callback !== undefined) { |
|
687 | if (callback !== undefined) { | |
681 | callback(); |
|
688 | callback(); | |
682 | }; |
|
689 | }; | |
683 | } |
|
690 | } | |
684 | }; |
|
691 | }; | |
685 | IPython.save_widget.status_loading(); |
|
692 | IPython.save_widget.status_loading(); | |
686 | $.ajax("/notebooks/" + notebook_id, settings); |
|
693 | $.ajax("/notebooks/" + notebook_id, settings); | |
687 | } |
|
694 | } | |
688 |
|
695 | |||
689 |
|
696 | |||
690 | Notebook.prototype.notebook_loaded = function (data, status, xhr) { |
|
697 | Notebook.prototype.notebook_loaded = function (data, status, xhr) { | |
691 | this.fromJSON(data); |
|
698 | this.fromJSON(data); | |
692 | if (this.ncells() === 0) { |
|
699 | if (this.ncells() === 0) { | |
693 | this.insert_code_cell_after(); |
|
700 | this.insert_code_cell_after(); | |
694 | }; |
|
701 | }; | |
695 | IPython.save_widget.status_save(); |
|
702 | IPython.save_widget.status_save(); | |
696 | IPython.save_widget.set_notebook_name(data.name); |
|
703 | IPython.save_widget.set_notebook_name(data.name); | |
697 | this.start_kernel(); |
|
704 | this.start_kernel(); | |
698 | // fromJSON always selects the last cell inserted. We need to wait |
|
705 | // fromJSON always selects the last cell inserted. We need to wait | |
699 | // until that is done before scrolling to the top. |
|
706 | // until that is done before scrolling to the top. | |
700 | setTimeout(function () { |
|
707 | setTimeout(function () { | |
701 | IPython.notebook.select(0); |
|
708 | IPython.notebook.select(0); | |
702 | IPython.notebook.scroll_to_top(); |
|
709 | IPython.notebook.scroll_to_top(); | |
703 | }, 50); |
|
710 | }, 50); | |
704 | }; |
|
711 | }; | |
705 |
|
712 | |||
706 | IPython.Notebook = Notebook; |
|
713 | IPython.Notebook = Notebook; | |
707 |
|
714 | |||
708 | return IPython; |
|
715 | return IPython; | |
709 |
|
716 | |||
710 | }(IPython)); |
|
717 | }(IPython)); | |
711 |
|
718 |
@@ -1,238 +1,238 b'' | |||||
1 |
|
1 | |||
2 | //============================================================================ |
|
2 | //============================================================================ | |
3 | // Cell |
|
3 | // Cell | |
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 | // Base PanelSection class |
|
10 | // Base PanelSection class | |
11 |
|
11 | |||
12 | var PanelSection = function (selector) { |
|
12 | var PanelSection = function (selector) { | |
13 | this.selector = selector; |
|
13 | this.selector = selector; | |
14 | if (this.selector !== undefined) { |
|
14 | if (this.selector !== undefined) { | |
15 | this.element = $(selector); |
|
15 | this.element = $(selector); | |
16 | this.header = this.element.find('h3.section_header'); |
|
16 | this.header = this.element.find('h3.section_header'); | |
17 | this.content = this.element.find('div.section_content'); |
|
17 | this.content = this.element.find('div.section_content'); | |
18 | this.style(); |
|
18 | this.style(); | |
19 | this.bind_events(); |
|
19 | this.bind_events(); | |
20 | } |
|
20 | } | |
21 | this.expanded = true; |
|
21 | this.expanded = true; | |
22 | }; |
|
22 | }; | |
23 |
|
23 | |||
24 |
|
24 | |||
25 | PanelSection.prototype.style = function () { |
|
25 | PanelSection.prototype.style = function () { | |
26 | this.header.addClass('ui-widget ui-state-default'); |
|
26 | this.header.addClass('ui-widget ui-state-default'); | |
27 | this.content.addClass('ui-widget section_content'); |
|
27 | this.content.addClass('ui-widget section_content'); | |
28 | }; |
|
28 | }; | |
29 |
|
29 | |||
30 |
|
30 | |||
31 | PanelSection.prototype.bind_events = function () { |
|
31 | PanelSection.prototype.bind_events = function () { | |
32 | var that = this; |
|
32 | var that = this; | |
33 | this.header.click(function () { |
|
33 | this.header.click(function () { | |
34 | that.toggle(); |
|
34 | that.toggle(); | |
35 | }); |
|
35 | }); | |
36 | this.header.hover(function () { |
|
36 | this.header.hover(function () { | |
37 | that.header.toggleClass('ui-state-hover'); |
|
37 | that.header.toggleClass('ui-state-hover'); | |
38 | }); |
|
38 | }); | |
39 | }; |
|
39 | }; | |
40 |
|
40 | |||
41 |
|
41 | |||
42 | PanelSection.prototype.expand = function () { |
|
42 | PanelSection.prototype.expand = function () { | |
43 | if (!this.expanded) { |
|
43 | if (!this.expanded) { | |
44 | this.content.slideDown('fast'); |
|
44 | this.content.slideDown('fast'); | |
45 | this.expanded = true; |
|
45 | this.expanded = true; | |
46 | }; |
|
46 | }; | |
47 | }; |
|
47 | }; | |
48 |
|
48 | |||
49 |
|
49 | |||
50 | PanelSection.prototype.collapse = function () { |
|
50 | PanelSection.prototype.collapse = function () { | |
51 | if (this.expanded) { |
|
51 | if (this.expanded) { | |
52 | this.content.slideUp('fast'); |
|
52 | this.content.slideUp('fast'); | |
53 | this.expanded = false; |
|
53 | this.expanded = false; | |
54 | }; |
|
54 | }; | |
55 | }; |
|
55 | }; | |
56 |
|
56 | |||
57 |
|
57 | |||
58 | PanelSection.prototype.toggle = function () { |
|
58 | PanelSection.prototype.toggle = function () { | |
59 | if (this.expanded === true) { |
|
59 | if (this.expanded === true) { | |
60 | this.collapse(); |
|
60 | this.collapse(); | |
61 | } else { |
|
61 | } else { | |
62 | this.expand(); |
|
62 | this.expand(); | |
63 | }; |
|
63 | }; | |
64 | }; |
|
64 | }; | |
65 |
|
65 | |||
66 |
|
66 | |||
67 | PanelSection.prototype.create_children = function () {}; |
|
67 | PanelSection.prototype.create_children = function () {}; | |
68 |
|
68 | |||
69 |
|
69 | |||
70 | // NotebookSection |
|
70 | // NotebookSection | |
71 |
|
71 | |||
72 | var NotebookSection = function () { |
|
72 | var NotebookSection = function () { | |
73 | PanelSection.apply(this, arguments); |
|
73 | PanelSection.apply(this, arguments); | |
74 | }; |
|
74 | }; | |
75 |
|
75 | |||
76 |
|
76 | |||
77 | NotebookSection.prototype = new PanelSection(); |
|
77 | NotebookSection.prototype = new PanelSection(); | |
78 |
|
78 | |||
79 |
|
79 | |||
80 | NotebookSection.prototype.style = function () { |
|
80 | NotebookSection.prototype.style = function () { | |
81 | PanelSection.prototype.style.apply(this); |
|
81 | PanelSection.prototype.style.apply(this); | |
82 | this.content.addClass('ui-helper-clearfix'); |
|
82 | this.content.addClass('ui-helper-clearfix'); | |
83 | this.content.find('div.section_row').addClass('ui-helper-clearfix'); |
|
83 | this.content.find('div.section_row').addClass('ui-helper-clearfix'); | |
84 | this.content.find('#new_open').buttonset(); |
|
84 | this.content.find('#new_open').buttonset(); | |
85 | this.content.find('#download_notebook').button(); |
|
85 | this.content.find('#download_notebook').button(); | |
86 | this.content.find('#upload_notebook').button(); |
|
86 | this.content.find('#upload_notebook').button(); | |
87 | this.content.find('#download_format').addClass('ui-widget ui-widget-content'); |
|
87 | this.content.find('#download_format').addClass('ui-widget ui-widget-content'); | |
88 | this.content.find('#download_format option').addClass('ui-widget ui-widget-content'); |
|
88 | this.content.find('#download_format option').addClass('ui-widget ui-widget-content'); | |
89 | }; |
|
89 | }; | |
90 |
|
90 | |||
91 |
|
91 | |||
92 | NotebookSection.prototype.bind_events = function () { |
|
92 | NotebookSection.prototype.bind_events = function () { | |
93 | PanelSection.prototype.bind_events.apply(this); |
|
93 | PanelSection.prototype.bind_events.apply(this); | |
94 | var that = this; |
|
94 | var that = this; | |
95 | this.content.find('#new_notebook').click(function () { |
|
95 | this.content.find('#new_notebook').click(function () { | |
96 | window.open('/new'); |
|
96 | window.open('/new'); | |
97 | }); |
|
97 | }); | |
98 | this.content.find('#open_notebook').click(function () { |
|
98 | this.content.find('#open_notebook').click(function () { | |
99 | window.open('/'); |
|
99 | window.open('/'); | |
100 | }); |
|
100 | }); | |
101 | this.content.find('#download_notebook').click(function () { |
|
101 | this.content.find('#download_notebook').click(function () { | |
102 | var format = that.content.find('#download_format').val(); |
|
102 | var format = that.content.find('#download_format').val(); | |
103 | var notebook_id = IPython.save_widget.get_notebook_id(); |
|
103 | var notebook_id = IPython.save_widget.get_notebook_id(); | |
104 | var url = '/notebooks/' + notebook_id + '?format=' + format; |
|
104 | var url = '/notebooks/' + notebook_id + '?format=' + format; | |
105 | window.open(url,'_newtab'); |
|
105 | window.open(url,'_newtab'); | |
106 | }); |
|
106 | }); | |
107 | }; |
|
107 | }; | |
108 |
|
108 | |||
109 | // CellSection |
|
109 | // CellSection | |
110 |
|
110 | |||
111 | var CellSection = function () { |
|
111 | var CellSection = function () { | |
112 | PanelSection.apply(this, arguments); |
|
112 | PanelSection.apply(this, arguments); | |
113 | }; |
|
113 | }; | |
114 |
|
114 | |||
115 |
|
115 | |||
116 | CellSection.prototype = new PanelSection(); |
|
116 | CellSection.prototype = new PanelSection(); | |
117 |
|
117 | |||
118 |
|
118 | |||
119 | CellSection.prototype.style = function () { |
|
119 | CellSection.prototype.style = function () { | |
120 | PanelSection.prototype.style.apply(this); |
|
120 | PanelSection.prototype.style.apply(this); | |
121 | this.content.addClass('ui-helper-clearfix'); |
|
121 | this.content.addClass('ui-helper-clearfix'); | |
122 | this.content.find('div.section_row').addClass('ui-helper-clearfix'); |
|
122 | this.content.find('div.section_row').addClass('ui-helper-clearfix'); | |
123 | this.content.find('#delete_cell').button(); |
|
123 | this.content.find('#delete_cell').button(); | |
124 | this.content.find('#insert').buttonset(); |
|
124 | this.content.find('#insert').buttonset(); | |
125 | this.content.find('#move').buttonset(); |
|
125 | this.content.find('#move').buttonset(); | |
126 | this.content.find('#cell_type').buttonset(); |
|
126 | this.content.find('#cell_type').buttonset(); | |
127 | this.content.find('#toggle_output').buttonset(); |
|
127 | this.content.find('#toggle_output').buttonset(); | |
128 | this.content.find('#run_cells').buttonset(); |
|
128 | this.content.find('#run_cells').buttonset(); | |
129 | }; |
|
129 | }; | |
130 |
|
130 | |||
131 |
|
131 | |||
132 | CellSection.prototype.bind_events = function () { |
|
132 | CellSection.prototype.bind_events = function () { | |
133 | PanelSection.prototype.bind_events.apply(this); |
|
133 | PanelSection.prototype.bind_events.apply(this); | |
134 | this.content.find('#collapse_cell').click(function () { |
|
134 | this.content.find('#collapse_cell').click(function () { | |
135 | IPython.notebook.collapse(); |
|
135 | IPython.notebook.collapse(); | |
136 | }); |
|
136 | }); | |
137 | this.content.find('#expand_cell').click(function () { |
|
137 | this.content.find('#expand_cell').click(function () { | |
138 | IPython.notebook.expand(); |
|
138 | IPython.notebook.expand(); | |
139 | }); |
|
139 | }); | |
140 | this.content.find('#delete_cell').click(function () { |
|
140 | this.content.find('#delete_cell').click(function () { | |
141 | IPython.notebook.delete_cell(); |
|
141 | IPython.notebook.delete_cell(); | |
142 | }); |
|
142 | }); | |
143 | this.content.find('#insert_cell_above').click(function () { |
|
143 | this.content.find('#insert_cell_above').click(function () { | |
144 | IPython.notebook.insert_code_cell_before(); |
|
144 | IPython.notebook.insert_code_cell_before(); | |
145 | }); |
|
145 | }); | |
146 | this.content.find('#insert_cell_below').click(function () { |
|
146 | this.content.find('#insert_cell_below').click(function () { | |
147 | IPython.notebook.insert_code_cell_after(); |
|
147 | IPython.notebook.insert_code_cell_after(); | |
148 | }); |
|
148 | }); | |
149 | this.content.find('#move_cell_up').click(function () { |
|
149 | this.content.find('#move_cell_up').click(function () { | |
150 | IPython.notebook.move_cell_up(); |
|
150 | IPython.notebook.move_cell_up(); | |
151 | }); |
|
151 | }); | |
152 | this.content.find('#move_cell_down').click(function () { |
|
152 | this.content.find('#move_cell_down').click(function () { | |
153 | IPython.notebook.move_cell_down(); |
|
153 | IPython.notebook.move_cell_down(); | |
154 | }); |
|
154 | }); | |
155 | this.content.find('#to_code').click(function () { |
|
155 | this.content.find('#to_code').click(function () { | |
156 | IPython.notebook.to_code(); |
|
156 | IPython.notebook.to_code(); | |
157 | }); |
|
157 | }); | |
158 | this.content.find('#to_html').click(function () { |
|
158 | this.content.find('#to_html').click(function () { | |
159 | IPython.notebook.to_html(); |
|
159 | IPython.notebook.to_html(); | |
160 | }); |
|
160 | }); | |
161 |
this.content.find('#to_ |
|
161 | this.content.find('#to_markdown').click(function () { | |
162 |
IPython.notebook.to_ |
|
162 | IPython.notebook.to_markdown(); | |
163 | }); |
|
163 | }); | |
164 | this.content.find('#run_selected_cell').click(function () { |
|
164 | this.content.find('#run_selected_cell').click(function () { | |
165 | IPython.notebook.execute_selected_cell(); |
|
165 | IPython.notebook.execute_selected_cell(); | |
166 | }); |
|
166 | }); | |
167 | this.content.find('#run_all_cells').click(function () { |
|
167 | this.content.find('#run_all_cells').click(function () { | |
168 | IPython.notebook.execute_all_cells(); |
|
168 | IPython.notebook.execute_all_cells(); | |
169 | }); |
|
169 | }); | |
170 | }; |
|
170 | }; | |
171 |
|
171 | |||
172 |
|
172 | |||
173 | // KernelSection |
|
173 | // KernelSection | |
174 |
|
174 | |||
175 | var KernelSection = function () { |
|
175 | var KernelSection = function () { | |
176 | PanelSection.apply(this, arguments); |
|
176 | PanelSection.apply(this, arguments); | |
177 | }; |
|
177 | }; | |
178 |
|
178 | |||
179 |
|
179 | |||
180 | KernelSection.prototype = new PanelSection(); |
|
180 | KernelSection.prototype = new PanelSection(); | |
181 |
|
181 | |||
182 |
|
182 | |||
183 | KernelSection.prototype.style = function () { |
|
183 | KernelSection.prototype.style = function () { | |
184 | PanelSection.prototype.style.apply(this); |
|
184 | PanelSection.prototype.style.apply(this); | |
185 | this.content.addClass('ui-helper-clearfix'); |
|
185 | this.content.addClass('ui-helper-clearfix'); | |
186 | this.content.find('div.section_row').addClass('ui-helper-clearfix'); |
|
186 | this.content.find('div.section_row').addClass('ui-helper-clearfix'); | |
187 | this.content.find('#int_restart').buttonset(); |
|
187 | this.content.find('#int_restart').buttonset(); | |
188 | }; |
|
188 | }; | |
189 |
|
189 | |||
190 |
|
190 | |||
191 | KernelSection.prototype.bind_events = function () { |
|
191 | KernelSection.prototype.bind_events = function () { | |
192 | PanelSection.prototype.bind_events.apply(this); |
|
192 | PanelSection.prototype.bind_events.apply(this); | |
193 | this.content.find('#restart_kernel').click(function () { |
|
193 | this.content.find('#restart_kernel').click(function () { | |
194 | IPython.notebook.kernel.restart(); |
|
194 | IPython.notebook.kernel.restart(); | |
195 | }); |
|
195 | }); | |
196 | this.content.find('#int_kernel').click(function () { |
|
196 | this.content.find('#int_kernel').click(function () { | |
197 | IPython.notebook.kernel.interrupt(); |
|
197 | IPython.notebook.kernel.interrupt(); | |
198 | }); |
|
198 | }); | |
199 | }; |
|
199 | }; | |
200 |
|
200 | |||
201 |
|
201 | |||
202 | // HelpSection |
|
202 | // HelpSection | |
203 |
|
203 | |||
204 | var HelpSection = function () { |
|
204 | var HelpSection = function () { | |
205 | PanelSection.apply(this, arguments); |
|
205 | PanelSection.apply(this, arguments); | |
206 | }; |
|
206 | }; | |
207 |
|
207 | |||
208 |
|
208 | |||
209 | HelpSection.prototype = new PanelSection(); |
|
209 | HelpSection.prototype = new PanelSection(); | |
210 |
|
210 | |||
211 |
|
211 | |||
212 | HelpSection.prototype.style = function () { |
|
212 | HelpSection.prototype.style = function () { | |
213 | PanelSection.prototype.style.apply(this); |
|
213 | PanelSection.prototype.style.apply(this); | |
214 | PanelSection.prototype.style.apply(this); |
|
214 | PanelSection.prototype.style.apply(this); | |
215 | this.content.addClass('ui-helper-clearfix'); |
|
215 | this.content.addClass('ui-helper-clearfix'); | |
216 | this.content.find('div.section_row').addClass('ui-helper-clearfix'); |
|
216 | this.content.find('div.section_row').addClass('ui-helper-clearfix'); | |
217 | this.content.find('#help_buttons0').buttonset(); |
|
217 | this.content.find('#help_buttons0').buttonset(); | |
218 | this.content.find('#help_buttons1').buttonset(); |
|
218 | this.content.find('#help_buttons1').buttonset(); | |
219 | }; |
|
219 | }; | |
220 |
|
220 | |||
221 |
|
221 | |||
222 | HelpSection.prototype.bind_events = function () { |
|
222 | HelpSection.prototype.bind_events = function () { | |
223 | PanelSection.prototype.bind_events.apply(this); |
|
223 | PanelSection.prototype.bind_events.apply(this); | |
224 | }; |
|
224 | }; | |
225 |
|
225 | |||
226 |
|
226 | |||
227 | // Set module variables |
|
227 | // Set module variables | |
228 |
|
228 | |||
229 | IPython.PanelSection = PanelSection; |
|
229 | IPython.PanelSection = PanelSection; | |
230 | IPython.NotebookSection = NotebookSection; |
|
230 | IPython.NotebookSection = NotebookSection; | |
231 | IPython.CellSection = CellSection; |
|
231 | IPython.CellSection = CellSection; | |
232 | IPython.KernelSection = KernelSection; |
|
232 | IPython.KernelSection = KernelSection; | |
233 | IPython.HelpSection = HelpSection; |
|
233 | IPython.HelpSection = HelpSection; | |
234 |
|
234 | |||
235 | return IPython; |
|
235 | return IPython; | |
236 |
|
236 | |||
237 | }(IPython)); |
|
237 | }(IPython)); | |
238 |
|
238 |
@@ -1,156 +1,249 b'' | |||||
1 |
|
1 | |||
2 | //============================================================================ |
|
2 | //============================================================================ | |
3 |
// |
|
3 | // TextCell | |
4 | //============================================================================ |
|
4 | //============================================================================ | |
5 |
|
5 | |||
6 | var IPython = (function (IPython) { |
|
6 | var IPython = (function (IPython) { | |
7 |
|
7 | |||
8 | var HTMLCell = function (notebook) { |
|
8 | // TextCell base class | |
|
9 | ||||
|
10 | var TextCell = function (notebook) { | |||
|
11 | this.code_mirror_mode = this.code_mirror_mode || 'htmlmixed'; | |||
|
12 | this.placeholder = this.placeholder || ''; | |||
9 | IPython.Cell.apply(this, arguments); |
|
13 | IPython.Cell.apply(this, arguments); | |
10 | this.placeholder = "Type <strong>HTML</strong> and LaTeX: $\\alpha^2$" |
|
|||
11 | this.rendered = false; |
|
14 | this.rendered = false; | |
|
15 | this.cell_type = this.cell_type || 'text'; | |||
12 | }; |
|
16 | }; | |
13 |
|
17 | |||
14 |
|
18 | |||
15 |
|
|
19 | TextCell.prototype = new IPython.Cell(); | |
16 |
|
20 | |||
17 |
|
21 | |||
18 |
|
22 | TextCell.prototype.create_element = function () { | ||
19 | HTMLCell.prototype.create_element = function () { |
|
23 | var cell = $("<div>").addClass('cell text_cell border-box-sizing'); | |
20 |
var |
|
24 | var input_area = $('<div/>').addClass('text_cell_input'); | |
21 | var input_area = $('<div/>').addClass('html_cell_input'); |
|
|||
22 | this.code_mirror = CodeMirror(input_area.get(0), { |
|
25 | this.code_mirror = CodeMirror(input_area.get(0), { | |
23 | indentUnit : 4, |
|
26 | indentUnit : 4, | |
24 | enterMode : 'flat', |
|
27 | enterMode : 'flat', | |
25 | tabMode: 'shift', |
|
28 | tabMode: 'shift', | |
26 |
mode: |
|
29 | mode: this.code_mirror_mode, | |
27 | theme: 'default', |
|
30 | theme: 'default', | |
28 | value: this.placeholder |
|
31 | value: this.placeholder | |
29 | }); |
|
32 | }); | |
30 | // The tabindex=-1 makes this div focusable. |
|
33 | // The tabindex=-1 makes this div focusable. | |
31 |
var render_area = $('<div/>').addClass(' |
|
34 | var render_area = $('<div/>').addClass('text_cell_render'). | |
32 | addClass('rendered_html').attr('tabindex','-1'); |
|
35 | addClass('rendered_html').attr('tabindex','-1'); | |
33 | cell.append(input_area).append(render_area); |
|
36 | cell.append(input_area).append(render_area); | |
34 | this.element = cell; |
|
37 | this.element = cell; | |
35 | }; |
|
38 | }; | |
36 |
|
39 | |||
37 |
|
40 | |||
38 |
|
|
41 | TextCell.prototype.bind_events = function () { | |
39 | IPython.Cell.prototype.bind_events.apply(this); |
|
42 | IPython.Cell.prototype.bind_events.apply(this); | |
40 | var that = this; |
|
43 | var that = this; | |
41 | this.element.keydown(function (event) { |
|
44 | this.element.keydown(function (event) { | |
42 | if (event.which === 13) { |
|
45 | if (event.which === 13) { | |
43 | if (that.rendered) { |
|
46 | if (that.rendered) { | |
44 | that.edit(); |
|
47 | that.edit(); | |
45 | event.preventDefault(); |
|
48 | event.preventDefault(); | |
46 | }; |
|
49 | }; | |
47 | }; |
|
50 | }; | |
48 | }); |
|
51 | }); | |
49 | }; |
|
52 | }; | |
50 |
|
53 | |||
51 |
|
54 | |||
52 |
|
|
55 | TextCell.prototype.select = function () { | |
53 | IPython.Cell.prototype.select.apply(this); |
|
56 | IPython.Cell.prototype.select.apply(this); | |
54 |
var output = this.element.find("div. |
|
57 | var output = this.element.find("div.text_cell_render"); | |
55 | output.trigger('focus'); |
|
58 | output.trigger('focus'); | |
56 | }; |
|
59 | }; | |
57 |
|
60 | |||
58 |
|
61 | |||
59 |
|
|
62 | TextCell.prototype.edit = function () { | |
60 | if (this.rendered === true) { |
|
63 | if (this.rendered === true) { | |
61 |
var |
|
64 | var text_cell = this.element; | |
62 |
var output = |
|
65 | var output = text_cell.find("div.text_cell_render"); | |
63 | output.hide(); |
|
66 | output.hide(); | |
64 |
|
|
67 | text_cell.find('div.text_cell_input').show(); | |
65 | this.code_mirror.focus(); |
|
68 | this.code_mirror.focus(); | |
66 | this.code_mirror.refresh(); |
|
69 | this.code_mirror.refresh(); | |
67 | this.rendered = false; |
|
70 | this.rendered = false; | |
68 | }; |
|
71 | }; | |
69 | }; |
|
72 | }; | |
70 |
|
73 | |||
71 |
|
74 | |||
72 | HTMLCell.prototype.render = function () { |
|
75 | // Subclasses must define render. | |
73 | if (this.rendered === false) { |
|
76 | TextCell.prototype.render = function () {}; | |
74 | var html_cell = this.element; |
|
|||
75 | var output = html_cell.find("div.html_cell_render"); |
|
|||
76 | var text = this.get_source(); |
|
|||
77 | if (text === "") {text = this.placeholder;}; |
|
|||
78 | this.set_rendered(text); |
|
|||
79 | MathJax.Hub.Queue(["Typeset",MathJax.Hub]); |
|
|||
80 | html_cell.find('div.html_cell_input').hide(); |
|
|||
81 | output.show(); |
|
|||
82 | this.rendered = true; |
|
|||
83 | }; |
|
|||
84 | }; |
|
|||
85 |
|
77 | |||
86 |
|
78 | |||
87 |
|
|
79 | TextCell.prototype.config_mathjax = function () { | |
88 |
var |
|
80 | var text_cell = this.element; | |
89 | var that = this; |
|
81 | var that = this; | |
90 |
|
|
82 | text_cell.click(function () { | |
91 | that.edit(); |
|
83 | that.edit(); | |
92 | }).focusout(function () { |
|
84 | }).focusout(function () { | |
93 | that.render(); |
|
85 | that.render(); | |
94 | }); |
|
86 | }); | |
95 |
|
87 | |||
96 |
|
|
88 | text_cell.trigger("focusout"); | |
97 | }; |
|
89 | }; | |
98 |
|
90 | |||
99 |
|
91 | |||
100 |
|
|
92 | TextCell.prototype.get_source = function() { | |
101 | return this.code_mirror.getValue(); |
|
93 | return this.code_mirror.getValue(); | |
102 | }; |
|
94 | }; | |
103 |
|
95 | |||
104 |
|
96 | |||
105 |
|
|
97 | TextCell.prototype.set_source = function(text) { | |
106 | this.code_mirror.setValue(text); |
|
98 | this.code_mirror.setValue(text); | |
107 | this.code_mirror.refresh(); |
|
99 | this.code_mirror.refresh(); | |
108 | }; |
|
100 | }; | |
109 |
|
101 | |||
110 |
|
102 | |||
111 |
|
|
103 | TextCell.prototype.get_rendered = function(text) { | |
112 |
this.element.find('div. |
|
104 | return this.element.find('div.text_cell_render').html(); | |
113 | }; |
|
105 | }; | |
114 |
|
106 | |||
115 |
|
107 | |||
116 |
|
|
108 | TextCell.prototype.set_rendered = function(text) { | |
|
109 | this.element.find('div.text_cell_render').html(text); | |||
|
110 | }; | |||
|
111 | ||||
|
112 | ||||
|
113 | TextCell.prototype.at_top = function () { | |||
117 | if (this.rendered) { |
|
114 | if (this.rendered) { | |
118 | return true; |
|
115 | return true; | |
119 | } else { |
|
116 | } else { | |
120 | return false; |
|
117 | return false; | |
121 | } |
|
118 | } | |
122 | }; |
|
119 | }; | |
123 |
|
120 | |||
124 |
|
121 | |||
125 |
|
|
122 | TextCell.prototype.at_bottom = function () { | |
126 | if (this.rendered) { |
|
123 | if (this.rendered) { | |
127 | return true; |
|
124 | return true; | |
128 | } else { |
|
125 | } else { | |
129 | return false; |
|
126 | return false; | |
130 | } |
|
127 | } | |
131 | }; |
|
128 | }; | |
132 |
|
129 | |||
133 |
|
130 | |||
134 |
|
|
131 | TextCell.prototype.fromJSON = function (data) { | |
135 |
if (data.cell_type === |
|
132 | if (data.cell_type === this.cell_type) { | |
136 | if (data.source !== undefined) { |
|
133 | if (data.source !== undefined) { | |
137 | this.set_source(data.source); |
|
134 | this.set_source(data.source); | |
138 | this.set_rendered(data.source); |
|
135 | this.set_rendered(data.source); | |
139 | }; |
|
136 | }; | |
140 | }; |
|
137 | }; | |
141 | } |
|
138 | } | |
142 |
|
139 | |||
143 |
|
140 | |||
144 |
|
|
141 | TextCell.prototype.toJSON = function () { | |
145 | var data = {} |
|
142 | var data = {} | |
146 |
data.cell_type = |
|
143 | data.cell_type = this.cell_type; | |
147 | data.source = this.get_source(); |
|
144 | data.source = this.get_source(); | |
|
145 | data.rendered = this.get_rendered(); | |||
148 | return data; |
|
146 | return data; | |
149 | }; |
|
147 | }; | |
150 |
|
148 | |||
|
149 | ||||
|
150 | // HTMLCell | |||
|
151 | ||||
|
152 | var HTMLCell = function (notebook) { | |||
|
153 | this.placeholder = "Type <strong>HTML</strong> and LaTeX: $\\alpha^2$"; | |||
|
154 | IPython.TextCell.apply(this, arguments); | |||
|
155 | this.cell_type = 'html'; | |||
|
156 | }; | |||
|
157 | ||||
|
158 | ||||
|
159 | HTMLCell.prototype = new TextCell(); | |||
|
160 | ||||
|
161 | ||||
|
162 | HTMLCell.prototype.render = function () { | |||
|
163 | if (this.rendered === false) { | |||
|
164 | var text = this.get_source(); | |||
|
165 | if (text === "") {text = this.placeholder;}; | |||
|
166 | this.set_rendered(text); | |||
|
167 | MathJax.Hub.Queue(["Typeset",MathJax.Hub]); | |||
|
168 | this.element.find('div.text_cell_input').hide(); | |||
|
169 | this.element.find("div.text_cell_render").show(); | |||
|
170 | this.rendered = true; | |||
|
171 | }; | |||
|
172 | }; | |||
|
173 | ||||
|
174 | ||||
|
175 | // MarkdownCell | |||
|
176 | ||||
|
177 | var MarkdownCell = function (notebook) { | |||
|
178 | this.placeholder = "Type *Markdown* and LaTeX: $\\alpha^2$"; | |||
|
179 | IPython.TextCell.apply(this, arguments); | |||
|
180 | this.cell_type = 'markdown'; | |||
|
181 | }; | |||
|
182 | ||||
|
183 | ||||
|
184 | MarkdownCell.prototype = new TextCell(); | |||
|
185 | ||||
|
186 | ||||
|
187 | MarkdownCell.prototype.render = function () { | |||
|
188 | if (this.rendered === false) { | |||
|
189 | var text = this.get_source(); | |||
|
190 | if (text === "") {text = this.placeholder;}; | |||
|
191 | var html = IPython.markdown_converter.makeHtml(text); | |||
|
192 | this.set_rendered(html); | |||
|
193 | MathJax.Hub.Queue(["Typeset",MathJax.Hub]); | |||
|
194 | this.element.find('div.text_cell_input').hide(); | |||
|
195 | this.element.find("div.text_cell_render").show(); | |||
|
196 | this.rendered = true; | |||
|
197 | }; | |||
|
198 | }; | |||
|
199 | ||||
|
200 | ||||
|
201 | // RSTCell | |||
|
202 | ||||
|
203 | var RSTCell = function (notebook) { | |||
|
204 | this.placeholder = "Type *ReStructured Text* and LaTeX: $\\alpha^2$"; | |||
|
205 | IPython.TextCell.apply(this, arguments); | |||
|
206 | this.cell_type = 'rst'; | |||
|
207 | }; | |||
|
208 | ||||
|
209 | ||||
|
210 | RSTCell.prototype = new TextCell(); | |||
|
211 | ||||
|
212 | ||||
|
213 | RSTCell.prototype.render = function () { | |||
|
214 | if (this.rendered === false) { | |||
|
215 | var text = this.get_source(); | |||
|
216 | if (text === "") {text = this.placeholder;}; | |||
|
217 | var settings = { | |||
|
218 | processData : false, | |||
|
219 | cache : false, | |||
|
220 | type : "POST", | |||
|
221 | data : text, | |||
|
222 | headers : {'Content-Type': 'application/x-rst'}, | |||
|
223 | success : $.proxy(this.handle_render,this) | |||
|
224 | }; | |||
|
225 | $.ajax("/rstservice/render", settings); | |||
|
226 | this.element.find('div.text_cell_input').hide(); | |||
|
227 | this.element.find("div.text_cell_render").show(); | |||
|
228 | this.set_rendered("Rendering..."); | |||
|
229 | }; | |||
|
230 | }; | |||
|
231 | ||||
|
232 | ||||
|
233 | RSTCell.prototype.handle_render = function (data, status, xhr) { | |||
|
234 | this.set_rendered(data); | |||
|
235 | MathJax.Hub.Queue(["Typeset",MathJax.Hub]); | |||
|
236 | this.rendered = true; | |||
|
237 | }; | |||
|
238 | ||||
|
239 | ||||
|
240 | IPython.TextCell = TextCell; | |||
151 | IPython.HTMLCell = HTMLCell; |
|
241 | IPython.HTMLCell = HTMLCell; | |
|
242 | IPython.MarkdownCell = MarkdownCell; | |||
|
243 | IPython.RSTCell = RSTCell; | |||
|
244 | ||||
152 |
|
245 | |||
153 | return IPython; |
|
246 | return IPython; | |
154 |
|
247 | |||
155 | }(IPython)); |
|
248 | }(IPython)); | |
156 |
|
249 |
@@ -1,204 +1,209 b'' | |||||
1 | <!DOCTYPE HTML> |
|
1 | <!DOCTYPE HTML> | |
2 | <html> |
|
2 | <html> | |
3 |
|
3 | |||
4 | <head> |
|
4 | <head> | |
5 | <meta charset="utf-8"> |
|
5 | <meta charset="utf-8"> | |
6 |
|
6 | |||
7 | <title>IPython Notebook</title> |
|
7 | <title>IPython Notebook</title> | |
8 |
|
8 | |||
9 | <link rel="stylesheet" href="static/jquery/css/themes/aristo/jquery-wijmo.css" type="text/css" /> |
|
9 | <link rel="stylesheet" href="static/jquery/css/themes/aristo/jquery-wijmo.css" type="text/css" /> | |
10 | <!-- <link rel="stylesheet" href="static/jquery/css/themes/rocket/jquery-wijmo.css" type="text/css" /> --> |
|
10 | <!-- <link rel="stylesheet" href="static/jquery/css/themes/rocket/jquery-wijmo.css" type="text/css" /> --> | |
11 | <!-- <link rel="stylesheet" href="static/jquery/css/themes/smoothness/jquery-ui-1.8.14.custom.css" type="text/css" />--> |
|
11 | <!-- <link rel="stylesheet" href="static/jquery/css/themes/smoothness/jquery-ui-1.8.14.custom.css" type="text/css" />--> | |
12 |
|
12 | |||
13 | <script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML" charset="utf-8"></script> |
|
13 | <script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML" charset="utf-8"></script> | |
14 | <!-- <script type='text/javascript' src='static/mathjax/MathJax.js?config=TeX-AMS_HTML' charset='utf-8'></script> --> |
|
14 | <!-- <script type='text/javascript' src='static/mathjax/MathJax.js?config=TeX-AMS_HTML' charset='utf-8'></script> --> | |
15 | <script type="text/javascript"> |
|
15 | <script type="text/javascript"> | |
16 | if (typeof MathJax == 'undefined') { |
|
16 | if (typeof MathJax == 'undefined') { | |
17 | console.log("Trying to load local copy of MathJax"); |
|
17 | console.log("Trying to load local copy of MathJax"); | |
18 | document.write(unescape("%3Cscript type='text/javascript' src='static/mathjax/MathJax.js%3Fconfig=TeX-AMS_HTML' charset='utf-8'%3E%3C/script%3E")); |
|
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 | </script> |
|
20 | </script> | |
21 |
|
21 | |||
22 | <link rel="stylesheet" href="static/codemirror-2.12/lib/codemirror.css"> |
|
22 | <link rel="stylesheet" href="static/codemirror-2.12/lib/codemirror.css"> | |
23 | <link rel="stylesheet" href="static/codemirror-2.12/mode/rst/rst.css"> |
|
23 | <link rel="stylesheet" href="static/codemirror-2.12/mode/rst/rst.css"> | |
24 | <link rel="stylesheet" href="static/codemirror-2.12/theme/ipython.css"> |
|
24 | <link rel="stylesheet" href="static/codemirror-2.12/theme/ipython.css"> | |
25 | <link rel="stylesheet" href="static/codemirror-2.12/theme/default.css"> |
|
25 | <link rel="stylesheet" href="static/codemirror-2.12/theme/default.css"> | |
26 |
|
26 | |||
27 | <link rel="stylesheet" href="static/css/boilerplate.css" type="text/css" /> |
|
27 | <link rel="stylesheet" href="static/css/boilerplate.css" type="text/css" /> | |
28 | <link rel="stylesheet" href="static/css/layout.css" type="text/css" /> |
|
28 | <link rel="stylesheet" href="static/css/layout.css" type="text/css" /> | |
29 | <link rel="stylesheet" href="static/css/base.css" type="text/css" /> |
|
29 | <link rel="stylesheet" href="static/css/base.css" type="text/css" /> | |
30 | <link rel="stylesheet" href="static/css/notebook.css" type="text/css" /> |
|
30 | <link rel="stylesheet" href="static/css/notebook.css" type="text/css" /> | |
|
31 | <link rel="stylesheet" href="static/css/renderedhtml.css" type="text/css" /> | |||
|
32 | ||||
31 |
|
33 | |||
32 | </head> |
|
34 | </head> | |
33 |
|
35 | |||
34 | <body> |
|
36 | <body> | |
35 |
|
37 | |||
36 | <div id="header"> |
|
38 | <div id="header"> | |
37 | <span id="ipython_notebook"><h1>IPython Notebook</h1></span> |
|
39 | <span id="ipython_notebook"><h1>IPython Notebook</h1></span> | |
38 | <span id="save_widget"> |
|
40 | <span id="save_widget"> | |
39 | <input type="text" id="notebook_name" size="20"></textarea> |
|
41 | <input type="text" id="notebook_name" size="20"></textarea> | |
40 | <span id="notebook_id" style="display:none">{{notebook_id}}</span> |
|
42 | <span id="notebook_id" style="display:none">{{notebook_id}}</span> | |
41 | <button id="save_notebook">Save</button> |
|
43 | <button id="save_notebook">Save</button> | |
42 | </span> |
|
44 | </span> | |
43 | <span id="kernel_status">Idle</span> |
|
45 | <span id="kernel_status">Idle</span> | |
44 | </div> |
|
46 | </div> | |
45 |
|
47 | |||
46 | <div id="main_app"> |
|
48 | <div id="main_app"> | |
47 |
|
49 | |||
48 | <div id="left_panel"> |
|
50 | <div id="left_panel"> | |
49 |
|
51 | |||
50 | <div id="notebook_section"> |
|
52 | <div id="notebook_section"> | |
51 | <h3 class="section_header">Notebook</h3> |
|
53 | <h3 class="section_header">Notebook</h3> | |
52 | <div class="section_content"> |
|
54 | <div class="section_content"> | |
53 | <div class="section_row"> |
|
55 | <div class="section_row"> | |
54 | <span id="new_open" class="section_row_buttons"> |
|
56 | <span id="new_open" class="section_row_buttons"> | |
55 | <button id="new_notebook">New</button> |
|
57 | <button id="new_notebook">New</button> | |
56 | <button id="open_notebook">Open</button> |
|
58 | <button id="open_notebook">Open</button> | |
57 | </span> |
|
59 | </span> | |
58 | <span class="section_row_header">Actions</span> |
|
60 | <span class="section_row_header">Actions</span> | |
59 | </div> |
|
61 | </div> | |
60 | <div class="section_row"> |
|
62 | <div class="section_row"> | |
61 | <span class="section_row_buttons"> |
|
63 | <span class="section_row_buttons"> | |
62 | <button id="download_notebook">Export</button> |
|
64 | <button id="download_notebook">Export</button> | |
63 | </span> |
|
65 | </span> | |
64 | <span> |
|
66 | <span> | |
65 | <select id="download_format"> |
|
67 | <select id="download_format"> | |
66 | <option value="xml">xml</option> |
|
68 | <option value="xml">xml</option> | |
67 | <option value="json">json</option> |
|
69 | <option value="json">json</option> | |
68 | <option value="py">py</option> |
|
70 | <option value="py">py</option> | |
69 | </select> |
|
71 | </select> | |
70 | </span> |
|
72 | </span> | |
71 | </div> |
|
73 | </div> | |
72 | </div> |
|
74 | </div> | |
73 | </div> |
|
75 | </div> | |
74 |
|
76 | |||
75 | <div id="cell_section"> |
|
77 | <div id="cell_section"> | |
76 | <h3 class="section_header">Cell</h3> |
|
78 | <h3 class="section_header">Cell</h3> | |
77 | <div class="section_content"> |
|
79 | <div class="section_content"> | |
78 | <div class="section_row"> |
|
80 | <div class="section_row"> | |
79 | <span class="section_row_buttons"> |
|
81 | <span class="section_row_buttons"> | |
80 | <button id="delete_cell">Delete</button> |
|
82 | <button id="delete_cell">Delete</button> | |
81 | </span> |
|
83 | </span> | |
82 | <span class="section_row_header">Actions</span> |
|
84 | <span class="section_row_header">Actions</span> | |
83 | </div> |
|
85 | </div> | |
84 | <div class="section_row"> |
|
86 | <div class="section_row"> | |
|
87 | <span id="cell_type" class="section_row_buttons"> | |||
|
88 | <button id="to_code">Code</button> | |||
|
89 | <button id="to_html">HTML</button> | |||
|
90 | <button id="to_markdown">Markdown</button> | |||
|
91 | </span> | |||
|
92 | <!-- <span class="button_label">Format</span> --> | |||
|
93 | </div> | |||
|
94 | <div class="section_row"> | |||
85 | <span id="insert" class="section_row_buttons"> |
|
95 | <span id="insert" class="section_row_buttons"> | |
86 | <button id="insert_cell_above">Above</button> |
|
96 | <button id="insert_cell_above">Above</button> | |
87 | <button id="insert_cell_below">Below</button> |
|
97 | <button id="insert_cell_below">Below</button> | |
88 | </span> |
|
98 | </span> | |
89 | <span class="button_label">Insert</span> |
|
99 | <span class="button_label">Insert</span> | |
90 | </div> |
|
100 | </div> | |
91 | <div class="section_row"> |
|
101 | <div class="section_row"> | |
92 | <span id="move" class="section_row_buttons"> |
|
102 | <span id="move" class="section_row_buttons"> | |
93 | <button id="move_cell_up">Up</button> |
|
103 | <button id="move_cell_up">Up</button> | |
94 | <button id="move_cell_down">Down</button> |
|
104 | <button id="move_cell_down">Down</button> | |
95 | </span> |
|
105 | </span> | |
96 | <span class="button_label">Move</span> |
|
106 | <span class="button_label">Move</span> | |
97 | </div> |
|
107 | </div> | |
98 | <div class="section_row"> |
|
108 | <div class="section_row"> | |
99 | <span id="cell_type" class="section_row_buttons"> |
|
|||
100 | <button id="to_code">Code</button> |
|
|||
101 | <button id="to_html">HTML</button> |
|
|||
102 | <button id="to_rst">RST</button> |
|
|||
103 | </span> |
|
|||
104 | <span class="button_label">Format</span> |
|
|||
105 | </div> |
|
|||
106 | <div class="section_row"> |
|
|||
107 | <span id="toggle_output" class="section_row_buttons"> |
|
109 | <span id="toggle_output" class="section_row_buttons"> | |
108 | <button id="collapse_cell">Collapse</button> |
|
110 | <button id="collapse_cell">Collapse</button> | |
109 | <button id="expand_cell">Expand</button> |
|
111 | <button id="expand_cell">Expand</button> | |
110 | </span> |
|
112 | </span> | |
111 | <span class="button_label">Output</span> |
|
113 | <span class="button_label">Output</span> | |
112 | </div> |
|
114 | </div> | |
113 | <div class="section_row"> |
|
115 | <div class="section_row"> | |
114 | <span id="run_cells" class="section_row_buttons"> |
|
116 | <span id="run_cells" class="section_row_buttons"> | |
115 | <button id="run_selected_cell">Selected</button> |
|
117 | <button id="run_selected_cell">Selected</button> | |
116 | <button id="run_all_cells">All</button> |
|
118 | <button id="run_all_cells">All</button> | |
117 | </span> |
|
119 | </span> | |
118 | <span class="button_label">Run</span> |
|
120 | <span class="button_label">Run</span> | |
119 | </div> |
|
121 | </div> | |
120 | </div> |
|
122 | </div> | |
121 | </div> |
|
123 | </div> | |
122 |
|
124 | |||
123 | <div id="kernel_section"> |
|
125 | <div id="kernel_section"> | |
124 | <h3 class="section_header">Kernel</h3> |
|
126 | <h3 class="section_header">Kernel</h3> | |
125 | <div class="section_content"> |
|
127 | <div class="section_content"> | |
126 | <div class="section_row"> |
|
128 | <div class="section_row"> | |
127 | <span id="int_restart" class="section_row_buttons"> |
|
129 | <span id="int_restart" class="section_row_buttons"> | |
128 | <button id="int_kernel">Interrupt</button> |
|
130 | <button id="int_kernel">Interrupt</button> | |
129 | <button id="restart_kernel">Restart</button> |
|
131 | <button id="restart_kernel">Restart</button> | |
130 | </span> |
|
132 | </span> | |
131 | <span class="section_row_header">Actions</span> |
|
133 | <span class="section_row_header">Actions</span> | |
132 | </div> |
|
134 | </div> | |
133 | <div class="section_row"> |
|
135 | <div class="section_row"> | |
134 | <span id="kernel_persist"> |
|
136 | <span id="kernel_persist"> | |
135 | <input type="checkbox" id="kill_kernel"></input> |
|
137 | <input type="checkbox" id="kill_kernel"></input> | |
136 | </span> |
|
138 | </span> | |
137 | <span class="checkbox_label">Kill kernel upon exit:</span> |
|
139 | <span class="checkbox_label">Kill kernel upon exit:</span> | |
138 | </div> |
|
140 | </div> | |
139 | </div> |
|
141 | </div> | |
140 | </div> |
|
142 | </div> | |
141 |
|
143 | |||
142 | <div id="help_section"> |
|
144 | <div id="help_section"> | |
143 | <h3 class="section_header">Help</h3> |
|
145 | <h3 class="section_header">Help</h3> | |
144 | <div class="section_content"> |
|
146 | <div class="section_content"> | |
145 | <div class="section_row"> |
|
147 | <div class="section_row"> | |
146 | <span id="help_buttons0" class="section_row_buttons"> |
|
148 | <span id="help_buttons0" class="section_row_buttons"> | |
147 | <button id="python_help"><a href="http://docs.python.org" target="_blank">Python</a></button> |
|
149 | <button id="python_help"><a href="http://docs.python.org" target="_blank">Python</a></button> | |
148 | <button id="ipython_help"><a href="http://ipython.org/documentation.html" target="_blank">IPython</a></button> |
|
150 | <button id="ipython_help"><a href="http://ipython.org/documentation.html" target="_blank">IPython</a></button> | |
149 | <button id="numpy_help"><a href="http://docs.scipy.org/doc/numpy/reference/" target="_blank">NumPy</a></button> |
|
151 | <button id="numpy_help"><a href="http://docs.scipy.org/doc/numpy/reference/" target="_blank">NumPy</a></button> | |
150 | </span> |
|
152 | </span> | |
151 | <span class="section_row_header">Links</span> |
|
153 | <span class="section_row_header">Links</span> | |
152 | </div> |
|
154 | </div> | |
153 | <div class="section_row"> |
|
155 | <div class="section_row"> | |
154 | <span id="help_buttons1" class="section_row_buttons"> |
|
156 | <span id="help_buttons1" class="section_row_buttons"> | |
155 | <button id="matplotlib_help"><a href="http://matplotlib.sourceforge.net/" target="_blank">MPL</a></button> |
|
157 | <button id="matplotlib_help"><a href="http://matplotlib.sourceforge.net/" target="_blank">MPL</a></button> | |
156 | <button id="scipy_help"><a href="http://docs.scipy.org/doc/scipy/reference/" target="_blank">SciPy</a></button> |
|
158 | <button id="scipy_help"><a href="http://docs.scipy.org/doc/scipy/reference/" target="_blank">SciPy</a></button> | |
157 | <button id="sympy_help"><a href="http://docs.sympy.org/dev/index.html" target="_blank">SymPy</a></button> |
|
159 | <button id="sympy_help"><a href="http://docs.sympy.org/dev/index.html" target="_blank">SymPy</a></button> | |
158 | </span> |
|
160 | </span> | |
159 | </div> |
|
161 | </div> | |
160 | </div> |
|
162 | </div> | |
161 | </div> |
|
163 | </div> | |
162 |
|
164 | |||
163 | </div> |
|
165 | </div> | |
164 | <div id="left_panel_splitter"></div> |
|
166 | <div id="left_panel_splitter"></div> | |
165 | <div id="notebook_panel"> |
|
167 | <div id="notebook_panel"> | |
166 | <div id="notebook"></div> |
|
168 | <div id="notebook"></div> | |
167 | <div id="pager_splitter"></div> |
|
169 | <div id="pager_splitter"></div> | |
168 | <div id="pager"></div> |
|
170 | <div id="pager"></div> | |
169 | </div> |
|
171 | </div> | |
170 |
|
172 | |||
171 | </div> |
|
173 | </div> | |
172 |
|
174 | |||
173 | <script src="static/jquery/js/jquery-1.6.2.min.js" type="text/javascript" charset="utf-8"></script> |
|
175 | <script src="static/jquery/js/jquery-1.6.2.min.js" type="text/javascript" charset="utf-8"></script> | |
174 | <script src="static/jquery/js/jquery-ui-1.8.14.custom.min.js" type="text/javascript" charset="utf-8"></script> |
|
176 | <script src="static/jquery/js/jquery-ui-1.8.14.custom.min.js" type="text/javascript" charset="utf-8"></script> | |
175 | <script src="static/jquery/js/jquery.autogrow.js" type="text/javascript" charset="utf-8"></script> |
|
177 | <script src="static/jquery/js/jquery.autogrow.js" type="text/javascript" charset="utf-8"></script> | |
|
178 | ||||
|
179 | <script src="static/codemirror-2.12/lib/codemirror.js" charset="utf-8"></script> | |||
|
180 | <script src="static/codemirror-2.12/mode/python/python.js" charset="utf-8"></script> | |||
|
181 | <script src="static/codemirror-2.12/mode/htmlmixed/htmlmixed.js" charset="utf-8"></script> | |||
|
182 | <script src="static/codemirror-2.12/mode/xml/xml.js" charset="utf-8"></script> | |||
|
183 | <script src="static/codemirror-2.12/mode/javascript/javascript.js" charset="utf-8"></script> | |||
|
184 | <script src="static/codemirror-2.12/mode/css/css.js" charset="utf-8"></script> | |||
|
185 | <script src="static/codemirror-2.12/mode/rst/rst.js" charset="utf-8"></script> | |||
|
186 | ||||
|
187 | <script src="static/pagedown/Markdown.Converter.js" charset="utf-8"></script> | |||
|
188 | ||||
176 | <script src="static/js/namespace.js" type="text/javascript" charset="utf-8"></script> |
|
189 | <script src="static/js/namespace.js" type="text/javascript" charset="utf-8"></script> | |
177 | <script src="static/js/utils.js" type="text/javascript" charset="utf-8"></script> |
|
190 | <script src="static/js/utils.js" type="text/javascript" charset="utf-8"></script> | |
178 | <script src="static/js/cell.js" type="text/javascript" charset="utf-8"></script> |
|
191 | <script src="static/js/cell.js" type="text/javascript" charset="utf-8"></script> | |
179 | <script src="static/js/codecell.js" type="text/javascript" charset="utf-8"></script> |
|
192 | <script src="static/js/codecell.js" type="text/javascript" charset="utf-8"></script> | |
180 |
<script src="static/js/ |
|
193 | <script src="static/js/textcell.js" type="text/javascript" charset="utf-8"></script> | |
181 | <script src="static/js/rstcell.js" type="text/javascript" charset="utf-8"></script> |
|
|||
182 | <script src="static/js/kernel.js" type="text/javascript" charset="utf-8"></script> |
|
194 | <script src="static/js/kernel.js" type="text/javascript" charset="utf-8"></script> | |
183 | <script src="static/js/kernelstatus.js" type="text/javascript" charset="utf-8"></script> |
|
195 | <script src="static/js/kernelstatus.js" type="text/javascript" charset="utf-8"></script> | |
184 | <script src="static/js/layout.js" type="text/javascript" charset="utf-8"></script> |
|
196 | <script src="static/js/layout.js" type="text/javascript" charset="utf-8"></script> | |
185 | <script src="static/js/savewidget.js" type="text/javascript" charset="utf-8"></script> |
|
197 | <script src="static/js/savewidget.js" type="text/javascript" charset="utf-8"></script> | |
186 | <script src="static/js/pager.js" type="text/javascript" charset="utf-8"></script> |
|
198 | <script src="static/js/pager.js" type="text/javascript" charset="utf-8"></script> | |
187 | <script src="static/js/panelsection.js" type="text/javascript" charset="utf-8"></script> |
|
199 | <script src="static/js/panelsection.js" type="text/javascript" charset="utf-8"></script> | |
188 | <script src="static/js/leftpanel.js" type="text/javascript" charset="utf-8"></script> |
|
200 | <script src="static/js/leftpanel.js" type="text/javascript" charset="utf-8"></script> | |
189 | <script src="static/js/notebook.js" type="text/javascript" charset="utf-8"></script> |
|
201 | <script src="static/js/notebook.js" type="text/javascript" charset="utf-8"></script> | |
190 | <script src="static/js/notebook_main.js" type="text/javascript" charset="utf-8"></script> |
|
202 | <script src="static/js/notebook_main.js" type="text/javascript" charset="utf-8"></script> | |
191 | <script src="static/codemirror-2.12/lib/codemirror.js" charset="utf-8"></script> |
|
203 | ||
192 | <script src="static/codemirror-2.12/mode/python/python.js" charset="utf-8"></script> |
|
|||
193 | <script src="static/codemirror-2.12/mode/htmlmixed/htmlmixed.js" charset="utf-8"></script> |
|
|||
194 | <script src="static/codemirror-2.12/mode/xml/xml.js" charset="utf-8"></script> |
|
|||
195 | <script src="static/codemirror-2.12/mode/javascript/javascript.js" charset="utf-8"></script> |
|
|||
196 | <script src="static/codemirror-2.12/mode/css/css.js" charset="utf-8"></script> |
|
|||
197 | <script src="static/codemirror-2.12/mode/rst/rst.js" charset="utf-8"></script> |
|
|||
198 | <script src="static/pagedown/Markdown.Converter.js" charset="utf-8"></script> |
|
|||
199 |
|
204 | |||
200 | </body> |
|
205 | </body> | |
201 |
|
206 | |||
202 | </html> |
|
207 | </html> | |
203 |
|
208 | |||
204 |
|
209 |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
General Comments 0
You need to be logged in to leave comments.
Login now