Show More
@@ -307,10 +307,21 b' define(["components/underscore/underscore-min",' | |||||
307 | var WidgetView = Backbone.View.extend({ |
|
307 | var WidgetView = Backbone.View.extend({ | |
308 |
|
308 | |||
309 | initialize: function() { |
|
309 | initialize: function() { | |
|
310 | this.visible = true; | |||
310 | this.model.on('change',this.update,this); |
|
311 | this.model.on('change',this.update,this); | |
311 | }, |
|
312 | }, | |
312 |
|
313 | |||
313 | update: function() { |
|
314 | update: function() { | |
|
315 | if (this.model.get('visible') != undefined) { | |||
|
316 | if (this.visible != this.model.get('visible')) { | |||
|
317 | this.visible = this.model.get('visible'); | |||
|
318 | if (this.visible) { | |||
|
319 | this.$el.show(); | |||
|
320 | } else { | |||
|
321 | this.$el.hide(); | |||
|
322 | } | |||
|
323 | } | |||
|
324 | } | |||
314 | if (this.model.css != undefined) { |
|
325 | if (this.model.css != undefined) { | |
315 | for (var selector in this.model.css) { |
|
326 | for (var selector in this.model.css) { | |
316 | if (this.model.css.hasOwnProperty(selector)) { |
|
327 | if (this.model.css.hasOwnProperty(selector)) { |
@@ -21,7 +21,7 b' import os' | |||||
21 | import IPython |
|
21 | import IPython | |
22 | from IPython.kernel.comm import Comm |
|
22 | from IPython.kernel.comm import Comm | |
23 | from IPython.config import LoggingConfigurable |
|
23 | from IPython.config import LoggingConfigurable | |
24 | from IPython.utils.traitlets import Unicode, Dict, List, Instance |
|
24 | from IPython.utils.traitlets import Unicode, Dict, List, Instance, Bool | |
25 | from IPython.display import Javascript, display |
|
25 | from IPython.display import Javascript, display | |
26 | from IPython.utils.py3compat import string_types |
|
26 | from IPython.utils.py3compat import string_types | |
27 |
|
27 | |||
@@ -50,6 +50,7 b' class Widget(LoggingConfigurable):' | |||||
50 | default_view_name = Unicode(help="""Default view registered in the frontend |
|
50 | default_view_name = Unicode(help="""Default view registered in the frontend | |
51 | to use to represent the widget.""") |
|
51 | to use to represent the widget.""") | |
52 | parent = Instance('IPython.html.widgets.widget.Widget') |
|
52 | parent = Instance('IPython.html.widgets.widget.Widget') | |
|
53 | visible = Bool(True, help="Whether or not the widget is visible.") | |||
53 |
|
54 | |||
54 | def _parent_changed(self, name, old, new): |
|
55 | def _parent_changed(self, name, old, new): | |
55 | if self._displayed: |
|
56 | if self._displayed: | |
@@ -107,7 +108,7 b' class Widget(LoggingConfigurable):' | |||||
107 |
|
108 | |||
108 | # Properties |
|
109 | # Properties | |
109 | def _get_keys(self): |
|
110 | def _get_keys(self): | |
110 | keys = ['_css'] |
|
111 | keys = ['_css', 'visible'] | |
111 | keys.extend(self._keys) |
|
112 | keys.extend(self._keys) | |
112 | return keys |
|
113 | return keys | |
113 | keys = property(_get_keys) |
|
114 | keys = property(_get_keys) |
General Comments 0
You need to be logged in to leave comments.
Login now