Show More
@@ -377,7 +377,7 var IPython = (function (IPython) { | |||||
377 | Notebook.prototype.get_next_cell = function (cell) { |
|
377 | Notebook.prototype.get_next_cell = function (cell) { | |
378 | var result = null; |
|
378 | var result = null; | |
379 | var index = this.find_cell_index(cell); |
|
379 | var index = this.find_cell_index(cell); | |
380 | if (index !== null && index < this.ncells()) { |
|
380 | if (this.is_valid_cell_index(index+1)) { | |
381 | result = this.get_cell(index+1); |
|
381 | result = this.get_cell(index+1); | |
382 | } |
|
382 | } | |
383 | return result; |
|
383 | return result; | |
@@ -425,7 +425,7 var IPython = (function (IPython) { | |||||
425 |
|
425 | |||
426 |
|
426 | |||
427 | Notebook.prototype.is_valid_cell_index = function (index) { |
|
427 | Notebook.prototype.is_valid_cell_index = function (index) { | |
428 |
if (index != |
|
428 | if (index != undefined && index >= 0 && index < this.ncells()) { | |
429 | return true; |
|
429 | return true; | |
430 | } else { |
|
430 | } else { | |
431 | return false; |
|
431 | return false; | |
@@ -446,7 +446,7 var IPython = (function (IPython) { | |||||
446 | // Cell selection. |
|
446 | // Cell selection. | |
447 |
|
447 | |||
448 | Notebook.prototype.select = function (index) { |
|
448 | Notebook.prototype.select = function (index) { | |
449 | if (index !== undefined && index >= 0 && index < this.ncells()) { |
|
449 | if (this.is_valid_cell_index(index)) { | |
450 | var sindex = this.get_selected_index() |
|
450 | var sindex = this.get_selected_index() | |
451 | if (sindex !== null && index !== sindex) { |
|
451 | if (sindex !== null && index !== sindex) { | |
452 | this.get_cell(sindex).unselect(); |
|
452 | this.get_cell(sindex).unselect(); | |
@@ -469,18 +469,14 var IPython = (function (IPython) { | |||||
469 |
|
469 | |||
470 | Notebook.prototype.select_next = function () { |
|
470 | Notebook.prototype.select_next = function () { | |
471 | var index = this.get_selected_index(); |
|
471 | var index = this.get_selected_index(); | |
472 | if (index !== null && index >= 0 && (index+1) < this.ncells()) { |
|
472 | this.select(index+1); | |
473 | this.select(index+1); |
|
|||
474 | }; |
|
|||
475 | return this; |
|
473 | return this; | |
476 | }; |
|
474 | }; | |
477 |
|
475 | |||
478 |
|
476 | |||
479 | Notebook.prototype.select_prev = function () { |
|
477 | Notebook.prototype.select_prev = function () { | |
480 | var index = this.get_selected_index(); |
|
478 | var index = this.get_selected_index(); | |
481 | if (index !== null && index >= 0 && (index-1) < this.ncells()) { |
|
479 | this.select(index-1); | |
482 | this.select(index-1); |
|
|||
483 | }; |
|
|||
484 | return this; |
|
480 | return this; | |
485 | }; |
|
481 | }; | |
486 |
|
482 | |||
@@ -489,7 +485,7 var IPython = (function (IPython) { | |||||
489 |
|
485 | |||
490 | Notebook.prototype.move_cell_up = function (index) { |
|
486 | Notebook.prototype.move_cell_up = function (index) { | |
491 | var i = this.index_or_selected(); |
|
487 | var i = this.index_or_selected(); | |
492 |
if ( |
|
488 | if (this.is_valid_cell_index(index) && i > 0) { | |
493 | var pivot = this.get_cell_element(i-1); |
|
489 | var pivot = this.get_cell_element(i-1); | |
494 | var tomove = this.get_cell_element(i); |
|
490 | var tomove = this.get_cell_element(i); | |
495 | if (pivot !== null && tomove !== null) { |
|
491 | if (pivot !== null && tomove !== null) { | |
@@ -497,15 +493,15 var IPython = (function (IPython) { | |||||
497 | pivot.before(tomove); |
|
493 | pivot.before(tomove); | |
498 | this.select(i-1); |
|
494 | this.select(i-1); | |
499 | }; |
|
495 | }; | |
|
496 | this.dirty = true; | |||
500 | }; |
|
497 | }; | |
501 | this.dirty = true; |
|
|||
502 | return this; |
|
498 | return this; | |
503 | }; |
|
499 | }; | |
504 |
|
500 | |||
505 |
|
501 | |||
506 | Notebook.prototype.move_cell_down = function (index) { |
|
502 | Notebook.prototype.move_cell_down = function (index) { | |
507 | var i = this.index_or_selected(); |
|
503 | var i = this.index_or_selected(); | |
508 | if (i !== null && i < (this.ncells()-1) && i >= 0) { |
|
504 | if ( this.is_valid_cell_index(i) && this.is_valid_cell_index(i+1)) { | |
509 | var pivot = this.get_cell_element(i+1); |
|
505 | var pivot = this.get_cell_element(i+1); | |
510 | var tomove = this.get_cell_element(i); |
|
506 | var tomove = this.get_cell_element(i); | |
511 | if (pivot !== null && tomove !== null) { |
|
507 | if (pivot !== null && tomove !== null) { |
General Comments 0
You need to be logged in to leave comments.
Login now