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