Show More
@@ -49,17 +49,18 b' define([' | |||
|
49 | 49 | |
|
50 | 50 | /** |
|
51 | 51 | * Contains and manages cells. |
|
52 | * | |
|
52 | 53 | * @class Notebook |
|
53 | 54 | * @param {string} selector |
|
54 |
* @param { |
|
|
55 | * events: $(Events) instance | |
|
56 | * keyboard_manager: KeyboardManager instance | |
|
57 | * contents: Contents instance | |
|
58 | * save_widget: SaveWidget instance | |
|
59 | * config: dictionary | |
|
60 | * base_url : string | |
|
61 | * notebook_path : string | |
|
62 | * notebook_name : string | |
|
55 | * @param {object} options - Dictionary of keyword arguments. | |
|
56 | * @param {jQuery} options.events - selector of Events | |
|
57 | * @param {KeyboardManager} options.keyboard_manager | |
|
58 | * @param {Contents} options.contents | |
|
59 | * @param {SaveWidget} options.save_widget | |
|
60 | * @param {object} options.config | |
|
61 | * @param {string} options.base_url | |
|
62 | * @param {string} options.notebook_path | |
|
63 | * @param {string} options.notebook_name | |
|
63 | 64 | */ |
|
64 | 65 | var Notebook = function (selector, options) { |
|
65 | 66 | this.config = utils.mergeopt(Notebook, options.config); |
@@ -354,16 +355,16 b' define([' | |||
|
354 | 355 | /** |
|
355 | 356 | * Scroll the top of the page to a given cell. |
|
356 | 357 | * |
|
357 |
* @param { |
|
|
358 |
* @param { |
|
|
359 |
* @return { |
|
|
358 | * @param {integer} index - An index of the cell to view | |
|
359 | * @param {integer} time - Animation time in milliseconds | |
|
360 | * @return {integer} Pixel offset from the top of the container | |
|
360 | 361 | */ |
|
361 |
Notebook.prototype.scroll_to_cell = function ( |
|
|
362 | Notebook.prototype.scroll_to_cell = function (index, time) { | |
|
362 | 363 | var cells = this.get_cells(); |
|
363 | 364 | time = time || 0; |
|
364 |
|
|
|
365 |
|
|
|
366 |
var scroll_value = cells[ |
|
|
365 | index = Math.min(cells.length-1,index); | |
|
366 | index = Math.max(0 ,index); | |
|
367 | var scroll_value = cells[index].element.position().top-cells[0].element.position().top ; | |
|
367 | 368 | this.element.animate({scrollTop:scroll_value}, time); |
|
368 | 369 | return scroll_value; |
|
369 | 370 | }; |
@@ -386,7 +387,6 b' define([' | |||
|
386 | 387 | |
|
387 | 388 | /** |
|
388 | 389 | * Display a dialog that allows the user to edit the Notebook's metadata. |
|
389 | * @return {null} | |
|
390 | 390 | */ |
|
391 | 391 | Notebook.prototype.edit_metadata = function () { |
|
392 | 392 | var that = this; |
@@ -414,7 +414,7 b' define([' | |||
|
414 | 414 | /** |
|
415 | 415 | * Get a particular cell element. |
|
416 | 416 | * |
|
417 |
* @param { |
|
|
417 | * @param {integer} index An index of a cell to select | |
|
418 | 418 | * @return {jQuery} A selector of the given cell. |
|
419 | 419 | */ |
|
420 | 420 | Notebook.prototype.get_cell_element = function (index) { |
@@ -439,7 +439,7 b' define([' | |||
|
439 | 439 | /** |
|
440 | 440 | * Count the cells in this notebook. |
|
441 | 441 | * |
|
442 |
* @return { |
|
|
442 | * @return {integer} The number of cells in this notebook | |
|
443 | 443 | */ |
|
444 | 444 | Notebook.prototype.ncells = function () { |
|
445 | 445 | return this.get_cell_elements().length; |
@@ -459,9 +459,9 b' define([' | |||
|
459 | 459 | }; |
|
460 | 460 | |
|
461 | 461 | /** |
|
462 | * Get a Cell object from this notebook. | |
|
462 | * Get a Cell objects from this notebook. | |
|
463 | 463 | * |
|
464 |
* @param { |
|
|
464 | * @param {integer} index - An index of a cell to retrieve | |
|
465 | 465 | * @return {Cell} Cell or null if no cell was found. |
|
466 | 466 | */ |
|
467 | 467 | Notebook.prototype.get_cell = function (index) { |
@@ -476,7 +476,7 b' define([' | |||
|
476 | 476 | /** |
|
477 | 477 | * Get the cell below a given cell. |
|
478 | 478 | * |
|
479 |
* @param {Cell} cell |
|
|
479 | * @param {Cell} cell | |
|
480 | 480 | * @return {Cell} the next cell or null if no cell was found. |
|
481 | 481 | */ |
|
482 | 482 | Notebook.prototype.get_next_cell = function (cell) { |
@@ -491,7 +491,7 b' define([' | |||
|
491 | 491 | /** |
|
492 | 492 | * Get the cell above a given cell. |
|
493 | 493 | * |
|
494 |
* @param {Cell} cell |
|
|
494 | * @param {Cell} cell | |
|
495 | 495 | * @return {Cell} The previous cell or null if no cell was found. |
|
496 | 496 | */ |
|
497 | 497 | Notebook.prototype.get_prev_cell = function (cell) { |
@@ -506,8 +506,8 b' define([' | |||
|
506 | 506 | /** |
|
507 | 507 | * Get the numeric index of a given cell. |
|
508 | 508 | * |
|
509 |
* @param {Cell} cell |
|
|
510 |
* @return { |
|
|
509 | * @param {Cell} cell | |
|
510 | * @return {integer} The cell's numeric index or null if no cell was found. | |
|
511 | 511 | */ |
|
512 | 512 | Notebook.prototype.find_cell_index = function (cell) { |
|
513 | 513 | var result = null; |
@@ -520,10 +520,10 b' define([' | |||
|
520 | 520 | }; |
|
521 | 521 | |
|
522 | 522 | /** |
|
523 |
* |
|
|
523 | * Return given index if defined, or the selected index if not. | |
|
524 | 524 | * |
|
525 |
* @param { |
|
|
526 | * @return {number} The given index, or selected index if none is provided. | |
|
525 | * @param {integer} [index] - A cell's index | |
|
526 | * @return {integer} cell index | |
|
527 | 527 | */ |
|
528 | 528 | Notebook.prototype.index_or_selected = function (index) { |
|
529 | 529 | var i; |
@@ -540,6 +540,7 b' define([' | |||
|
540 | 540 | |
|
541 | 541 | /** |
|
542 | 542 | * Get the currently selected cell. |
|
543 | * | |
|
543 | 544 | * @return {Cell} The selected cell |
|
544 | 545 | */ |
|
545 | 546 | Notebook.prototype.get_selected_cell = function () { |
@@ -550,7 +551,7 b' define([' | |||
|
550 | 551 | /** |
|
551 | 552 | * Check whether a cell index is valid. |
|
552 | 553 | * |
|
553 |
* @param { |
|
|
554 | * @param {integer} index - A cell index | |
|
554 | 555 | * @return True if the index is valid, false otherwise |
|
555 | 556 | */ |
|
556 | 557 | Notebook.prototype.is_valid_cell_index = function (index) { |
@@ -563,8 +564,8 b' define([' | |||
|
563 | 564 | |
|
564 | 565 | /** |
|
565 | 566 | * Get the index of the currently selected cell. |
|
566 | ||
|
567 |
* @return { |
|
|
567 | * | |
|
568 | * @return {integer} The selected cell's numeric index | |
|
568 | 569 | */ |
|
569 | 570 | Notebook.prototype.get_selected_index = function () { |
|
570 | 571 | var result = null; |
@@ -582,7 +583,7 b' define([' | |||
|
582 | 583 | /** |
|
583 | 584 | * Programmatically select a cell. |
|
584 | 585 | * |
|
585 |
* @param { |
|
|
586 | * @param {integer} index - A cell's index | |
|
586 | 587 | * @return {Notebook} This notebook |
|
587 | 588 | */ |
|
588 | 589 | Notebook.prototype.select = function (index) { |
@@ -639,8 +640,8 b' define([' | |||
|
639 | 640 | /** |
|
640 | 641 | * Gets the index of the cell that is in edit mode. |
|
641 | 642 | * |
|
642 |
* @return |
|
|
643 |
* |
|
|
643 | * @return {integer} index | |
|
644 | */ | |
|
644 | 645 | Notebook.prototype.get_edit_index = function () { |
|
645 | 646 | var result = null; |
|
646 | 647 | this.get_cell_elements().filter(function (index) { |
@@ -654,8 +655,8 b' define([' | |||
|
654 | 655 | /** |
|
655 | 656 | * Handle when a a cell blurs and the notebook should enter command mode. |
|
656 | 657 | * |
|
657 | * @param {Cell} [cell] Cell to enter command mode on. | |
|
658 |
* |
|
|
658 | * @param {Cell} [cell] - Cell to enter command mode on. | |
|
659 | */ | |
|
659 | 660 | Notebook.prototype.handle_command_mode = function (cell) { |
|
660 | 661 | if (this.mode !== 'command') { |
|
661 | 662 | cell.command_mode(); |
@@ -667,7 +668,7 b' define([' | |||
|
667 | 668 | |
|
668 | 669 | /** |
|
669 | 670 | * Make the notebook enter command mode. |
|
670 |
* |
|
|
671 | */ | |
|
671 | 672 | Notebook.prototype.command_mode = function () { |
|
672 | 673 | var cell = this.get_cell(this.get_edit_index()); |
|
673 | 674 | if (cell && this.mode !== 'command') { |
@@ -682,7 +683,7 b' define([' | |||
|
682 | 683 | * Handle when a cell fires it's edit_mode event. |
|
683 | 684 | * |
|
684 | 685 | * @param {Cell} [cell] Cell to enter edit mode on. |
|
685 |
* |
|
|
686 | */ | |
|
686 | 687 | Notebook.prototype.handle_edit_mode = function (cell) { |
|
687 | 688 | if (cell && this.mode !== 'edit') { |
|
688 | 689 | cell.edit_mode(); |
@@ -694,7 +695,7 b' define([' | |||
|
694 | 695 | |
|
695 | 696 | /** |
|
696 | 697 | * Make a cell enter edit mode. |
|
697 |
* |
|
|
698 | */ | |
|
698 | 699 | Notebook.prototype.edit_mode = function () { |
|
699 | 700 | var cell = this.get_selected_cell(); |
|
700 | 701 | if (cell && this.mode !== 'edit') { |
@@ -705,7 +706,7 b' define([' | |||
|
705 | 706 | |
|
706 | 707 | /** |
|
707 | 708 | * Focus the currently selected cell. |
|
708 |
* |
|
|
709 | */ | |
|
709 | 710 | Notebook.prototype.focus_cell = function () { |
|
710 | 711 | var cell = this.get_selected_cell(); |
|
711 | 712 | if (cell === null) {return;} // No cell is selected |
@@ -717,9 +718,9 b' define([' | |||
|
717 | 718 | /** |
|
718 | 719 | * Move given (or selected) cell up and select it. |
|
719 | 720 | * |
|
720 | * @param {integer} [index] cell index | |
|
721 | * @param {integer} [index] - cell index | |
|
721 | 722 | * @return {Notebook} This notebook |
|
722 |
* |
|
|
723 | */ | |
|
723 | 724 | Notebook.prototype.move_cell_up = function (index) { |
|
724 | 725 | var i = this.index_or_selected(index); |
|
725 | 726 | if (this.is_valid_cell_index(i) && i > 0) { |
@@ -739,11 +740,11 b' define([' | |||
|
739 | 740 | |
|
740 | 741 | |
|
741 | 742 | /** |
|
742 | * Move given (or selected) cell down and select it | |
|
743 | * Move given (or selected) cell down and select it. | |
|
743 | 744 | * |
|
744 | * @param {integer} [index] cell index | |
|
745 | * @param {integer} [index] - cell index | |
|
745 | 746 | * @return {Notebook} This notebook |
|
746 |
* |
|
|
747 | */ | |
|
747 | 748 | Notebook.prototype.move_cell_down = function (index) { |
|
748 | 749 | var i = this.index_or_selected(index); |
|
749 | 750 | if (this.is_valid_cell_index(i) && this.is_valid_cell_index(i+1)) { |
@@ -767,7 +768,7 b' define([' | |||
|
767 | 768 | /** |
|
768 | 769 | * Delete a cell from the notebook. |
|
769 | 770 | * |
|
770 | * @param {integer} [index] cell's numeric index | |
|
771 | * @param {integer} [index] - cell's numeric index | |
|
771 | 772 | * @return {Notebook} This notebook |
|
772 | 773 | */ |
|
773 | 774 | Notebook.prototype.delete_cell = function (index) { |
@@ -846,15 +847,14 b' define([' | |||
|
846 | 847 | * If cell type is not provided, it will default to the type of the |
|
847 | 848 | * currently active cell. |
|
848 | 849 | * |
|
849 | * Similar to insert_above, but index parameter is mandatory | |
|
850 | * | |
|
851 | * Index will be brought back into the accessible range [0,n] | |
|
850 | * Similar to insert_above, but index parameter is mandatory. | |
|
852 | 851 | * |
|
853 | * @param {string} [type] in ['code','markdown', 'raw'], defaults to 'code' | |
|
854 | * @param {integer} [index] a valid index where to insert cell | |
|
852 | * Index will be brought back into the accessible range [0,n]. | |
|
855 | 853 | * |
|
854 | * @param {string} [type] - in ['code','markdown', 'raw'], defaults to 'code' | |
|
855 | * @param {integer} [index] - a valid index where to insert cell | |
|
856 | 856 | * @return {Cell|null} created cell or null |
|
857 |
* |
|
|
857 | */ | |
|
858 | 858 | Notebook.prototype.insert_cell_at_index = function(type, index){ |
|
859 | 859 | |
|
860 | 860 | var ncells = this.ncells(); |
@@ -919,11 +919,11 b' define([' | |||
|
919 | 919 | |
|
920 | 920 | /** |
|
921 | 921 | * Insert an element at given cell index. |
|
922 | * return true if everything whent fine. | |
|
923 | 922 | * |
|
924 | 923 | * @param {HTMLElement} element - a cell element |
|
925 | * @param {integer} [index] a valid index where to inser cell | |
|
926 | **/ | |
|
924 | * @param {integer} [index] - a valid index where to inser cell | |
|
925 | * @returns {boolean} success | |
|
926 | */ | |
|
927 | 927 | Notebook.prototype._insert_element_at_index = function(element, index){ |
|
928 | 928 | if (element === undefined){ |
|
929 | 929 | return false; |
@@ -955,13 +955,10 b' define([' | |||
|
955 | 955 | * Insert a cell of given type above given index, or at top |
|
956 | 956 | * of notebook if index smaller than 0. |
|
957 | 957 | * |
|
958 | * default index value is the one of currently selected cell | |
|
959 | * | |
|
960 | * @param {string} [type] cell type | |
|
961 | * @param {integer} [index] | |
|
962 | * | |
|
958 | * @param {string} [type] - cell type | |
|
959 | * @param {integer} [index] - defaults to the currently selected cell | |
|
963 | 960 | * @return {Cell|null} handle to created cell or null |
|
964 |
* |
|
|
961 | */ | |
|
965 | 962 | Notebook.prototype.insert_cell_above = function (type, index) { |
|
966 | 963 | index = this.index_or_selected(index); |
|
967 | 964 | return this.insert_cell_at_index(type, index); |
@@ -971,13 +968,10 b' define([' | |||
|
971 | 968 | * Insert a cell of given type below given index, or at bottom |
|
972 | 969 | * of notebook if index greater than number of cells |
|
973 | 970 | * |
|
974 | * default index value is the one of currently selected cell | |
|
975 | * | |
|
976 | * @param {string} [type] cell type | |
|
977 | * @param {integer} [index] | |
|
978 | * | |
|
971 | * @param {string} [type] - cell type | |
|
972 | * @param {integer} [index] - defaults to the currently selected cell | |
|
979 | 973 | * @return {Cell|null} handle to created cell or null |
|
980 |
* |
|
|
974 | */ | |
|
981 | 975 | Notebook.prototype.insert_cell_below = function (type, index) { |
|
982 | 976 | index = this.index_or_selected(index); |
|
983 | 977 | return this.insert_cell_at_index(type, index+1); |
@@ -987,10 +981,9 b' define([' | |||
|
987 | 981 | /** |
|
988 | 982 | * Insert cell at end of notebook |
|
989 | 983 | * |
|
990 | * @param {string} type cell type | |
|
991 | * | |
|
992 | * @return {Cell|null} the added cell; or null | |
|
993 | **/ | |
|
984 | * @param {string} type - cell type | |
|
985 | * @return {Cell|null} handle to created cell or null | |
|
986 | */ | |
|
994 | 987 | Notebook.prototype.insert_cell_at_bottom = function (type){ |
|
995 | 988 | var len = this.ncells(); |
|
996 | 989 | return this.insert_cell_below(type,len-1); |
@@ -999,7 +992,7 b' define([' | |||
|
999 | 992 | /** |
|
1000 | 993 | * Turn a cell into a code cell. |
|
1001 | 994 | * |
|
1002 |
* @param { |
|
|
995 | * @param {integer} [index] - cell index | |
|
1003 | 996 | */ |
|
1004 | 997 | Notebook.prototype.to_code = function (index) { |
|
1005 | 998 | var i = this.index_or_selected(index); |
@@ -1030,7 +1023,7 b' define([' | |||
|
1030 | 1023 | /** |
|
1031 | 1024 | * Turn a cell into a Markdown cell. |
|
1032 | 1025 | * |
|
1033 |
* @param { |
|
|
1026 | * @param {integer} [index] - cell index | |
|
1034 | 1027 | */ |
|
1035 | 1028 | Notebook.prototype.to_markdown = function (index) { |
|
1036 | 1029 | var i = this.index_or_selected(index); |
@@ -1067,7 +1060,7 b' define([' | |||
|
1067 | 1060 | /** |
|
1068 | 1061 | * Turn a cell into a raw text cell. |
|
1069 | 1062 | * |
|
1070 |
* @param { |
|
|
1063 | * @param {integer} [index] - cell index | |
|
1071 | 1064 | */ |
|
1072 | 1065 | Notebook.prototype.to_raw = function (index) { |
|
1073 | 1066 | var i = this.index_or_selected(index); |
@@ -1099,7 +1092,7 b' define([' | |||
|
1099 | 1092 | }; |
|
1100 | 1093 | |
|
1101 | 1094 | /** |
|
1102 |
* |
|
|
1095 | * Warn about heading cell support removal. | |
|
1103 | 1096 | */ |
|
1104 | 1097 | Notebook.prototype._warn_heading = function () { |
|
1105 | 1098 | dialog.modal({ |
@@ -1119,10 +1112,10 b' define([' | |||
|
1119 | 1112 | }; |
|
1120 | 1113 | |
|
1121 | 1114 | /** |
|
1122 |
* Turn a cell into a markdown cell |
|
|
1115 | * Turn a cell into a heading containing markdown cell. | |
|
1123 | 1116 | * |
|
1124 |
* @param { |
|
|
1125 |
* @param { |
|
|
1117 | * @param {integer} [index] - cell index | |
|
1118 | * @param {integer} [level] - heading level (e.g., 1 for h1) | |
|
1126 | 1119 | */ |
|
1127 | 1120 | Notebook.prototype.to_heading = function (index, level) { |
|
1128 | 1121 | this.to_markdown(index); |
@@ -1139,7 +1132,7 b' define([' | |||
|
1139 | 1132 | // Cut/Copy/Paste |
|
1140 | 1133 | |
|
1141 | 1134 | /** |
|
1142 | * Enable UI elements for pasting cells. | |
|
1135 | * Enable the UI elements for pasting cells. | |
|
1143 | 1136 | */ |
|
1144 | 1137 | Notebook.prototype.enable_paste = function () { |
|
1145 | 1138 | var that = this; |
@@ -1155,7 +1148,7 b' define([' | |||
|
1155 | 1148 | }; |
|
1156 | 1149 | |
|
1157 | 1150 | /** |
|
1158 | * Disable UI elements for pasting cells. | |
|
1151 | * Disable the UI elements for pasting cells. | |
|
1159 | 1152 | */ |
|
1160 | 1153 | Notebook.prototype.disable_paste = function () { |
|
1161 | 1154 | if (this.paste_enabled) { |
@@ -1188,7 +1181,7 b' define([' | |||
|
1188 | 1181 | }; |
|
1189 | 1182 | |
|
1190 | 1183 | /** |
|
1191 |
* Replace the selected cell with |
|
|
1184 | * Replace the selected cell with the cell in the clipboard. | |
|
1192 | 1185 | */ |
|
1193 | 1186 | Notebook.prototype.paste_cell_replace = function () { |
|
1194 | 1187 | if (this.clipboard !== null && this.paste_enabled) { |
@@ -1228,7 +1221,7 b' define([' | |||
|
1228 | 1221 | // Split/merge |
|
1229 | 1222 | |
|
1230 | 1223 | /** |
|
1231 |
* Split the selected cell into two |
|
|
1224 | * Split the selected cell into two cells. | |
|
1232 | 1225 | */ |
|
1233 | 1226 | Notebook.prototype.split_cell = function () { |
|
1234 | 1227 | var cell = this.get_selected_cell(); |
@@ -1244,7 +1237,7 b' define([' | |||
|
1244 | 1237 | }; |
|
1245 | 1238 | |
|
1246 | 1239 | /** |
|
1247 |
* |
|
|
1240 | * Merge the selected cell into the cell above it. | |
|
1248 | 1241 | */ |
|
1249 | 1242 | Notebook.prototype.merge_cell_above = function () { |
|
1250 | 1243 | var index = this.get_selected_index(); |
@@ -1277,7 +1270,7 b' define([' | |||
|
1277 | 1270 | }; |
|
1278 | 1271 | |
|
1279 | 1272 | /** |
|
1280 |
* |
|
|
1273 | * Merge the selected cell into the cell below it. | |
|
1281 | 1274 | */ |
|
1282 | 1275 | Notebook.prototype.merge_cell_below = function () { |
|
1283 | 1276 | var index = this.get_selected_index(); |
@@ -1315,7 +1308,7 b' define([' | |||
|
1315 | 1308 | /** |
|
1316 | 1309 | * Hide a cell's output. |
|
1317 | 1310 | * |
|
1318 |
* @param {integer} index - |
|
|
1311 | * @param {integer} index - cell index | |
|
1319 | 1312 | */ |
|
1320 | 1313 | Notebook.prototype.collapse_output = function (index) { |
|
1321 | 1314 | var i = this.index_or_selected(index); |
@@ -1342,7 +1335,7 b' define([' | |||
|
1342 | 1335 | /** |
|
1343 | 1336 | * Show a cell's output. |
|
1344 | 1337 | * |
|
1345 |
* @param {integer} index - |
|
|
1338 | * @param {integer} index - cell index | |
|
1346 | 1339 | */ |
|
1347 | 1340 | Notebook.prototype.expand_output = function (index) { |
|
1348 | 1341 | var i = this.index_or_selected(index); |
@@ -1369,7 +1362,7 b' define([' | |||
|
1369 | 1362 | /** |
|
1370 | 1363 | * Clear the selected CodeCell's output area. |
|
1371 | 1364 | * |
|
1372 |
* @param {integer} index - |
|
|
1365 | * @param {integer} index - cell index | |
|
1373 | 1366 | */ |
|
1374 | 1367 | Notebook.prototype.clear_output = function (index) { |
|
1375 | 1368 | var i = this.index_or_selected(index); |
@@ -1395,7 +1388,7 b' define([' | |||
|
1395 | 1388 | /** |
|
1396 | 1389 | * Scroll the selected CodeCell's output area. |
|
1397 | 1390 | * |
|
1398 |
* @param {integer} index - |
|
|
1391 | * @param {integer} index - cell index | |
|
1399 | 1392 | */ |
|
1400 | 1393 | Notebook.prototype.scroll_output = function (index) { |
|
1401 | 1394 | var i = this.index_or_selected(index); |
@@ -1407,7 +1400,7 b' define([' | |||
|
1407 | 1400 | }; |
|
1408 | 1401 | |
|
1409 | 1402 | /** |
|
1410 |
* Expand each code cell's output area |
|
|
1403 | * Expand each code cell's output area and add a scrollbar for long output. | |
|
1411 | 1404 | */ |
|
1412 | 1405 | Notebook.prototype.scroll_all_output = function () { |
|
1413 | 1406 | this.get_cells().map(function (cell, i) { |
@@ -1419,9 +1412,10 b' define([' | |||
|
1419 | 1412 | this.set_dirty(true); |
|
1420 | 1413 | }; |
|
1421 | 1414 | |
|
1422 | /** Toggle whether a cell's output is collapsed or expanded. | |
|
1415 | /** | |
|
1416 | * Toggle whether a cell's output is collapsed or expanded. | |
|
1423 | 1417 | * |
|
1424 |
* @param {integer} index - |
|
|
1418 | * @param {integer} index - cell index | |
|
1425 | 1419 | */ |
|
1426 | 1420 | Notebook.prototype.toggle_output = function (index) { |
|
1427 | 1421 | var i = this.index_or_selected(index); |
@@ -1433,7 +1427,7 b' define([' | |||
|
1433 | 1427 | }; |
|
1434 | 1428 | |
|
1435 | 1429 | /** |
|
1436 |
* |
|
|
1430 | * Toggle the output of all cells. | |
|
1437 | 1431 | */ |
|
1438 | 1432 | Notebook.prototype.toggle_all_output = function () { |
|
1439 | 1433 | this.get_cells().map(function (cell, i) { |
@@ -1448,7 +1442,7 b' define([' | |||
|
1448 | 1442 | /** |
|
1449 | 1443 | * Toggle a scrollbar for long cell outputs. |
|
1450 | 1444 | * |
|
1451 |
* @param {integer} index - |
|
|
1445 | * @param {integer} index - cell index | |
|
1452 | 1446 | */ |
|
1453 | 1447 | Notebook.prototype.toggle_output_scroll = function (index) { |
|
1454 | 1448 | var i = this.index_or_selected(index); |
@@ -1540,7 +1534,7 b' define([' | |||
|
1540 | 1534 | |
|
1541 | 1535 | /** |
|
1542 | 1536 | * Once a session is started, link the code cells to the kernel and pass the |
|
1543 | * comm manager to the widget manager | |
|
1537 | * comm manager to the widget manager. | |
|
1544 | 1538 | */ |
|
1545 | 1539 | Notebook.prototype._session_started = function (){ |
|
1546 | 1540 | this._session_starting = false; |
@@ -1553,7 +1547,9 b' define([' | |||
|
1553 | 1547 | } |
|
1554 | 1548 | } |
|
1555 | 1549 | }; |
|
1550 | ||
|
1556 | 1551 | /** |
|
1552 | * Called when the session fails to start. | |
|
1557 | 1553 | */ |
|
1558 | 1554 |
Notebook.prototype._session_start_failed = function |
|
1559 | 1555 | this._session_starting = false; |
@@ -1676,8 +1672,8 b' define([' | |||
|
1676 | 1672 | /** |
|
1677 | 1673 | * Execute a contiguous range of cells. |
|
1678 | 1674 | * |
|
1679 |
* @param {integer} start - |
|
|
1680 |
* @param {integer} end - |
|
|
1675 | * @param {integer} start - index of the first cell to execute (inclusive) | |
|
1676 | * @param {integer} end - index of the last cell to execute (exclusive) | |
|
1681 | 1677 | */ |
|
1682 | 1678 | Notebook.prototype.execute_cell_range = function (start, end) { |
|
1683 | 1679 | this.command_mode(); |
@@ -1702,7 +1698,7 b' define([' | |||
|
1702 | 1698 | /** |
|
1703 | 1699 | * Setter method for this notebook's name. |
|
1704 | 1700 | * |
|
1705 |
* @param {string} name |
|
|
1701 | * @param {string} name | |
|
1706 | 1702 | */ |
|
1707 | 1703 | Notebook.prototype.set_notebook_name = function (name) { |
|
1708 | 1704 | var parent = utils.url_path_split(this.notebook_path)[0]; |
@@ -1728,7 +1724,7 b' define([' | |||
|
1728 | 1724 | /** |
|
1729 | 1725 | * Load a notebook from JSON (.ipynb). |
|
1730 | 1726 | * |
|
1731 |
* @param { |
|
|
1727 | * @param {object} data - JSON representation of a notebook | |
|
1732 | 1728 | */ |
|
1733 | 1729 | Notebook.prototype.fromJSON = function (data) { |
|
1734 | 1730 | |
@@ -1780,7 +1776,7 b' define([' | |||
|
1780 | 1776 | /** |
|
1781 | 1777 | * Dump this notebook into a JSON-friendly object. |
|
1782 | 1778 | * |
|
1783 |
* @return { |
|
|
1779 | * @return {object} A JSON-friendly representation of this notebook. | |
|
1784 | 1780 | */ |
|
1785 | 1781 | Notebook.prototype.toJSON = function () { |
|
1786 | 1782 | // remove the conversion indicator, which only belongs in-memory |
@@ -1812,7 +1808,7 b' define([' | |||
|
1812 | 1808 | }; |
|
1813 | 1809 | |
|
1814 | 1810 | /** |
|
1815 |
* Start an autosave timer |
|
|
1811 | * Start an autosave timer which periodically saves the notebook. | |
|
1816 | 1812 | * |
|
1817 | 1813 | * @param {integer} interval - the autosave interval in milliseconds |
|
1818 | 1814 | */ |
@@ -1883,7 +1879,7 b' define([' | |||
|
1883 | 1879 | * Success callback for saving a notebook. |
|
1884 | 1880 | * |
|
1885 | 1881 | * @param {integer} start - Time when the save request start |
|
1886 |
* @param { |
|
|
1882 | * @param {object} data - JSON representation of a notebook | |
|
1887 | 1883 | */ |
|
1888 | 1884 | Notebook.prototype.save_notebook_success = function (start, data) { |
|
1889 | 1885 | this.set_dirty(false); |
@@ -1920,7 +1916,7 b' define([' | |||
|
1920 | 1916 | }; |
|
1921 | 1917 | |
|
1922 | 1918 | /** |
|
1923 |
* |
|
|
1919 | * Update the autosave interval based on the duration of the last save. | |
|
1924 | 1920 | * |
|
1925 | 1921 | * @param {integer} timestamp - when the save request started |
|
1926 | 1922 | */ |
@@ -1988,7 +1984,6 b' define([' | |||
|
1988 | 1984 | |
|
1989 | 1985 | /** |
|
1990 | 1986 | * Make a copy of the current notebook. |
|
1991 | * @return {null} | |
|
1992 | 1987 | */ |
|
1993 | 1988 | Notebook.prototype.copy_notebook = function () { |
|
1994 | 1989 | var that = this; |
@@ -2009,7 +2004,7 b' define([' | |||
|
2009 | 2004 | }; |
|
2010 | 2005 | |
|
2011 | 2006 | /** |
|
2012 | * Rename the notebook | |
|
2007 | * Rename the notebook. | |
|
2013 | 2008 | * @param {string} new_name |
|
2014 | 2009 | * @return {Promise} promise that resolves when the notebook is renamed. |
|
2015 | 2010 | */ |
@@ -2033,7 +2028,6 b' define([' | |||
|
2033 | 2028 | |
|
2034 | 2029 | /** |
|
2035 | 2030 | * Delete this notebook |
|
2036 | * @return {null} | |
|
2037 | 2031 | */ |
|
2038 | 2032 | Notebook.prototype.delete = function () { |
|
2039 | 2033 | this.contents.delete(this.notebook_path); |
@@ -2059,7 +2053,7 b' define([' | |||
|
2059 | 2053 | * |
|
2060 | 2054 | * Load notebook data from the JSON response. |
|
2061 | 2055 | * |
|
2062 |
* @param { |
|
|
2056 | * @param {object} data JSON representation of a notebook | |
|
2063 | 2057 | */ |
|
2064 | 2058 | Notebook.prototype.load_notebook_success = function (data) { |
|
2065 | 2059 | var failed, msg; |
@@ -2220,7 +2214,7 b' define([' | |||
|
2220 | 2214 | }); |
|
2221 | 2215 | }; |
|
2222 | 2216 | |
|
2223 |
/********************* checkpoint-related ******************** |
|
|
2217 | /********************* checkpoint-related ********************/ | |
|
2224 | 2218 | |
|
2225 | 2219 | /** |
|
2226 | 2220 | * Save the notebook then immediately create a checkpoint. |
@@ -2232,7 +2226,6 b' define([' | |||
|
2232 | 2226 | |
|
2233 | 2227 | /** |
|
2234 | 2228 | * Add a checkpoint for this notebook. |
|
2235 | * for use as a callback from checkpoint creation. | |
|
2236 | 2229 | */ |
|
2237 | 2230 | Notebook.prototype.add_checkpoint = function (checkpoint) { |
|
2238 | 2231 | var found = false; |
@@ -2266,7 +2259,7 b' define([' | |||
|
2266 | 2259 | /** |
|
2267 | 2260 | * Success callback for listing checkpoints. |
|
2268 | 2261 | * |
|
2269 |
* @param { |
|
|
2262 | * @param {object} data - JSON representation of a checkpoint | |
|
2270 | 2263 | */ |
|
2271 | 2264 | Notebook.prototype.list_checkpoints_success = function (data) { |
|
2272 | 2265 | this.checkpoints = data; |
@@ -2294,7 +2287,7 b' define([' | |||
|
2294 | 2287 | /** |
|
2295 | 2288 | * Success callback for creating a checkpoint. |
|
2296 | 2289 | * |
|
2297 |
* @param { |
|
|
2290 | * @param {object} data - JSON representation of a checkpoint | |
|
2298 | 2291 | */ |
|
2299 | 2292 | Notebook.prototype.create_checkpoint_success = function (data) { |
|
2300 | 2293 | this.add_checkpoint(data); |
@@ -2304,7 +2297,6 b' define([' | |||
|
2304 | 2297 | /** |
|
2305 | 2298 | * Display the restore checkpoint dialog |
|
2306 | 2299 | * @param {string} checkpoint ID |
|
2307 | * @return {null} | |
|
2308 | 2300 | */ |
|
2309 | 2301 | Notebook.prototype.restore_checkpoint_dialog = function (checkpoint) { |
|
2310 | 2302 | var that = this; |
@@ -2388,7 +2380,7 b' define([' | |||
|
2388 | 2380 | }; |
|
2389 | 2381 | |
|
2390 | 2382 | /** |
|
2391 | * Success callback for deleting a notebook checkpoint | |
|
2383 | * Success callback for deleting a notebook checkpoint. | |
|
2392 | 2384 | */ |
|
2393 | 2385 | Notebook.prototype.delete_checkpoint_success = function () { |
|
2394 | 2386 | this.events.trigger('checkpoint_deleted.Notebook'); |
General Comments 0
You need to be logged in to leave comments.
Login now