From ef2c71c34d788d4d23a535881d4d54656c03b7ba Mon Sep 17 00:00:00 2001 From: Jonathan Frederic Date: Mon, 3 Feb 2014 16:47:06 -0800 Subject: [PATCH 1/2] Fix command mode & popup view bug Added elements property to PopupView --- IPython/html/static/notebook/js/widgetmanager.js | 10 ++++++++-- .../static/notebook/js/widgets/widget_container.js | 8 ++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/IPython/html/static/notebook/js/widgetmanager.js b/IPython/html/static/notebook/js/widgetmanager.js index eeff6ebe2..f8f03804f 100644 --- a/IPython/html/static/notebook/js/widgetmanager.js +++ b/IPython/html/static/notebook/js/widgetmanager.js @@ -93,8 +93,14 @@ WidgetManager.prototype._handle_display_view = function (view) { // Have the IPython keyboard manager disable its event // handling so the widget can capture keyboard input. - // Note, this is only done on the outer most widget. - IPython.keyboard_manager.register_events(view.$el); + // Note, this is only done on the outer most widgets. + if (view.elements) { + for (var i = 0; i < view.elements.length; i++) { + IPython.keyboard_manager.register_events(view.elements[i]); + } + } else { + IPython.keyboard_manager.register_events(view.$el); + } }; WidgetManager.prototype.create_view = function(model, options, view) { diff --git a/IPython/html/static/notebook/js/widgets/widget_container.js b/IPython/html/static/notebook/js/widgets/widget_container.js index 8c7e1721d..0f0497454 100644 --- a/IPython/html/static/notebook/js/widgets/widget_container.js +++ b/IPython/html/static/notebook/js/widgets/widget_container.js @@ -75,6 +75,14 @@ define(["notebook/js/widgets/widget"], function(WidgetManager) { .mousedown(function(){ that.bring_to_front(); }); + + // Set the elements array since the this.$window element is not child + // of this.$el and the parent widget manager or other widgets may + // need to know about all of the top-level widgets. The IPython + // widget manager uses this to register the elements with the + // keyboard manager. + this.elements = [this.$el, this.$window] + this.$title_bar = $('
') .addClass('popover-title') .appendTo(this.$window) From 4a314ea3da6e1d08fdde5c356d6f75cac4d3afe7 Mon Sep 17 00:00:00 2001 From: Jonathan Frederic Date: Tue, 4 Feb 2014 09:44:38 -0800 Subject: [PATCH 2/2] Unconditionally register $el with keyboard manager also s/elements/additional_elements --- IPython/html/static/notebook/js/widgetmanager.js | 12 ++++++------ .../static/notebook/js/widgets/widget_container.js | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/IPython/html/static/notebook/js/widgetmanager.js b/IPython/html/static/notebook/js/widgetmanager.js index f8f03804f..67eeb90cb 100644 --- a/IPython/html/static/notebook/js/widgetmanager.js +++ b/IPython/html/static/notebook/js/widgetmanager.js @@ -94,13 +94,13 @@ // Have the IPython keyboard manager disable its event // handling so the widget can capture keyboard input. // Note, this is only done on the outer most widgets. - if (view.elements) { - for (var i = 0; i < view.elements.length; i++) { - IPython.keyboard_manager.register_events(view.elements[i]); + IPython.keyboard_manager.register_events(view.$el); + + if (view.additional_elements) { + for (var i = 0; i < view.additional_elements.length; i++) { + IPython.keyboard_manager.register_events(view.additional_elements[i]); } - } else { - IPython.keyboard_manager.register_events(view.$el); - } + } }; WidgetManager.prototype.create_view = function(model, options, view) { diff --git a/IPython/html/static/notebook/js/widgets/widget_container.js b/IPython/html/static/notebook/js/widgets/widget_container.js index 0f0497454..eb538c2db 100644 --- a/IPython/html/static/notebook/js/widgets/widget_container.js +++ b/IPython/html/static/notebook/js/widgets/widget_container.js @@ -81,7 +81,7 @@ define(["notebook/js/widgets/widget"], function(WidgetManager) { // need to know about all of the top-level widgets. The IPython // widget manager uses this to register the elements with the // keyboard manager. - this.elements = [this.$el, this.$window] + this.additional_elements = [this.$window] this.$title_bar = $('
') .addClass('popover-title')