##// 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 Notebook.prototype.is_valid_cell_index = function (index) {
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 return true;
429 return true;
430 } else {
430 } else {
431 return false;
431 return false;
@@ -483,9 +483,14 b' var IPython = (function (IPython) {'
483
483
484 // Cell movement
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 Notebook.prototype.move_cell_up = function (index) {
491 Notebook.prototype.move_cell_up = function (index) {
487 var i = this.index_or_selected();
492 var i = this.index_or_selected(index);
488 if (this.is_valid_cell_index(index) && i > 0) {
493 if (this.is_valid_cell_index(i) && i > 0) {
489 var pivot = this.get_cell_element(i-1);
494 var pivot = this.get_cell_element(i-1);
490 var tomove = this.get_cell_element(i);
495 var tomove = this.get_cell_element(i);
491 if (pivot !== null && tomove !== null) {
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 Notebook.prototype.move_cell_down = function (index) {
512 Notebook.prototype.move_cell_down = function (index) {
503 var i = this.index_or_selected();
513 var i = this.index_or_selected(index);
504 if ( this.is_valid_cell_index(i) && this.is_valid_cell_index(i+1)) {
514 if ( this.is_valid_cell_index(i) && this.is_valid_cell_index(i+1)) {
505 var pivot = this.get_cell_element(i+1);
515 var pivot = this.get_cell_element(i+1);
506 var tomove = this.get_cell_element(i);
516 var tomove = this.get_cell_element(i);
@@ -594,7 +604,7 b' var IPython = (function (IPython) {'
594 * return true if everything whent fine.
604 * return true if everything whent fine.
595 **/
605 **/
596 Notebook.prototype._insert_element_at_index = function(element, index){
606 Notebook.prototype._insert_element_at_index = function(element, index){
597 if (element == undefined){
607 if (element === undefined){
598 return false;
608 return false;
599 }
609 }
600
610
@@ -603,7 +613,7 b' var IPython = (function (IPython) {'
603 if (ncells === 0) {
613 if (ncells === 0) {
604 // special case append if empty
614 // special case append if empty
605 this.element.find('div.end_space').before(element);
615 this.element.find('div.end_space').before(element);
606 } else if ( ncells == index ) {
616 } else if ( ncells === index ) {
607 // special case append it the end, but not empty
617 // special case append it the end, but not empty
608 this.get_cell_element(index-1).after(element);
618 this.get_cell_element(index-1).after(element);
609 } else if (this.is_valid_cell_index(index)) {
619 } else if (this.is_valid_cell_index(index)) {
General Comments 0
You need to be logged in to leave comments. Login now