From f9ac12eb4402d5bcd9863df1cc49d6243b8ed60f 2014-01-17 17:03:29 From: Jonathan Frederic Date: 2014-01-17 17:03:29 Subject: [PATCH] Widget require.js fix The WidgetManager namespace is passed around instead of a widget_manager instance... --- diff --git a/IPython/html/static/notebook/js/widgetmanager.js b/IPython/html/static/notebook/js/widgetmanager.js index dbb3ab0..26697ae 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 bf30c62..21c0a69 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 1c2569f..960b143 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 f2df595..6a5f460 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 c8f478a..9f8bde2 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 f443985..aa06f72 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_float_range.js b/IPython/html/static/notebook/js/widgets/widget_float_range.js index 7b17462..7074ece 100644 --- a/IPython/html/static/notebook/js/widgets/widget_float_range.js +++ b/IPython/html/static/notebook/js/widgets/widget_float_range.js @@ -14,7 +14,7 @@ * @namespace IPython **/ -define(["notebook/js/widgets/widget"], function(widget_manager){ +define(["notebook/js/widgets/widget"], function(WidgetManager){ var FloatSliderView = IPython.DOMWidgetView.extend({ render : function(){ @@ -121,7 +121,7 @@ define(["notebook/js/widgets/widget"], function(widget_manager){ this.touch(); }, }); - widget_manager.register_widget_view('FloatSliderView', FloatSliderView); + WidgetManager.register_widget_view('FloatSliderView', FloatSliderView); var FloatTextView = IPython.DOMWidgetView.extend({ @@ -218,7 +218,7 @@ define(["notebook/js/widgets/widget"], function(widget_manager){ } } }); - widget_manager.register_widget_view('FloatTextView', FloatTextView); + WidgetManager.register_widget_view('FloatTextView', FloatTextView); var ProgressView = IPython.DOMWidgetView.extend({ @@ -263,5 +263,5 @@ define(["notebook/js/widgets/widget"], function(widget_manager){ return ProgressView.__super__.update.apply(this); }, }); - widget_manager.register_widget_view('ProgressView', ProgressView); + WidgetManager.register_widget_view('ProgressView', ProgressView); }); diff --git a/IPython/html/static/notebook/js/widgets/widget_image.js b/IPython/html/static/notebook/js/widgets/widget_image.js index b2b1045..26162d6 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 708f37e..1643238 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_int_range.js b/IPython/html/static/notebook/js/widgets/widget_int_range.js index 1f762af..a02a98b 100644 --- a/IPython/html/static/notebook/js/widgets/widget_int_range.js +++ b/IPython/html/static/notebook/js/widgets/widget_int_range.js @@ -14,7 +14,7 @@ * @namespace IPython **/ -define(["notebook/js/widgets/widget"], function(widget_manager){ +define(["notebook/js/widgets/widget"], function(WidgetManager){ var IntSliderView = IPython.DOMWidgetView.extend({ render : function(){ @@ -120,7 +120,7 @@ define(["notebook/js/widgets/widget"], function(widget_manager){ this.touch(); }, }); - widget_manager.register_widget_view('IntSliderView', IntSliderView); + WidgetManager.register_widget_view('IntSliderView', IntSliderView); var IntTextView = IPython.DOMWidgetView.extend({ @@ -216,5 +216,5 @@ define(["notebook/js/widgets/widget"], function(widget_manager){ } } }); - widget_manager.register_widget_view('IntTextView', IntTextView); + WidgetManager.register_widget_view('IntTextView', IntTextView); }); diff --git a/IPython/html/static/notebook/js/widgets/widget_selection.js b/IPython/html/static/notebook/js/widgets/widget_selection.js index 32ff4c8..20bfb23 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 bcaaeb4..1c3558c 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 ebd62ed..a241faa 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); });