Show More
@@ -13,6 +13,7 var IPython = (function (IPython) { | |||||
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.dirty = false; | |||
16 | this.msg_cell_map = {}; |
|
17 | this.msg_cell_map = {}; | |
17 | this.style(); |
|
18 | this.style(); | |
18 | this.create_elements(); |
|
19 | this.create_elements(); | |
@@ -89,12 +90,12 var IPython = (function (IPython) { | |||||
89 | }); |
|
90 | }); | |
90 |
|
91 | |||
91 | $(window).bind('beforeunload', function () { |
|
92 | $(window).bind('beforeunload', function () { | |
92 | var kill_kernel = $('#kill_kernel').prop('checked'); |
|
93 | var kill_kernel = $('#kill_kernel').prop('checked'); | |
93 | if (kill_kernel) { |
|
94 | if (kill_kernel) { | |
94 | that.kernel.kill(); |
|
95 | that.kernel.kill(); | |
95 | return "You are about to exit this notebook and kill the kernel."; |
|
96 | } | |
96 |
|
|
97 | if (that.dirty) { | |
97 | return "You are about the exit this notebook and leave the kernel running."; |
|
98 | return "You have unsaved changes that will be lost if you leave this page."; | |
98 | }; |
|
99 | }; | |
99 | }); |
|
100 | }); | |
100 | }; |
|
101 | }; | |
@@ -222,12 +223,14 var IPython = (function (IPython) { | |||||
222 | this.select(i); |
|
223 | this.select(i); | |
223 | }; |
|
224 | }; | |
224 | }; |
|
225 | }; | |
|
226 | this.dirty = true; | |||
225 | return this; |
|
227 | return this; | |
226 | }; |
|
228 | }; | |
227 |
|
229 | |||
228 |
|
230 | |||
229 | Notebook.prototype.append_cell = function (cell) { |
|
231 | Notebook.prototype.append_cell = function (cell) { | |
230 | this.element.find('div.end_space').before(cell.element); |
|
232 | this.element.find('div.end_space').before(cell.element); | |
|
233 | this.dirty = true; | |||
231 | return this; |
|
234 | return this; | |
232 | }; |
|
235 | }; | |
233 |
|
236 | |||
@@ -241,6 +244,7 var IPython = (function (IPython) { | |||||
241 | if (index >= 0 && index < ncells) { |
|
244 | if (index >= 0 && index < ncells) { | |
242 | this.cell_elements().eq(index).after(cell.element); |
|
245 | this.cell_elements().eq(index).after(cell.element); | |
243 | }; |
|
246 | }; | |
|
247 | this.dirty = true; | |||
244 | return this |
|
248 | return this | |
245 | }; |
|
249 | }; | |
246 |
|
250 | |||
@@ -254,6 +258,7 var IPython = (function (IPython) { | |||||
254 | if (index >= 0 && index < ncells) { |
|
258 | if (index >= 0 && index < ncells) { | |
255 | this.cell_elements().eq(index).before(cell.element); |
|
259 | this.cell_elements().eq(index).before(cell.element); | |
256 | }; |
|
260 | }; | |
|
261 | this.dirty = true; | |||
257 | return this; |
|
262 | return this; | |
258 | }; |
|
263 | }; | |
259 |
|
264 | |||
@@ -269,6 +274,7 var IPython = (function (IPython) { | |||||
269 | this.select(i-1); |
|
274 | this.select(i-1); | |
270 | }; |
|
275 | }; | |
271 | }; |
|
276 | }; | |
|
277 | this.dirty = true; | |||
272 | return this; |
|
278 | return this; | |
273 | } |
|
279 | } | |
274 |
|
280 | |||
@@ -284,6 +290,7 var IPython = (function (IPython) { | |||||
284 | this.select(i+1); |
|
290 | this.select(i+1); | |
285 | }; |
|
291 | }; | |
286 | }; |
|
292 | }; | |
|
293 | this.dirty = true; | |||
287 | return this; |
|
294 | return this; | |
288 | } |
|
295 | } | |
289 |
|
296 | |||
@@ -386,6 +393,7 var IPython = (function (IPython) { | |||||
386 | target_cell.set_code(source_cell.get_source()); |
|
393 | target_cell.set_code(source_cell.get_source()); | |
387 | source_element.remove(); |
|
394 | source_element.remove(); | |
388 | }; |
|
395 | }; | |
|
396 | this.dirty = true; | |||
389 | }; |
|
397 | }; | |
390 |
|
398 | |||
391 |
|
399 | |||
@@ -413,6 +421,7 var IPython = (function (IPython) { | |||||
413 | source_element.remove(); |
|
421 | source_element.remove(); | |
414 | target_cell.edit(); |
|
422 | target_cell.edit(); | |
415 | } |
|
423 | } | |
|
424 | this.dirty = true; | |||
416 | }; |
|
425 | }; | |
417 |
|
426 | |||
418 |
|
427 | |||
@@ -440,6 +449,7 var IPython = (function (IPython) { | |||||
440 | source_element.remove(); |
|
449 | source_element.remove(); | |
441 | target_cell.edit(); |
|
450 | target_cell.edit(); | |
442 | } |
|
451 | } | |
|
452 | this.dirty = true; | |||
443 | }; |
|
453 | }; | |
444 |
|
454 | |||
445 |
|
455 | |||
@@ -448,12 +458,14 var IPython = (function (IPython) { | |||||
448 | Notebook.prototype.collapse = function (index) { |
|
458 | Notebook.prototype.collapse = function (index) { | |
449 | var i = this.index_or_selected(index); |
|
459 | var i = this.index_or_selected(index); | |
450 | this.cells()[i].collapse(); |
|
460 | this.cells()[i].collapse(); | |
|
461 | this.dirty = true; | |||
451 | }; |
|
462 | }; | |
452 |
|
463 | |||
453 |
|
464 | |||
454 | Notebook.prototype.expand = function (index) { |
|
465 | Notebook.prototype.expand = function (index) { | |
455 | var i = this.index_or_selected(index); |
|
466 | var i = this.index_or_selected(index); | |
456 | this.cells()[i].expand(); |
|
467 | this.cells()[i].expand(); | |
|
468 | this.dirty = true; | |||
457 | }; |
|
469 | }; | |
458 |
|
470 | |||
459 |
|
471 | |||
@@ -474,6 +486,7 var IPython = (function (IPython) { | |||||
474 | cells[i].clear_output(); |
|
486 | cells[i].clear_output(); | |
475 | } |
|
487 | } | |
476 | }; |
|
488 | }; | |
|
489 | this.dirty = true; | |||
477 | }; |
|
490 | }; | |
478 |
|
491 | |||
479 |
|
492 | |||
@@ -508,6 +521,7 var IPython = (function (IPython) { | |||||
508 | var cell = this.cell_for_msg(reply.parent_header.msg_id); |
|
521 | var cell = this.cell_for_msg(reply.parent_header.msg_id); | |
509 | if (msg_type === "execute_reply") { |
|
522 | if (msg_type === "execute_reply") { | |
510 | cell.set_input_prompt(content.execution_count); |
|
523 | cell.set_input_prompt(content.execution_count); | |
|
524 | this.dirty = true; | |||
511 | } else if (msg_type === "complete_reply") { |
|
525 | } else if (msg_type === "complete_reply") { | |
512 | cell.finish_completing(content.matched_text, content.matches); |
|
526 | cell.finish_completing(content.matched_text, content.matches); | |
513 | }; |
|
527 | }; | |
@@ -527,6 +541,7 var IPython = (function (IPython) { | |||||
527 | var index = this.find_cell_index(cell); |
|
541 | var index = this.find_cell_index(cell); | |
528 | var new_cell = this.insert_code_cell_after(index); |
|
542 | var new_cell = this.insert_code_cell_after(index); | |
529 | new_cell.set_code(payload[i].text); |
|
543 | new_cell.set_code(payload[i].text); | |
|
544 | this.dirty = true; | |||
530 | } |
|
545 | } | |
531 | }; |
|
546 | }; | |
532 | }; |
|
547 | }; | |
@@ -596,6 +611,7 var IPython = (function (IPython) { | |||||
596 | json.traceback = traceback; |
|
611 | json.traceback = traceback; | |
597 | }; |
|
612 | }; | |
598 | cell.append_output(json); |
|
613 | cell.append_output(json); | |
|
614 | this.dirty = true; | |||
599 | }; |
|
615 | }; | |
600 |
|
616 | |||
601 |
|
617 | |||
@@ -655,6 +671,7 var IPython = (function (IPython) { | |||||
655 | that.select(cell_index+1); |
|
671 | that.select(cell_index+1); | |
656 | }; |
|
672 | }; | |
657 | }; |
|
673 | }; | |
|
674 | this.dirty = true; | |||
658 | }; |
|
675 | }; | |
659 |
|
676 | |||
660 |
|
677 | |||
@@ -745,6 +762,7 var IPython = (function (IPython) { | |||||
745 |
|
762 | |||
746 |
|
763 | |||
747 | Notebook.prototype.notebook_saved = function (data, status, xhr) { |
|
764 | Notebook.prototype.notebook_saved = function (data, status, xhr) { | |
|
765 | this.dirty = false; | |||
748 | setTimeout($.proxy(IPython.save_widget.status_save,IPython.save_widget),500); |
|
766 | setTimeout($.proxy(IPython.save_widget.status_save,IPython.save_widget),500); | |
749 | } |
|
767 | } | |
750 |
|
768 | |||
@@ -778,6 +796,7 var IPython = (function (IPython) { | |||||
778 | IPython.save_widget.status_save(); |
|
796 | IPython.save_widget.status_save(); | |
779 | IPython.save_widget.set_notebook_name(data.name); |
|
797 | IPython.save_widget.set_notebook_name(data.name); | |
780 | this.start_kernel(); |
|
798 | this.start_kernel(); | |
|
799 | this.dirty = false; | |||
781 | // fromJSON always selects the last cell inserted. We need to wait |
|
800 | // fromJSON always selects the last cell inserted. We need to wait | |
782 | // until that is done before scrolling to the top. |
|
801 | // until that is done before scrolling to the top. | |
783 | setTimeout(function () { |
|
802 | setTimeout(function () { |
General Comments 0
You need to be logged in to leave comments.
Login now