##// END OF EJS Templates
Only send diff message if diff isn't corrupt....
Jonathan Frederic -
Show More
@@ -1,437 +1,458 b''
1 //----------------------------------------------------------------------------
1 //----------------------------------------------------------------------------
2 // Copyright (C) 2013 The IPython Development Team
2 // Copyright (C) 2013 The IPython Development Team
3 //
3 //
4 // Distributed under the terms of the BSD License. The full license is in
4 // Distributed under the terms of the BSD License. The full license is in
5 // the file COPYING, distributed as part of this software.
5 // the file COPYING, distributed as part of this software.
6 //----------------------------------------------------------------------------
6 //----------------------------------------------------------------------------
7
7
8 //============================================================================
8 //============================================================================
9 // Base Widget Model and View classes
9 // Base Widget Model and View classes
10 //============================================================================
10 //============================================================================
11
11
12 /**
12 /**
13 * @module IPython
13 * @module IPython
14 * @namespace IPython
14 * @namespace IPython
15 **/
15 **/
16
16
17 define(["notebook/js/widgetmanager",
17 define(["notebook/js/widgetmanager",
18 "underscore",
18 "underscore",
19 "backbone"],
19 "backbone"],
20 function(WidgetManager, _, Backbone){
20 function(WidgetManager, _, Backbone){
21
21
22 var WidgetModel = Backbone.Model.extend({
22 var WidgetModel = Backbone.Model.extend({
23 constructor: function (widget_manager, model_id, comm) {
23 constructor: function (widget_manager, model_id, comm) {
24 // Constructor
24 // Constructor
25 //
25 //
26 // Creates a WidgetModel instance.
26 // Creates a WidgetModel instance.
27 //
27 //
28 // Parameters
28 // Parameters
29 // ----------
29 // ----------
30 // widget_manager : WidgetManager instance
30 // widget_manager : WidgetManager instance
31 // model_id : string
31 // model_id : string
32 // An ID unique to this model.
32 // An ID unique to this model.
33 // comm : Comm instance (optional)
33 // comm : Comm instance (optional)
34 this.widget_manager = widget_manager;
34 this.widget_manager = widget_manager;
35 this._set_calls = 0;
35 this.pending_msgs = 0;
36 this.pending_msgs = 0;
36 this.msg_throttle = 3;
37 this.msg_throttle = 3;
37 this.msg_buffer = null;
38 this.msg_buffer = null;
38 this.key_value_lock = null;
39 this.key_value_lock = null;
39 this.id = model_id;
40 this.id = model_id;
40 this.views = [];
41 this.views = [];
41
42
42 if (comm !== undefined) {
43 if (comm !== undefined) {
43 // Remember comm associated with the model.
44 // Remember comm associated with the model.
44 this.comm = comm;
45 this.comm = comm;
45 comm.model = this;
46 comm.model = this;
46
47
47 // Hook comm messages up to model.
48 // Hook comm messages up to model.
48 comm.on_close($.proxy(this._handle_comm_closed, this));
49 comm.on_close($.proxy(this._handle_comm_closed, this));
49 comm.on_msg($.proxy(this._handle_comm_msg, this));
50 comm.on_msg($.proxy(this._handle_comm_msg, this));
50 }
51 }
51 return Backbone.Model.apply(this);
52 return Backbone.Model.apply(this);
52 },
53 },
53
54
54 send: function (content, callbacks) {
55 send: function (content, callbacks) {
55 // Send a custom msg over the comm.
56 // Send a custom msg over the comm.
56 if (this.comm !== undefined) {
57 if (this.comm !== undefined) {
57 var data = {method: 'custom', content: content};
58 var data = {method: 'custom', content: content};
58 this.comm.send(data, callbacks);
59 this.comm.send(data, callbacks);
59 this.pending_msgs++;
60 this.pending_msgs++;
60 }
61 }
61 },
62 },
62
63
63 _handle_comm_closed: function (msg) {
64 _handle_comm_closed: function (msg) {
64 // Handle when a widget is closed.
65 // Handle when a widget is closed.
65 this.trigger('comm:close');
66 this.trigger('comm:close');
66 delete this.comm.model; // Delete ref so GC will collect widget model.
67 delete this.comm.model; // Delete ref so GC will collect widget model.
67 delete this.comm;
68 delete this.comm;
68 delete this.model_id; // Delete id from model so widget manager cleans up.
69 delete this.model_id; // Delete id from model so widget manager cleans up.
69 _.each(this.views, function(view, i) {
70 _.each(this.views, function(view, i) {
70 view.remove();
71 view.remove();
71 });
72 });
72 },
73 },
73
74
74 _handle_comm_msg: function (msg) {
75 _handle_comm_msg: function (msg) {
75 // Handle incoming comm msg.
76 // Handle incoming comm msg.
76 var method = msg.content.data.method;
77 var method = msg.content.data.method;
77 switch (method) {
78 switch (method) {
78 case 'update':
79 case 'update':
79 this.apply_update(msg.content.data.state);
80 this.apply_update(msg.content.data.state);
80 break;
81 break;
81 case 'custom':
82 case 'custom':
82 this.trigger('msg:custom', msg.content.data.content);
83 this.trigger('msg:custom', msg.content.data.content);
83 break;
84 break;
84 case 'display':
85 case 'display':
85 this.widget_manager.display_view(msg, this);
86 this.widget_manager.display_view(msg, this);
86 break;
87 break;
87 }
88 }
88 },
89 },
89
90
90 apply_update: function (state) {
91 apply_update: function (state) {
91 // Handle when a widget is updated via the python side.
92 // Handle when a widget is updated via the python side.
92 var that = this;
93 var that = this;
93 _.each(state, function(value, key) {
94 _.each(state, function(value, key) {
94 that.key_value_lock = [key, value];
95 that.key_value_lock = [key, value];
95 try {
96 try {
96 that.set(key, that._unpack_models(value));
97 that.set(key, that._unpack_models(value));
97 } finally {
98 } finally {
98 that.key_value_lock = null;
99 that.key_value_lock = null;
99 }
100 }
100 });
101 });
101 },
102 },
102
103
103 _handle_status: function (msg, callbacks) {
104 _handle_status: function (msg, callbacks) {
104 // Handle status msgs.
105 // Handle status msgs.
105
106
106 // execution_state : ('busy', 'idle', 'starting')
107 // execution_state : ('busy', 'idle', 'starting')
107 if (this.comm !== undefined) {
108 if (this.comm !== undefined) {
108 if (msg.content.execution_state ==='idle') {
109 if (msg.content.execution_state ==='idle') {
109 // Send buffer if this message caused another message to be
110 // Send buffer if this message caused another message to be
110 // throttled.
111 // throttled.
111 if (this.msg_buffer !== null &&
112 if (this.msg_buffer !== null &&
112 this.msg_throttle === this.pending_msgs) {
113 this.msg_throttle === this.pending_msgs) {
113 var data = {method: 'backbone', sync_method: 'update', sync_data: this.msg_buffer};
114 var data = {method: 'backbone', sync_method: 'update', sync_data: this.msg_buffer};
114 this.comm.send(data, callbacks);
115 this.comm.send(data, callbacks);
115 this.msg_buffer = null;
116 this.msg_buffer = null;
116 } else {
117 } else {
117 --this.pending_msgs;
118 --this.pending_msgs;
118 }
119 }
119 }
120 }
120 }
121 }
121 },
122 },
122
123
123 callbacks: function(view) {
124 callbacks: function(view) {
124 // Create msg callbacks for a comm msg.
125 // Create msg callbacks for a comm msg.
125 var callbacks = this.widget_manager.callbacks(view);
126 var callbacks = this.widget_manager.callbacks(view);
126
127
127 if (callbacks.iopub === undefined) {
128 if (callbacks.iopub === undefined) {
128 callbacks.iopub = {};
129 callbacks.iopub = {};
129 }
130 }
130
131
131 var that = this;
132 var that = this;
132 callbacks.iopub.status = function (msg) {
133 callbacks.iopub.status = function (msg) {
133 that._handle_status(msg, callbacks);
134 that._handle_status(msg, callbacks);
134 };
135 };
135 return callbacks;
136 return callbacks;
136 },
137 },
137
138
139 set: function(key, val, options) {
140 // Set a value.
141 this._set_calls++;
142 return WidgetModel.__super__.set.apply(this, arguments);
143 },
144
138 sync: function (method, model, options) {
145 sync: function (method, model, options) {
139 // Handle sync to the back-end. Called when a model.save() is called.
146 // Handle sync to the back-end. Called when a model.save() is called.
140
147
141 // Make sure a comm exists.
148 // Make sure a comm exists.
142 var error = options.error || function() {
149 var error = options.error || function() {
143 console.error('Backbone sync error:', arguments);
150 console.error('Backbone sync error:', arguments);
144 };
151 };
145 if (this.comm === undefined) {
152 if (this.comm === undefined) {
146 error();
153 error();
147 return false;
154 return false;
148 }
155 }
149
156
150 // Delete any key value pairs that the back-end already knows about.
157 // Delete any key value pairs that the back-end already knows about.
151 var attrs = (method === 'patch') ? options.attrs : model.toJSON(options);
158 var attrs = (method === 'patch') ? options.attrs : model.toJSON(options);
152 if (this.key_value_lock !== null) {
159 if (this.key_value_lock !== null) {
153 var key = this.key_value_lock[0];
160 var key = this.key_value_lock[0];
154 var value = this.key_value_lock[1];
161 var value = this.key_value_lock[1];
155 if (attrs[key] === value) {
162 if (attrs[key] === value) {
156 delete attrs[key];
163 delete attrs[key];
157 }
164 }
158 }
165 }
159
166
160 // Only sync if there are attributes to send to the back-end.
167 // Only sync if there are attributes to send to the back-end.
168 attrs = this._pack_models(attrs);
161 if (_.size(attrs) > 0) {
169 if (_.size(attrs) > 0) {
162
170
163 // If this message was sent via backbone itself, it will not
171 // If this message was sent via backbone itself, it will not
164 // have any callbacks. It's important that we create callbacks
172 // have any callbacks. It's important that we create callbacks
165 // so we can listen for status messages, etc...
173 // so we can listen for status messages, etc...
166 var callbacks = options.callbacks || this.callbacks();
174 var callbacks = options.callbacks || this.callbacks();
167
175
168 // Check throttle.
176 // Check throttle.
169 if (this.pending_msgs >= this.msg_throttle) {
177 if (this.pending_msgs >= this.msg_throttle) {
170 // The throttle has been exceeded, buffer the current msg so
178 // The throttle has been exceeded, buffer the current msg so
171 // it can be sent once the kernel has finished processing
179 // it can be sent once the kernel has finished processing
172 // some of the existing messages.
180 // some of the existing messages.
173
181
174 // Combine updates if it is a 'patch' sync, otherwise replace updates
182 // Combine updates if it is a 'patch' sync, otherwise replace updates
175 switch (method) {
183 switch (method) {
176 case 'patch':
184 case 'patch':
177 this.msg_buffer = $.extend(this.msg_buffer || {}, attrs);
185 this.msg_buffer = $.extend(this.msg_buffer || {}, attrs);
178 break;
186 break;
179 case 'update':
187 case 'update':
180 case 'create':
188 case 'create':
181 this.msg_buffer = attrs;
189 this.msg_buffer = attrs;
182 break;
190 break;
183 default:
191 default:
184 error();
192 error();
185 return false;
193 return false;
186 }
194 }
187 this.msg_buffer_callbacks = callbacks;
195 this.msg_buffer_callbacks = callbacks;
188
196
189 } else {
197 } else {
190 // We haven't exceeded the throttle, send the message like
198 // We haven't exceeded the throttle, send the message like
191 // normal.
199 // normal.
192 var data = {method: 'backbone', sync_data: attrs};
200 var data = {method: 'backbone', sync_data: attrs};
193 this.comm.send(data, callbacks);
201 this.comm.send(data, callbacks);
194 this.pending_msgs++;
202 this.pending_msgs++;
195 }
203 }
196 }
204 }
197 // Since the comm is a one-way communication, assume the message
205 // Since the comm is a one-way communication, assume the message
198 // arrived. Don't call success since we don't have a model back from the server
206 // arrived. Don't call success since we don't have a model back from the server
199 // this means we miss out on the 'sync' event.
207 // this means we miss out on the 'sync' event.
208 this._set_calls = 0;
200 },
209 },
201
210
202 save_changes: function(callbacks) {
211 save_changes: function(callbacks) {
203 // Push this model's state to the back-end
212 // Push this model's state to the back-end
204 //
213 //
205 // This invokes a Backbone.Sync.
214 // This invokes a Backbone.Sync.
215
216 // Backbone only remembers the diff of the most recent set()
217 // opertation. Calling set multiple times in a row results in a
218 // loss of diff information which means we need to send a full
219 // state. If diffing is important to the user, model.set(...) should
220 // only be called once prior to a view.touch(). If multiple
221 // parameters need to be set, use the model.set({key1: val1, key2: val2, ...})
222 // signature.
223 if (self._set_calls <= 1) {
206 this.save(this.changedAttributes(), {patch: true, callbacks: callbacks});
224 this.save(this.changedAttributes(), {patch: true, callbacks: callbacks});
225 } else {
226 this.save(null, {patch: false, callbacks: callbacks});
227 }
207 },
228 },
208
229
209 _pack_models: function(value) {
230 _pack_models: function(value) {
210 // Replace models with model ids recursively.
231 // Replace models with model ids recursively.
211 if (value instanceof Backbone.Model) {
232 if (value instanceof Backbone.Model) {
212 return value.id;
233 return value.id;
213
234
214 } else if ($.isArray(value)) {
235 } else if ($.isArray(value)) {
215 var packed = [];
236 var packed = [];
216 var that = this;
237 var that = this;
217 _.each(value, function(sub_value, key) {
238 _.each(value, function(sub_value, key) {
218 packed.push(that._pack_models(sub_value));
239 packed.push(that._pack_models(sub_value));
219 });
240 });
220 return packed;
241 return packed;
221
242
222 } else if (value instanceof Object) {
243 } else if (value instanceof Object) {
223 var packed = {};
244 var packed = {};
224 var that = this;
245 var that = this;
225 _.each(value, function(sub_value, key) {
246 _.each(value, function(sub_value, key) {
226 packed[key] = that._pack_models(sub_value);
247 packed[key] = that._pack_models(sub_value);
227 });
248 });
228 return packed;
249 return packed;
229
250
230 } else {
251 } else {
231 return value;
252 return value;
232 }
253 }
233 },
254 },
234
255
235 _unpack_models: function(value) {
256 _unpack_models: function(value) {
236 // Replace model ids with models recursively.
257 // Replace model ids with models recursively.
237 if ($.isArray(value)) {
258 if ($.isArray(value)) {
238 var unpacked = [];
259 var unpacked = [];
239 var that = this;
260 var that = this;
240 _.each(value, function(sub_value, key) {
261 _.each(value, function(sub_value, key) {
241 unpacked.push(that._unpack_models(sub_value));
262 unpacked.push(that._unpack_models(sub_value));
242 });
263 });
243 return unpacked;
264 return unpacked;
244
265
245 } else if (value instanceof Object) {
266 } else if (value instanceof Object) {
246 var unpacked = {};
267 var unpacked = {};
247 var that = this;
268 var that = this;
248 _.each(value, function(sub_value, key) {
269 _.each(value, function(sub_value, key) {
249 unpacked[key] = that._unpack_models(sub_value);
270 unpacked[key] = that._unpack_models(sub_value);
250 });
271 });
251 return unpacked;
272 return unpacked;
252
273
253 } else {
274 } else {
254 var model = this.widget_manager.get_model(value);
275 var model = this.widget_manager.get_model(value);
255 if (model) {
276 if (model) {
256 return model;
277 return model;
257 } else {
278 } else {
258 return value;
279 return value;
259 }
280 }
260 }
281 }
261 },
282 },
262
283
263 });
284 });
264 WidgetManager.register_widget_model('WidgetModel', WidgetModel);
285 WidgetManager.register_widget_model('WidgetModel', WidgetModel);
265
286
266
287
267 var WidgetView = Backbone.View.extend({
288 var WidgetView = Backbone.View.extend({
268 initialize: function(parameters) {
289 initialize: function(parameters) {
269 // Public constructor.
290 // Public constructor.
270 this.model.on('change',this.update,this);
291 this.model.on('change',this.update,this);
271 this.options = parameters.options;
292 this.options = parameters.options;
272 this.child_views = [];
293 this.child_views = [];
273 this.model.views.push(this);
294 this.model.views.push(this);
274 },
295 },
275
296
276 update: function(){
297 update: function(){
277 // Triggered on model change.
298 // Triggered on model change.
278 //
299 //
279 // Update view to be consistent with this.model
300 // Update view to be consistent with this.model
280 },
301 },
281
302
282 create_child_view: function(child_model, options) {
303 create_child_view: function(child_model, options) {
283 // Create and return a child view.
304 // Create and return a child view.
284 //
305 //
285 // -given a model and (optionally) a view name if the view name is
306 // -given a model and (optionally) a view name if the view name is
286 // not given, it defaults to the model's default view attribute.
307 // not given, it defaults to the model's default view attribute.
287
308
288 // TODO: this is hacky, and makes the view depend on this cell attribute and widget manager behavior
309 // TODO: this is hacky, and makes the view depend on this cell attribute and widget manager behavior
289 // it would be great to have the widget manager add the cell metadata
310 // it would be great to have the widget manager add the cell metadata
290 // to the subview without having to add it here.
311 // to the subview without having to add it here.
291 var child_view = this.model.widget_manager.create_view(child_model, options || {}, this);
312 var child_view = this.model.widget_manager.create_view(child_model, options || {}, this);
292 this.child_views[child_model.id] = child_view;
313 this.child_views[child_model.id] = child_view;
293 return child_view;
314 return child_view;
294 },
315 },
295
316
296 delete_child_view: function(child_model, options) {
317 delete_child_view: function(child_model, options) {
297 // Delete a child view that was previously created using create_child_view.
318 // Delete a child view that was previously created using create_child_view.
298 var view = this.child_views[child_model.id];
319 var view = this.child_views[child_model.id];
299 if (view !== undefined) {
320 if (view !== undefined) {
300 delete this.child_views[child_model.id];
321 delete this.child_views[child_model.id];
301 view.remove();
322 view.remove();
302 }
323 }
303 },
324 },
304
325
305 do_diff: function(old_list, new_list, removed_callback, added_callback) {
326 do_diff: function(old_list, new_list, removed_callback, added_callback) {
306 // Difference a changed list and call remove and add callbacks for
327 // Difference a changed list and call remove and add callbacks for
307 // each removed and added item in the new list.
328 // each removed and added item in the new list.
308 //
329 //
309 // Parameters
330 // Parameters
310 // ----------
331 // ----------
311 // old_list : array
332 // old_list : array
312 // new_list : array
333 // new_list : array
313 // removed_callback : Callback(item)
334 // removed_callback : Callback(item)
314 // Callback that is called for each item removed.
335 // Callback that is called for each item removed.
315 // added_callback : Callback(item)
336 // added_callback : Callback(item)
316 // Callback that is called for each item added.
337 // Callback that is called for each item added.
317
338
318
339
319 // removed items
340 // removed items
320 _.each(_.difference(old_list, new_list), function(item, index, list) {
341 _.each(_.difference(old_list, new_list), function(item, index, list) {
321 removed_callback(item);
342 removed_callback(item);
322 }, this);
343 }, this);
323
344
324 // added items
345 // added items
325 _.each(_.difference(new_list, old_list), function(item, index, list) {
346 _.each(_.difference(new_list, old_list), function(item, index, list) {
326 added_callback(item);
347 added_callback(item);
327 }, this);
348 }, this);
328 },
349 },
329
350
330 callbacks: function(){
351 callbacks: function(){
331 // Create msg callbacks for a comm msg.
352 // Create msg callbacks for a comm msg.
332 return this.model.callbacks(this);
353 return this.model.callbacks(this);
333 },
354 },
334
355
335 render: function(){
356 render: function(){
336 // Render the view.
357 // Render the view.
337 //
358 //
338 // By default, this is only called the first time the view is created
359 // By default, this is only called the first time the view is created
339 },
360 },
340
361
341 send: function (content) {
362 send: function (content) {
342 // Send a custom msg associated with this view.
363 // Send a custom msg associated with this view.
343 this.model.send(content, this.callbacks());
364 this.model.send(content, this.callbacks());
344 },
365 },
345
366
346 touch: function () {
367 touch: function () {
347 this.model.save_changes(this.callbacks());
368 this.model.save_changes(this.callbacks());
348 },
369 },
349 });
370 });
350
371
351
372
352 var DOMWidgetView = WidgetView.extend({
373 var DOMWidgetView = WidgetView.extend({
353 initialize: function (options) {
374 initialize: function (options) {
354 // Public constructor
375 // Public constructor
355
376
356 // In the future we may want to make changes more granular
377 // In the future we may want to make changes more granular
357 // (e.g., trigger on visible:change).
378 // (e.g., trigger on visible:change).
358 this.model.on('change', this.update, this);
379 this.model.on('change', this.update, this);
359 this.model.on('msg:custom', this.on_msg, this);
380 this.model.on('msg:custom', this.on_msg, this);
360 DOMWidgetView.__super__.initialize.apply(this, arguments);
381 DOMWidgetView.__super__.initialize.apply(this, arguments);
361 },
382 },
362
383
363 on_msg: function(msg) {
384 on_msg: function(msg) {
364 // Handle DOM specific msgs.
385 // Handle DOM specific msgs.
365 switch(msg.msg_type) {
386 switch(msg.msg_type) {
366 case 'add_class':
387 case 'add_class':
367 this.add_class(msg.selector, msg.class_list);
388 this.add_class(msg.selector, msg.class_list);
368 break;
389 break;
369 case 'remove_class':
390 case 'remove_class':
370 this.remove_class(msg.selector, msg.class_list);
391 this.remove_class(msg.selector, msg.class_list);
371 break;
392 break;
372 }
393 }
373 },
394 },
374
395
375 add_class: function (selector, class_list) {
396 add_class: function (selector, class_list) {
376 // Add a DOM class to an element.
397 // Add a DOM class to an element.
377 this._get_selector_element(selector).addClass(class_list);
398 this._get_selector_element(selector).addClass(class_list);
378 },
399 },
379
400
380 remove_class: function (selector, class_list) {
401 remove_class: function (selector, class_list) {
381 // Remove a DOM class from an element.
402 // Remove a DOM class from an element.
382 this._get_selector_element(selector).removeClass(class_list);
403 this._get_selector_element(selector).removeClass(class_list);
383 },
404 },
384
405
385 update: function () {
406 update: function () {
386 // Update the contents of this view
407 // Update the contents of this view
387 //
408 //
388 // Called when the model is changed. The model may have been
409 // Called when the model is changed. The model may have been
389 // changed by another view or by a state update from the back-end.
410 // changed by another view or by a state update from the back-end.
390 // The very first update seems to happen before the element is
411 // The very first update seems to happen before the element is
391 // finished rendering so we use setTimeout to give the element time
412 // finished rendering so we use setTimeout to give the element time
392 // to render
413 // to render
393 var e = this.$el;
414 var e = this.$el;
394 var visible = this.model.get('visible');
415 var visible = this.model.get('visible');
395 setTimeout(function() {e.toggle(visible);},0);
416 setTimeout(function() {e.toggle(visible);},0);
396
417
397 var css = this.model.get('_css');
418 var css = this.model.get('_css');
398 if (css === undefined) {return;}
419 if (css === undefined) {return;}
399 var that = this;
420 var that = this;
400 _.each(css, function(css_traits, selector){
421 _.each(css, function(css_traits, selector){
401 // Apply the css traits to all elements that match the selector.
422 // Apply the css traits to all elements that match the selector.
402 var elements = that._get_selector_element(selector);
423 var elements = that._get_selector_element(selector);
403 if (elements.length > 0) {
424 if (elements.length > 0) {
404 _.each(css_traits, function(css_value, css_key){
425 _.each(css_traits, function(css_value, css_key){
405 elements.css(css_key, css_value);
426 elements.css(css_key, css_value);
406 });
427 });
407 }
428 }
408 });
429 });
409 },
430 },
410
431
411 _get_selector_element: function (selector) {
432 _get_selector_element: function (selector) {
412 // Get the elements via the css selector.
433 // Get the elements via the css selector.
413
434
414 // If the selector is blank, apply the style to the $el_to_style
435 // If the selector is blank, apply the style to the $el_to_style
415 // element. If the $el_to_style element is not defined, use apply
436 // element. If the $el_to_style element is not defined, use apply
416 // the style to the view's element.
437 // the style to the view's element.
417 var elements;
438 var elements;
418 if (!selector) {
439 if (!selector) {
419 if (this.$el_to_style === undefined) {
440 if (this.$el_to_style === undefined) {
420 elements = this.$el;
441 elements = this.$el;
421 } else {
442 } else {
422 elements = this.$el_to_style;
443 elements = this.$el_to_style;
423 }
444 }
424 } else {
445 } else {
425 elements = this.$el.find(selector);
446 elements = this.$el.find(selector);
426 }
447 }
427 return elements;
448 return elements;
428 },
449 },
429 });
450 });
430
451
431 IPython.WidgetModel = WidgetModel;
452 IPython.WidgetModel = WidgetModel;
432 IPython.WidgetView = WidgetView;
453 IPython.WidgetView = WidgetView;
433 IPython.DOMWidgetView = DOMWidgetView;
454 IPython.DOMWidgetView = DOMWidgetView;
434
455
435 // Pass through WidgetManager namespace.
456 // Pass through WidgetManager namespace.
436 return WidgetManager;
457 return WidgetManager;
437 });
458 });
General Comments 0
You need to be logged in to leave comments. Login now