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