Show More
@@ -145,7 +145,7 b' var IPython = (function (IPython) {' | |||||
145 | }; |
|
145 | }; | |
146 |
|
146 | |||
147 | this.element.bind('collapse_pager', function (event, extrap) { |
|
147 | this.element.bind('collapse_pager', function (event, extrap) { | |
148 | var time = (extrap != undefined) ? ((extrap.duration != undefined ) ? extrap.duration : 'fast') : 'fast'; |
|
148 | var time = (extrap !== undefined) ? ((extrap.duration !== undefined ) ? extrap.duration : 'fast') : 'fast'; | |
149 | collapse_time(time); |
|
149 | collapse_time(time); | |
150 | }); |
|
150 | }); | |
151 |
|
151 | |||
@@ -158,7 +158,7 b' var IPython = (function (IPython) {' | |||||
158 | }; |
|
158 | }; | |
159 |
|
159 | |||
160 | this.element.bind('expand_pager', function (event, extrap) { |
|
160 | this.element.bind('expand_pager', function (event, extrap) { | |
161 | var time = (extrap != undefined) ? ((extrap.duration != undefined ) ? extrap.duration : 'fast') : 'fast'; |
|
161 | var time = (extrap !== undefined) ? ((extrap.duration !== undefined ) ? extrap.duration : 'fast') : 'fast'; | |
162 | expand_time(time); |
|
162 | expand_time(time); | |
163 | }); |
|
163 | }); | |
164 |
|
164 | |||
@@ -187,7 +187,7 b' var IPython = (function (IPython) {' | |||||
187 | } else { |
|
187 | } else { | |
188 | return "Unsaved changes will be lost."; |
|
188 | return "Unsaved changes will be lost."; | |
189 | } |
|
189 | } | |
190 |
} |
|
190 | } | |
191 | // Null is the *only* return value that will make the browser not |
|
191 | // Null is the *only* return value that will make the browser not | |
192 | // pop up the "don't leave" dialog. |
|
192 | // pop up the "don't leave" dialog. | |
193 | return null; |
|
193 | return null; | |
@@ -219,7 +219,7 b' var IPython = (function (IPython) {' | |||||
219 | */ |
|
219 | */ | |
220 | Notebook.prototype.scroll_to_cell = function (cell_number, time) { |
|
220 | Notebook.prototype.scroll_to_cell = function (cell_number, time) { | |
221 | var cells = this.get_cells(); |
|
221 | var cells = this.get_cells(); | |
222 |
|
|
222 | time = time || 0; | |
223 | cell_number = Math.min(cells.length-1,cell_number); |
|
223 | cell_number = Math.min(cells.length-1,cell_number); | |
224 | cell_number = Math.max(0 ,cell_number); |
|
224 | cell_number = Math.max(0 ,cell_number); | |
225 | var scroll_value = cells[cell_number].element.position().top-cells[0].element.position().top ; |
|
225 | var scroll_value = cells[cell_number].element.position().top-cells[0].element.position().top ; | |
@@ -331,7 +331,7 b' var IPython = (function (IPython) {' | |||||
331 | result = ce.data('cell'); |
|
331 | result = ce.data('cell'); | |
332 | } |
|
332 | } | |
333 | return result; |
|
333 | return result; | |
334 | } |
|
334 | }; | |
335 |
|
335 | |||
336 | /** |
|
336 | /** | |
337 | * Get the cell below a given cell. |
|
337 | * Get the cell below a given cell. | |
@@ -347,7 +347,7 b' var IPython = (function (IPython) {' | |||||
347 | result = this.get_cell(index+1); |
|
347 | result = this.get_cell(index+1); | |
348 | } |
|
348 | } | |
349 | return result; |
|
349 | return result; | |
350 | } |
|
350 | }; | |
351 |
|
351 | |||
352 | /** |
|
352 | /** | |
353 | * Get the cell above a given cell. |
|
353 | * Get the cell above a given cell. | |
@@ -365,7 +365,7 b' var IPython = (function (IPython) {' | |||||
365 | result = this.get_cell(index-1); |
|
365 | result = this.get_cell(index-1); | |
366 | } |
|
366 | } | |
367 | return result; |
|
367 | return result; | |
368 | } |
|
368 | }; | |
369 |
|
369 | |||
370 | /** |
|
370 | /** | |
371 | * Get the numeric index of a given cell. |
|
371 | * Get the numeric index of a given cell. | |
@@ -379,7 +379,7 b' var IPython = (function (IPython) {' | |||||
379 | this.get_cell_elements().filter(function (index) { |
|
379 | this.get_cell_elements().filter(function (index) { | |
380 | if ($(this).data("cell") === cell) { |
|
380 | if ($(this).data("cell") === cell) { | |
381 | result = index; |
|
381 | result = index; | |
382 |
} |
|
382 | } | |
383 | }); |
|
383 | }); | |
384 | return result; |
|
384 | return result; | |
385 | }; |
|
385 | }; | |
@@ -426,8 +426,8 b' var IPython = (function (IPython) {' | |||||
426 | return true; |
|
426 | return true; | |
427 | } else { |
|
427 | } else { | |
428 | return false; |
|
428 | return false; | |
429 |
} |
|
429 | } | |
430 | } |
|
430 | }; | |
431 |
|
431 | |||
432 | /** |
|
432 | /** | |
433 | * Get the index of the currently selected cell. |
|
433 | * Get the index of the currently selected cell. | |
@@ -440,7 +440,7 b' var IPython = (function (IPython) {' | |||||
440 | this.get_cell_elements().filter(function (index) { |
|
440 | this.get_cell_elements().filter(function (index) { | |
441 | if ($(this).data("cell").selected === true) { |
|
441 | if ($(this).data("cell").selected === true) { | |
442 | result = index; |
|
442 | result = index; | |
443 |
} |
|
443 | } | |
444 | }); |
|
444 | }); | |
445 | return result; |
|
445 | return result; | |
446 | }; |
|
446 | }; | |
@@ -457,11 +457,11 b' var IPython = (function (IPython) {' | |||||
457 | */ |
|
457 | */ | |
458 | Notebook.prototype.select = function (index) { |
|
458 | Notebook.prototype.select = function (index) { | |
459 | if (this.is_valid_cell_index(index)) { |
|
459 | if (this.is_valid_cell_index(index)) { | |
460 | var sindex = this.get_selected_index() |
|
460 | var sindex = this.get_selected_index(); | |
461 | if (sindex !== null && index !== sindex) { |
|
461 | if (sindex !== null && index !== sindex) { | |
462 | this.command_mode(); |
|
462 | this.command_mode(); | |
463 | this.get_cell(sindex).unselect(); |
|
463 | this.get_cell(sindex).unselect(); | |
464 |
} |
|
464 | } | |
465 | var cell = this.get_cell(index); |
|
465 | var cell = this.get_cell(index); | |
466 | cell.select(); |
|
466 | cell.select(); | |
467 | if (cell.cell_type === 'heading') { |
|
467 | if (cell.cell_type === 'heading') { | |
@@ -472,8 +472,8 b' var IPython = (function (IPython) {' | |||||
472 | $([IPython.events]).trigger('selected_cell_type_changed.Notebook', |
|
472 | $([IPython.events]).trigger('selected_cell_type_changed.Notebook', | |
473 | {'cell_type':cell.cell_type} |
|
473 | {'cell_type':cell.cell_type} | |
474 | ); |
|
474 | ); | |
475 |
} |
|
475 | } | |
476 |
} |
|
476 | } | |
477 | return this; |
|
477 | return this; | |
478 | }; |
|
478 | }; | |
479 |
|
479 | |||
@@ -509,7 +509,7 b' var IPython = (function (IPython) {' | |||||
509 | this.get_cell_elements().filter(function (index) { |
|
509 | this.get_cell_elements().filter(function (index) { | |
510 | if ($(this).data("cell").mode === 'edit') { |
|
510 | if ($(this).data("cell").mode === 'edit') { | |
511 | result = index; |
|
511 | result = index; | |
512 |
} |
|
512 | } | |
513 | }); |
|
513 | }); | |
514 | return result; |
|
514 | return result; | |
515 | }; |
|
515 | }; | |
@@ -521,10 +521,10 b' var IPython = (function (IPython) {' | |||||
521 | var cell = this.get_cell(index); |
|
521 | var cell = this.get_cell(index); | |
522 | if (cell) { |
|
522 | if (cell) { | |
523 | cell.command_mode(); |
|
523 | cell.command_mode(); | |
524 |
} |
|
524 | } | |
525 | this.mode = 'command'; |
|
525 | this.mode = 'command'; | |
526 | IPython.keyboard_manager.command_mode(); |
|
526 | IPython.keyboard_manager.command_mode(); | |
527 |
} |
|
527 | } | |
528 | }; |
|
528 | }; | |
529 |
|
529 | |||
530 | Notebook.prototype.edit_mode = function () { |
|
530 | Notebook.prototype.edit_mode = function () { | |
@@ -537,7 +537,7 b' var IPython = (function (IPython) {' | |||||
537 | this.mode = 'edit'; |
|
537 | this.mode = 'edit'; | |
538 | IPython.keyboard_manager.edit_mode(); |
|
538 | IPython.keyboard_manager.edit_mode(); | |
539 | cell.edit_mode(); |
|
539 | cell.edit_mode(); | |
540 |
} |
|
540 | } | |
541 | }; |
|
541 | }; | |
542 |
|
542 | |||
543 | Notebook.prototype.focus_cell = function () { |
|
543 | Notebook.prototype.focus_cell = function () { | |
@@ -566,9 +566,9 b' var IPython = (function (IPython) {' | |||||
566 | this.select(i-1); |
|
566 | this.select(i-1); | |
567 | var cell = this.get_selected_cell(); |
|
567 | var cell = this.get_selected_cell(); | |
568 | cell.focus_cell(); |
|
568 | cell.focus_cell(); | |
569 |
} |
|
569 | } | |
570 | this.set_dirty(true); |
|
570 | this.set_dirty(true); | |
571 |
} |
|
571 | } | |
572 | return this; |
|
572 | return this; | |
573 | }; |
|
573 | }; | |
574 |
|
574 | |||
@@ -591,8 +591,8 b' var IPython = (function (IPython) {' | |||||
591 | this.select(i+1); |
|
591 | this.select(i+1); | |
592 | var cell = this.get_selected_cell(); |
|
592 | var cell = this.get_selected_cell(); | |
593 | cell.focus_cell(); |
|
593 | cell.focus_cell(); | |
594 |
} |
|
594 | } | |
595 |
} |
|
595 | } | |
596 | this.set_dirty(); |
|
596 | this.set_dirty(); | |
597 | return this; |
|
597 | return this; | |
598 | }; |
|
598 | }; | |
@@ -632,10 +632,10 b' var IPython = (function (IPython) {' | |||||
632 | this.select(i); |
|
632 | this.select(i); | |
633 | this.undelete_index = i; |
|
633 | this.undelete_index = i; | |
634 | this.undelete_below = false; |
|
634 | this.undelete_below = false; | |
635 |
} |
|
635 | } | |
636 | $([IPython.events]).trigger('delete.Cell', {'cell': cell, 'index': i}); |
|
636 | $([IPython.events]).trigger('delete.Cell', {'cell': cell, 'index': i}); | |
637 | this.set_dirty(true); |
|
637 | this.set_dirty(true); | |
638 |
} |
|
638 | } | |
639 | return this; |
|
639 | return this; | |
640 | }; |
|
640 | }; | |
641 |
|
641 | |||
@@ -673,7 +673,7 b' var IPython = (function (IPython) {' | |||||
673 | this.undelete_index = null; |
|
673 | this.undelete_index = null; | |
674 | } |
|
674 | } | |
675 | $('#undelete_cell').addClass('disabled'); |
|
675 | $('#undelete_cell').addClass('disabled'); | |
676 | } |
|
676 | }; | |
677 |
|
677 | |||
678 | /** |
|
678 | /** | |
679 | * Insert a cell so that after insertion the cell is at given index. |
|
679 | * Insert a cell so that after insertion the cell is at given index. | |
@@ -691,8 +691,8 b' var IPython = (function (IPython) {' | |||||
691 | Notebook.prototype.insert_cell_at_index = function(type, index){ |
|
691 | Notebook.prototype.insert_cell_at_index = function(type, index){ | |
692 |
|
692 | |||
693 | var ncells = this.ncells(); |
|
693 | var ncells = this.ncells(); | |
694 |
|
|
694 | index = Math.min(index,ncells); | |
695 |
|
|
695 | index = Math.max(index,0); | |
696 | var cell = null; |
|
696 | var cell = null; | |
697 |
|
697 | |||
698 | if (ncells === 0 || this.is_valid_cell_index(index) || index === ncells) { |
|
698 | if (ncells === 0 || this.is_valid_cell_index(index) || index === ncells) { | |
@@ -832,8 +832,8 b' var IPython = (function (IPython) {' | |||||
832 | source_element.remove(); |
|
832 | source_element.remove(); | |
833 | this.select(i); |
|
833 | this.select(i); | |
834 | this.set_dirty(true); |
|
834 | this.set_dirty(true); | |
835 |
} |
|
835 | } | |
836 |
} |
|
836 | } | |
837 | }; |
|
837 | }; | |
838 |
|
838 | |||
839 | /** |
|
839 | /** | |
@@ -852,7 +852,7 b' var IPython = (function (IPython) {' | |||||
852 | var text = source_cell.get_text(); |
|
852 | var text = source_cell.get_text(); | |
853 | if (text === source_cell.placeholder) { |
|
853 | if (text === source_cell.placeholder) { | |
854 | text = ''; |
|
854 | text = ''; | |
855 |
} |
|
855 | } | |
856 | // We must show the editor before setting its contents |
|
856 | // We must show the editor before setting its contents | |
857 | target_cell.unrender(); |
|
857 | target_cell.unrender(); | |
858 | target_cell.set_text(text); |
|
858 | target_cell.set_text(text); | |
@@ -865,8 +865,8 b' var IPython = (function (IPython) {' | |||||
865 | target_cell.render(); |
|
865 | target_cell.render(); | |
866 | } |
|
866 | } | |
867 | this.set_dirty(true); |
|
867 | this.set_dirty(true); | |
868 |
} |
|
868 | } | |
869 |
} |
|
869 | } | |
870 | }; |
|
870 | }; | |
871 |
|
871 | |||
872 | /** |
|
872 | /** | |
@@ -886,7 +886,7 b' var IPython = (function (IPython) {' | |||||
886 | var text = source_cell.get_text(); |
|
886 | var text = source_cell.get_text(); | |
887 | if (text === source_cell.placeholder) { |
|
887 | if (text === source_cell.placeholder) { | |
888 | text = ''; |
|
888 | text = ''; | |
889 |
} |
|
889 | } | |
890 | // We must show the editor before setting its contents |
|
890 | // We must show the editor before setting its contents | |
891 | target_cell.unrender(); |
|
891 | target_cell.unrender(); | |
892 | target_cell.set_text(text); |
|
892 | target_cell.set_text(text); | |
@@ -896,8 +896,8 b' var IPython = (function (IPython) {' | |||||
896 | source_element.remove(); |
|
896 | source_element.remove(); | |
897 | this.select(i); |
|
897 | this.select(i); | |
898 | this.set_dirty(true); |
|
898 | this.set_dirty(true); | |
899 |
} |
|
899 | } | |
900 |
} |
|
900 | } | |
901 | }; |
|
901 | }; | |
902 |
|
902 | |||
903 | /** |
|
903 | /** | |
@@ -921,7 +921,7 b' var IPython = (function (IPython) {' | |||||
921 | var text = source_cell.get_text(); |
|
921 | var text = source_cell.get_text(); | |
922 | if (text === source_cell.placeholder) { |
|
922 | if (text === source_cell.placeholder) { | |
923 | text = ''; |
|
923 | text = ''; | |
924 |
} |
|
924 | } | |
925 | // We must show the editor before setting its contents |
|
925 | // We must show the editor before setting its contents | |
926 | target_cell.set_level(level); |
|
926 | target_cell.set_level(level); | |
927 | target_cell.unrender(); |
|
927 | target_cell.unrender(); | |
@@ -934,12 +934,12 b' var IPython = (function (IPython) {' | |||||
934 | if ((source_cell instanceof IPython.TextCell) && source_cell.rendered) { |
|
934 | if ((source_cell instanceof IPython.TextCell) && source_cell.rendered) { | |
935 | target_cell.render(); |
|
935 | target_cell.render(); | |
936 | } |
|
936 | } | |
937 |
} |
|
937 | } | |
938 | this.set_dirty(true); |
|
938 | this.set_dirty(true); | |
939 | $([IPython.events]).trigger('selected_cell_type_changed.Notebook', |
|
939 | $([IPython.events]).trigger('selected_cell_type_changed.Notebook', | |
940 | {'cell_type':'heading',level:level} |
|
940 | {'cell_type':'heading',level:level} | |
941 | ); |
|
941 | ); | |
942 |
} |
|
942 | } | |
943 | }; |
|
943 | }; | |
944 |
|
944 | |||
945 |
|
945 | |||
@@ -960,7 +960,7 b' var IPython = (function (IPython) {' | |||||
960 | $('#paste_cell_below').removeClass('disabled') |
|
960 | $('#paste_cell_below').removeClass('disabled') | |
961 | .on('click', function () {that.paste_cell_below();}); |
|
961 | .on('click', function () {that.paste_cell_below();}); | |
962 | this.paste_enabled = true; |
|
962 | this.paste_enabled = true; | |
963 |
} |
|
963 | } | |
964 | }; |
|
964 | }; | |
965 |
|
965 | |||
966 | /** |
|
966 | /** | |
@@ -974,7 +974,7 b' var IPython = (function (IPython) {' | |||||
974 | $('#paste_cell_above').addClass('disabled').off('click'); |
|
974 | $('#paste_cell_above').addClass('disabled').off('click'); | |
975 | $('#paste_cell_below').addClass('disabled').off('click'); |
|
975 | $('#paste_cell_below').addClass('disabled').off('click'); | |
976 | this.paste_enabled = false; |
|
976 | this.paste_enabled = false; | |
977 |
} |
|
977 | } | |
978 | }; |
|
978 | }; | |
979 |
|
979 | |||
980 | /** |
|
980 | /** | |
@@ -985,7 +985,7 b' var IPython = (function (IPython) {' | |||||
985 | Notebook.prototype.cut_cell = function () { |
|
985 | Notebook.prototype.cut_cell = function () { | |
986 | this.copy_cell(); |
|
986 | this.copy_cell(); | |
987 | this.delete_cell(); |
|
987 | this.delete_cell(); | |
988 | } |
|
988 | }; | |
989 |
|
989 | |||
990 | /** |
|
990 | /** | |
991 | * Copy a cell. |
|
991 | * Copy a cell. | |
@@ -1011,7 +1011,7 b' var IPython = (function (IPython) {' | |||||
1011 | var old_cell = this.get_next_cell(new_cell); |
|
1011 | var old_cell = this.get_next_cell(new_cell); | |
1012 | this.delete_cell(this.find_cell_index(old_cell)); |
|
1012 | this.delete_cell(this.find_cell_index(old_cell)); | |
1013 | this.select(this.find_cell_index(new_cell)); |
|
1013 | this.select(this.find_cell_index(new_cell)); | |
1014 |
} |
|
1014 | } | |
1015 | }; |
|
1015 | }; | |
1016 |
|
1016 | |||
1017 | /** |
|
1017 | /** | |
@@ -1025,7 +1025,7 b' var IPython = (function (IPython) {' | |||||
1025 | var new_cell = this.insert_cell_above(cell_data.cell_type); |
|
1025 | var new_cell = this.insert_cell_above(cell_data.cell_type); | |
1026 | new_cell.fromJSON(cell_data); |
|
1026 | new_cell.fromJSON(cell_data); | |
1027 | new_cell.focus_cell(); |
|
1027 | new_cell.focus_cell(); | |
1028 |
} |
|
1028 | } | |
1029 | }; |
|
1029 | }; | |
1030 |
|
1030 | |||
1031 | /** |
|
1031 | /** | |
@@ -1039,7 +1039,7 b' var IPython = (function (IPython) {' | |||||
1039 | var new_cell = this.insert_cell_below(cell_data.cell_type); |
|
1039 | var new_cell = this.insert_cell_below(cell_data.cell_type); | |
1040 | new_cell.fromJSON(cell_data); |
|
1040 | new_cell.fromJSON(cell_data); | |
1041 | new_cell.focus_cell(); |
|
1041 | new_cell.focus_cell(); | |
1042 |
} |
|
1042 | } | |
1043 | }; |
|
1043 | }; | |
1044 |
|
1044 | |||
1045 | // Split/merge |
|
1045 | // Split/merge | |
@@ -1070,7 +1070,7 b' var IPython = (function (IPython) {' | |||||
1070 | new_cell.unrender(); |
|
1070 | new_cell.unrender(); | |
1071 | new_cell.set_text(texta); |
|
1071 | new_cell.set_text(texta); | |
1072 | } |
|
1072 | } | |
1073 |
} |
|
1073 | } | |
1074 | }; |
|
1074 | }; | |
1075 |
|
1075 | |||
1076 | /** |
|
1076 | /** | |
@@ -1104,10 +1104,10 b' var IPython = (function (IPython) {' | |||||
1104 | // that of the original selected cell; |
|
1104 | // that of the original selected cell; | |
1105 | cell.render(); |
|
1105 | cell.render(); | |
1106 | } |
|
1106 | } | |
1107 |
} |
|
1107 | } | |
1108 | this.delete_cell(index-1); |
|
1108 | this.delete_cell(index-1); | |
1109 | this.select(this.find_cell_index(cell)); |
|
1109 | this.select(this.find_cell_index(cell)); | |
1110 |
} |
|
1110 | } | |
1111 | }; |
|
1111 | }; | |
1112 |
|
1112 | |||
1113 | /** |
|
1113 | /** | |
@@ -1141,10 +1141,10 b' var IPython = (function (IPython) {' | |||||
1141 | // that of the original selected cell; |
|
1141 | // that of the original selected cell; | |
1142 | cell.render(); |
|
1142 | cell.render(); | |
1143 | } |
|
1143 | } | |
1144 |
} |
|
1144 | } | |
1145 | this.delete_cell(index+1); |
|
1145 | this.delete_cell(index+1); | |
1146 | this.select(this.find_cell_index(cell)); |
|
1146 | this.select(this.find_cell_index(cell)); | |
1147 |
} |
|
1147 | } | |
1148 | }; |
|
1148 | }; | |
1149 |
|
1149 | |||
1150 |
|
1150 | |||
@@ -1364,8 +1364,8 b' var IPython = (function (IPython) {' | |||||
1364 | var cell = this.get_cell(i); |
|
1364 | var cell = this.get_cell(i); | |
1365 | if (cell instanceof IPython.CodeCell) { |
|
1365 | if (cell instanceof IPython.CodeCell) { | |
1366 | cell.set_kernel(this.session.kernel); |
|
1366 | cell.set_kernel(this.session.kernel); | |
1367 |
} |
|
1367 | } | |
1368 |
} |
|
1368 | } | |
1369 | }; |
|
1369 | }; | |
1370 |
|
1370 | |||
1371 | /** |
|
1371 | /** | |
@@ -1406,7 +1406,7 b' var IPython = (function (IPython) {' | |||||
1406 | this.command_mode(); |
|
1406 | this.command_mode(); | |
1407 | cell.focus_cell(); |
|
1407 | cell.focus_cell(); | |
1408 | this.set_dirty(true); |
|
1408 | this.set_dirty(true); | |
1409 | } |
|
1409 | }; | |
1410 |
|
1410 | |||
1411 | /** |
|
1411 | /** | |
1412 | * Execute or render cell outputs and insert a new cell below. |
|
1412 | * Execute or render cell outputs and insert a new cell below. | |
@@ -1502,7 +1502,7 b' var IPython = (function (IPython) {' | |||||
1502 | for (var i=start; i<end; i++) { |
|
1502 | for (var i=start; i<end; i++) { | |
1503 | this.select(i); |
|
1503 | this.select(i); | |
1504 | this.execute_cell(); |
|
1504 | this.execute_cell(); | |
1505 |
} |
|
1505 | } | |
1506 | }; |
|
1506 | }; | |
1507 |
|
1507 | |||
1508 | // Persistance and loading |
|
1508 | // Persistance and loading | |
@@ -1537,11 +1537,11 b' var IPython = (function (IPython) {' | |||||
1537 | */ |
|
1537 | */ | |
1538 | Notebook.prototype.test_notebook_name = function (nbname) { |
|
1538 | Notebook.prototype.test_notebook_name = function (nbname) { | |
1539 | nbname = nbname || ''; |
|
1539 | nbname = nbname || ''; | |
1540 |
if (this.notebook_name_blacklist_re.test(nbname) |
|
1540 | if (nbname.length>0 && !this.notebook_name_blacklist_re.test(nbname)) { | |
1541 | return true; |
|
1541 | return true; | |
1542 | } else { |
|
1542 | } else { | |
1543 | return false; |
|
1543 | return false; | |
1544 |
} |
|
1544 | } | |
1545 | }; |
|
1545 | }; | |
1546 |
|
1546 | |||
1547 | /** |
|
1547 | /** | |
@@ -1559,7 +1559,7 b' var IPython = (function (IPython) {' | |||||
1559 | for (i=0; i<ncells; i++) { |
|
1559 | for (i=0; i<ncells; i++) { | |
1560 | // Always delete cell 0 as they get renumbered as they are deleted. |
|
1560 | // Always delete cell 0 as they get renumbered as they are deleted. | |
1561 | this.delete_cell(0); |
|
1561 | this.delete_cell(0); | |
1562 |
} |
|
1562 | } | |
1563 | // Save the metadata and name. |
|
1563 | // Save the metadata and name. | |
1564 | this.metadata = content.metadata; |
|
1564 | this.metadata = content.metadata; | |
1565 | this.notebook_name = data.name; |
|
1565 | this.notebook_name = data.name; | |
@@ -1583,8 +1583,8 b' var IPython = (function (IPython) {' | |||||
1583 |
|
1583 | |||
1584 | new_cell = this.insert_cell_at_index(cell_data.cell_type, i); |
|
1584 | new_cell = this.insert_cell_at_index(cell_data.cell_type, i); | |
1585 | new_cell.fromJSON(cell_data); |
|
1585 | new_cell.fromJSON(cell_data); | |
1586 |
} |
|
1586 | } | |
1587 |
} |
|
1587 | } | |
1588 | if (content.worksheets.length > 1) { |
|
1588 | if (content.worksheets.length > 1) { | |
1589 | IPython.dialog.modal({ |
|
1589 | IPython.dialog.modal({ | |
1590 | title : "Multiple worksheets", |
|
1590 | title : "Multiple worksheets", | |
@@ -1612,7 +1612,7 b' var IPython = (function (IPython) {' | |||||
1612 | var cell_array = new Array(ncells); |
|
1612 | var cell_array = new Array(ncells); | |
1613 | for (var i=0; i<ncells; i++) { |
|
1613 | for (var i=0; i<ncells; i++) { | |
1614 | cell_array[i] = cells[i].toJSON(); |
|
1614 | cell_array[i] = cells[i].toJSON(); | |
1615 |
} |
|
1615 | } | |
1616 | var data = { |
|
1616 | var data = { | |
1617 | // Only handle 1 worksheet for now. |
|
1617 | // Only handle 1 worksheet for now. | |
1618 | worksheets : [{ |
|
1618 | worksheets : [{ | |
@@ -1648,7 +1648,7 b' var IPython = (function (IPython) {' | |||||
1648 | } else { |
|
1648 | } else { | |
1649 | this.autosave_timer = null; |
|
1649 | this.autosave_timer = null; | |
1650 | $([IPython.events]).trigger("autosave_disabled.Notebook"); |
|
1650 | $([IPython.events]).trigger("autosave_disabled.Notebook"); | |
1651 |
} |
|
1651 | } | |
1652 | }; |
|
1652 | }; | |
1653 |
|
1653 | |||
1654 | /** |
|
1654 | /** | |
@@ -1707,7 +1707,7 b' var IPython = (function (IPython) {' | |||||
1707 | if (this._checkpoint_after_save) { |
|
1707 | if (this._checkpoint_after_save) { | |
1708 | this.create_checkpoint(); |
|
1708 | this.create_checkpoint(); | |
1709 | this._checkpoint_after_save = false; |
|
1709 | this._checkpoint_after_save = false; | |
1710 |
} |
|
1710 | } | |
1711 | }; |
|
1711 | }; | |
1712 |
|
1712 | |||
1713 | /** |
|
1713 | /** | |
@@ -1842,19 +1842,18 b' var IPython = (function (IPython) {' | |||||
1842 |
|
1842 | |||
1843 |
|
1843 | |||
1844 | Notebook.prototype.rename_success = function (json, status, xhr) { |
|
1844 | Notebook.prototype.rename_success = function (json, status, xhr) { | |
1845 | this.notebook_name = json.name; |
|
1845 | var name = this.notebook_name = json.name; | |
1846 | var name = this.notebook_name; |
|
|||
1847 | var path = json.path; |
|
1846 | var path = json.path; | |
1848 | this.session.rename_notebook(name, path); |
|
1847 | this.session.rename_notebook(name, path); | |
1849 | $([IPython.events]).trigger('notebook_renamed.Notebook', json); |
|
1848 | $([IPython.events]).trigger('notebook_renamed.Notebook', json); | |
1850 | } |
|
1849 | }; | |
1851 |
|
1850 | |||
1852 | Notebook.prototype.rename_error = function (xhr, status, error) { |
|
1851 | Notebook.prototype.rename_error = function (xhr, status, error) { | |
1853 | var that = this; |
|
1852 | var that = this; | |
1854 | var dialog = $('<div/>').append( |
|
1853 | var dialog = $('<div/>').append( | |
1855 | $("<p/>").addClass("rename-message") |
|
1854 | $("<p/>").addClass("rename-message") | |
1856 | .text('This notebook name already exists.') |
|
1855 | .text('This notebook name already exists.') | |
1857 | ) |
|
1856 | ); | |
1858 | $([IPython.events]).trigger('notebook_rename_failed.Notebook', [xhr, status, error]); |
|
1857 | $([IPython.events]).trigger('notebook_rename_failed.Notebook', [xhr, status, error]); | |
1859 | IPython.dialog.modal({ |
|
1858 | IPython.dialog.modal({ | |
1860 | title: "Notebook Rename Error!", |
|
1859 | title: "Notebook Rename Error!", | |
@@ -1878,7 +1877,7 b' var IPython = (function (IPython) {' | |||||
1878 | that.find('input[type="text"]').focus(); |
|
1877 | that.find('input[type="text"]').focus(); | |
1879 | } |
|
1878 | } | |
1880 | }); |
|
1879 | }); | |
1881 | } |
|
1880 | }; | |
1882 |
|
1881 | |||
1883 | /** |
|
1882 | /** | |
1884 | * Request a notebook's data from the server. |
|
1883 | * Request a notebook's data from the server. | |
@@ -1928,7 +1927,7 b' var IPython = (function (IPython) {' | |||||
1928 | } else { |
|
1927 | } else { | |
1929 | this.select(0); |
|
1928 | this.select(0); | |
1930 | this.command_mode(); |
|
1929 | this.command_mode(); | |
1931 |
} |
|
1930 | } | |
1932 | this.set_dirty(false); |
|
1931 | this.set_dirty(false); | |
1933 | this.scroll_to_top(); |
|
1932 | this.scroll_to_top(); | |
1934 | if (data.orig_nbformat !== undefined && data.nbformat !== data.orig_nbformat) { |
|
1933 | if (data.orig_nbformat !== undefined && data.nbformat !== data.orig_nbformat) { | |
@@ -1953,7 +1952,7 b' var IPython = (function (IPython) {' | |||||
1953 | var this_vs = 'v' + data.nbformat + '.' + this.nbformat_minor; |
|
1952 | var this_vs = 'v' + data.nbformat + '.' + this.nbformat_minor; | |
1954 | var msg = "This notebook is version " + orig_vs + ", but we only fully support up to " + |
|
1953 | var msg = "This notebook is version " + orig_vs + ", but we only fully support up to " + | |
1955 | this_vs + ". You can still work with this notebook, but some features " + |
|
1954 | this_vs + ". You can still work with this notebook, but some features " + | |
1956 | "introduced in later notebook versions may not be available." |
|
1955 | "introduced in later notebook versions may not be available."; | |
1957 |
|
1956 | |||
1958 | IPython.dialog.modal({ |
|
1957 | IPython.dialog.modal({ | |
1959 | title : "Newer Notebook", |
|
1958 | title : "Newer Notebook", | |
@@ -1969,7 +1968,7 b' var IPython = (function (IPython) {' | |||||
1969 |
|
1968 | |||
1970 | // Create the session after the notebook is completely loaded to prevent |
|
1969 | // Create the session after the notebook is completely loaded to prevent | |
1971 | // code execution upon loading, which is a security risk. |
|
1970 | // code execution upon loading, which is a security risk. | |
1972 | if (this.session == null) { |
|
1971 | if (this.session === null) { | |
1973 | this.start_session(); |
|
1972 | this.start_session(); | |
1974 | } |
|
1973 | } | |
1975 | // load our checkpoint list |
|
1974 | // load our checkpoint list | |
@@ -1994,10 +1993,11 b' var IPython = (function (IPython) {' | |||||
1994 | */ |
|
1993 | */ | |
1995 | Notebook.prototype.load_notebook_error = function (xhr, status, error) { |
|
1994 | Notebook.prototype.load_notebook_error = function (xhr, status, error) { | |
1996 | $([IPython.events]).trigger('notebook_load_failed.Notebook', [xhr, status, error]); |
|
1995 | $([IPython.events]).trigger('notebook_load_failed.Notebook', [xhr, status, error]); | |
|
1996 | var msg; | |||
1997 | if (xhr.status === 400) { |
|
1997 | if (xhr.status === 400) { | |
1998 |
|
|
1998 | msg = error; | |
1999 | } else if (xhr.status === 500) { |
|
1999 | } else if (xhr.status === 500) { | |
2000 |
|
|
2000 | msg = "An unknown error occurred while loading this notebook. " + | |
2001 | "This version can load notebook formats " + |
|
2001 | "This version can load notebook formats " + | |
2002 | "v" + this.nbformat + " or earlier."; |
|
2002 | "v" + this.nbformat + " or earlier."; | |
2003 | } |
|
2003 | } | |
@@ -2008,7 +2008,7 b' var IPython = (function (IPython) {' | |||||
2008 | "OK": {} |
|
2008 | "OK": {} | |
2009 | } |
|
2009 | } | |
2010 | }); |
|
2010 | }); | |
2011 | } |
|
2011 | }; | |
2012 |
|
2012 | |||
2013 | /********************* checkpoint-related *********************/ |
|
2013 | /********************* checkpoint-related *********************/ | |
2014 |
|
2014 | |||
@@ -2073,7 +2073,7 b' var IPython = (function (IPython) {' | |||||
2073 | * @param {jqXHR} xhr jQuery Ajax object |
|
2073 | * @param {jqXHR} xhr jQuery Ajax object | |
2074 | */ |
|
2074 | */ | |
2075 | Notebook.prototype.list_checkpoints_success = function (data, status, xhr) { |
|
2075 | Notebook.prototype.list_checkpoints_success = function (data, status, xhr) { | |
2076 |
|
|
2076 | data = $.parseJSON(data); | |
2077 | this.checkpoints = data; |
|
2077 | this.checkpoints = data; | |
2078 | if (data.length) { |
|
2078 | if (data.length) { | |
2079 | this.last_checkpoint = data[data.length - 1]; |
|
2079 | this.last_checkpoint = data[data.length - 1]; | |
@@ -2124,7 +2124,7 b' var IPython = (function (IPython) {' | |||||
2124 | * @param {jqXHR} xhr jQuery Ajax object |
|
2124 | * @param {jqXHR} xhr jQuery Ajax object | |
2125 | */ |
|
2125 | */ | |
2126 | Notebook.prototype.create_checkpoint_success = function (data, status, xhr) { |
|
2126 | Notebook.prototype.create_checkpoint_success = function (data, status, xhr) { | |
2127 |
|
|
2127 | data = $.parseJSON(data); | |
2128 | this.add_checkpoint(data); |
|
2128 | this.add_checkpoint(data); | |
2129 | $([IPython.events]).trigger('checkpoint_created.Notebook', data); |
|
2129 | $([IPython.events]).trigger('checkpoint_created.Notebook', data); | |
2130 | }; |
|
2130 | }; | |
@@ -2143,7 +2143,7 b' var IPython = (function (IPython) {' | |||||
2143 |
|
2143 | |||
2144 | Notebook.prototype.restore_checkpoint_dialog = function (checkpoint) { |
|
2144 | Notebook.prototype.restore_checkpoint_dialog = function (checkpoint) { | |
2145 | var that = this; |
|
2145 | var that = this; | |
2146 |
|
|
2146 | checkpoint = checkpoint || this.last_checkpoint; | |
2147 | if ( ! checkpoint ) { |
|
2147 | if ( ! checkpoint ) { | |
2148 | console.log("restore dialog, but no checkpoint to restore to!"); |
|
2148 | console.log("restore dialog, but no checkpoint to restore to!"); | |
2149 | return; |
|
2149 | return; | |
@@ -2178,7 +2178,7 b' var IPython = (function (IPython) {' | |||||
2178 | Cancel : {} |
|
2178 | Cancel : {} | |
2179 | } |
|
2179 | } | |
2180 | }); |
|
2180 | }); | |
2181 | } |
|
2181 | }; | |
2182 |
|
2182 | |||
2183 | /** |
|
2183 | /** | |
2184 | * Restore the notebook to a checkpoint state. |
|
2184 | * Restore the notebook to a checkpoint state. |
General Comments 0
You need to be logged in to leave comments.
Login now