set cell_type properly first-class in the Cell object

- in toJSON
- don't clobber existing value in Cell constructor
This commit is contained in:
MinRK 2013-11-20 16:17:12 -08:00
parent f420b48aae
commit 9fc9580256
3 changed files with 3 additions and 4 deletions

View File

@ -52,7 +52,7 @@ var IPython = (function (IPython) {
// same order. Easiest is to create and set to null in parent class.
this.element = null;
this.cell_type = null;
this.cell_type = this.cell_type || null;
this.code_mirror = null;
@ -201,6 +201,7 @@ var IPython = (function (IPython) {
Cell.prototype.toJSON = function () {
var data = {};
data.metadata = this.metadata;
data.cell_type = this.cell_type;
return data;
};

View File

@ -444,7 +444,6 @@ var IPython = (function (IPython) {
CodeCell.prototype.toJSON = function () {
var data = IPython.Cell.prototype.toJSON.apply(this);
data.input = this.get_text();
data.cell_type = 'code';
// is finite protect against undefined and '*' value
if (isFinite(this.input_prompt_number)) {
data.prompt_number = this.input_prompt_number;

View File

@ -276,7 +276,6 @@ var IPython = (function (IPython) {
*/
TextCell.prototype.toJSON = function () {
var data = IPython.Cell.prototype.toJSON.apply(this);
data.cell_type = this.cell_type;
data.source = this.get_text();
if (data.source == this.placeholder) {
data.source = "";
@ -357,7 +356,7 @@ var IPython = (function (IPython) {
var that = this;
this.element.focusout(
function() { that.auto_highlight(); }
);
);
};
RawCell.options_default = {