mirror of
https://github.com/jupyter/notebook.git
synced 2024-12-21 04:10:17 +08:00
DEBUG
Added lots of log calls and a couple small 'fixes' (attempts)
This commit is contained in:
parent
7913305312
commit
206d35a89e
@ -147,23 +147,31 @@ var IPython = (function (IPython) {
|
|||||||
}
|
}
|
||||||
if (this.code_mirror) {
|
if (this.code_mirror) {
|
||||||
this.code_mirror.on('focus', function(cm, change) {
|
this.code_mirror.on('focus', function(cm, change) {
|
||||||
|
console.log('cell focused');
|
||||||
|
if (that._continue_blur) {
|
||||||
|
that._continue_blur = false;
|
||||||
|
} else {
|
||||||
|
if (that.mode === 'command') {
|
||||||
$([IPython.events]).trigger('edit_mode.Cell', {cell: that});
|
$([IPython.events]).trigger('edit_mode.Cell', {cell: that});
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (this.code_mirror) {
|
if (this.code_mirror) {
|
||||||
this.code_mirror.on('blur', function(cm, change) {
|
this.code_mirror.on('blur', function(cm, change) {
|
||||||
if (that.mode === 'edit') {
|
console.log('cell blur');
|
||||||
setTimeout(function () {
|
that._continue_blur = true;
|
||||||
|
setTimeout($.proxy(function () {
|
||||||
|
if (that._continue_blur) {
|
||||||
|
console.log('cell blur> edit true> callback');
|
||||||
var isf = IPython.utils.is_focused;
|
var isf = IPython.utils.is_focused;
|
||||||
var trigger = true;
|
if (! (isf('div#tooltip') || isf('div.completions'))) {
|
||||||
if (isf('div#tooltip') || isf('div.completions')) {
|
if (that.mode === 'edit') {
|
||||||
trigger = false;
|
|
||||||
}
|
|
||||||
if (trigger) {
|
|
||||||
$([IPython.events]).trigger('command_mode.Cell', {cell: that});
|
$([IPython.events]).trigger('command_mode.Cell', {cell: that});
|
||||||
}
|
}
|
||||||
}, 1);
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}, that), 1);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -725,29 +725,35 @@ var IPython = (function (IPython) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
KeyboardManager.prototype.edit_mode = function () {
|
KeyboardManager.prototype.edit_mode = function () {
|
||||||
|
console.log('kb edit');
|
||||||
this.last_mode = this.mode;
|
this.last_mode = this.mode;
|
||||||
this.mode = 'edit';
|
this.mode = 'edit';
|
||||||
};
|
};
|
||||||
|
|
||||||
KeyboardManager.prototype.command_mode = function () {
|
KeyboardManager.prototype.command_mode = function () {
|
||||||
|
console.log('kb command');
|
||||||
this.last_mode = this.mode;
|
this.last_mode = this.mode;
|
||||||
this.mode = 'command';
|
this.mode = 'command';
|
||||||
};
|
};
|
||||||
|
|
||||||
KeyboardManager.prototype.enable = function () {
|
KeyboardManager.prototype.enable = function () {
|
||||||
|
console.log('kb enable');
|
||||||
this.enabled = true;
|
this.enabled = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
KeyboardManager.prototype.disable = function () {
|
KeyboardManager.prototype.disable = function () {
|
||||||
|
console.log('kb disable');
|
||||||
this.enabled = false;
|
this.enabled = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
KeyboardManager.prototype.register_events = function (e) {
|
KeyboardManager.prototype.register_events = function (e) {
|
||||||
var that = this;
|
var that = this;
|
||||||
e.on('focusin', function () {
|
e.on('focusin', function () {
|
||||||
|
console.log('kb focus in');
|
||||||
that.disable();
|
that.disable();
|
||||||
});
|
});
|
||||||
e.on('focusout', function () {
|
e.on('focusout', function () {
|
||||||
|
console.log('kb focus out');
|
||||||
that.enable();
|
that.enable();
|
||||||
});
|
});
|
||||||
// There are times (raw_input) where we remove the element from the DOM before
|
// There are times (raw_input) where we remove the element from the DOM before
|
||||||
@ -755,6 +761,7 @@ var IPython = (function (IPython) {
|
|||||||
// which gets triggered upon removal, iff it is focused at the time.
|
// which gets triggered upon removal, iff it is focused at the time.
|
||||||
e.on('remove', function () {
|
e.on('remove', function () {
|
||||||
if (document.activeElement === e[0]) {
|
if (document.activeElement === e[0]) {
|
||||||
|
console.log('kb remove');
|
||||||
that.enable();
|
that.enable();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -116,12 +116,18 @@ var IPython = (function (IPython) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
$([IPython.events]).on('edit_mode.Cell', function (event, data) {
|
$([IPython.events]).on('edit_mode.Cell', function (event, data) {
|
||||||
|
console.log('edit mode cell');
|
||||||
var index = that.find_cell_index(data.cell);
|
var index = that.find_cell_index(data.cell);
|
||||||
that.select(index);
|
that.select(index);
|
||||||
that.edit_mode();
|
that.edit_mode();
|
||||||
});
|
});
|
||||||
|
|
||||||
$([IPython.events]).on('command_mode.Cell', function (event, data) {
|
$([IPython.events]).on('command_mode.Cell', function (event, data) {
|
||||||
|
console.log('command mode cell');
|
||||||
|
// In Firefox the focus event is called before the blur event. In
|
||||||
|
// other words, two cells elements may be focused at any given time.
|
||||||
|
// Here we verify that no cells are currently in edit mode before
|
||||||
|
// putting the entire notebook in command mode.
|
||||||
that.command_mode();
|
that.command_mode();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -459,7 +465,6 @@ var IPython = (function (IPython) {
|
|||||||
if (this.is_valid_cell_index(index)) {
|
if (this.is_valid_cell_index(index)) {
|
||||||
var sindex = this.get_selected_index();
|
var sindex = this.get_selected_index();
|
||||||
if (sindex !== null && index !== sindex) {
|
if (sindex !== null && index !== sindex) {
|
||||||
this.command_mode();
|
|
||||||
this.get_cell(sindex).unselect();
|
this.get_cell(sindex).unselect();
|
||||||
}
|
}
|
||||||
var cell = this.get_cell(index);
|
var cell = this.get_cell(index);
|
||||||
@ -515,6 +520,7 @@ var IPython = (function (IPython) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Notebook.prototype.command_mode = function () {
|
Notebook.prototype.command_mode = function () {
|
||||||
|
console.log('cell.command_mode');
|
||||||
if (this.mode !== 'command') {
|
if (this.mode !== 'command') {
|
||||||
$([IPython.events]).trigger('command_mode.Notebook');
|
$([IPython.events]).trigger('command_mode.Notebook');
|
||||||
var index = this.get_edit_index();
|
var index = this.get_edit_index();
|
||||||
@ -528,6 +534,7 @@ var IPython = (function (IPython) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Notebook.prototype.edit_mode = function () {
|
Notebook.prototype.edit_mode = function () {
|
||||||
|
console.log('cell.edit_mode');
|
||||||
if (this.mode !== 'edit') {
|
if (this.mode !== 'edit') {
|
||||||
$([IPython.events]).trigger('edit_mode.Notebook');
|
$([IPython.events]).trigger('edit_mode.Notebook');
|
||||||
var cell = this.get_selected_cell();
|
var cell = this.get_selected_cell();
|
||||||
@ -1402,6 +1409,7 @@ var IPython = (function (IPython) {
|
|||||||
var cell = this.get_selected_cell();
|
var cell = this.get_selected_cell();
|
||||||
var cell_index = this.find_cell_index(cell);
|
var cell_index = this.find_cell_index(cell);
|
||||||
|
|
||||||
|
console.log('execute cell command_mode');
|
||||||
cell.execute();
|
cell.execute();
|
||||||
this.command_mode();
|
this.command_mode();
|
||||||
cell.focus_cell();
|
cell.focus_cell();
|
||||||
@ -1923,6 +1931,7 @@ var IPython = (function (IPython) {
|
|||||||
*/
|
*/
|
||||||
Notebook.prototype.load_notebook_success = function (data, status, xhr) {
|
Notebook.prototype.load_notebook_success = function (data, status, xhr) {
|
||||||
this.fromJSON(data);
|
this.fromJSON(data);
|
||||||
|
console.log('load notebook success');
|
||||||
if (this.ncells() === 0) {
|
if (this.ncells() === 0) {
|
||||||
this.insert_cell_below('code');
|
this.insert_cell_below('code');
|
||||||
this.select(0);
|
this.select(0);
|
||||||
|
Loading…
Reference in New Issue
Block a user