##// END OF EJS Templates
Use a property instead of a setter method
Jonathan Frederic -
Show More
@@ -45,7 +45,18 define([
45 this.selected = false;
45 this.selected = false;
46 this.rendered = false;
46 this.rendered = false;
47 this.mode = 'command';
47 this.mode = 'command';
48 this.metadata = {};
48
49 // Metadata property
50 var that = this;
51 this._metadata = {};
52 Object.defineProperty(this, 'metadata', {
53 get: function() { return that._metadata; },
54 set: function(value) {
55 that._metadata = value;
56 that.celltoolbar.rebuild();
57 }
58 });
59
49 // load this from metadata later ?
60 // load this from metadata later ?
50 this.user_highlight = 'auto';
61 this.user_highlight = 'auto';
51 this.cm_config = config.cm_config;
62 this.cm_config = config.cm_config;
@@ -392,16 +403,6 define([
392 */
403 */
393 Cell.prototype.set_text = function (text) {
404 Cell.prototype.set_text = function (text) {
394 };
405 };
395
396 /**
397 * Set the metadata of the cell and triggers the celltoolbars to update.
398 * @method set_metadata
399 * @param {dictionary} metadata
400 */
401 Cell.prototype.set_metadata = function (metadata) {
402 this.metadata = metadata;
403 this.celltoolbar.rebuild();
404 };
405
406
406 /**
407 /**
407 * should be overritten by subclass
408 * should be overritten by subclass
@@ -422,9 +423,8 define([
422 **/
423 **/
423 Cell.prototype.fromJSON = function (data) {
424 Cell.prototype.fromJSON = function (data) {
424 if (data.metadata !== undefined) {
425 if (data.metadata !== undefined) {
425 this.set_metadata(data.metadata);
426 this.metadata = data.metadata;
426 }
427 }
427 this.celltoolbar.rebuild();
428 };
428 };
429
429
430
430
@@ -995,7 +995,7 define([
995 text = '';
995 text = '';
996 }
996 }
997 //metadata
997 //metadata
998 target_cell.set_metadata(source_cell.metadata);
998 target_cell.metadata = source_cell.metadata;
999
999
1000 target_cell.set_text(text);
1000 target_cell.set_text(text);
1001 // make this value the starting point, so that we can only undo
1001 // make this value the starting point, so that we can only undo
@@ -1029,7 +1029,7 define([
1029 text = '';
1029 text = '';
1030 }
1030 }
1031 // metadata
1031 // metadata
1032 target_cell.set_metadata(source_cell.metadata);
1032 target_cell.metadata = source_cell.metadata;
1033 // We must show the editor before setting its contents
1033 // We must show the editor before setting its contents
1034 target_cell.unrender();
1034 target_cell.unrender();
1035 target_cell.set_text(text);
1035 target_cell.set_text(text);
@@ -1067,7 +1067,7 define([
1067 text = '';
1067 text = '';
1068 }
1068 }
1069 //metadata
1069 //metadata
1070 target_cell.set_metadata(source_cell.metadata);
1070 target_cell.metadata = source_cell.metadata;
1071 // We must show the editor before setting its contents
1071 // We must show the editor before setting its contents
1072 target_cell.unrender();
1072 target_cell.unrender();
1073 target_cell.set_text(text);
1073 target_cell.set_text(text);
General Comments 0
You need to be logged in to leave comments. Login now