##// END OF EJS Templates
Merge pull request #4515 from Carreau/load-speedup...
Min RK -
r13580:af808396 merge
parent child Browse files
Show More
@@ -39,18 +39,28 b' var IPython = (function (IPython) {'
39 39 this.placeholder = options.placeholder || '';
40 40 this.read_only = options.cm_config.readOnly;
41 41 this.selected = false;
42 this.element = null;
43 42 this.metadata = {};
44 43 // load this from metadata later ?
45 44 this.user_highlight = 'auto';
46 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 59 this.create_element();
48 60 if (this.element !== null) {
49 61 this.element.data("cell", this);
50 62 this.bind_events();
51 63 }
52 this.cell_id = utils.uuid();
53 this._options = options;
54 64 };
55 65
56 66 Cell.options_default = {
@@ -295,6 +305,7 b' var IPython = (function (IPython) {'
295 305 this.code_mirror.setOption('mode', mode);
296 306 return;
297 307 }
308 var current_mode = this.code_mirror.getOption('mode', mode);
298 309 var first_line = this.code_mirror.getLine(0);
299 310 // loop on every pairs
300 311 for( var mode in modes) {
@@ -303,6 +314,9 b' var IPython = (function (IPython) {'
303 314 for(var reg in regs ) {
304 315 // here we handle non magic_modes
305 316 if(first_line.match(regs[reg]) != null) {
317 if(current_mode == mode){
318 return;
319 }
306 320 if (mode.search('magic_') != 0) {
307 321 this.code_mirror.setOption('mode', mode);
308 322 CodeMirror.autoLoadMode(this.code_mirror, mode);
@@ -312,6 +326,9 b' var IPython = (function (IPython) {'
312 326 var close = modes[mode]['close']|| "%%end";
313 327 var mmode = mode;
314 328 mode = mmode.substr(6);
329 if(current_mode == mode){
330 return;
331 }
315 332 CodeMirror.autoLoadMode(this.code_mirror, mode);
316 333 // create on the fly a mode that swhitch between
317 334 // plain/text and smth else otherwise `%%` is
@@ -339,6 +356,9 b' var IPython = (function (IPython) {'
339 356 } catch(e) {
340 357 default_mode = 'text/plain';
341 358 }
359 if( current_mode === default_mode){
360 return
361 }
342 362 this.code_mirror.setOption('mode', default_mode);
343 363 };
344 364
@@ -62,11 +62,17 b' var IPython = (function (IPython) {'
62 62 */
63 63 var CodeCell = function (kernel, options) {
64 64 this.kernel = kernel || null;
65 this.code_mirror = null;
66 this.input_prompt_number = null;
67 65 this.collapsed = false;
68 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 77 var cm_overwrite_options = {
72 78 onKeyEvent: $.proxy(this.handle_codemirror_keyevent,this)
@@ -129,13 +135,7 b' var IPython = (function (IPython) {'
129 135 cell.append(input).append(output);
130 136 this.element = cell;
131 137 this.output_area = new IPython.OutputArea(output, true);
132
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 }
138 this.completer = new IPython.Completer(this);
139 139 };
140 140
141 141 /**
@@ -202,8 +202,10 b' var IPython = (function (IPython) {'
202 202 return true;
203 203 } else if (event.keyCode === key.TAB && event.type == 'keydown') {
204 204 // Tab completion.
205 //Do not trim here because of tooltip
206 if (editor.somethingSelected()) { return false; }
205 IPython.tooltip.remove_and_cancel_tooltip();
206 if (editor.somethingSelected()) {
207 return false;
208 }
207 209 var pre_cursor = editor.getRange({line:cur.line,ch:0},cur);
208 210 if (pre_cursor.trim() === "") {
209 211 // Don't autocomplete if the part of the line before the cursor
@@ -443,7 +445,8 b' var IPython = (function (IPython) {'
443 445 var data = IPython.Cell.prototype.toJSON.apply(this);
444 446 data.input = this.get_text();
445 447 data.cell_type = 'code';
446 if (this.input_prompt_number) {
448 // is finite protect against undefined and '*' value
449 if (isFinite(this.input_prompt_number)) {
447 450 data.prompt_number = this.input_prompt_number;
448 451 }
449 452 var outputs = this.output_area.toJSON();
@@ -1588,7 +1588,7 b' var IPython = (function (IPython) {'
1588 1588 cell_data.cell_type = 'raw';
1589 1589 }
1590 1590
1591 new_cell = this.insert_cell_below(cell_data.cell_type);
1591 new_cell = this.insert_cell_at_bottom(cell_data.cell_type);
1592 1592 new_cell.fromJSON(cell_data);
1593 1593 };
1594 1594 };
@@ -576,12 +576,13 b' var IPython = (function (IPython) {'
576 576
577 577 OutputArea.prototype.append_png = function (png, md, element) {
578 578 var toinsert = this.create_output_subarea(md, "output_png");
579 var img = $("<img/>").attr('src','data:image/png;base64,'+png);
579 var img = $("<img/>");
580 img[0].setAttribute('src','data:image/png;base64,'+png);
580 581 if (md['height']) {
581 img.attr('height', md['height']);
582 img[0].setAttribute('height', md['height']);
582 583 }
583 584 if (md['width']) {
584 img.attr('width', md['width']);
585 img[0].setAttribute('width', md['width']);
585 586 }
586 587 this._dblclick_to_reset_size(img);
587 588 toinsert.append(img);
General Comments 0
You need to be logged in to leave comments. Login now