##// END OF EJS Templates
Cells call grow by hand when they reload from JSON.
Brian Granger -
Show More
@@ -580,6 +580,23 b' var Cell = function (notebook) {'
580 580 };
581 581
582 582
583 Cell.prototype.grow = function(element) {
584 // Grow the cell by hand. This is used upon reloading from JSON, when the
585 // autogrow handler is not called.
586 var dom = element.get(0);
587 var lines_count = 0;
588 // modified split rule from
589 // http://stackoverflow.com/questions/2035910/how-to-get-the-number-of-lines-in-a-textarea/2036424#2036424
590 var lines = dom.value.split(/\r|\r\n|\n/);
591 lines_count = lines.length;
592 if (lines_count >= 1) {
593 dom.rows = lines_count;
594 } else {
595 dom.rows = 1;
596 }
597 };
598
599
583 600 Cell.prototype.select = function () {
584 601 this.element.addClass('ui-widget-content ui-corner-all');
585 602 this.selected = true;
@@ -658,6 +675,7 b' CodeCell.prototype.append_pyout = function (data, n) {'
658 675 };
659 676 };
660 677
678
661 679 CodeCell.prototype.append_pyerr = function (ename, evalue, tb) {
662 680 var s = '';
663 681 var len = tb.length;
@@ -752,6 +770,7 b' CodeCell.prototype.fromJSON = function (data) {'
752 770 if (data.cell_type === 'code') {
753 771 this.set_code(data.code);
754 772 this.set_input_prompt(data.prompt_number);
773 this.grow(this.element.find("textarea.input_textarea"));
755 774 };
756 775 };
757 776
@@ -853,6 +872,7 b' TextCell.prototype.set_text = function(text) {'
853 872 TextCell.prototype.fromJSON = function (data) {
854 873 if (data.cell_type === 'text') {
855 874 this.set_text(data.text);
875 this.grow(this.element.find("textarea.text_cell_input"));
856 876 };
857 877 }
858 878
General Comments 0
You need to be logged in to leave comments. Login now