##// END OF EJS Templates
Some clean-up
Jonathan Frederic -
Show More
@@ -50,7 +50,7 b' define(['
50 50 /**
51 51 * Contains and manages cells.
52 52 * @class Notebook
53 * @param {String} selector
53 * @param {string} selector
54 54 * @param {dictionary} options - Dictionary of keyword arguments.
55 55 * events: $(Events) instance
56 56 * keyboard_manager: KeyboardManager instance
@@ -315,7 +315,7 b' define(['
315 315 };
316 316
317 317 /**
318 * trigger a warning dialog about missing functionality from newer minor versions
318 * Trigger a warning dialog about missing functionality from newer minor versions
319 319 */
320 320 Notebook.prototype.warn_nbformat_minor = function (event) {
321 321 var v = 'v' + this.nbformat + '.';
@@ -354,9 +354,9 b' define(['
354 354 /**
355 355 * Scroll the top of the page to a given cell.
356 356 *
357 * @param {Number} cell_number An index of the cell to view
358 * @param {Number} time Animation time in milliseconds
359 * @return {Number} Pixel offset from the top of the container
357 * @param {number} cell_number An index of the cell to view
358 * @param {number} time Animation time in milliseconds
359 * @return {number} Pixel offset from the top of the container
360 360 */
361 361 Notebook.prototype.scroll_to_cell = function (cell_number, time) {
362 362 var cells = this.get_cells();
@@ -384,6 +384,10 b' define(['
384 384
385 385 // Edit Notebook metadata
386 386
387 /**
388 * Display a dialog that allows the user to edit the Notebook's metadata.
389 * @return {null}
390 */
387 391 Notebook.prototype.edit_metadata = function () {
388 392 var that = this;
389 393 dialog.edit_metadata({
@@ -410,7 +414,7 b' define(['
410 414 /**
411 415 * Get a particular cell element.
412 416 *
413 * @param {Number} index An index of a cell to select
417 * @param {number} index An index of a cell to select
414 418 * @return {jQuery} A selector of the given cell.
415 419 */
416 420 Notebook.prototype.get_cell_element = function (index) {
@@ -425,7 +429,7 b' define(['
425 429 /**
426 430 * Try to get a particular cell by msg_id.
427 431 *
428 * @param {String} msg_id A message UUID
432 * @param {string} msg_id A message UUID
429 433 * @return {Cell} Cell or null if no cell was found.
430 434 */
431 435 Notebook.prototype.get_msg_cell = function (msg_id) {
@@ -435,7 +439,7 b' define(['
435 439 /**
436 440 * Count the cells in this notebook.
437 441 *
438 * @return {Number} The number of cells in this notebook
442 * @return {number} The number of cells in this notebook
439 443 */
440 444 Notebook.prototype.ncells = function () {
441 445 return this.get_cell_elements().length;
@@ -457,7 +461,7 b' define(['
457 461 /**
458 462 * Get a Cell object from this notebook.
459 463 *
460 * @param {Number} index An index of a cell to retrieve
464 * @param {number} index An index of a cell to retrieve
461 465 * @return {Cell} Cell or null if no cell was found.
462 466 */
463 467 Notebook.prototype.get_cell = function (index) {
@@ -503,7 +507,7 b' define(['
503 507 * Get the numeric index of a given cell.
504 508 *
505 509 * @param {Cell} cell The provided cell
506 * @return {Number} The cell's numeric index or null if no cell was found.
510 * @return {number} The cell's numeric index or null if no cell was found.
507 511 */
508 512 Notebook.prototype.find_cell_index = function (cell) {
509 513 var result = null;
@@ -518,8 +522,8 b' define(['
518 522 /**
519 523 * Get a given index , or the selected index if none is provided.
520 524 *
521 * @param {Number} index A cell's index
522 * @return {Number} The given index, or selected index if none is provided.
525 * @param {number} index A cell's index
526 * @return {number} The given index, or selected index if none is provided.
523 527 */
524 528 Notebook.prototype.index_or_selected = function (index) {
525 529 var i;
@@ -546,7 +550,7 b' define(['
546 550 /**
547 551 * Check whether a cell index is valid.
548 552 *
549 * @param {Number} index A cell index
553 * @param {number} index A cell index
550 554 * @return True if the index is valid, false otherwise
551 555 */
552 556 Notebook.prototype.is_valid_cell_index = function (index) {
@@ -560,7 +564,7 b' define(['
560 564 /**
561 565 * Get the index of the currently selected cell.
562 566
563 * @return {Number} The selected cell's numeric index
567 * @return {number} The selected cell's numeric index
564 568 */
565 569 Notebook.prototype.get_selected_index = function () {
566 570 var result = null;
@@ -578,7 +582,7 b' define(['
578 582 /**
579 583 * Programmatically select a cell.
580 584 *
581 * @param {Number} index A cell's index
585 * @param {number} index A cell's index
582 586 * @return {Notebook} This notebook
583 587 */
584 588 Notebook.prototype.select = function (index) {
@@ -635,7 +639,7 b' define(['
635 639 /**
636 640 * Gets the index of the cell that is in edit mode.
637 641 *
638 * @return index {int}
642 * @return index {integer}
639 643 **/
640 644 Notebook.prototype.get_edit_index = function () {
641 645 var result = null;
@@ -650,7 +654,7 b' define(['
650 654 /**
651 655 * Handle when a a cell blurs and the notebook should enter command mode.
652 656 *
653 * @param [cell] {Cell} Cell to enter command mode on.
657 * @param {Cell} [cell] Cell to enter command mode on.
654 658 **/
655 659 Notebook.prototype.handle_command_mode = function (cell) {
656 660 if (this.mode !== 'command') {
@@ -677,7 +681,7 b' define(['
677 681 /**
678 682 * Handle when a cell fires it's edit_mode event.
679 683 *
680 * @param [cell] {Cell} Cell to enter edit mode on.
684 * @param {Cell} [cell] Cell to enter edit mode on.
681 685 **/
682 686 Notebook.prototype.handle_edit_mode = function (cell) {
683 687 if (cell && this.mode !== 'edit') {
@@ -713,7 +717,7 b' define(['
713 717 /**
714 718 * Move given (or selected) cell up and select it.
715 719 *
716 * @param [index] {integer} cell index
720 * @param {integer} [index] cell index
717 721 * @return {Notebook} This notebook
718 722 **/
719 723 Notebook.prototype.move_cell_up = function (index) {
@@ -737,7 +741,7 b' define(['
737 741 /**
738 742 * Move given (or selected) cell down and select it
739 743 *
740 * @param [index] {integer} cell index
744 * @param {integer} [index] cell index
741 745 * @return {Notebook} This notebook
742 746 **/
743 747 Notebook.prototype.move_cell_down = function (index) {
@@ -763,7 +767,7 b' define(['
763 767 /**
764 768 * Delete a cell from the notebook.
765 769 *
766 * @param [index] A cell's numeric index
770 * @param {integer} [index] cell's numeric index
767 771 * @return {Notebook} This notebook
768 772 */
769 773 Notebook.prototype.delete_cell = function (index) {
@@ -846,10 +850,10 b' define(['
846 850 *
847 851 * Index will be brought back into the accessible range [0,n]
848 852 *
849 * @param [type] {string} in ['code','markdown', 'raw'], defaults to 'code'
850 * @param [index] {int} a valid index where to insert cell
853 * @param {string} [type] in ['code','markdown', 'raw'], defaults to 'code'
854 * @param {integer} [index] a valid index where to insert cell
851 855 *
852 * @return cell {cell|null} created cell or null
856 * @return {Cell|null} created cell or null
853 857 **/
854 858 Notebook.prototype.insert_cell_at_index = function(type, index){
855 859
@@ -917,9 +921,9 b' define(['
917 921 * Insert an element at given cell index.
918 922 * return true if everything whent fine.
919 923 *
920 * @param element {dom_element} a cell element
921 * @param [index] {int} a valid index where to inser cell
922 924 * @private
925 * @param {HTMLElement} element - a cell element
926 * @param {integer} [index] a valid index where to inser cell
923 927 **/
924 928 Notebook.prototype._insert_element_at_index = function(element, index){
925 929 if (element === undefined){
@@ -954,10 +958,10 b' define(['
954 958 *
955 959 * default index value is the one of currently selected cell
956 960 *
957 * @param [type] {string} cell type
958 * @param [index] {integer}
961 * @param {string} [type] cell type
962 * @param {integer} [index]
959 963 *
960 * @return handle to created cell or null
964 * @return {Cell|null} handle to created cell or null
961 965 **/
962 966 Notebook.prototype.insert_cell_above = function (type, index) {
963 967 index = this.index_or_selected(index);
@@ -970,10 +974,10 b' define(['
970 974 *
971 975 * default index value is the one of currently selected cell
972 976 *
973 * @param [type] {string} cell type
974 * @param [index] {integer}
977 * @param {string} [type] cell type
978 * @param {integer} [index]
975 979 *
976 * @return handle to created cell or null
980 * @return {Cell|null} handle to created cell or null
977 981 **/
978 982 Notebook.prototype.insert_cell_below = function (type, index) {
979 983 index = this.index_or_selected(index);
@@ -984,9 +988,9 b' define(['
984 988 /**
985 989 * Insert cell at end of notebook
986 990 *
987 * @param {String} type cell type
991 * @param {string} type cell type
988 992 *
989 * @return the added cell; or null
993 * @return {Cell|null} the added cell; or null
990 994 **/
991 995 Notebook.prototype.insert_cell_at_bottom = function (type){
992 996 var len = this.ncells();
@@ -996,7 +1000,7 b' define(['
996 1000 /**
997 1001 * Turn a cell into a code cell.
998 1002 *
999 * @param {Number} [index] A cell's index
1003 * @param {number} [index] A cell's index
1000 1004 */
1001 1005 Notebook.prototype.to_code = function (index) {
1002 1006 var i = this.index_or_selected(index);
@@ -1027,7 +1031,7 b' define(['
1027 1031 /**
1028 1032 * Turn a cell into a Markdown cell.
1029 1033 *
1030 * @param {Number} [index] A cell's index
1034 * @param {number} [index] A cell's index
1031 1035 */
1032 1036 Notebook.prototype.to_markdown = function (index) {
1033 1037 var i = this.index_or_selected(index);
@@ -1064,7 +1068,7 b' define(['
1064 1068 /**
1065 1069 * Turn a cell into a raw text cell.
1066 1070 *
1067 * @param {Number} [index] A cell's index
1071 * @param {number} [index] A cell's index
1068 1072 */
1069 1073 Notebook.prototype.to_raw = function (index) {
1070 1074 var i = this.index_or_selected(index);
@@ -1095,11 +1099,11 b' define(['
1095 1099 }
1096 1100 };
1097 1101
1098 Notebook.prototype._warn_heading = function () {
1099 1102 /**
1100 1103 * warn about heading cells being removed
1101 1104 * @private
1102 1105 */
1106 Notebook.prototype._warn_heading = function () {
1103 1107 dialog.modal({
1104 1108 notebook: this,
1105 1109 keyboard_manager: this.keyboard_manager,
@@ -1116,13 +1120,13 b' define(['
1116 1120 });
1117 1121 };
1118 1122
1119 Notebook.prototype.to_heading = function (index, level) {
1120 1123 /**
1121 1124 * Turn a cell into a markdown cell with a heading.
1122 1125 *
1123 * @param {Number} [index] A cell's index
1124 * @param {Number} [level] A heading level (e.g., 1 for h1)
1126 * @param {number} [index] A cell's index
1127 * @param {number} [level] A heading level (e.g., 1 for h1)
1125 1128 */
1129 Notebook.prototype.to_heading = function (index, level) {
1126 1130 this.to_markdown(index);
1127 1131 level = level || 1;
1128 1132 var i = this.index_or_selected(index);
@@ -1313,7 +1317,7 b' define(['
1313 1317 /**
1314 1318 * Hide a cell's output.
1315 1319 *
1316 * @param {Number} index A cell's numeric index
1320 * @param {integer} index - A cell's numeric index
1317 1321 */
1318 1322 Notebook.prototype.collapse_output = function (index) {
1319 1323 var i = this.index_or_selected(index);
@@ -1340,7 +1344,7 b' define(['
1340 1344 /**
1341 1345 * Show a cell's output.
1342 1346 *
1343 * @param {Number} index A cell's numeric index
1347 * @param {integer} index - A cell's numeric index
1344 1348 */
1345 1349 Notebook.prototype.expand_output = function (index) {
1346 1350 var i = this.index_or_selected(index);
@@ -1367,7 +1371,7 b' define(['
1367 1371 /**
1368 1372 * Clear the selected CodeCell's output area.
1369 1373 *
1370 * @param {Number} index A cell's numeric index
1374 * @param {integer} index - A cell's numeric index
1371 1375 */
1372 1376 Notebook.prototype.clear_output = function (index) {
1373 1377 var i = this.index_or_selected(index);
@@ -1393,7 +1397,7 b' define(['
1393 1397 /**
1394 1398 * Scroll the selected CodeCell's output area.
1395 1399 *
1396 * @param {Number} index A cell's numeric index
1400 * @param {integer} index - A cell's numeric index
1397 1401 */
1398 1402 Notebook.prototype.scroll_output = function (index) {
1399 1403 var i = this.index_or_selected(index);
@@ -1419,7 +1423,7 b' define(['
1419 1423
1420 1424 /** Toggle whether a cell's output is collapsed or expanded.
1421 1425 *
1422 * @param {Number} index A cell's numeric index
1426 * @param {integer} index - A cell's numeric index
1423 1427 */
1424 1428 Notebook.prototype.toggle_output = function (index) {
1425 1429 var i = this.index_or_selected(index);
@@ -1446,7 +1450,7 b' define(['
1446 1450 /**
1447 1451 * Toggle a scrollbar for long cell outputs.
1448 1452 *
1449 * @param {Number} index A cell's numeric index
1453 * @param {integer} index - A cell's numeric index
1450 1454 */
1451 1455 Notebook.prototype.toggle_output_scroll = function (index) {
1452 1456 var i = this.index_or_selected(index);
@@ -1676,8 +1680,8 b' define(['
1676 1680 /**
1677 1681 * Execute a contiguous range of cells.
1678 1682 *
1679 * @param {Number} start Index of the first cell to execute (inclusive)
1680 * @param {Number} end Index of the last cell to execute (exclusive)
1683 * @param {integer} start - Index of the first cell to execute (inclusive)
1684 * @param {integer} end - Index of the last cell to execute (exclusive)
1681 1685 */
1682 1686 Notebook.prototype.execute_cell_range = function (start, end) {
1683 1687 this.command_mode();
@@ -1692,7 +1696,7 b' define(['
1692 1696 /**
1693 1697 * Getter method for this notebook's name.
1694 1698 *
1695 * @return {String} This notebook's name (excluding file extension)
1699 * @return {string} This notebook's name (excluding file extension)
1696 1700 */
1697 1701 Notebook.prototype.get_notebook_name = function () {
1698 1702 var nbname = this.notebook_name.substring(0,this.notebook_name.length-6);
@@ -1702,7 +1706,7 b' define(['
1702 1706 /**
1703 1707 * Setter method for this notebook's name.
1704 1708 *
1705 * @param {String} name A new name for this notebook
1709 * @param {string} name A new name for this notebook
1706 1710 */
1707 1711 Notebook.prototype.set_notebook_name = function (name) {
1708 1712 var parent = utils.url_path_split(this.notebook_path)[0];
@@ -1713,8 +1717,8 b' define(['
1713 1717 /**
1714 1718 * Check that a notebook's name is valid.
1715 1719 *
1716 * @param {String} nbname A name for this notebook
1717 * @return {Boolean} True if the name is valid, false if invalid
1720 * @param {string} nbname - A name for this notebook
1721 * @return {boolean} True if the name is valid, false if invalid
1718 1722 */
1719 1723 Notebook.prototype.test_notebook_name = function (nbname) {
1720 1724 nbname = nbname || '';
@@ -1728,7 +1732,7 b' define(['
1728 1732 /**
1729 1733 * Load a notebook from JSON (.ipynb).
1730 1734 *
1731 * @param {Object} data JSON representation of a notebook
1735 * @param {Object} data - JSON representation of a notebook
1732 1736 */
1733 1737 Notebook.prototype.fromJSON = function (data) {
1734 1738
@@ -1814,7 +1818,7 b' define(['
1814 1818 /**
1815 1819 * Start an autosave timer, for periodically saving the notebook.
1816 1820 *
1817 * @param {Integer} interval the autosave interval in milliseconds
1821 * @param {integer} interval - the autosave interval in milliseconds
1818 1822 */
1819 1823 Notebook.prototype.set_autosave_interval = function (interval) {
1820 1824 var that = this;
@@ -1882,8 +1886,8 b' define(['
1882 1886 /**
1883 1887 * Success callback for saving a notebook.
1884 1888 *
1885 * @param {Integer} start Time when the save request start
1886 * @param {Object} data JSON representation of a notebook
1889 * @param {integer} start - Time when the save request start
1890 * @param {Object} data - JSON representation of a notebook
1887 1891 */
1888 1892 Notebook.prototype.save_notebook_success = function (start, data) {
1889 1893 this.set_dirty(false);
@@ -1922,7 +1926,7 b' define(['
1922 1926 /**
1923 1927 * update the autosave interval based on how long the last save took
1924 1928 *
1925 * @param {Integer} timestamp when the save request started
1929 * @param {integer} timestamp - when the save request started
1926 1930 * @private
1927 1931 */
1928 1932 Notebook.prototype._update_autosave_interval = function (start) {
@@ -1941,7 +1945,6 b' define(['
1941 1945
1942 1946 /**
1943 1947 * Explicitly trust the output of this notebook.
1944 *
1945 1948 */
1946 1949 Notebook.prototype.trust_notebook = function () {
1947 1950 var body = $("<div>").append($("<p>")
@@ -2044,7 +2047,7 b' define(['
2044 2047 /**
2045 2048 * Request a notebook's data from the server.
2046 2049 *
2047 * @param {String} notebook_path A notebook to load
2050 * @param {string} notebook_path - A notebook to load
2048 2051 */
2049 2052 Notebook.prototype.load_notebook = function (notebook_path) {
2050 2053 this.notebook_path = notebook_path;
@@ -2268,7 +2271,7 b' define(['
2268 2271 /**
2269 2272 * Success callback for listing checkpoints.
2270 2273 *
2271 * @param {Object} data JSON representation of a checkpoint
2274 * @param {Object} data - JSON representation of a checkpoint
2272 2275 */
2273 2276 Notebook.prototype.list_checkpoints_success = function (data) {
2274 2277 this.checkpoints = data;
@@ -2296,13 +2299,18 b' define(['
2296 2299 /**
2297 2300 * Success callback for creating a checkpoint.
2298 2301 *
2299 * @param {Object} data JSON representation of a checkpoint
2302 * @param {Object} data - JSON representation of a checkpoint
2300 2303 */
2301 2304 Notebook.prototype.create_checkpoint_success = function (data) {
2302 2305 this.add_checkpoint(data);
2303 2306 this.events.trigger('checkpoint_created.Notebook', data);
2304 2307 };
2305 2308
2309 /**
2310 * Display the restore checkpoint dialog
2311 * @param {string} checkpoint ID
2312 * @return {null}
2313 */
2306 2314 Notebook.prototype.restore_checkpoint_dialog = function (checkpoint) {
2307 2315 var that = this;
2308 2316 checkpoint = checkpoint || this.last_checkpoint;
@@ -2347,7 +2355,7 b' define(['
2347 2355 /**
2348 2356 * Restore the notebook to a checkpoint state.
2349 2357 *
2350 * @param {String} checkpoint ID
2358 * @param {string} checkpoint ID
2351 2359 */
2352 2360 Notebook.prototype.restore_checkpoint = function (checkpoint) {
2353 2361 this.events.trigger('notebook_restoring.Notebook', checkpoint);
@@ -2371,7 +2379,7 b' define(['
2371 2379 /**
2372 2380 * Delete a notebook checkpoint.
2373 2381 *
2374 * @param {String} checkpoint ID
2382 * @param {string} checkpoint ID
2375 2383 */
2376 2384 Notebook.prototype.delete_checkpoint = function (checkpoint) {
2377 2385 this.events.trigger('notebook_restoring.Notebook', checkpoint);
General Comments 0
You need to be logged in to leave comments. Login now