Show More
@@ -18,10 +18,7 b' define(["notebook/js/widgetmanager",' | |||
|
18 | 18 | "underscore", |
|
19 | 19 | "backbone"], |
|
20 | 20 | function(widget_manager, underscore, backbone){ |
|
21 | ||
|
22 | //-------------------------------------------------------------------- | |
|
23 | // WidgetModel class | |
|
24 | //-------------------------------------------------------------------- | |
|
21 | ||
|
25 | 22 | var WidgetModel = Backbone.Model.extend({ |
|
26 | 23 | constructor: function (widget_manager, model_id, comm) { |
|
27 | 24 | // Construcctor |
@@ -55,14 +52,15 b' function(widget_manager, underscore, backbone){' | |||
|
55 | 52 | }, |
|
56 | 53 | |
|
57 | 54 | send: function (content, callbacks) { |
|
55 | // Send a custom msg over the comm. | |
|
58 | 56 | if (this.comm !== undefined) { |
|
59 | 57 | var data = {method: 'custom', custom_content: content}; |
|
60 | 58 | this.comm.send(data, callbacks); |
|
61 | 59 | } |
|
62 | 60 | }, |
|
63 | 61 | |
|
64 | // Handle when a widget is closed. | |
|
65 | 62 | _handle_comm_closed: function (msg) { |
|
63 | // Handle when a widget is closed. | |
|
66 | 64 | this.trigger('comm:close'); |
|
67 | 65 | delete this.comm.model; // Delete ref so GC will collect widget model. |
|
68 | 66 | delete this.comm; |
@@ -70,9 +68,8 b' function(widget_manager, underscore, backbone){' | |||
|
70 | 68 | // TODO: Handle deletion, like this.destroy(), and delete views, etc. |
|
71 | 69 | }, |
|
72 | 70 | |
|
73 | ||
|
74 | // Handle incoming comm msg. | |
|
75 | 71 | _handle_comm_msg: function (msg) { |
|
72 | // Handle incoming comm msg. | |
|
76 | 73 | var method = msg.content.data.method; |
|
77 | 74 | switch (method) { |
|
78 | 75 | case 'update': |
@@ -87,9 +84,8 b' function(widget_manager, underscore, backbone){' | |||
|
87 | 84 | } |
|
88 | 85 | }, |
|
89 | 86 | |
|
90 | ||
|
91 | // Handle when a widget is updated via the python side. | |
|
92 | 87 | apply_update: function (state) { |
|
88 | // Handle when a widget is updated via the python side. | |
|
93 | 89 | for (var key in state) { |
|
94 | 90 | if (state.hasOwnProperty(key)) { |
|
95 | 91 | var value = state[key]; |
@@ -105,9 +101,10 b' function(widget_manager, underscore, backbone){' | |||
|
105 | 101 | this.save(); |
|
106 | 102 | }, |
|
107 | 103 | |
|
108 | ||
|
109 | 104 | _handle_status: function (msg, callbacks) { |
|
110 | //execution_state : ('busy', 'idle', 'starting') | |
|
105 | // Handle status msgs. | |
|
106 | ||
|
107 | // execution_state : ('busy', 'idle', 'starting') | |
|
111 | 108 | if (this.comm !== undefined) { |
|
112 | 109 | if (msg.content.execution_state ==='idle') { |
|
113 | 110 | // Send buffer if this message caused another message to be |
@@ -124,9 +121,8 b' function(widget_manager, underscore, backbone){' | |||
|
124 | 121 | } |
|
125 | 122 | }, |
|
126 | 123 | |
|
127 | ||
|
128 | // Custom syncronization logic. | |
|
129 | 124 | _handle_sync: function (method, options) { |
|
125 | // Custom syncronization logic. | |
|
130 | 126 | var model_json = this.toJSON(); |
|
131 | 127 | var attr; |
|
132 | 128 | |
@@ -176,6 +172,7 b' function(widget_manager, underscore, backbone){' | |||
|
176 | 172 | }, |
|
177 | 173 | |
|
178 | 174 | _pack_models: function(value) { |
|
175 | // Replace models with model ids recursively. | |
|
179 | 176 | if (value instanceof Backbone.Model) { |
|
180 | 177 | return value.id; |
|
181 | 178 | } else if (value instanceof Object) { |
@@ -190,6 +187,7 b' function(widget_manager, underscore, backbone){' | |||
|
190 | 187 | }, |
|
191 | 188 | |
|
192 | 189 | _unpack_models: function(value) { |
|
190 | // Replace model ids with models recursively. | |
|
193 | 191 | if (value instanceof Object) { |
|
194 | 192 | var unpacked = {}; |
|
195 | 193 | for (var key in value) { |
@@ -210,11 +208,9 b' function(widget_manager, underscore, backbone){' | |||
|
210 | 208 | widget_manager.register_widget_model('WidgetModel', WidgetModel); |
|
211 | 209 | |
|
212 | 210 | |
|
213 | //-------------------------------------------------------------------- | |
|
214 | // WidgetView class | |
|
215 | //-------------------------------------------------------------------- | |
|
216 | 211 | var WidgetView = Backbone.View.extend({ |
|
217 | 212 | initialize: function(parameters) { |
|
213 | // Public constructor. | |
|
218 | 214 | this.model.on('change',this.update,this); |
|
219 | 215 | this.options = parameters.options; |
|
220 | 216 | this.child_views = []; |
@@ -222,19 +218,23 b' function(widget_manager, underscore, backbone){' | |||
|
222 | 218 | }, |
|
223 | 219 | |
|
224 | 220 | update: function(){ |
|
225 | // update view to be consistent with this.model | |
|
226 | // triggered on model change | |
|
221 | // Triggered on model change. | |
|
222 | // | |
|
223 | // Update view to be consistent with this.model | |
|
227 | 224 | }, |
|
228 | 225 | |
|
229 | 226 | create_child_view: function(child_model, options) { |
|
230 |
// |
|
|
231 | // if the view name is not given, it defaults to the model's default view attribute | |
|
227 | // Create and return a child view. | |
|
228 | // | |
|
229 | // - given a model and (optionally) a view name if the view name is | |
|
230 | // not given, it defaults to the model's default view attribute. | |
|
232 | 231 | var child_view = this.model.widget_manager.create_view(child_model, options); |
|
233 | 232 | this.child_views[child_model.id] = child_view; |
|
234 | 233 | return child_view; |
|
235 | 234 | }, |
|
236 | 235 | |
|
237 | 236 | delete_child_view: function(child_model, options) { |
|
237 | // Delete a child view that was previously created using create_child_view. | |
|
238 | 238 | var view = this.child_views[child_model.id]; |
|
239 | 239 | delete this.child_views[child_model.id]; |
|
240 | 240 | view.remove(); |
@@ -266,31 +266,42 b' function(widget_manager, underscore, backbone){' | |||
|
266 | 266 | }, |
|
267 | 267 | |
|
268 | 268 | callbacks: function(){ |
|
269 | // Create msg callbacks for a comm msg. | |
|
269 | 270 | return this.model.widget_manager.callbacks(this); |
|
270 | 271 | }, |
|
271 | 272 | |
|
272 | 273 | render: function(){ |
|
273 | // render the view. By default, this is only called the first time the view is created | |
|
274 | // Render the view. | |
|
275 | // | |
|
276 | // By default, this is only called the first time the view is created | |
|
274 | 277 | }, |
|
278 | ||
|
275 | 279 | send: function (content) { |
|
280 | // Send a custom msg associated with this view. | |
|
276 | 281 | this.model.send(content, this.callbacks()); |
|
277 | 282 | }, |
|
278 | 283 | |
|
279 | 284 | touch: function () { |
|
285 | // Associate recent model changes with this notebook. | |
|
280 | 286 | this.model.save(this.model.changedAttributes(), {patch: true, callbacks: this.callbacks()}); |
|
281 | 287 | }, |
|
282 | 288 | |
|
283 | 289 | }); |
|
284 | 290 | |
|
291 | ||
|
285 | 292 | var DOMWidgetView = WidgetView.extend({ |
|
286 | 293 | initialize: function (options) { |
|
287 | // TODO: make changes more granular (e.g., trigger on visible:change) | |
|
294 | // Public constructor | |
|
295 | ||
|
296 | // In the future we may want to make changes more granular | |
|
297 | // (e.g., trigger on visible:change). | |
|
288 | 298 | this.model.on('change', this.update, this); |
|
289 | 299 | this.model.on('msg:custom', this.on_msg, this); |
|
290 | 300 | DOMWidgetView.__super__.initialize.apply(this, arguments); |
|
291 | 301 | }, |
|
292 | 302 | |
|
293 | 303 | on_msg: function(msg) { |
|
304 | // Handle DOM specific msgs. | |
|
294 | 305 | switch(msg.msg_type) { |
|
295 | 306 | case 'add_class': |
|
296 | 307 | this.add_class(msg.selector, msg.class_list); |
@@ -302,10 +313,12 b' function(widget_manager, underscore, backbone){' | |||
|
302 | 313 | }, |
|
303 | 314 | |
|
304 | 315 | add_class: function (selector, class_list) { |
|
316 | // Add a DOM class to an element. | |
|
305 | 317 | this._get_selector_element(selector).addClass(class_list); |
|
306 | 318 | }, |
|
307 | 319 | |
|
308 | 320 | remove_class: function (selector, class_list) { |
|
321 | // Remove a DOM class from an element. | |
|
309 | 322 | this._get_selector_element(selector).removeClass(class_list); |
|
310 | 323 | }, |
|
311 | 324 | |
@@ -340,10 +353,11 b' function(widget_manager, underscore, backbone){' | |||
|
340 | 353 | }, |
|
341 | 354 | |
|
342 | 355 | _get_selector_element: function (selector) { |
|
343 |
// Get the elements via the css selector. |
|
|
344 | // blank, apply the style to the $el_to_style element. If | |
|
345 | // the $el_to_style element is not defined, use apply the | |
|
346 | // style to the view's element. | |
|
356 | // Get the elements via the css selector. | |
|
357 | ||
|
358 | // If the selector is blank, apply the style to the $el_to_style | |
|
359 | // element. If the $el_to_style element is not defined, use apply | |
|
360 | // the style to the view's element. | |
|
347 | 361 | var elements; |
|
348 | 362 | if (selector === undefined || selector === null || selector === '') { |
|
349 | 363 | if (this.$el_to_style === undefined) { |
@@ -362,5 +376,6 b' function(widget_manager, underscore, backbone){' | |||
|
362 | 376 | IPython.WidgetView = WidgetView; |
|
363 | 377 | IPython.DOMWidgetView = DOMWidgetView; |
|
364 | 378 | |
|
379 | // Pass through widget_manager instance (probably not a good practice). | |
|
365 | 380 | return widget_manager; |
|
366 | 381 | }); |
@@ -15,10 +15,10 b'' | |||
|
15 | 15 | **/ |
|
16 | 16 | |
|
17 | 17 | define(["notebook/js/widgets/widget"], function(widget_manager){ |
|
18 | ||
|
18 | 19 | var CheckBoxView = IPython.DOMWidgetView.extend({ |
|
19 | ||
|
20 | // Called when view is rendered. | |
|
21 | 20 | render : function(){ |
|
21 | // Called when view is rendered. | |
|
22 | 22 | this.$el |
|
23 | 23 | .addClass('widget-hbox-single'); |
|
24 | 24 | this.$label = $('<div />') |
@@ -35,6 +35,8 b' define(["notebook/js/widgets/widget"], function(widget_manager){' | |||
|
35 | 35 | }, |
|
36 | 36 | |
|
37 | 37 | handle_click: function() { |
|
38 | // Handles when the checkbox is clicked. | |
|
39 | ||
|
38 | 40 | // Calling model.set will trigger all of the other views of the |
|
39 | 41 | // model to update. |
|
40 | 42 | var value = this.model.get('value'); |
@@ -65,13 +67,12 b' define(["notebook/js/widgets/widget"], function(widget_manager){' | |||
|
65 | 67 | }, |
|
66 | 68 | |
|
67 | 69 | }); |
|
68 | ||
|
69 | 70 | widget_manager.register_widget_view('CheckBoxView', CheckBoxView); |
|
70 | 71 | |
|
72 | ||
|
71 | 73 | var ToggleButtonView = IPython.DOMWidgetView.extend({ |
|
72 | ||
|
73 | // Called when view is rendered. | |
|
74 | 74 | render : function() { |
|
75 | // Called when view is rendered. | |
|
75 | 76 | var that = this; |
|
76 | 77 | this.setElement($('<button />') |
|
77 | 78 | .addClass('btn') |
@@ -110,8 +111,8 b' define(["notebook/js/widgets/widget"], function(widget_manager){' | |||
|
110 | 111 | return ToggleButtonView.__super__.update.apply(this); |
|
111 | 112 | }, |
|
112 | 113 | |
|
113 | // Handles and validates user input. | |
|
114 | 114 | handle_click: function(e) { |
|
115 | // Handles and validates user input. | |
|
115 | 116 | |
|
116 | 117 | // Calling model.set will trigger all of the other views of the |
|
117 | 118 | // model to update. |
@@ -120,7 +121,5 b' define(["notebook/js/widgets/widget"], function(widget_manager){' | |||
|
120 | 121 | this.touch(); |
|
121 | 122 | }, |
|
122 | 123 | }); |
|
123 | ||
|
124 | 124 | widget_manager.register_widget_view('ToggleButtonView', ToggleButtonView); |
|
125 | ||
|
126 | 125 | }); |
@@ -15,10 +15,10 b'' | |||
|
15 | 15 | **/ |
|
16 | 16 | |
|
17 | 17 | define(["notebook/js/widgets/widget"], function(widget_manager){ |
|
18 | var ButtonView = IPython.DOMWidgetView.extend({ | |
|
19 | ||
|
20 | // Called when view is rendered. | |
|
18 | ||
|
19 | var ButtonView = IPython.DOMWidgetView.extend({ | |
|
21 | 20 | render : function(){ |
|
21 | // Called when view is rendered. | |
|
22 | 22 | this.setElement($("<button />") |
|
23 | 23 | .addClass('btn')); |
|
24 | 24 | |
@@ -49,14 +49,14 b' define(["notebook/js/widgets/widget"], function(widget_manager){' | |||
|
49 | 49 | }, |
|
50 | 50 | |
|
51 | 51 | events: { |
|
52 | // Dictionary of events and their handlers. | |
|
52 | 53 | 'click': '_handle_click', |
|
53 | 54 | }, |
|
54 | 55 | |
|
55 | 56 | _handle_click: function(){ |
|
57 | // Handles when the button is clicked. | |
|
56 | 58 | this.send({event: 'click'}); |
|
57 | 59 | }, |
|
58 | 60 | }); |
|
59 | ||
|
60 | 61 | widget_manager.register_widget_view('ButtonView', ButtonView); |
|
61 | ||
|
62 | 62 | }); |
@@ -15,9 +15,10 b'' | |||
|
15 | 15 | **/ |
|
16 | 16 | |
|
17 | 17 | define(["notebook/js/widgets/widget"], function(widget_manager) { |
|
18 | var ContainerView = IPython.DOMWidgetView.extend({ | |
|
19 | ||
|
18 | ||
|
19 | var ContainerView = IPython.DOMWidgetView.extend({ | |
|
20 | 20 | render: function(){ |
|
21 | // Called when view is rendered. | |
|
21 | 22 | this.$el |
|
22 | 23 | .addClass('widget-container'); |
|
23 | 24 | this.children={}; |
@@ -29,6 +30,7 b' define(["notebook/js/widgets/widget"], function(widget_manager) {' | |||
|
29 | 30 | }, |
|
30 | 31 | |
|
31 | 32 | update_children: function(old_list, new_list) { |
|
33 | // Called when the children list changes. | |
|
32 | 34 | this.do_diff(old_list, |
|
33 | 35 | new_list, |
|
34 | 36 | $.proxy(this.remove_child_model, this), |
@@ -36,11 +38,13 b' define(["notebook/js/widgets/widget"], function(widget_manager) {' | |||
|
36 | 38 | }, |
|
37 | 39 | |
|
38 | 40 | remove_child_model: function(model) { |
|
41 | // Called when a model is removed from the children list. | |
|
39 | 42 | this.child_views[model.id].remove(); |
|
40 | 43 | this.delete_child_view(model); |
|
41 | 44 | }, |
|
42 | 45 | |
|
43 | 46 | add_child_model: function(model) { |
|
47 | // Called when a model is added to the children list. | |
|
44 | 48 | var view = this.create_child_view(model); |
|
45 | 49 | this.$el.append(view.$el); |
|
46 | 50 | }, |
@@ -53,13 +57,12 b' define(["notebook/js/widgets/widget"], function(widget_manager) {' | |||
|
53 | 57 | return ContainerView.__super__.update.apply(this); |
|
54 | 58 | }, |
|
55 | 59 | }); |
|
56 | ||
|
57 | 60 | widget_manager.register_widget_view('ContainerView', ContainerView); |
|
58 | 61 | |
|
59 | 62 | |
|
60 | var ModalView = IPython.DOMWidgetView.extend({ | |
|
61 | ||
|
63 | var ModalView = IPython.DOMWidgetView.extend({ | |
|
62 | 64 | render: function(){ |
|
65 | // Called when view is rendered. | |
|
63 | 66 | var that = this; |
|
64 | 67 | this.children={}; |
|
65 | 68 | this.update_children([], this.model.get('children')); |
@@ -160,13 +163,14 b' define(["notebook/js/widgets/widget"], function(widget_manager) {' | |||
|
160 | 163 | }, |
|
161 | 164 | |
|
162 | 165 | hide: function() { |
|
166 | // Called when the modal hide button is clicked. | |
|
163 | 167 | this.$window.hide(); |
|
164 | 168 | this.$show_button.removeClass('btn-info'); |
|
165 | 169 | }, |
|
166 | 170 | |
|
167 | 171 | show: function() { |
|
172 | // Called when the modal show button is clicked. | |
|
168 | 173 | this.$show_button.addClass('btn-info'); |
|
169 | ||
|
170 | 174 | this.$window.show(); |
|
171 | 175 | if (this.popped_out) { |
|
172 | 176 | this.$window.css("positon", "absolute"); |
@@ -178,6 +182,7 b' define(["notebook/js/widgets/widget"], function(widget_manager) {' | |||
|
178 | 182 | }, |
|
179 | 183 | |
|
180 | 184 | bring_to_front: function() { |
|
185 | // Make the modal top-most, z-ordered about the other modals. | |
|
181 | 186 | var $widget_modals = $(".widget-modal"); |
|
182 | 187 | var max_zindex = 0; |
|
183 | 188 | $widget_modals.each(function (index, el){ |
@@ -197,6 +202,7 b' define(["notebook/js/widgets/widget"], function(widget_manager) {' | |||
|
197 | 202 | }, |
|
198 | 203 | |
|
199 | 204 | update_children: function(old_list, new_list) { |
|
205 | // Called when the children list is modified. | |
|
200 | 206 | this.do_diff(old_list, |
|
201 | 207 | new_list, |
|
202 | 208 | $.proxy(this.remove_child_model, this), |
@@ -204,11 +210,13 b' define(["notebook/js/widgets/widget"], function(widget_manager) {' | |||
|
204 | 210 | }, |
|
205 | 211 | |
|
206 | 212 | remove_child_model: function(model) { |
|
213 | // Called when a child is removed from children list. | |
|
207 | 214 | this.child_views[model.id].remove(); |
|
208 | 215 | this.delete_child_view(model); |
|
209 | 216 | }, |
|
210 | 217 | |
|
211 | 218 | add_child_model: function(model) { |
|
219 | // Called when a child is added to children list. | |
|
212 | 220 | var view = this.create_child_view(model); |
|
213 | 221 | this.$body.append(view.$el); |
|
214 | 222 | }, |
@@ -245,7 +253,8 b' define(["notebook/js/widgets/widget"], function(widget_manager) {' | |||
|
245 | 253 | }, |
|
246 | 254 | |
|
247 | 255 | _get_selector_element: function(selector) { |
|
248 | ||
|
256 | // Get an element view a 'special' jquery selector. (see widget.js) | |
|
257 | // | |
|
249 | 258 | // Since the modal actually isn't within the $el in the DOM, we need to extend |
|
250 | 259 | // the selector logic to allow the user to set css on the modal if need be. |
|
251 | 260 | // The convention used is: |
@@ -263,8 +272,6 b' define(["notebook/js/widgets/widget"], function(widget_manager) {' | |||
|
263 | 272 | return ModalView.__super__._get_selector_element.apply(this, [selector]); |
|
264 | 273 | } |
|
265 | 274 | }, |
|
266 | ||
|
267 | 275 | }); |
|
268 | ||
|
269 | 276 | widget_manager.register_widget_view('ModalView', ModalView); |
|
270 | 277 | }); |
@@ -15,10 +15,10 b'' | |||
|
15 | 15 | **/ |
|
16 | 16 | |
|
17 | 17 | define(["notebook/js/widgets/widget"], function(widget_manager){ |
|
18 | ||
|
18 | 19 | var FloatSliderView = IPython.DOMWidgetView.extend({ |
|
19 | ||
|
20 | // Called when view is rendered. | |
|
21 | 20 | render : function(){ |
|
21 | // Called when view is rendered. | |
|
22 | 22 | this.$el |
|
23 | 23 | .addClass('widget-hbox-single'); |
|
24 | 24 | this.$label = $('<div />') |
@@ -107,24 +107,26 b' define(["notebook/js/widgets/widget"], function(widget_manager){' | |||
|
107 | 107 | return FloatSliderView.__super__.update.apply(this); |
|
108 | 108 | }, |
|
109 | 109 | |
|
110 | // Handles: User input | |
|
111 | events: { "slide" : "handleSliderChange" }, | |
|
110 | events: { | |
|
111 | // Dictionary of events and their handlers. | |
|
112 | "slide" : "handleSliderChange" | |
|
113 | }, | |
|
114 | ||
|
112 | 115 | handleSliderChange: function(e, ui) { |
|
113 | ||
|
116 | // Handle when the slider value is changed. | |
|
117 | ||
|
114 | 118 | // Calling model.set will trigger all of the other views of the |
|
115 | 119 | // model to update. |
|
116 | 120 | this.model.set('value', ui.value, {updated_view: this}); |
|
117 | 121 | this.touch(); |
|
118 | 122 | }, |
|
119 | 123 | }); |
|
120 | ||
|
121 | 124 | widget_manager.register_widget_view('FloatSliderView', FloatSliderView); |
|
122 | 125 | |
|
123 | 126 | |
|
124 | var FloatTextView = IPython.DOMWidgetView.extend({ | |
|
125 | ||
|
126 | // Called when view is rendered. | |
|
127 | var FloatTextView = IPython.DOMWidgetView.extend({ | |
|
127 | 128 | render : function(){ |
|
129 | // Called when view is rendered. | |
|
128 | 130 | this.$el |
|
129 | 131 | .addClass('widget-hbox-single'); |
|
130 | 132 | this.$label = $('<div />') |
@@ -144,7 +146,6 b' define(["notebook/js/widgets/widget"], function(widget_manager){' | |||
|
144 | 146 | // |
|
145 | 147 | // Called when the model is changed. The model may have been |
|
146 | 148 | // changed by another view or by a state update from the back-end. |
|
147 | ||
|
148 | 149 | if (options === undefined || options.updated_view != this) { |
|
149 | 150 | var value = this.model.get('value'); |
|
150 | 151 | if (parseFloat(this.$textbox.val()) != value) { |
@@ -168,15 +169,20 b' define(["notebook/js/widgets/widget"], function(widget_manager){' | |||
|
168 | 169 | return FloatTextView.__super__.update.apply(this); |
|
169 | 170 | }, |
|
170 | 171 | |
|
172 | events: { | |
|
173 | // Dictionary of events and their handlers. | |
|
174 | ||
|
175 | "keyup input" : "handleChanging", | |
|
176 | "paste input" : "handleChanging", | |
|
177 | "cut input" : "handleChanging", | |
|
178 | ||
|
179 | // Fires only when control is validated or looses focus. | |
|
180 | "change input" : "handleChanged" | |
|
181 | }, | |
|
171 | 182 | |
|
172 | events: {"keyup input" : "handleChanging", | |
|
173 | "paste input" : "handleChanging", | |
|
174 | "cut input" : "handleChanging", | |
|
175 | "change input" : "handleChanged"}, // Fires only when control is validated or looses focus. | |
|
176 | ||
|
177 | // Handles and validates user input. | |
|
178 | 183 | handleChanging: function(e) { |
|
179 | ||
|
184 | // Handles and validates user input. | |
|
185 | ||
|
180 | 186 | // Try to parse value as a float. |
|
181 | 187 | var numericalValue = 0.0; |
|
182 | 188 | if (e.target.value !== '') { |
@@ -205,22 +211,19 b' define(["notebook/js/widgets/widget"], function(widget_manager){' | |||
|
205 | 211 | } |
|
206 | 212 | }, |
|
207 | 213 | |
|
208 | // Applies validated input. | |
|
209 | 214 | handleChanged: function(e) { |
|
210 |
// |
|
|
215 | // Applies validated input. | |
|
211 | 216 | if (this.model.get('value') != e.target.value) { |
|
212 | 217 | e.target.value = this.model.get('value'); |
|
213 | 218 | } |
|
214 | 219 | } |
|
215 | 220 | }); |
|
216 | ||
|
217 | 221 | widget_manager.register_widget_view('FloatTextView', FloatTextView); |
|
218 | 222 | |
|
219 | 223 | |
|
220 | var ProgressView = IPython.DOMWidgetView.extend({ | |
|
221 | ||
|
222 | // Called when view is rendered. | |
|
224 | var ProgressView = IPython.DOMWidgetView.extend({ | |
|
223 | 225 | render : function(){ |
|
226 | // Called when view is rendered. | |
|
224 | 227 | this.$el |
|
225 | 228 | .addClass('widget-hbox-single'); |
|
226 | 229 | this.$label = $('<div />') |
@@ -258,9 +261,7 b' define(["notebook/js/widgets/widget"], function(widget_manager){' | |||
|
258 | 261 | this.$label.show(); |
|
259 | 262 | } |
|
260 | 263 | return ProgressView.__super__.update.apply(this); |
|
261 | }, | |
|
262 | ||
|
264 | }, | |
|
263 | 265 | }); |
|
264 | ||
|
265 | 266 | widget_manager.register_widget_view('ProgressView', ProgressView); |
|
266 | 267 | }); |
@@ -15,10 +15,10 b'' | |||
|
15 | 15 | **/ |
|
16 | 16 | |
|
17 | 17 | define(["notebook/js/widgets/widget"], function(widget_manager){ |
|
18 | var ImageView = IPython.DOMWidgetView.extend({ | |
|
19 | ||
|
20 | // Called when view is rendered. | |
|
18 | ||
|
19 | var ImageView = IPython.DOMWidgetView.extend({ | |
|
21 | 20 | render : function(){ |
|
21 | // Called when view is rendered. | |
|
22 | 22 | this.setElement($("<img />")); |
|
23 | 23 | this.update(); // Set defaults. |
|
24 | 24 | }, |
@@ -46,9 +46,6 b' define(["notebook/js/widgets/widget"], function(widget_manager){' | |||
|
46 | 46 | } |
|
47 | 47 | return ImageView.__super__.update.apply(this); |
|
48 | 48 | }, |
|
49 | ||
|
50 | 49 | }); |
|
51 | ||
|
52 | 50 | widget_manager.register_widget_view('ImageView', ImageView); |
|
53 | ||
|
54 | 51 | }); |
@@ -15,10 +15,10 b'' | |||
|
15 | 15 | **/ |
|
16 | 16 | |
|
17 | 17 | define(["notebook/js/widgets/widget"], function(widget_manager){ |
|
18 | var IntSliderView = IPython.DOMWidgetView.extend({ | |
|
19 | ||
|
20 | // Called when view is rendered. | |
|
18 | ||
|
19 | var IntSliderView = IPython.DOMWidgetView.extend({ | |
|
21 | 20 | render : function(){ |
|
21 | // Called when view is rendered. | |
|
22 | 22 | this.$el |
|
23 | 23 | .addClass('widget-hbox-single'); |
|
24 | 24 | this.$label = $('<div />') |
@@ -106,23 +106,26 b' define(["notebook/js/widgets/widget"], function(widget_manager){' | |||
|
106 | 106 | return IntSliderView.__super__.update.apply(this); |
|
107 | 107 | }, |
|
108 | 108 | |
|
109 | // Handles: User input | |
|
110 | events: { "slide" : "handleSliderChange" }, | |
|
109 | events: { | |
|
110 | // Dictionary of events and their handlers. | |
|
111 | "slide" : "handleSliderChange" | |
|
112 | }, | |
|
113 | ||
|
111 | 114 | handleSliderChange: function(e, ui) { |
|
112 | ||
|
115 | // Called when the slider value is changed. | |
|
116 | ||
|
113 | 117 | // Calling model.set will trigger all of the other views of the |
|
114 | 118 | // model to update. |
|
115 | 119 | this.model.set('value', ~~ui.value, {updated_view: this}); // Double bit-wise not to truncate decimel |
|
116 | 120 | this.touch(); |
|
117 | 121 | }, |
|
118 | 122 | }); |
|
119 | ||
|
120 | 123 | widget_manager.register_widget_view('IntSliderView', IntSliderView); |
|
121 | 124 | |
|
122 | var IntTextView = IPython.DOMWidgetView.extend({ | |
|
123 | ||
|
124 | // Called when view is rendered. | |
|
125 | ||
|
126 | var IntTextView = IPython.DOMWidgetView.extend({ | |
|
125 | 127 | render : function(){ |
|
128 | // Called when view is rendered. | |
|
126 | 129 | this.$el |
|
127 | 130 | .addClass('widget-hbox-single'); |
|
128 | 131 | this.$label = $('<div />') |
@@ -164,15 +167,19 b' define(["notebook/js/widgets/widget"], function(widget_manager){' | |||
|
164 | 167 | } |
|
165 | 168 | return IntTextView.__super__.update.apply(this); |
|
166 | 169 | }, |
|
170 | ||
|
171 | events: { | |
|
172 | // Dictionary of events and their handlers. | |
|
173 | "keyup input" : "handleChanging", | |
|
174 | "paste input" : "handleChanging", | |
|
175 | "cut input" : "handleChanging", | |
|
176 | ||
|
177 | // Fires only when control is validated or looses focus. | |
|
178 | "change input" : "handleChanged" | |
|
179 | }, | |
|
167 | 180 | |
|
168 | ||
|
169 | events: {"keyup input" : "handleChanging", | |
|
170 | "paste input" : "handleChanging", | |
|
171 | "cut input" : "handleChanging", | |
|
172 | "change input" : "handleChanged"}, // Fires only when control is validated or looses focus. | |
|
173 | ||
|
174 | // Handles and validates user input. | |
|
175 | 181 | handleChanging: function(e) { |
|
182 | // Handles and validates user input. | |
|
176 | 183 | |
|
177 | 184 | // Try to parse value as a float. |
|
178 | 185 | var numericalValue = 0; |
@@ -202,14 +209,12 b' define(["notebook/js/widgets/widget"], function(widget_manager){' | |||
|
202 | 209 | } |
|
203 | 210 | }, |
|
204 | 211 | |
|
205 | // Applies validated input. | |
|
206 | 212 | handleChanged: function(e) { |
|
207 |
// |
|
|
213 | // Applies validated input. | |
|
208 | 214 | if (this.model.get('value') != e.target.value) { |
|
209 | 215 | e.target.value = this.model.get('value'); |
|
210 | 216 | } |
|
211 | 217 | } |
|
212 | 218 | }); |
|
213 | ||
|
214 | 219 | widget_manager.register_widget_view('IntTextView', IntTextView); |
|
215 | 220 | }); |
@@ -15,11 +15,10 b'' | |||
|
15 | 15 | **/ |
|
16 | 16 | |
|
17 | 17 | define(["notebook/js/widgets/widget"], function(widget_manager){ |
|
18 | ||
|
18 | 19 | var DropdownView = IPython.DOMWidgetView.extend({ |
|
19 | ||
|
20 | // Called when view is rendered. | |
|
21 | 20 | render : function(){ |
|
22 | ||
|
21 | // Called when view is rendered. | |
|
23 | 22 | this.$el |
|
24 | 23 | .addClass('widget-hbox-single') |
|
25 | 24 | .html(''); |
@@ -101,8 +100,8 b' define(["notebook/js/widgets/widget"], function(widget_manager){' | |||
|
101 | 100 | return DropdownView.__super__.update.apply(this); |
|
102 | 101 | }, |
|
103 | 102 | |
|
104 | // Handle when a value is clicked. | |
|
105 | 103 | handle_click: function (e) { |
|
104 | // Handle when a value is clicked. | |
|
106 | 105 | |
|
107 | 106 | // Calling model.set will trigger all of the other views of the |
|
108 | 107 | // model to update. |
@@ -111,13 +110,12 b' define(["notebook/js/widgets/widget"], function(widget_manager){' | |||
|
111 | 110 | }, |
|
112 | 111 | |
|
113 | 112 | }); |
|
114 | ||
|
115 | 113 | widget_manager.register_widget_view('DropdownView', DropdownView); |
|
116 | 114 | |
|
117 | var RadioButtonsView = IPython.DOMWidgetView.extend({ | |
|
118 | ||
|
119 | // Called when view is rendered. | |
|
115 | ||
|
116 | var RadioButtonsView = IPython.DOMWidgetView.extend({ | |
|
120 | 117 | render : function(){ |
|
118 | // Called when view is rendered. | |
|
121 | 119 | this.$el |
|
122 | 120 | .addClass('widget-hbox'); |
|
123 | 121 | this.$label = $('<div />') |
@@ -193,8 +191,8 b' define(["notebook/js/widgets/widget"], function(widget_manager){' | |||
|
193 | 191 | return RadioButtonsView.__super__.update.apply(this); |
|
194 | 192 | }, |
|
195 | 193 | |
|
196 | // Handle when a value is clicked. | |
|
197 | 194 | handle_click: function (e) { |
|
195 | // Handle when a value is clicked. | |
|
198 | 196 | |
|
199 | 197 | // Calling model.set will trigger all of the other views of the |
|
200 | 198 | // model to update. |
@@ -202,14 +200,12 b' define(["notebook/js/widgets/widget"], function(widget_manager){' | |||
|
202 | 200 | this.touch(); |
|
203 | 201 | }, |
|
204 | 202 | }); |
|
205 | ||
|
206 | 203 | widget_manager.register_widget_view('RadioButtonsView', RadioButtonsView); |
|
207 | 204 | |
|
208 | 205 | |
|
209 | var ToggleButtonsView = IPython.DOMWidgetView.extend({ | |
|
210 | ||
|
211 | // Called when view is rendered. | |
|
206 | var ToggleButtonsView = IPython.DOMWidgetView.extend({ | |
|
212 | 207 | render : function(){ |
|
208 | // Called when view is rendered. | |
|
213 | 209 | this.$el |
|
214 | 210 | .addClass('widget-hbox-single'); |
|
215 | 211 | this.$label = $('<div />') |
@@ -280,23 +276,21 b' define(["notebook/js/widgets/widget"], function(widget_manager){' | |||
|
280 | 276 | return ToggleButtonsView.__super__.update.apply(this); |
|
281 | 277 | }, |
|
282 | 278 | |
|
283 | // Handle when a value is clicked. | |
|
284 | 279 | handle_click: function (e) { |
|
280 | // Handle when a value is clicked. | |
|
285 | 281 | |
|
286 | 282 | // Calling model.set will trigger all of the other views of the |
|
287 | 283 | // model to update. |
|
288 | 284 | this.model.set('value', $(e.target).html(), {updated_view: this}); |
|
289 | 285 | this.touch(); |
|
290 | }, | |
|
291 | ||
|
286 | }, | |
|
292 | 287 | }); |
|
293 | ||
|
294 | 288 | widget_manager.register_widget_view('ToggleButtonsView', ToggleButtonsView); |
|
295 | 289 | |
|
296 | var ListBoxView = IPython.DOMWidgetView.extend({ | |
|
297 | ||
|
298 | // Called when view is rendered. | |
|
290 | ||
|
291 | var ListBoxView = IPython.DOMWidgetView.extend({ | |
|
299 | 292 | render : function(){ |
|
293 | // Called when view is rendered. | |
|
300 | 294 | this.$el |
|
301 | 295 | .addClass('widget-hbox'); |
|
302 | 296 | this.$label = $('<div />') |
@@ -364,16 +358,14 b' define(["notebook/js/widgets/widget"], function(widget_manager){' | |||
|
364 | 358 | return ListBoxView.__super__.update.apply(this); |
|
365 | 359 | }, |
|
366 | 360 | |
|
367 | // Handle when a value is clicked. | |
|
368 | 361 | handle_click: function (e) { |
|
362 | // Handle when a value is clicked. | |
|
369 | 363 | |
|
370 | 364 | // Calling model.set will trigger all of the other views of the |
|
371 | 365 | // model to update. |
|
372 | 366 | this.model.set('value', $(e.target).html(), {updated_view: this}); |
|
373 | 367 | this.touch(); |
|
374 | }, | |
|
375 | ||
|
368 | }, | |
|
376 | 369 | }); |
|
377 | ||
|
378 | 370 | widget_manager.register_widget_view('ListBoxView', ListBoxView); |
|
379 | 371 | }); |
@@ -15,9 +15,10 b'' | |||
|
15 | 15 | **/ |
|
16 | 16 | |
|
17 | 17 | define(["notebook/js/widgets/widget"], function(widget_manager){ |
|
18 | ||
|
18 | 19 | var AccordionView = IPython.DOMWidgetView.extend({ |
|
19 | ||
|
20 | 20 | render: function(){ |
|
21 | // Called when view is rendered. | |
|
21 | 22 | var guid = 'accordion' + IPython.utils.uuid(); |
|
22 | 23 | this.$el |
|
23 | 24 | .attr('id', guid) |
@@ -35,7 +36,6 b' define(["notebook/js/widgets/widget"], function(widget_manager){' | |||
|
35 | 36 | // |
|
36 | 37 | // Called when the model is changed. The model may have been |
|
37 | 38 | // changed by another view or by a state update from the back-end. |
|
38 | ||
|
39 | 39 | if (options === undefined || options.updated_view != this) { |
|
40 | 40 | // Set tab titles |
|
41 | 41 | var titles = this.model.get('_titles'); |
@@ -67,6 +67,7 b' define(["notebook/js/widgets/widget"], function(widget_manager){' | |||
|
67 | 67 | }, |
|
68 | 68 | |
|
69 | 69 | update_children: function(old_list, new_list) { |
|
70 | // Called when the children list is modified. | |
|
70 | 71 | this.do_diff(old_list, |
|
71 | 72 | new_list, |
|
72 | 73 | $.proxy(this.remove_child_model, this), |
@@ -74,6 +75,7 b' define(["notebook/js/widgets/widget"], function(widget_manager){' | |||
|
74 | 75 | }, |
|
75 | 76 | |
|
76 | 77 | remove_child_model: function(model) { |
|
78 | // Called when a child is removed from children list. | |
|
77 | 79 | var accordion_group = this.model_containers[model.id]; |
|
78 | 80 | this.containers.splice(accordion_group.container_index, 1); |
|
79 | 81 | delete this.model_containers[model.id]; |
@@ -82,6 +84,7 b' define(["notebook/js/widgets/widget"], function(widget_manager){' | |||
|
82 | 84 | }, |
|
83 | 85 | |
|
84 | 86 | add_child_model: function(model) { |
|
87 | // Called when a child is added to children list. | |
|
85 | 88 | var view = this.create_child_view(model); |
|
86 | 89 | var index = this.containers.length; |
|
87 | 90 | var uuid = IPython.utils.uuid(); |
@@ -126,17 +129,18 b' define(["notebook/js/widgets/widget"], function(widget_manager){' | |||
|
126 | 129 | setTimeout(function(){ that.update(); }, 500); |
|
127 | 130 | }, |
|
128 | 131 | }); |
|
129 | ||
|
130 | 132 | widget_manager.register_widget_view('AccordionView', AccordionView); |
|
131 | 133 | |
|
132 | var TabView = IPython.DOMWidgetView.extend({ | |
|
133 | ||
|
134 | ||
|
135 | var TabView = IPython.DOMWidgetView.extend({ | |
|
134 | 136 | initialize: function() { |
|
137 | // Public constructor. | |
|
135 | 138 | this.containers = []; |
|
136 | 139 | TabView.__super__.initialize.apply(this, arguments); |
|
137 | 140 | }, |
|
138 | 141 | |
|
139 | 142 | render: function(){ |
|
143 | // Called when view is rendered. | |
|
140 | 144 | var uuid = 'tabs'+IPython.utils.uuid(); |
|
141 | 145 | var that = this; |
|
142 | 146 | this.$tabs = $('<div />', {id: uuid}) |
@@ -152,19 +156,9 b' define(["notebook/js/widgets/widget"], function(widget_manager){' | |||
|
152 | 156 | this.update_children(model.previous('children'), value); |
|
153 | 157 | }, this); |
|
154 | 158 | }, |
|
155 | ||
|
156 | update_children: function(old_list, new_list) { | |
|
157 | _.each(this.containers, function(element, index, list) { | |
|
158 | element.remove(); | |
|
159 | }, this); | |
|
160 | this.containers = []; | |
|
161 | this.update_child_views(old_list, new_list); | |
|
162 | _.each(new_list, function(element, index, list) { | |
|
163 | this.add_child_view(this.child_views[element]); | |
|
164 | }, this) | |
|
165 | }, | |
|
166 | ||
|
159 | ||
|
167 | 160 | update_children: function(old_list, new_list) { |
|
161 | // Called when the children list is modified. | |
|
168 | 162 | this.do_diff(old_list, |
|
169 | 163 | new_list, |
|
170 | 164 | $.proxy(this.remove_child_model, this), |
@@ -172,6 +166,7 b' define(["notebook/js/widgets/widget"], function(widget_manager){' | |||
|
172 | 166 | }, |
|
173 | 167 | |
|
174 | 168 | remove_child_model: function(model) { |
|
169 | // Called when a child is removed from children list. | |
|
175 | 170 | var view = this.child_views[model.id]; |
|
176 | 171 | this.containers.splice(view.parent_tab.tab_text_index, 1); |
|
177 | 172 | view.parent_tab.remove(); |
@@ -181,6 +176,7 b' define(["notebook/js/widgets/widget"], function(widget_manager){' | |||
|
181 | 176 | }, |
|
182 | 177 | |
|
183 | 178 | add_child_model: function(model) { |
|
179 | // Called when a child is added to children list. | |
|
184 | 180 | var view = this.create_child_view(model); |
|
185 | 181 | var index = this.containers.length; |
|
186 | 182 | var uuid = IPython.utils.uuid(); |
@@ -238,11 +234,11 b' define(["notebook/js/widgets/widget"], function(widget_manager){' | |||
|
238 | 234 | }, |
|
239 | 235 | |
|
240 | 236 | select_page: function(index) { |
|
237 | // Select a page. | |
|
241 | 238 | this.$tabs.find('li') |
|
242 | 239 | .removeClass('active'); |
|
243 | 240 | this.containers[index].tab('show'); |
|
244 | 241 | }, |
|
245 | 242 | }); |
|
246 | ||
|
247 | 243 | widget_manager.register_widget_view('TabView', TabView); |
|
248 | 244 | }); |
@@ -15,10 +15,10 b'' | |||
|
15 | 15 | **/ |
|
16 | 16 | |
|
17 | 17 | define(["notebook/js/widgets/widget"], function(widget_manager){ |
|
18 | var HTMLView = IPython.DOMWidgetView.extend({ | |
|
19 | ||
|
20 | // Called when view is rendered. | |
|
18 | ||
|
19 | var HTMLView = IPython.DOMWidgetView.extend({ | |
|
21 | 20 | render : function(){ |
|
21 | // Called when view is rendered. | |
|
22 | 22 | this.update(); // Set defaults. |
|
23 | 23 | }, |
|
24 | 24 | |
@@ -30,16 +30,13 b' define(["notebook/js/widgets/widget"], function(widget_manager){' | |||
|
30 | 30 | this.$el.html(this.model.get('value')); |
|
31 | 31 | return HTMLView.__super__.update.apply(this); |
|
32 | 32 | }, |
|
33 | ||
|
34 | 33 | }); |
|
35 | ||
|
36 | 34 | widget_manager.register_widget_view('HTMLView', HTMLView); |
|
37 | 35 | |
|
38 | 36 | |
|
39 | var LatexView = IPython.DOMWidgetView.extend({ | |
|
40 | ||
|
41 | // Called when view is rendered. | |
|
37 | var LatexView = IPython.DOMWidgetView.extend({ | |
|
42 | 38 | render : function(){ |
|
39 | // Called when view is rendered. | |
|
43 | 40 | this.update(); // Set defaults. |
|
44 | 41 | }, |
|
45 | 42 | |
@@ -52,16 +49,14 b' define(["notebook/js/widgets/widget"], function(widget_manager){' | |||
|
52 | 49 | MathJax.Hub.Queue(["Typeset",MathJax.Hub,this.$el.get(0)]); |
|
53 | 50 | |
|
54 | 51 | return LatexView.__super__.update.apply(this); |
|
55 | }, | |
|
56 | ||
|
52 | }, | |
|
57 | 53 | }); |
|
58 | ||
|
59 | 54 | widget_manager.register_widget_view('LatexView', LatexView); |
|
60 | 55 | |
|
61 | var TextAreaView = IPython.DOMWidgetView.extend({ | |
|
62 | ||
|
63 | // Called when view is rendered. | |
|
56 | ||
|
57 | var TextAreaView = IPython.DOMWidgetView.extend({ | |
|
64 | 58 | render: function(){ |
|
59 | // Called when view is rendered. | |
|
65 | 60 | this.$el |
|
66 | 61 | .addClass('widget-hbox') |
|
67 | 62 | .html(''); |
@@ -79,19 +74,18 b' define(["notebook/js/widgets/widget"], function(widget_manager){' | |||
|
79 | 74 | this.model.on('msg:custom', $.proxy(this._handle_textarea_msg, this)); |
|
80 | 75 | }, |
|
81 | 76 | |
|
82 | ||
|
83 | 77 | _handle_textarea_msg: function (content){ |
|
78 | // Handle when a custom msg is recieved from the back-end. | |
|
84 | 79 | if (content.method == "scroll_to_bottom") { |
|
85 | 80 | this.scroll_to_bottom(); |
|
86 | 81 | } |
|
87 | 82 | }, |
|
88 | 83 | |
|
89 | ||
|
90 | 84 | scroll_to_bottom: function (){ |
|
85 | // Scroll the text-area view to the bottom. | |
|
91 | 86 | this.$textbox.scrollTop(this.$textbox[0].scrollHeight); |
|
92 | 87 | }, |
|
93 | 88 | |
|
94 | ||
|
95 | 89 | update: function(options){ |
|
96 | 90 | // Update the contents of this view |
|
97 | 91 | // |
@@ -114,12 +108,15 b' define(["notebook/js/widgets/widget"], function(widget_manager){' | |||
|
114 | 108 | return TextAreaView.__super__.update.apply(this); |
|
115 | 109 | }, |
|
116 | 110 | |
|
117 | events: {"keyup textarea": "handleChanging", | |
|
118 | "paste textarea": "handleChanging", | |
|
119 |
|
|
|
111 | events: { | |
|
112 | // Dictionary of events and their handlers. | |
|
113 | "keyup textarea": "handleChanging", | |
|
114 | "paste textarea": "handleChanging", | |
|
115 | "cut textarea": "handleChanging" | |
|
116 | }, | |
|
120 | 117 | |
|
121 | // Handles and validates user input. | |
|
122 | 118 | handleChanging: function(e) { |
|
119 | // Handles and validates user input. | |
|
123 | 120 | |
|
124 | 121 | // Calling model.set will trigger all of the other views of the |
|
125 | 122 | // model to update. |
@@ -127,13 +124,12 b' define(["notebook/js/widgets/widget"], function(widget_manager){' | |||
|
127 | 124 | this.touch(); |
|
128 | 125 | }, |
|
129 | 126 | }); |
|
130 | ||
|
131 | 127 | widget_manager.register_widget_view('TextAreaView', TextAreaView); |
|
132 | 128 | |
|
133 | var TextBoxView = IPython.DOMWidgetView.extend({ | |
|
134 | ||
|
135 | // Called when view is rendered. | |
|
129 | ||
|
130 | var TextBoxView = IPython.DOMWidgetView.extend({ | |
|
136 | 131 | render: function(){ |
|
132 | // Called when view is rendered. | |
|
137 | 133 | this.$el |
|
138 | 134 | .addClass('widget-hbox-single') |
|
139 | 135 | .html(''); |
@@ -173,13 +169,16 b' define(["notebook/js/widgets/widget"], function(widget_manager){' | |||
|
173 | 169 | return TextBoxView.__super__.update.apply(this); |
|
174 | 170 | }, |
|
175 | 171 | |
|
176 | events: {"keyup input": "handleChanging", | |
|
177 | "paste input": "handleChanging", | |
|
178 |
|
|
|
179 |
|
|
|
172 | events: { | |
|
173 | // Dictionary of events and their handlers. | |
|
174 | "keyup input": "handleChanging", | |
|
175 | "paste input": "handleChanging", | |
|
176 | "cut input": "handleChanging", | |
|
177 | "keypress input": "handleKeypress" | |
|
178 | }, | |
|
180 | 179 | |
|
181 | // Handles and validates user input. | |
|
182 | 180 | handleChanging: function(e) { |
|
181 | // Handles and validates user input. | |
|
183 | 182 | |
|
184 | 183 | // Calling model.set will trigger all of the other views of the |
|
185 | 184 | // model to update. |
@@ -187,13 +186,12 b' define(["notebook/js/widgets/widget"], function(widget_manager){' | |||
|
187 | 186 | this.touch(); |
|
188 | 187 | }, |
|
189 | 188 | |
|
190 | // Handles text submition | |
|
191 | 189 | handleKeypress: function(e) { |
|
190 | // Handles text submition | |
|
192 | 191 | if (e.keyCode == 13) { // Return key |
|
193 | 192 | this.send({event: 'submit'}); |
|
194 | 193 | } |
|
195 | 194 | }, |
|
196 | 195 | }); |
|
197 | ||
|
198 | 196 | widget_manager.register_widget_view('TextBoxView', TextBoxView); |
|
199 | 197 | }); |
General Comments 0
You need to be logged in to leave comments.
Login now