diff --git a/IPython/html/static/notebook/js/widgetmanager.js b/IPython/html/static/notebook/js/widgetmanager.js index 5529ddf..7dc90e6 100644 --- a/IPython/html/static/notebook/js/widgetmanager.js +++ b/IPython/html/static/notebook/js/widgetmanager.js @@ -27,7 +27,7 @@ // Backbone.sync method must be in widgetmanager.js file instead of // widget.js so it can be overwritten for different contexts. - Backbone.sync = function (method, model, options, error) { + Backbone.sync = function (method, model, options) { var result = model._handle_sync(method, options); if (options.success) { options.success(result); @@ -51,6 +51,7 @@ // Register already-registered widget model types with the comm manager. for (var widget_model_name in this._model_types) { + // TODO: Should not be a for. this.comm_manager.register_target(widget_model_name, $.proxy(this._handle_comm_open, this)); } }; diff --git a/IPython/html/static/notebook/js/widgets/widget_container.js b/IPython/html/static/notebook/js/widgets/widget_container.js index 98b1675..005b005 100644 --- a/IPython/html/static/notebook/js/widgets/widget_container.js +++ b/IPython/html/static/notebook/js/widgets/widget_container.js @@ -16,34 +16,6 @@ define(["notebook/js/widgets/widget"], function(widget_manager) { - var set_flex_property = function(element, property_name, enabled) { - if (enabled) { - element.addClass(property_name); - } else { - element.removeClass(property_name); - } - }; - - var set_flex_properties = function(context, element) { - - // Apply flexible box model properties by adding and removing - // corrosponding CSS classes. - // Defined in IPython/html/static/base/less/flexbox.less - set_flex_property(element, 'vbox', context.model.get('_vbox')); - set_flex_property(element, 'hbox', context.model.get('_hbox')); - set_flex_property(element, 'start', context.model.get('_pack_start')); - set_flex_property(element, 'center', context.model.get('_pack_center')); - set_flex_property(element, 'end', context.model.get('_pack_end')); - set_flex_property(element, 'align-start', context.model.get('_align_start')); - set_flex_property(element, 'align-center', context.model.get('_align_center')); - set_flex_property(element, 'align-end', context.model.get('_align_end')); - set_flex_property(element, 'box-flex0', context.model.get('_flex0')); - set_flex_property(element, 'box-flex1', context.model.get('_flex1')); - set_flex_property(element, 'box-flex2', context.model.get('_flex2')); - }; - - - var ContainerModel = IPython.WidgetModel.extend({}); widget_manager.register_widget_model('ContainerWidgetModel', ContainerModel); @@ -73,7 +45,6 @@ define(["notebook/js/widgets/widget"], function(widget_manager) { // // Called when the model is changed. The model may have been // changed by another view or by a state update from the back-end. - set_flex_properties(this, this.$el); return ContainerView.__super__.update.apply(this); }, }); @@ -233,8 +204,6 @@ define(["notebook/js/widgets/widget"], function(widget_manager) { // // Called when the model is changed. The model may have been // changed by another view or by a state update from the back-end. - set_flex_properties(this, this.$body); - var description = this.model.get('description'); description = description.replace(/ /g, ' ', 'm'); description = description.replace(/\n/g, '
\n', 'm'); diff --git a/IPython/html/tests/casperjs/test_cases/widgets_floatrange.js b/IPython/html/tests/casperjs/test_cases/widgets_floatrange.js index 826434d..c6c3cbd 100644 --- a/IPython/html/tests/casperjs/test_cases/widgets_floatrange.js +++ b/IPython/html/tests/casperjs/test_cases/widgets_floatrange.js @@ -11,8 +11,9 @@ casper.notebook_test(function () { var floatrange_index = this.append_cell( 'floatrange = widgets.FloatRangeWidget()\n' + + 'floatrange2 = widgets.FloatRangeWidget()\n' + 'display(floatrange)\n' + - 'display(floatrange, view_name="FloatTextView")\n' + + 'display(floatrange2)\n' + 'print("Success")\n'); this.execute_cell_then(floatrange_index, function(index){ diff --git a/IPython/html/widgets/widget.py b/IPython/html/widgets/widget.py index 2182d2d..df69558 100644 --- a/IPython/html/widgets/widget.py +++ b/IPython/html/widgets/widget.py @@ -327,7 +327,7 @@ class DOMWidget(Widget): # Private/protected declarations _css = Dict() # Internal CSS property dict - keys = ['visible', '_css'] + Widget.keys + keys = ['visible', '_css'] + Widget.keys # TODO def get_css(self, key, selector=""): """Get a CSS property of the widget. diff --git a/IPython/html/widgets/widget_container.py b/IPython/html/widgets/widget_container.py index d8eb8d0..ae89546 100644 --- a/IPython/html/widgets/widget_container.py +++ b/IPython/html/widgets/widget_container.py @@ -25,179 +25,8 @@ class ContainerWidget(DOMWidget): # Keys, all private and managed by helper methods. Flexible box model # classes... - keys = ['_vbox', '_hbox', '_align_start', '_align_end', '_align_center', - '_pack_start', '_pack_end', '_pack_center', '_flex0', '_flex1', - '_flex2', 'description', 'button_text', - 'children'] + DOMWidget.keys + keys = ['description', 'button_text', 'children'] + DOMWidget.keys # TODO: Use add/remove_class children = List(Instance(DOMWidget)) description = Unicode() button_text = Unicode() - _hbox = Bool(False) - _vbox = Bool(False) - _align_start = Bool(False) - _align_end = Bool(False) - _align_center = Bool(False) - _pack_start = Bool(False) - _pack_end = Bool(False) - _pack_center = Bool(False) - _flex0 = Bool(False) - _flex1 = Bool(False) - _flex2 = Bool(False) - - def hbox(self, enabled=True): - """Make this container an hbox. Automatically disables conflicting - features. - - Parameters - ---------- - enabled: bool (optional) - Enabled or disable the hbox feature of the container, defaults to - True.""" - self._hbox = enabled - if enabled: - self._vbox = False - - def vbox(self, enabled=True): - """Make this container an vbox. Automatically disables conflicting - features. - - Parameters - ---------- - enabled: bool (optional) - Enabled or disable the vbox feature of the container, defaults to - True.""" - self._vbox = enabled - if enabled: - self._hbox = False - - def align_start(self, enabled=True): - """Make the contents of this container align to the start of the axis. - Automatically disables conflicting alignments. - - Parameters - ---------- - enabled: bool (optional) - Enabled or disable the start alignment of the container, defaults to - True.""" - self._align_start = enabled - if enabled: - self._align_end = False - self._align_center = False - - def align_end(self, enabled=True): - """Make the contents of this container align to the end of the axis. - Automatically disables conflicting alignments. - - Parameters - ---------- - enabled: bool (optional) - Enabled or disable the end alignment of the container, defaults to - True.""" - self._align_end = enabled - if enabled: - self._align_start = False - self._align_center = False - - def align_center(self, enabled=True): - """Make the contents of this container align to the center of the axis. - Automatically disables conflicting alignments. - - Parameters - ---------- - enabled: bool (optional) - Enabled or disable the center alignment of the container, defaults to - True.""" - self._align_center = enabled - if enabled: - self._align_start = False - self._align_end = False - - - def pack_start(self, enabled=True): - """Make the contents of this container pack to the start of the axis. - Automatically disables conflicting packings. - - Parameters - ---------- - enabled: bool (optional) - Enabled or disable the start packing of the container, defaults to - True.""" - self._pack_start = enabled - if enabled: - self._pack_end = False - self._pack_center = False - - def pack_end(self, enabled=True): - """Make the contents of this container pack to the end of the axis. - Automatically disables conflicting packings. - - Parameters - ---------- - enabled: bool (optional) - Enabled or disable the end packing of the container, defaults to - True.""" - self._pack_end = enabled - if enabled: - self._pack_start = False - self._pack_center = False - - def pack_center(self, enabled=True): - """Make the contents of this container pack to the center of the axis. - Automatically disables conflicting packings. - - Parameters - ---------- - enabled: bool (optional) - Enabled or disable the center packing of the container, defaults to - True.""" - self._pack_center = enabled - if enabled: - self._pack_start = False - self._pack_end = False - - - def flex0(self, enabled=True): - """Put this container in flex0 mode. Automatically disables conflicting - flex modes. See the widget tutorial part 5 example notebook for more - information. - - Parameters - ---------- - enabled: bool (optional) - Enabled or disable the flex0 attribute of the container, defaults to - True.""" - self._flex0 = enabled - if enabled: - self._flex1 = False - self._flex2 = False - - def flex1(self, enabled=True): - """Put this container in flex1 mode. Automatically disables conflicting - flex modes. See the widget tutorial part 5 example notebook for more - information. - - Parameters - ---------- - enabled: bool (optional) - Enabled or disable the flex1 attribute of the container, defaults to - True.""" - self._flex1 = enabled - if enabled: - self._flex0 = False - self._flex2 = False - - def flex2(self, enabled=True): - """Put this container in flex2 mode. Automatically disables conflicting - flex modes. See the widget tutorial part 5 example notebook for more - information. - - Parameters - ---------- - enabled: bool (optional) - Enabled or disable the flex2 attribute of the container, defaults to - True.""" - self._flex2 = enabled - if enabled: - self._flex0 = False - self._flex1 = False diff --git a/IPython/html/widgets/widget_image.py b/IPython/html/widgets/widget_image.py index 1ecdae6..d7557b7 100644 --- a/IPython/html/widgets/widget_image.py +++ b/IPython/html/widgets/widget_image.py @@ -29,7 +29,7 @@ class ImageWidget(DOMWidget): # Define the custom state properties to sync with the front-end keys = ['format', 'width', 'height', '_b64value'] + DOMWidget.keys format = Unicode('png') - width = Unicode() + width = Unicode() # TODO: C unicode height = Unicode() _b64value = Unicode() diff --git a/IPython/html/widgets/widget_selection.py b/IPython/html/widgets/widget_selection.py index cb935a9..91256d6 100644 --- a/IPython/html/widgets/widget_selection.py +++ b/IPython/html/widgets/widget_selection.py @@ -25,7 +25,7 @@ class SelectionWidget(DOMWidget): # Keys keys = ['value', 'values', 'disabled', 'description'] + DOMWidget.keys - value = Unicode(help="Selected value") + value = Unicode(help="Selected value") # TODO: Any support values = List(help="List of values the user can select") disabled = Bool(False, help="Enable or disable user changes") description = Unicode(help="Description of the value this widget represents")