diff --git a/IPython/html/static/notebook/js/cell.js b/IPython/html/static/notebook/js/cell.js
index 01c2f15..3156fde 100644
--- a/IPython/html/static/notebook/js/cell.js
+++ b/IPython/html/static/notebook/js/cell.js
@@ -57,11 +57,6 @@ var IPython = (function (IPython) {
this.cell_type = this.cell_type || null;
this.code_mirror = null;
- // This is a list of callbacks that are called when a cell's textual
- // region is unfocused. If one of the callbacks returns True, the cell
- // unfocus event will be ignored. Callbacks will be passed no arguments.
- this.cancel_unfocus_callbacks = [];
-
this.create_element();
if (this.element !== null) {
this.element.data("cell", this);
@@ -80,8 +75,7 @@ var IPython = (function (IPython) {
// FIXME: Workaround CM Bug #332 (Safari segfault on drag)
// by disabling drag/drop altogether on Safari
- // https://github.com/marijnh/CodeMirror/issues/332
-
+ // https://github.com/marijnh/CodeMirror/issues/332
if (utils.browser[0] == "Safari") {
Cell.options_default.cm_config.dragDrop = false;
}
@@ -89,11 +83,8 @@ var IPython = (function (IPython) {
Cell.prototype.mergeopt = function(_class, options, overwrite){
options = options || {};
overwrite = overwrite || {};
- return $.extend(true, {}, _class.options_default, options, overwrite)
-
- }
-
-
+ return $.extend(true, {}, _class.options_default, options, overwrite);
+ };
/**
* Empty. Subclasses must implement create_element.
@@ -272,10 +263,6 @@ var IPython = (function (IPython) {
* Check if this cell's unfocus event was legit.
*/
Cell.prototype.should_cancel_unfocus = function () {
- // Try user registered callbacks.
- for (var i=0; i').addClass('text_cell_input border-box-sizing');
- this.code_mirror = CodeMirror(input_area.get(0), this.cm_config);
+ this.code_mirror = new CodeMirror(input_area.get(0), this.cm_config);
// The tabindex=-1 makes this div focusable.
var render_area = $('').addClass('text_cell_render border-box-sizing').
addClass('rendered_html').attr('tabindex','-1');
@@ -104,7 +104,7 @@ var IPython = (function (IPython) {
this.element.dblclick(function () {
if (that.selected === false) {
$([IPython.events]).trigger('select.Cell', {'cell':that});
- };
+ }
$([IPython.events]).trigger('edit_mode.Cell', {cell: that});
});
};
@@ -145,7 +145,7 @@ var IPython = (function (IPython) {
return false;
} else {
return true;
- };
+ }
} else if (event.which === key.DOWNARROW && event.type === 'keydown') {
// If we are not at the bottom, let CM handle the down arrow and
// prevent the global keydown handler from handling it.
@@ -154,7 +154,7 @@ var IPython = (function (IPython) {
return false;
} else {
return true;
- };
+ }
} else if (event.which === key.ESC && event.type === 'keydown') {
if (that.code_mirror.options.keyMap === "vim-insert") {
// vim keyMap is active and in insert mode. In this case we leave vim
@@ -179,7 +179,7 @@ var IPython = (function (IPython) {
if (this.mode === 'edit') {
this.code_mirror.refresh();
}
- };
+ }
return cont;
};
@@ -196,7 +196,7 @@ var IPython = (function (IPython) {
this.refresh();
}
- };
+ }
return cont;
};
@@ -204,14 +204,19 @@ var IPython = (function (IPython) {
this.render();
};
- TextCell.prototype.edit_mode = function () {
+ TextCell.prototype.edit_mode = function (focus_editor) {
var cont = IPython.Cell.prototype.edit_mode.apply(this);
if (cont) {
- this.unrender();
- this.focus_editor();
- };
+ cont = this.unrender();
+ // Focus the editor if codemirror was just added to the page or the
+ // caller explicitly wants to focus the editor (usally when the
+ // edit_mode was triggered by something other than a mouse click).
+ if (cont || focus_editor) {
+ this.focus_editor();
+ }
+ }
return cont;
- }
+ };
/**
* setter: {{#crossLink "TextCell/set_text"}}{{/crossLink}}
@@ -261,8 +266,8 @@ var IPython = (function (IPython) {
return true;
} else {
return false;
- };
- };
+ }
+ }
};
/**
@@ -278,8 +283,8 @@ var IPython = (function (IPython) {
return true;
} else {
return false;
- };
- };
+ }
+ }
};
/**
@@ -332,7 +337,7 @@ var IPython = (function (IPython) {
mode: 'gfm'
},
placeholder: "Type *Markdown* and LaTeX: $\\alpha^2$"
- }
+ };
MarkdownCell.prototype = new TextCell();
@@ -363,8 +368,8 @@ var IPython = (function (IPython) {
}
this.element.find('div.text_cell_input').hide();
this.element.find("div.text_cell_render").show();
- this.typeset()
- };
+ this.typeset();
+ }
return cont;
};
@@ -378,7 +383,7 @@ var IPython = (function (IPython) {
*/
var RawCell = function (options) {
- options = this.mergeopt(RawCell,options)
+ options = this.mergeopt(RawCell,options);
TextCell.apply(this, [options]);
this.cell_type = 'raw';
// RawCell should always hide its rendered div
@@ -396,7 +401,7 @@ var IPython = (function (IPython) {
/** @method bind_events **/
RawCell.prototype.bind_events = function () {
TextCell.prototype.bind_events.apply(this);
- var that = this
+ var that = this;
this.element.focusout(function() {
that.auto_highlight();
});
@@ -452,7 +457,7 @@ var IPython = (function (IPython) {
/** @method fromJSON */
HeadingCell.prototype.fromJSON = function (data) {
- if (data.level != undefined){
+ if (data.level !== undefined){
this.level = data.level;
}
TextCell.prototype.fromJSON.apply(this, arguments);
@@ -492,7 +497,7 @@ var IPython = (function (IPython) {
if (this.rendered) {
this.rendered = false;
this.render();
- };
+ }
};
/** The depth of header cell, based on html (h1 to h6)
@@ -544,7 +549,7 @@ var IPython = (function (IPython) {
this.element.find('div.text_cell_input').hide();
this.element.find("div.text_cell_render").show();
- };
+ }
return cont;
};