##// END OF EJS Templates
some optimisation and code cleaning...
Matthias BUSSONNIER -
Show More
@@ -39,18 +39,28 b' var IPython = (function (IPython) {'
39 this.placeholder = options.placeholder || '';
39 this.placeholder = options.placeholder || '';
40 this.read_only = options.cm_config.readOnly;
40 this.read_only = options.cm_config.readOnly;
41 this.selected = false;
41 this.selected = false;
42 this.element = null;
43 this.metadata = {};
42 this.metadata = {};
44 // load this from metadata later ?
43 // load this from metadata later ?
45 this.user_highlight = 'auto';
44 this.user_highlight = 'auto';
46 this.cm_config = options.cm_config;
45 this.cm_config = options.cm_config;
46 this.cell_id = utils.uuid();
47 this._options = options;
48
49 // For JS VM engines optimisation, attributes should be all set (even
50 // to null) in the constructor, and if possible, if different subclass
51 // have new attributes with same name, they should be created in the
52 // same order. Easiest is to create and set to null in parent class.
53
54 this.element = null;
55 this.cell_type = null;
56 this.code_mirror = null;
57
58
47 this.create_element();
59 this.create_element();
48 if (this.element !== null) {
60 if (this.element !== null) {
49 this.element.data("cell", this);
61 this.element.data("cell", this);
50 this.bind_events();
62 this.bind_events();
51 }
63 }
52 this.cell_id = utils.uuid();
53 this._options = options;
54 };
64 };
55
65
56 Cell.options_default = {
66 Cell.options_default = {
@@ -309,7 +319,6 b' var IPython = (function (IPython) {'
309 }
319 }
310 if (mode.search('magic_') != 0) {
320 if (mode.search('magic_') != 0) {
311 this.code_mirror.setOption('mode', mode);
321 this.code_mirror.setOption('mode', mode);
312 console.log('from',current_mode,'to',mode)
313 CodeMirror.autoLoadMode(this.code_mirror, mode);
322 CodeMirror.autoLoadMode(this.code_mirror, mode);
314 return;
323 return;
315 }
324 }
@@ -336,7 +345,6 b' var IPython = (function (IPython) {'
336 );
345 );
337 });
346 });
338 this.code_mirror.setOption('mode', mmode);
347 this.code_mirror.setOption('mode', mmode);
339 console.log('from',current_mode,'to', mmode)
340 return;
348 return;
341 }
349 }
342 }
350 }
@@ -352,7 +360,6 b' var IPython = (function (IPython) {'
352 return
360 return
353 }
361 }
354 this.code_mirror.setOption('mode', default_mode);
362 this.code_mirror.setOption('mode', default_mode);
355 console.log('from',current_mode,'to', default_mode)
356 };
363 };
357
364
358 IPython.Cell = Cell;
365 IPython.Cell = Cell;
@@ -62,11 +62,17 b' var IPython = (function (IPython) {'
62 */
62 */
63 var CodeCell = function (kernel, options) {
63 var CodeCell = function (kernel, options) {
64 this.kernel = kernel || null;
64 this.kernel = kernel || null;
65 this.code_mirror = null;
66 this.input_prompt_number = null;
67 this.collapsed = false;
65 this.collapsed = false;
68 this.cell_type = "code";
66 this.cell_type = "code";
69
67
68 // create all attributed in constructor function
69 // even if null for V8 VM optimisation
70 this.input_prompt_number = null;
71 this.celltoolbar = null;
72 this.output_area = null;
73 this.last_msg_id = null;
74 this.completer = null;
75
70
76
71 var cm_overwrite_options = {
77 var cm_overwrite_options = {
72 onKeyEvent: $.proxy(this.handle_codemirror_keyevent,this)
78 onKeyEvent: $.proxy(this.handle_codemirror_keyevent,this)
@@ -129,13 +135,7 b' var IPython = (function (IPython) {'
129 cell.append(input).append(output);
135 cell.append(input).append(output);
130 this.element = cell;
136 this.element = cell;
131 this.output_area = new IPython.OutputArea(output, true);
137 this.output_area = new IPython.OutputArea(output, true);
132
138 this.completer = new IPython.Completer(this);
133 // construct a completer only if class exist
134 // otherwise no print view
135 if (IPython.Completer !== undefined)
136 {
137 this.completer = new IPython.Completer(this);
138 }
139 };
139 };
140
140
141 /**
141 /**
General Comments 0
You need to be logged in to leave comments. Login now