keyboardmanager.js
578 lines
| 19.5 KiB
| application/javascript
|
JavascriptLexer
Jonathan Frederic
|
r17866 | // Copyright (c) IPython Development Team. | ||
// Distributed under the terms of the Modified BSD License. | ||||
Jonathan Frederic
|
r17864 | |||
Jonathan Frederic
|
r17869 | define([ | ||
'base/js/namespace', | ||||
'jquery', | ||||
'base/js/utils', | ||||
'base/js/keyboard', | ||||
], function(IPython, $, utils, keyboard) { | ||||
Brian E. Granger
|
r14020 | "use strict"; | ||
Jonathan Frederic
|
r17871 | |||
Jonathan Frederic
|
r17198 | var browser = utils.browser[0]; | ||
var platform = utils.platform; | ||||
Brian E. Granger
|
r14020 | |||
Jonathan Frederic
|
r17198 | // Main keyboard manager for the notebook | ||
var keycodes = keyboard.keycodes; | ||||
Brian E. Granger
|
r14036 | |||
jon
|
r17210 | var KeyboardManager = function (options) { | ||
jon
|
r17211 | // Constructor | ||
// | ||||
// Parameters: | ||||
// options: dictionary | ||||
// Dictionary of keyword arguments. | ||||
// events: $(Events) instance | ||||
// pager: Pager instance | ||||
Jonathan Frederic
|
r17198 | this.mode = 'command'; | ||
this.enabled = true; | ||||
jon
|
r17210 | this.pager = options.pager; | ||
Jonathan Frederic
|
r17198 | this.quick_help = undefined; | ||
this.notebook = undefined; | ||||
this.bind_events(); | ||||
jon
|
r17210 | this.command_shortcuts = new keyboard.ShortcutManager(undefined, options.events); | ||
Jonathan Frederic
|
r17198 | this.command_shortcuts.add_shortcuts(this.get_default_common_shortcuts()); | ||
this.command_shortcuts.add_shortcuts(this.get_default_command_shortcuts()); | ||||
jon
|
r17210 | this.edit_shortcuts = new keyboard.ShortcutManager(undefined, options.events); | ||
Jonathan Frederic
|
r17198 | this.edit_shortcuts.add_shortcuts(this.get_default_common_shortcuts()); | ||
this.edit_shortcuts.add_shortcuts(this.get_default_edit_shortcuts()); | ||||
}; | ||||
Brian E. Granger
|
r14036 | |||
Jonathan Frederic
|
r17198 | KeyboardManager.prototype.get_default_common_shortcuts = function() { | ||
var that = this; | ||||
Jonathan Frederic
|
r17200 | var shortcuts = { | ||
Jonathan Frederic
|
r17871 | 'shift' : { | ||
help : '', | ||||
help_index : '', | ||||
handler : function (event) { | ||||
// ignore shift keydown | ||||
return true; | ||||
} | ||||
}, | ||||
'shift-enter' : { | ||||
help : 'run cell, select below', | ||||
help_index : 'ba', | ||||
handler : function (event) { | ||||
Jonathan Frederic
|
r17198 | that.notebook.execute_cell_and_select_below(); | ||
Jonathan Frederic
|
r17871 | return false; | ||
} | ||||
}, | ||||
'ctrl-enter' : { | ||||
help : 'run cell', | ||||
help_index : 'bb', | ||||
handler : function (event) { | ||||
Jonathan Frederic
|
r17198 | that.notebook.execute_cell(); | ||
Jonathan Frederic
|
r17871 | return false; | ||
} | ||||
}, | ||||
'alt-enter' : { | ||||
help : 'run cell, insert below', | ||||
help_index : 'bc', | ||||
handler : function (event) { | ||||
Jonathan Frederic
|
r17198 | that.notebook.execute_cell_and_insert_below(); | ||
Jonathan Frederic
|
r17871 | return false; | ||
} | ||||
Brian E. Granger
|
r14036 | } | ||
Jonathan Frederic
|
r17871 | }; | ||
Jonathan Frederic
|
r17198 | |||
Jonathan Frederic
|
r17871 | if (platform === 'MacOS') { | ||
Jonathan Frederic
|
r17198 | shortcuts['cmd-s'] = | ||
Jonathan Frederic
|
r17871 | { | ||
help : 'save notebook', | ||||
help_index : 'fb', | ||||
handler : function (event) { | ||||
Jonathan Frederic
|
r17198 | that.notebook.save_checkpoint(); | ||
Jonathan Frederic
|
r17871 | event.preventDefault(); | ||
return false; | ||||
} | ||||
}; | ||||
} else { | ||||
Jonathan Frederic
|
r17198 | shortcuts['ctrl-s'] = | ||
Jonathan Frederic
|
r17871 | { | ||
help : 'save notebook', | ||||
help_index : 'fb', | ||||
handler : function (event) { | ||||
Jonathan Frederic
|
r17198 | that.notebook.save_checkpoint(); | ||
Jonathan Frederic
|
r17871 | event.preventDefault(); | ||
return false; | ||||
} | ||||
}; | ||||
} | ||||
Jonathan Frederic
|
r17198 | return shortcuts; | ||
Jonathan Frederic
|
r15491 | }; | ||
Brian E. Granger
|
r14036 | |||
Jonathan Frederic
|
r17198 | KeyboardManager.prototype.get_default_edit_shortcuts = function() { | ||
var that = this; | ||||
return { | ||||
Jonathan Frederic
|
r17869 | 'esc' : { | ||
help : 'command mode', | ||||
help_index : 'aa', | ||||
handler : function (event) { | ||||
Jonathan Frederic
|
r17871 | that.notebook.command_mode(); | ||
Jonathan Frederic
|
r17864 | return false; | ||
Jonathan Frederic
|
r17198 | } | ||
Jonathan Frederic
|
r17869 | }, | ||
'ctrl-m' : { | ||||
help : 'command mode', | ||||
help_index : 'ab', | ||||
handler : function (event) { | ||||
Jonathan Frederic
|
r17871 | that.notebook.command_mode(); | ||
Paul Ivanov
|
r15837 | return false; | ||
Jonathan Frederic
|
r17869 | } | ||
}, | ||||
'up' : { | ||||
help : '', | ||||
help_index : '', | ||||
handler : function (event) { | ||||
Jonathan Frederic
|
r17871 | var index = that.notebook.get_selected_index(); | ||
var cell = that.notebook.get_cell(index); | ||||
Jonathan Frederic
|
r17869 | if (cell && cell.at_top() && index !== 0) { | ||
event.preventDefault(); | ||||
Jonathan Frederic
|
r17871 | that.notebook.command_mode(); | ||
that.notebook.select_prev(); | ||||
that.notebook.edit_mode(); | ||||
var cm = that.notebook.get_selected_cell().code_mirror; | ||||
Jonathan Frederic
|
r17869 | cm.setCursor(cm.lastLine(), 0); | ||
return false; | ||||
} else if (cell) { | ||||
var cm = cell.code_mirror; | ||||
cm.execCommand('goLineUp'); | ||||
return false; | ||||
} | ||||
} | ||||
}, | ||||
'down' : { | ||||
help : '', | ||||
help_index : '', | ||||
handler : function (event) { | ||||
Jonathan Frederic
|
r17871 | var index = that.notebook.get_selected_index(); | ||
var cell = that.notebook.get_cell(index); | ||||
if (cell.at_bottom() && index !== (that.notebook.ncells()-1)) { | ||||
Jonathan Frederic
|
r17869 | event.preventDefault(); | ||
Jonathan Frederic
|
r17871 | that.notebook.command_mode(); | ||
that.notebook.select_next(); | ||||
that.notebook.edit_mode(); | ||||
var cm = that.notebook.get_selected_cell().code_mirror; | ||||
Jonathan Frederic
|
r17869 | cm.setCursor(0, 0); | ||
return false; | ||||
} else { | ||||
var cm = cell.code_mirror; | ||||
cm.execCommand('goLineDown'); | ||||
return false; | ||||
} | ||||
} | ||||
}, | ||||
'ctrl-shift--' : { | ||||
help : 'split cell', | ||||
help_index : 'ea', | ||||
handler : function (event) { | ||||
Jonathan Frederic
|
r17871 | that.notebook.split_cell(); | ||
Paul Ivanov
|
r15837 | return false; | ||
Jonathan Frederic
|
r15491 | } | ||
Jonathan Frederic
|
r17869 | }, | ||
'ctrl-shift-subtract' : { | ||||
help : '', | ||||
help_index : 'eb', | ||||
handler : function (event) { | ||||
Jonathan Frederic
|
r17871 | that.notebook.split_cell(); | ||
Jonathan Frederic
|
r17869 | return false; | ||
} | ||||
}, | ||||
}; | ||||
Jonathan Frederic
|
r15491 | }; | ||
Brian E. Granger
|
r14816 | |||
Jonathan Frederic
|
r17198 | KeyboardManager.prototype.get_default_command_shortcuts = function() { | ||
var that = this; | ||||
return { | ||||
Jonathan Frederic
|
r17869 | 'space': { | ||
Jonathan Frederic
|
r17871 | help: "Scroll down", | ||
Jonathan Frederic
|
r17869 | handler: function(event) { | ||
Jonathan Frederic
|
r17876 | return that.notebook.scroll_manager.scroll(1); | ||
Jonathan Frederic
|
r17869 | }, | ||
Jonathan Frederic
|
r17864 | }, | ||
Jonathan Frederic
|
r17869 | 'shift-space': { | ||
Jonathan Frederic
|
r17871 | help: "Scroll up", | ||
Jonathan Frederic
|
r17869 | handler: function(event) { | ||
Jonathan Frederic
|
r17876 | return that.notebook.scroll_manager.scroll(-1); | ||
Jonathan Frederic
|
r17869 | }, | ||
Jonathan Frederic
|
r17864 | }, | ||
Jonathan Frederic
|
r17869 | 'enter' : { | ||
help : 'edit mode', | ||||
help_index : 'aa', | ||||
handler : function (event) { | ||||
Jonathan Frederic
|
r17871 | that.notebook.edit_mode(); | ||
Jonathan Frederic
|
r17869 | return false; | ||
Jonathan Frederic
|
r15491 | } | ||
Jonathan Frederic
|
r17869 | }, | ||
'up' : { | ||||
help : 'select previous cell', | ||||
help_index : 'da', | ||||
handler : function (event) { | ||||
Jonathan Frederic
|
r17871 | var index = that.notebook.get_selected_index(); | ||
Jonathan Frederic
|
r17869 | if (index !== 0 && index !== null) { | ||
Jonathan Frederic
|
r17871 | that.notebook.select_prev(); | ||
that.notebook.focus_cell(); | ||||
Jonathan Frederic
|
r17869 | } | ||
return false; | ||||
Jonathan Frederic
|
r15491 | } | ||
Jonathan Frederic
|
r17869 | }, | ||
'down' : { | ||||
help : 'select next cell', | ||||
help_index : 'db', | ||||
handler : function (event) { | ||||
Jonathan Frederic
|
r17871 | var index = that.notebook.get_selected_index(); | ||
if (index !== (that.notebook.ncells()-1) && index !== null) { | ||||
that.notebook.select_next(); | ||||
that.notebook.focus_cell(); | ||||
Jonathan Frederic
|
r17869 | } | ||
return false; | ||||
} | ||||
}, | ||||
'k' : { | ||||
help : 'select previous cell', | ||||
help_index : 'dc', | ||||
handler : function (event) { | ||||
Jonathan Frederic
|
r17871 | var index = that.notebook.get_selected_index(); | ||
Jonathan Frederic
|
r17869 | if (index !== 0 && index !== null) { | ||
Jonathan Frederic
|
r17871 | that.notebook.select_prev(); | ||
that.notebook.focus_cell(); | ||||
Jonathan Frederic
|
r17869 | } | ||
return false; | ||||
} | ||||
}, | ||||
'j' : { | ||||
help : 'select next cell', | ||||
help_index : 'dd', | ||||
handler : function (event) { | ||||
Jonathan Frederic
|
r17871 | var index = that.notebook.get_selected_index(); | ||
if (index !== (that.notebook.ncells()-1) && index !== null) { | ||||
that.notebook.select_next(); | ||||
that.notebook.focus_cell(); | ||||
Jonathan Frederic
|
r17869 | } | ||
return false; | ||||
} | ||||
}, | ||||
'x' : { | ||||
help : 'cut cell', | ||||
help_index : 'ee', | ||||
handler : function (event) { | ||||
Jonathan Frederic
|
r17871 | that.notebook.cut_cell(); | ||
Jonathan Frederic
|
r17869 | return false; | ||
} | ||||
}, | ||||
'c' : { | ||||
help : 'copy cell', | ||||
help_index : 'ef', | ||||
handler : function (event) { | ||||
Jonathan Frederic
|
r17871 | that.notebook.copy_cell(); | ||
Jonathan Frederic
|
r17869 | return false; | ||
} | ||||
}, | ||||
'shift-v' : { | ||||
help : 'paste cell above', | ||||
help_index : 'eg', | ||||
handler : function (event) { | ||||
Jonathan Frederic
|
r17871 | that.notebook.paste_cell_above(); | ||
Jonathan Frederic
|
r17869 | return false; | ||
} | ||||
}, | ||||
'v' : { | ||||
help : 'paste cell below', | ||||
help_index : 'eh', | ||||
handler : function (event) { | ||||
Jonathan Frederic
|
r17871 | that.notebook.paste_cell_below(); | ||
Jonathan Frederic
|
r17869 | return false; | ||
} | ||||
}, | ||||
'd' : { | ||||
help : 'delete cell (press twice)', | ||||
help_index : 'ej', | ||||
count: 2, | ||||
handler : function (event) { | ||||
Jonathan Frederic
|
r17871 | that.notebook.delete_cell(); | ||
Jonathan Frederic
|
r17869 | return false; | ||
} | ||||
}, | ||||
'a' : { | ||||
help : 'insert cell above', | ||||
help_index : 'ec', | ||||
handler : function (event) { | ||||
Jonathan Frederic
|
r17871 | that.notebook.insert_cell_above(); | ||
that.notebook.select_prev(); | ||||
that.notebook.focus_cell(); | ||||
Jonathan Frederic
|
r17869 | return false; | ||
Jonathan Frederic
|
r15491 | } | ||
Jonathan Frederic
|
r17869 | }, | ||
'b' : { | ||||
help : 'insert cell below', | ||||
help_index : 'ed', | ||||
handler : function (event) { | ||||
Jonathan Frederic
|
r17871 | that.notebook.insert_cell_below(); | ||
that.notebook.select_next(); | ||||
that.notebook.focus_cell(); | ||||
Jonathan Frederic
|
r17869 | return false; | ||
Jonathan Frederic
|
r17198 | } | ||
Jonathan Frederic
|
r17869 | }, | ||
'y' : { | ||||
help : 'to code', | ||||
help_index : 'ca', | ||||
handler : function (event) { | ||||
Jonathan Frederic
|
r17871 | that.notebook.to_code(); | ||
Jonathan Frederic
|
r17869 | return false; | ||
} | ||||
}, | ||||
'm' : { | ||||
help : 'to markdown', | ||||
help_index : 'cb', | ||||
handler : function (event) { | ||||
Jonathan Frederic
|
r17871 | that.notebook.to_markdown(); | ||
Jonathan Frederic
|
r17869 | return false; | ||
} | ||||
}, | ||||
'r' : { | ||||
help : 'to raw', | ||||
help_index : 'cc', | ||||
handler : function (event) { | ||||
Jonathan Frederic
|
r17871 | that.notebook.to_raw(); | ||
Jonathan Frederic
|
r17869 | return false; | ||
} | ||||
}, | ||||
'1' : { | ||||
help : 'to heading 1', | ||||
help_index : 'cd', | ||||
handler : function (event) { | ||||
Jonathan Frederic
|
r17871 | that.notebook.to_heading(undefined, 1); | ||
Jonathan Frederic
|
r17869 | return false; | ||
} | ||||
}, | ||||
'2' : { | ||||
help : 'to heading 2', | ||||
help_index : 'ce', | ||||
handler : function (event) { | ||||
Jonathan Frederic
|
r17871 | that.notebook.to_heading(undefined, 2); | ||
Jonathan Frederic
|
r17869 | return false; | ||
} | ||||
}, | ||||
'3' : { | ||||
help : 'to heading 3', | ||||
help_index : 'cf', | ||||
handler : function (event) { | ||||
Jonathan Frederic
|
r17871 | that.notebook.to_heading(undefined, 3); | ||
Jonathan Frederic
|
r17869 | return false; | ||
} | ||||
}, | ||||
'4' : { | ||||
help : 'to heading 4', | ||||
help_index : 'cg', | ||||
handler : function (event) { | ||||
Jonathan Frederic
|
r17871 | that.notebook.to_heading(undefined, 4); | ||
Jonathan Frederic
|
r17869 | return false; | ||
} | ||||
}, | ||||
'5' : { | ||||
help : 'to heading 5', | ||||
help_index : 'ch', | ||||
handler : function (event) { | ||||
Jonathan Frederic
|
r17871 | that.notebook.to_heading(undefined, 5); | ||
Jonathan Frederic
|
r17869 | return false; | ||
} | ||||
}, | ||||
'6' : { | ||||
help : 'to heading 6', | ||||
help_index : 'ci', | ||||
handler : function (event) { | ||||
Jonathan Frederic
|
r17871 | that.notebook.to_heading(undefined, 6); | ||
Jonathan Frederic
|
r17869 | return false; | ||
} | ||||
}, | ||||
'o' : { | ||||
help : 'toggle output', | ||||
help_index : 'gb', | ||||
handler : function (event) { | ||||
Jonathan Frederic
|
r17871 | that.notebook.toggle_output(); | ||
Jonathan Frederic
|
r17869 | return false; | ||
} | ||||
}, | ||||
'shift-o' : { | ||||
help : 'toggle output scrolling', | ||||
help_index : 'gc', | ||||
handler : function (event) { | ||||
Jonathan Frederic
|
r17871 | that.notebook.toggle_output_scroll(); | ||
Jonathan Frederic
|
r17869 | return false; | ||
} | ||||
}, | ||||
's' : { | ||||
help : 'save notebook', | ||||
help_index : 'fa', | ||||
handler : function (event) { | ||||
Jonathan Frederic
|
r17871 | that.notebook.save_checkpoint(); | ||
Jonathan Frederic
|
r17869 | return false; | ||
} | ||||
}, | ||||
'ctrl-j' : { | ||||
help : 'move cell down', | ||||
help_index : 'eb', | ||||
handler : function (event) { | ||||
Jonathan Frederic
|
r17871 | that.notebook.move_cell_down(); | ||
Jonathan Frederic
|
r17869 | return false; | ||
} | ||||
}, | ||||
'ctrl-k' : { | ||||
help : 'move cell up', | ||||
help_index : 'ea', | ||||
handler : function (event) { | ||||
Jonathan Frederic
|
r17871 | that.notebook.move_cell_up(); | ||
Jonathan Frederic
|
r17869 | return false; | ||
} | ||||
}, | ||||
'l' : { | ||||
help : 'toggle line numbers', | ||||
help_index : 'ga', | ||||
handler : function (event) { | ||||
Jonathan Frederic
|
r17871 | that.notebook.cell_toggle_line_numbers(); | ||
Jonathan Frederic
|
r17869 | return false; | ||
} | ||||
}, | ||||
'i' : { | ||||
help : 'interrupt kernel (press twice)', | ||||
help_index : 'ha', | ||||
count: 2, | ||||
handler : function (event) { | ||||
Jonathan Frederic
|
r17871 | that.notebook.kernel.interrupt(); | ||
Jonathan Frederic
|
r17869 | return false; | ||
} | ||||
}, | ||||
'0' : { | ||||
help : 'restart kernel (press twice)', | ||||
help_index : 'hb', | ||||
count: 2, | ||||
handler : function (event) { | ||||
Jonathan Frederic
|
r17871 | that.notebook.restart_kernel(); | ||
Jonathan Frederic
|
r17869 | return false; | ||
} | ||||
}, | ||||
'h' : { | ||||
help : 'keyboard shortcuts', | ||||
help_index : 'ge', | ||||
handler : function (event) { | ||||
Jonathan Frederic
|
r17871 | that.quick_help.show_keyboard_shortcuts(); | ||
Jonathan Frederic
|
r17869 | return false; | ||
} | ||||
}, | ||||
'z' : { | ||||
help : 'undo last delete', | ||||
help_index : 'ei', | ||||
handler : function (event) { | ||||
Jonathan Frederic
|
r17871 | that.notebook.undelete_cell(); | ||
Jonathan Frederic
|
r17869 | return false; | ||
} | ||||
}, | ||||
'shift-m' : { | ||||
help : 'merge cell below', | ||||
help_index : 'ek', | ||||
handler : function (event) { | ||||
Jonathan Frederic
|
r17871 | that.notebook.merge_cell_below(); | ||
Jonathan Frederic
|
r17869 | return false; | ||
} | ||||
}, | ||||
'q' : { | ||||
help : 'close pager', | ||||
help_index : 'gd', | ||||
handler : function (event) { | ||||
Jonathan Frederic
|
r17871 | that.pager.collapse(); | ||
Jonathan Frederic
|
r17869 | return false; | ||
} | ||||
}, | ||||
}; | ||||
Brian E. Granger
|
r14020 | }; | ||
KeyboardManager.prototype.bind_events = function () { | ||||
var that = this; | ||||
$(document).keydown(function (event) { | ||||
return that.handle_keydown(event); | ||||
}); | ||||
}; | ||||
KeyboardManager.prototype.handle_keydown = function (event) { | ||||
Jonathan Frederic
|
r17198 | var notebook = this.notebook; | ||
Brian E. Granger
|
r14089 | |||
Jonathan Frederic
|
r15491 | if (event.which === keycodes.esc) { | ||
Brian E. Granger
|
r14020 | // Intercept escape at highest level to avoid closing | ||
// websocket connection with firefox | ||||
event.preventDefault(); | ||||
} | ||||
Brian E. Granger
|
r14023 | if (!this.enabled) { | ||
Jonathan Frederic
|
r15491 | if (event.which === keycodes.esc) { | ||
Brian E. Granger
|
r14036 | // ESC | ||
notebook.command_mode(); | ||||
return false; | ||||
} | ||||
Brian E. Granger
|
r14023 | return true; | ||
Brian E. Granger
|
r14020 | } | ||
if (this.mode === 'edit') { | ||||
Brian E. Granger
|
r14036 | return this.edit_shortcuts.call_handler(event); | ||
} else if (this.mode === 'command') { | ||||
return this.command_shortcuts.call_handler(event); | ||||
Brian E. Granger
|
r14020 | } | ||
return true; | ||||
Jonathan Frederic
|
r15491 | }; | ||
Brian E. Granger
|
r14020 | |||
KeyboardManager.prototype.edit_mode = function () { | ||||
this.last_mode = this.mode; | ||||
this.mode = 'edit'; | ||||
Jonathan Frederic
|
r15491 | }; | ||
Brian E. Granger
|
r14020 | |||
KeyboardManager.prototype.command_mode = function () { | ||||
this.last_mode = this.mode; | ||||
this.mode = 'command'; | ||||
Jonathan Frederic
|
r15491 | }; | ||
Brian E. Granger
|
r14020 | |||
Brian E. Granger
|
r14024 | KeyboardManager.prototype.enable = function () { | ||
Brian E. Granger
|
r14030 | this.enabled = true; | ||
Jonathan Frederic
|
r15491 | }; | ||
Brian E. Granger
|
r14024 | |||
KeyboardManager.prototype.disable = function () { | ||||
Brian E. Granger
|
r14030 | this.enabled = false; | ||
Jonathan Frederic
|
r15491 | }; | ||
Brian E. Granger
|
r14024 | |||
Brian E. Granger
|
r14036 | KeyboardManager.prototype.register_events = function (e) { | ||
var that = this; | ||||
Jonathan Frederic
|
r15496 | var handle_focus = function () { | ||
Brian E. Granger
|
r14036 | that.disable(); | ||
Jonathan Frederic
|
r15496 | }; | ||
var handle_blur = function () { | ||||
Brian E. Granger
|
r14036 | that.enable(); | ||
Jonathan Frederic
|
r15496 | }; | ||
e.on('focusin', handle_focus); | ||||
e.on('focusout', handle_blur); | ||||
Jonathan Frederic
|
r15507 | // TODO: Very strange. The focusout event does not seem fire for the | ||
Jonathan Frederic
|
r15539 | // bootstrap textboxes on FF25&26... This works around that by | ||
// registering focus and blur events recursively on all inputs within | ||||
// registered element. | ||||
Jonathan Frederic
|
r15507 | e.find('input').blur(handle_blur); | ||
e.on('DOMNodeInserted', function (event) { | ||||
var target = $(event.target); | ||||
if (target.is('input')) { | ||||
target.blur(handle_blur); | ||||
} else { | ||||
target.find('input').blur(handle_blur); | ||||
} | ||||
}); | ||||
Brian E. Granger
|
r14046 | // There are times (raw_input) where we remove the element from the DOM before | ||
// focusout is called. In this case we bind to the remove event of jQueryUI, | ||||
MinRK
|
r15328 | // which gets triggered upon removal, iff it is focused at the time. | ||
Jonathan Frederic
|
r15539 | // is_focused must be used to check for the case where an element within | ||
// the element being removed is focused. | ||||
Brian E. Granger
|
r14046 | e.on('remove', function () { | ||
Jonathan Frederic
|
r17198 | if (utils.is_focused(e[0])) { | ||
MinRK
|
r15328 | that.enable(); | ||
} | ||||
Brian E. Granger
|
r14046 | }); | ||
Jonathan Frederic
|
r15491 | }; | ||
Brian E. Granger
|
r14036 | |||
Jonathan Frederic
|
r17198 | // For backwards compatability. | ||
Brian E. Granger
|
r14020 | IPython.KeyboardManager = KeyboardManager; | ||
Jonathan Frederic
|
r17201 | return {'KeyboardManager': KeyboardManager}; | ||
Jonathan Frederic
|
r17198 | }); | ||