##// END OF EJS Templates
fix i/index in move up/down and == -> ===
Matthias BUSSONNIER -
Show More
@@ -425,7 +425,7 b' var IPython = (function (IPython) {'
425 425
426 426
427 427 Notebook.prototype.is_valid_cell_index = function (index) {
428 if (index != undefined && index >= 0 && index < this.ncells()) {
428 if (index !== null && index >= 0 && index < this.ncells()) {
429 429 return true;
430 430 } else {
431 431 return false;
@@ -483,9 +483,14 b' var IPython = (function (IPython) {'
483 483
484 484 // Cell movement
485 485
486 /**
487 * Move given (or selected) cell up and select it
488 * @method move_cell_up
489 * @param [index] {integer} cell index
490 **/
486 491 Notebook.prototype.move_cell_up = function (index) {
487 var i = this.index_or_selected();
488 if (this.is_valid_cell_index(index) && i > 0) {
492 var i = this.index_or_selected(index);
493 if (this.is_valid_cell_index(i) && i > 0) {
489 494 var pivot = this.get_cell_element(i-1);
490 495 var tomove = this.get_cell_element(i);
491 496 if (pivot !== null && tomove !== null) {
@@ -499,8 +504,13 b' var IPython = (function (IPython) {'
499 504 };
500 505
501 506
507 /**
508 * Move given (or selected) cell down and select it
509 * @method move_cell_down
510 * @param [index] {integer} cell index
511 **/
502 512 Notebook.prototype.move_cell_down = function (index) {
503 var i = this.index_or_selected();
513 var i = this.index_or_selected(index);
504 514 if ( this.is_valid_cell_index(i) && this.is_valid_cell_index(i+1)) {
505 515 var pivot = this.get_cell_element(i+1);
506 516 var tomove = this.get_cell_element(i);
@@ -594,7 +604,7 b' var IPython = (function (IPython) {'
594 604 * return true if everything whent fine.
595 605 **/
596 606 Notebook.prototype._insert_element_at_index = function(element, index){
597 if (element == undefined){
607 if (element === undefined){
598 608 return false;
599 609 }
600 610
@@ -603,7 +613,7 b' var IPython = (function (IPython) {'
603 613 if (ncells === 0) {
604 614 // special case append if empty
605 615 this.element.find('div.end_space').before(element);
606 } else if ( ncells == index ) {
616 } else if ( ncells === index ) {
607 617 // special case append it the end, but not empty
608 618 this.get_cell_element(index-1).after(element);
609 619 } else if (this.is_valid_cell_index(index)) {
General Comments 0
You need to be logged in to leave comments. Login now