From e17200a53388f3ebac952e17acb6ecd32779c9fe Mon Sep 17 00:00:00 2001 From: Jonathan Frederic Date: Fri, 17 Jan 2014 17:03:29 +0000 Subject: [PATCH] Widget require.js fix The WidgetManager namespace is passed around instead of a widget_manager instance... --- IPython/html/static/notebook/js/widgetmanager.js | 2 +- .../html/static/notebook/js/widgets/widget.js | 8 ++++---- .../static/notebook/js/widgets/widget_bool.js | 6 +++--- .../static/notebook/js/widgets/widget_button.js | 4 ++-- .../notebook/js/widgets/widget_container.js | 6 +++--- .../static/notebook/js/widgets/widget_float.js | 16 +++------------- .../static/notebook/js/widgets/widget_image.js | 4 ++-- .../static/notebook/js/widgets/widget_int.js | 16 +++------------- .../notebook/js/widgets/widget_selection.js | 10 +++++----- .../js/widgets/widget_selectioncontainer.js | 6 +++--- .../static/notebook/js/widgets/widget_string.js | 10 +++++----- 11 files changed, 34 insertions(+), 54 deletions(-) diff --git a/IPython/html/static/notebook/js/widgetmanager.js b/IPython/html/static/notebook/js/widgetmanager.js index dbb3ab0e5..26697ae17 100644 --- a/IPython/html/static/notebook/js/widgetmanager.js +++ b/IPython/html/static/notebook/js/widgetmanager.js @@ -23,7 +23,7 @@ // elsewhere. define(["underscore", "backbone", - ], function (underscore, backbone) { + ], function (Underscore, Backbone) { Backbone.sync = function (method, model, options) { // Sync widget models to back-end. diff --git a/IPython/html/static/notebook/js/widgets/widget.js b/IPython/html/static/notebook/js/widgets/widget.js index bf30c6262..21c0a69e8 100644 --- a/IPython/html/static/notebook/js/widgets/widget.js +++ b/IPython/html/static/notebook/js/widgets/widget.js @@ -17,7 +17,7 @@ define(["notebook/js/widgetmanager", "underscore", "backbone"], -function(widget_manager, underscore, backbone){ +function(WidgetManager, Underscore, Backbone){ var WidgetModel = Backbone.Model.extend({ constructor: function (widget_manager, model_id, comm) { @@ -211,7 +211,7 @@ function(widget_manager, underscore, backbone){ }, }); - widget_manager.register_widget_model('WidgetModel', WidgetModel); + WidgetManager.register_widget_model('WidgetModel', WidgetModel); var WidgetView = Backbone.View.extend({ @@ -387,6 +387,6 @@ function(widget_manager, underscore, backbone){ IPython.WidgetView = WidgetView; IPython.DOMWidgetView = DOMWidgetView; - // Pass through widget_manager instance (probably not a good practice). - return widget_manager; + // Pass through WidgetManager namespace. + return WidgetManager; }); diff --git a/IPython/html/static/notebook/js/widgets/widget_bool.js b/IPython/html/static/notebook/js/widgets/widget_bool.js index 1c2569f50..960b14391 100644 --- a/IPython/html/static/notebook/js/widgets/widget_bool.js +++ b/IPython/html/static/notebook/js/widgets/widget_bool.js @@ -14,7 +14,7 @@ * @namespace IPython **/ -define(["notebook/js/widgets/widget"], function(widget_manager){ +define(["notebook/js/widgets/widget"], function(WidgetManager){ var CheckBoxView = IPython.DOMWidgetView.extend({ render : function(){ @@ -67,7 +67,7 @@ define(["notebook/js/widgets/widget"], function(widget_manager){ }, }); - widget_manager.register_widget_view('CheckBoxView', CheckBoxView); + WidgetManager.register_widget_view('CheckBoxView', CheckBoxView); var ToggleButtonView = IPython.DOMWidgetView.extend({ @@ -121,5 +121,5 @@ define(["notebook/js/widgets/widget"], function(widget_manager){ this.touch(); }, }); - widget_manager.register_widget_view('ToggleButtonView', ToggleButtonView); + WidgetManager.register_widget_view('ToggleButtonView', ToggleButtonView); }); diff --git a/IPython/html/static/notebook/js/widgets/widget_button.js b/IPython/html/static/notebook/js/widgets/widget_button.js index f2df595dc..6a5f460d7 100644 --- a/IPython/html/static/notebook/js/widgets/widget_button.js +++ b/IPython/html/static/notebook/js/widgets/widget_button.js @@ -14,7 +14,7 @@ * @namespace IPython **/ -define(["notebook/js/widgets/widget"], function(widget_manager){ +define(["notebook/js/widgets/widget"], function(WidgetManager){ var ButtonView = IPython.DOMWidgetView.extend({ render : function(){ @@ -58,5 +58,5 @@ define(["notebook/js/widgets/widget"], function(widget_manager){ this.send({event: 'click'}); }, }); - widget_manager.register_widget_view('ButtonView', ButtonView); + WidgetManager.register_widget_view('ButtonView', ButtonView); }); diff --git a/IPython/html/static/notebook/js/widgets/widget_container.js b/IPython/html/static/notebook/js/widgets/widget_container.js index c8f478a53..9f8bde2f7 100644 --- a/IPython/html/static/notebook/js/widgets/widget_container.js +++ b/IPython/html/static/notebook/js/widgets/widget_container.js @@ -14,7 +14,7 @@ * @namespace IPython **/ -define(["notebook/js/widgets/widget"], function(widget_manager) { +define(["notebook/js/widgets/widget"], function(WidgetManager) { var ContainerView = IPython.DOMWidgetView.extend({ render: function(){ @@ -57,7 +57,7 @@ define(["notebook/js/widgets/widget"], function(widget_manager) { return ContainerView.__super__.update.apply(this); }, }); - widget_manager.register_widget_view('ContainerView', ContainerView); + WidgetManager.register_widget_view('ContainerView', ContainerView); var ModalView = IPython.DOMWidgetView.extend({ @@ -273,5 +273,5 @@ define(["notebook/js/widgets/widget"], function(widget_manager) { } }, }); - widget_manager.register_widget_view('ModalView', ModalView); + WidgetManager.register_widget_view('ModalView', ModalView); }); diff --git a/IPython/html/static/notebook/js/widgets/widget_float.js b/IPython/html/static/notebook/js/widgets/widget_float.js index f443985ef..aa06f72c3 100644 --- a/IPython/html/static/notebook/js/widgets/widget_float.js +++ b/IPython/html/static/notebook/js/widgets/widget_float.js @@ -5,16 +5,6 @@ // the file COPYING, distributed as part of this software. //---------------------------------------------------------------------------- -//============================================================================ -// FloatWidget -//============================================================================ - -/** - * @module IPython - * @namespace IPython - **/ - -define(["notebook/js/widgets/widget"], function(widget_manager){ - // The Views for this model are shared with the bounded float, and can be - // found in widget_float_range.js. -}); \ No newline at end of file +// This file is a place holder to maintain a one to one mapping of widget_*.py +// files and widget_*.js widget and test files. The Views for this model are +// shared with the bounded float, and can be found in widget_float_range.js. diff --git a/IPython/html/static/notebook/js/widgets/widget_image.js b/IPython/html/static/notebook/js/widgets/widget_image.js index b2b1045d5..26162d641 100644 --- a/IPython/html/static/notebook/js/widgets/widget_image.js +++ b/IPython/html/static/notebook/js/widgets/widget_image.js @@ -14,7 +14,7 @@ * @namespace IPython **/ -define(["notebook/js/widgets/widget"], function(widget_manager){ +define(["notebook/js/widgets/widget"], function(WidgetManager){ var ImageView = IPython.DOMWidgetView.extend({ render : function(){ @@ -47,5 +47,5 @@ define(["notebook/js/widgets/widget"], function(widget_manager){ return ImageView.__super__.update.apply(this); }, }); - widget_manager.register_widget_view('ImageView', ImageView); + WidgetManager.register_widget_view('ImageView', ImageView); }); diff --git a/IPython/html/static/notebook/js/widgets/widget_int.js b/IPython/html/static/notebook/js/widgets/widget_int.js index 708f37e32..164323864 100644 --- a/IPython/html/static/notebook/js/widgets/widget_int.js +++ b/IPython/html/static/notebook/js/widgets/widget_int.js @@ -5,16 +5,6 @@ // the file COPYING, distributed as part of this software. //---------------------------------------------------------------------------- -//============================================================================ -// IntWidget -//============================================================================ - -/** - * @module IPython - * @namespace IPython - **/ - -define(["notebook/js/widgets/widget"], function(widget_manager){ - // The Views for this model are shared with the bounded int, and can be - // found in widget_int_range.js. -}); \ No newline at end of file +// This file is a place holder to maintain a one to one mapping of widget_*.py +// files and widget_*.js widget and test files. The Views for this model are +// shared with the bounded int, and can be found in widget_int_range.js. diff --git a/IPython/html/static/notebook/js/widgets/widget_selection.js b/IPython/html/static/notebook/js/widgets/widget_selection.js index 32ff4c802..20bfb23cc 100644 --- a/IPython/html/static/notebook/js/widgets/widget_selection.js +++ b/IPython/html/static/notebook/js/widgets/widget_selection.js @@ -14,7 +14,7 @@ * @namespace IPython **/ -define(["notebook/js/widgets/widget"], function(widget_manager){ +define(["notebook/js/widgets/widget"], function(WidgetManager){ var DropdownView = IPython.DOMWidgetView.extend({ render : function(){ @@ -114,7 +114,7 @@ define(["notebook/js/widgets/widget"], function(widget_manager){ }, }); - widget_manager.register_widget_view('DropdownView', DropdownView); + WidgetManager.register_widget_view('DropdownView', DropdownView); var RadioButtonsView = IPython.DOMWidgetView.extend({ @@ -204,7 +204,7 @@ define(["notebook/js/widgets/widget"], function(widget_manager){ this.touch(); }, }); - widget_manager.register_widget_view('RadioButtonsView', RadioButtonsView); + WidgetManager.register_widget_view('RadioButtonsView', RadioButtonsView); var ToggleButtonsView = IPython.DOMWidgetView.extend({ @@ -289,7 +289,7 @@ define(["notebook/js/widgets/widget"], function(widget_manager){ this.touch(); }, }); - widget_manager.register_widget_view('ToggleButtonsView', ToggleButtonsView); + WidgetManager.register_widget_view('ToggleButtonsView', ToggleButtonsView); var ListBoxView = IPython.DOMWidgetView.extend({ @@ -371,5 +371,5 @@ define(["notebook/js/widgets/widget"], function(widget_manager){ this.touch(); }, }); - widget_manager.register_widget_view('ListBoxView', ListBoxView); + WidgetManager.register_widget_view('ListBoxView', ListBoxView); }); diff --git a/IPython/html/static/notebook/js/widgets/widget_selectioncontainer.js b/IPython/html/static/notebook/js/widgets/widget_selectioncontainer.js index bcaaeb442..1c3558c19 100644 --- a/IPython/html/static/notebook/js/widgets/widget_selectioncontainer.js +++ b/IPython/html/static/notebook/js/widgets/widget_selectioncontainer.js @@ -14,7 +14,7 @@ * @namespace IPython **/ -define(["notebook/js/widgets/widget"], function(widget_manager){ +define(["notebook/js/widgets/widget"], function(WidgetManager){ var AccordionView = IPython.DOMWidgetView.extend({ render: function(){ @@ -129,7 +129,7 @@ define(["notebook/js/widgets/widget"], function(widget_manager){ setTimeout(function(){ that.update(); }, 500); }, }); - widget_manager.register_widget_view('AccordionView', AccordionView); + WidgetManager.register_widget_view('AccordionView', AccordionView); var TabView = IPython.DOMWidgetView.extend({ @@ -240,5 +240,5 @@ define(["notebook/js/widgets/widget"], function(widget_manager){ this.containers[index].tab('show'); }, }); - widget_manager.register_widget_view('TabView', TabView); + WidgetManager.register_widget_view('TabView', TabView); }); diff --git a/IPython/html/static/notebook/js/widgets/widget_string.js b/IPython/html/static/notebook/js/widgets/widget_string.js index ebd62ed1d..a241faa63 100644 --- a/IPython/html/static/notebook/js/widgets/widget_string.js +++ b/IPython/html/static/notebook/js/widgets/widget_string.js @@ -14,7 +14,7 @@ * @namespace IPython **/ -define(["notebook/js/widgets/widget"], function(widget_manager){ +define(["notebook/js/widgets/widget"], function(WidgetManager){ var HTMLView = IPython.DOMWidgetView.extend({ render : function(){ @@ -31,7 +31,7 @@ define(["notebook/js/widgets/widget"], function(widget_manager){ return HTMLView.__super__.update.apply(this); }, }); - widget_manager.register_widget_view('HTMLView', HTMLView); + WidgetManager.register_widget_view('HTMLView', HTMLView); var LatexView = IPython.DOMWidgetView.extend({ @@ -51,7 +51,7 @@ define(["notebook/js/widgets/widget"], function(widget_manager){ return LatexView.__super__.update.apply(this); }, }); - widget_manager.register_widget_view('LatexView', LatexView); + WidgetManager.register_widget_view('LatexView', LatexView); var TextAreaView = IPython.DOMWidgetView.extend({ @@ -124,7 +124,7 @@ define(["notebook/js/widgets/widget"], function(widget_manager){ this.touch(); }, }); - widget_manager.register_widget_view('TextAreaView', TextAreaView); + WidgetManager.register_widget_view('TextAreaView', TextAreaView); var TextBoxView = IPython.DOMWidgetView.extend({ @@ -193,5 +193,5 @@ define(["notebook/js/widgets/widget"], function(widget_manager){ } }, }); - widget_manager.register_widget_view('TextBoxView', TextBoxView); + WidgetManager.register_widget_view('TextBoxView', TextBoxView); });