mirror of
https://github.com/jupyter/notebook.git
synced 2025-01-24 12:05:22 +08:00
Use a property instead of a setter method
This commit is contained in:
parent
bfdf9596fd
commit
f2b6697098
@ -45,7 +45,18 @@ define([
|
||||
this.selected = false;
|
||||
this.rendered = false;
|
||||
this.mode = 'command';
|
||||
this.metadata = {};
|
||||
|
||||
// Metadata property
|
||||
var that = this;
|
||||
this._metadata = {};
|
||||
Object.defineProperty(this, 'metadata', {
|
||||
get: function() { return that._metadata; },
|
||||
set: function(value) {
|
||||
that._metadata = value;
|
||||
that.celltoolbar.rebuild();
|
||||
}
|
||||
});
|
||||
|
||||
// load this from metadata later ?
|
||||
this.user_highlight = 'auto';
|
||||
this.cm_config = config.cm_config;
|
||||
@ -392,16 +403,6 @@ define([
|
||||
*/
|
||||
Cell.prototype.set_text = function (text) {
|
||||
};
|
||||
|
||||
/**
|
||||
* Set the metadata of the cell and triggers the celltoolbars to update.
|
||||
* @method set_metadata
|
||||
* @param {dictionary} metadata
|
||||
*/
|
||||
Cell.prototype.set_metadata = function (metadata) {
|
||||
this.metadata = metadata;
|
||||
this.celltoolbar.rebuild();
|
||||
};
|
||||
|
||||
/**
|
||||
* should be overritten by subclass
|
||||
@ -422,9 +423,8 @@ define([
|
||||
**/
|
||||
Cell.prototype.fromJSON = function (data) {
|
||||
if (data.metadata !== undefined) {
|
||||
this.set_metadata(data.metadata);
|
||||
this.metadata = data.metadata;
|
||||
}
|
||||
this.celltoolbar.rebuild();
|
||||
};
|
||||
|
||||
|
||||
|
@ -995,7 +995,7 @@ define([
|
||||
text = '';
|
||||
}
|
||||
//metadata
|
||||
target_cell.set_metadata(source_cell.metadata);
|
||||
target_cell.metadata = source_cell.metadata;
|
||||
|
||||
target_cell.set_text(text);
|
||||
// make this value the starting point, so that we can only undo
|
||||
@ -1029,7 +1029,7 @@ define([
|
||||
text = '';
|
||||
}
|
||||
// metadata
|
||||
target_cell.set_metadata(source_cell.metadata);
|
||||
target_cell.metadata = source_cell.metadata;
|
||||
// We must show the editor before setting its contents
|
||||
target_cell.unrender();
|
||||
target_cell.set_text(text);
|
||||
@ -1067,7 +1067,7 @@ define([
|
||||
text = '';
|
||||
}
|
||||
//metadata
|
||||
target_cell.set_metadata(source_cell.metadata);
|
||||
target_cell.metadata = source_cell.metadata;
|
||||
// We must show the editor before setting its contents
|
||||
target_cell.unrender();
|
||||
target_cell.set_text(text);
|
||||
|
Loading…
Reference in New Issue
Block a user