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