##// END OF EJS Templates
make JS update comment more descriptive (english)
Jonathan Frederic -
Show More
@@ -269,8 +269,13 b' function(widget_manager, underscore, backbone){'
269 },
269 },
270
270
271 update: function () {
271 update: function () {
272 // the very first update seems to happen before the element is finished rendering
272 // Update the contents of this view
273 // so we use setTimeout to give the element time to render
273 //
274 // Called when the model is changed. The model may have been
275 // changed by another view or by a state update from the back-end.
276 // The very first update seems to happen before the element is
277 // finished rendering so we use setTimeout to give the element time
278 // to render
274 var e = this.$el;
279 var e = this.$el;
275 var visible = this.model.get('visible');
280 var visible = this.model.get('visible');
276 setTimeout(function() {e.toggle(visible)},0);
281 setTimeout(function() {e.toggle(visible)},0);
@@ -44,9 +44,11 b' define(["notebook/js/widgets/widget"], function(widget_manager){'
44 this.update(); // Set defaults.
44 this.update(); // Set defaults.
45 },
45 },
46
46
47 // Handles: Backend -> Frontend Sync
48 // Frontent -> Frontend Sync
49 update : function(){
47 update : function(){
48 // Update the contents of this view
49 //
50 // Called when the model is changed. The model may have been
51 // changed by another view or by a state update from the back-end.
50 if (!this.user_invoked_update) {
52 if (!this.user_invoked_update) {
51 this.$checkbox.prop('checked', this.model.get('value'));
53 this.$checkbox.prop('checked', this.model.get('value'));
52
54
@@ -84,9 +86,11 b' define(["notebook/js/widgets/widget"], function(widget_manager){'
84 this.update(); // Set defaults.
86 this.update(); // Set defaults.
85 },
87 },
86
88
87 // Handles: Backend -> Frontend Sync
88 // Frontent -> Frontend Sync
89 update : function(){
89 update : function(){
90 // Update the contents of this view
91 //
92 // Called when the model is changed. The model may have been
93 // changed by another view or by a state update from the back-end.
90 if (!this.user_invoked_update) {
94 if (!this.user_invoked_update) {
91 if (this.model.get('value')) {
95 if (this.model.get('value')) {
92 this.$button.addClass('active');
96 this.$button.addClass('active');
@@ -30,9 +30,11 b' define(["notebook/js/widgets/widget"], function(widget_manager){'
30 this.update(); // Set defaults.
30 this.update(); // Set defaults.
31 },
31 },
32
32
33 // Handles: Backend -> Frontend Sync
34 // Frontent -> Frontend Sync
35 update : function(){
33 update : function(){
34 // Update the contents of this view
35 //
36 // Called when the model is changed. The model may have been
37 // changed by another view or by a state update from the back-end.
36 var description = this.model.get('description');
38 var description = this.model.get('description');
37 description = description.replace(/ /g, ' ', 'm');
39 description = description.replace(/ /g, ' ', 'm');
38 description = description.replace(/\n/g, '<br>\n', 'm');
40 description = description.replace(/\n/g, '<br>\n', 'm');
@@ -69,6 +69,10 b' define(["notebook/js/widgets/widget"], function(widget_manager) {'
69 },
69 },
70
70
71 update: function(){
71 update: function(){
72 // Update the contents of this view
73 //
74 // Called when the model is changed. The model may have been
75 // changed by another view or by a state update from the back-end.
72 set_flex_properties(this, this.$el);
76 set_flex_properties(this, this.$el);
73 return IPython.DOMWidgetView.prototype.update.call(this);
77 return IPython.DOMWidgetView.prototype.update.call(this);
74 },
78 },
@@ -225,6 +229,10 b' define(["notebook/js/widgets/widget"], function(widget_manager) {'
225 },
229 },
226
230
227 update: function(){
231 update: function(){
232 // Update the contents of this view
233 //
234 // Called when the model is changed. The model may have been
235 // changed by another view or by a state update from the back-end.
228 set_flex_properties(this, this.$body);
236 set_flex_properties(this, this.$body);
229
237
230 var description = this.model.get('description');
238 var description = this.model.get('description');
@@ -44,9 +44,12 b' define(["notebook/js/widgets/widget"], function(widget_manager){'
44 this.update();
44 this.update();
45 },
45 },
46
46
47 // Handles: Backend -> Frontend Sync
48 // Frontent -> Frontend Sync
49 update : function(){
47 update : function(){
48 // Update the contents of this view
49 //
50 // Called when the model is changed. The model may have been
51 // changed by another view or by a state update from the back-end.
52
50 // Slider related keys.
53 // Slider related keys.
51 var _keys = ['step', 'max', 'min', 'disabled'];
54 var _keys = ['step', 'max', 'min', 'disabled'];
52 for (var index in _keys) {
55 for (var index in _keys) {
@@ -135,9 +138,12 b' define(["notebook/js/widgets/widget"], function(widget_manager){'
135 this.update(); // Set defaults.
138 this.update(); // Set defaults.
136 },
139 },
137
140
138 // Handles: Backend -> Frontend Sync
139 // Frontent -> Frontend Sync
140 update : function(){
141 update : function(){
142 // Update the contents of this view
143 //
144 // Called when the model is changed. The model may have been
145 // changed by another view or by a state update from the back-end.
146
141 var value = this.model.get('value');
147 var value = this.model.get('value');
142 if (!this.changing && parseFloat(this.$textbox.val()) != value) {
148 if (!this.changing && parseFloat(this.$textbox.val()) != value) {
143 this.$textbox.val(value);
149 this.$textbox.val(value);
@@ -230,9 +236,11 b' define(["notebook/js/widgets/widget"], function(widget_manager){'
230 this.update(); // Set defaults.
236 this.update(); // Set defaults.
231 },
237 },
232
238
233 // Handles: Backend -> Frontend Sync
234 // Frontent -> Frontend Sync
235 update : function(){
239 update : function(){
240 // Update the contents of this view
241 //
242 // Called when the model is changed. The model may have been
243 // changed by another view or by a state update from the back-end.
236 var value = this.model.get('value');
244 var value = this.model.get('value');
237 var max = this.model.get('max');
245 var max = this.model.get('max');
238 var min = this.model.get('min');
246 var min = this.model.get('min');
@@ -26,9 +26,11 b' define(["notebook/js/widgets/widget"], function(widget_manager){'
26 this.update(); // Set defaults.
26 this.update(); // Set defaults.
27 },
27 },
28
28
29 // Handles: Backend -> Frontend Sync
30 // Frontent -> Frontend Sync
31 update : function(){
29 update : function(){
30 // Update the contents of this view
31 //
32 // Called when the model is changed. The model may have been
33 // changed by another view or by a state update from the back-end.
32 var image_src = 'data:image/' + this.model.get('image_format') + ';base64,' + this.model.get('_b64value');
34 var image_src = 'data:image/' + this.model.get('image_format') + ';base64,' + this.model.get('_b64value');
33 this.$el.attr('src', image_src);
35 this.$el.attr('src', image_src);
34
36
@@ -18,7 +18,7 b' define(["notebook/js/widgets/widget"], function(widget_manager){'
18 var IntRangeWidgetModel = IPython.WidgetModel.extend({});
18 var IntRangeWidgetModel = IPython.WidgetModel.extend({});
19 widget_manager.register_widget_model('IntRangeWidgetModel', IntRangeWidgetModel);
19 widget_manager.register_widget_model('IntRangeWidgetModel', IntRangeWidgetModel);
20
20
21 var IntSliderView = IPython.WidgetView.extend({
21 var IntSliderView = IPython.DOMWidgetView.extend({
22
22
23 // Called when view is rendered.
23 // Called when view is rendered.
24 render : function(){
24 render : function(){
@@ -44,9 +44,12 b' define(["notebook/js/widgets/widget"], function(widget_manager){'
44 this.update();
44 this.update();
45 },
45 },
46
46
47 // Handles: Backend -> Frontend Sync
48 // Frontent -> Frontend Sync
49 update : function(){
47 update : function(){
48 // Update the contents of this view
49 //
50 // Called when the model is changed. The model may have been
51 // changed by another view or by a state update from the back-end.
52
50 // Slider related keys.
53 // Slider related keys.
51 var _keys = ['step', 'max', 'min', 'disabled'];
54 var _keys = ['step', 'max', 'min', 'disabled'];
52 for (var index in _keys) {
55 for (var index in _keys) {
@@ -102,7 +105,7 b' define(["notebook/js/widgets/widget"], function(widget_manager){'
102 this.$label.html(description);
105 this.$label.html(description);
103 this.$label.show();
106 this.$label.show();
104 }
107 }
105 return IPython.WidgetView.prototype.update.call(this);
108 return IPython.DOMWidgetView.prototype.update.call(this);
106 },
109 },
107
110
108 // Handles: User input
111 // Handles: User input
@@ -115,7 +118,7 b' define(["notebook/js/widgets/widget"], function(widget_manager){'
115
118
116 widget_manager.register_widget_view('IntSliderView', IntSliderView);
119 widget_manager.register_widget_view('IntSliderView', IntSliderView);
117
120
118 var IntTextView = IPython.WidgetView.extend({
121 var IntTextView = IPython.DOMWidgetView.extend({
119
122
120 // Called when view is rendered.
123 // Called when view is rendered.
121 render : function(){
124 render : function(){
@@ -134,9 +137,12 b' define(["notebook/js/widgets/widget"], function(widget_manager){'
134 this.update(); // Set defaults.
137 this.update(); // Set defaults.
135 },
138 },
136
139
137 // Handles: Backend -> Frontend Sync
138 // Frontent -> Frontend Sync
139 update : function(){
140 update : function(){
141 // Update the contents of this view
142 //
143 // Called when the model is changed. The model may have been
144 // changed by another view or by a state update from the back-end.
145
140 var value = this.model.get('value');
146 var value = this.model.get('value');
141 if (!this.changing && parseInt(this.$textbox.val()) != value) {
147 if (!this.changing && parseInt(this.$textbox.val()) != value) {
142 this.$textbox.val(value);
148 this.$textbox.val(value);
@@ -155,7 +161,7 b' define(["notebook/js/widgets/widget"], function(widget_manager){'
155 this.$label.html(description);
161 this.$label.html(description);
156 this.$label.show();
162 this.$label.show();
157 }
163 }
158 return IPython.WidgetView.prototype.update.call(this);
164 return IPython.DOMWidgetView.prototype.update.call(this);
159 },
165 },
160
166
161
167
@@ -45,6 +45,11 b' define(["notebook/js/widgets/widget"], function(widget_manager){'
45
45
46
46
47 update: function() {
47 update: function() {
48 // Update the contents of this view
49 //
50 // Called when the model is changed. The model may have been
51 // changed by another view or by a state update from the back-end.
52
48 // Set tab titles
53 // Set tab titles
49 var titles = this.model.get('_titles');
54 var titles = this.model.get('_titles');
50 for (var page_index in titles) {
55 for (var page_index in titles) {
@@ -153,6 +158,11 b' define(["notebook/js/widgets/widget"], function(widget_manager){'
153 },
158 },
154
159
155 update: function() {
160 update: function() {
161 // Update the contents of this view
162 //
163 // Called when the model is changed. The model may have been
164 // changed by another view or by a state update from the back-end.
165
156 // Set tab titles
166 // Set tab titles
157 var titles = this.model.get('_titles');
167 var titles = this.model.get('_titles');
158 for (var page_index in titles) {
168 for (var page_index in titles) {
@@ -55,9 +55,11 b' define(["notebook/js/widgets/widget"], function(widget_manager){'
55 this.update();
55 this.update();
56 },
56 },
57
57
58 // Handles: Backend -> Frontend Sync
59 // Frontent -> Frontend Sync
60 update : function(){
58 update : function(){
59 // Update the contents of this view
60 //
61 // Called when the model is changed. The model may have been
62 // changed by another view or by a state update from the back-end.
61
63
62 var selected_item_text = this.model.get('value');
64 var selected_item_text = this.model.get('value');
63 selected_item_text = selected_item_text.replace(/ /g, '&nbsp;');
65 selected_item_text = selected_item_text.replace(/ /g, '&nbsp;');
@@ -129,9 +131,11 b' define(["notebook/js/widgets/widget"], function(widget_manager){'
129 this.update();
131 this.update();
130 },
132 },
131
133
132 // Handles: Backend -> Frontend Sync
133 // Frontent -> Frontend Sync
134 update : function(){
134 update : function(){
135 // Update the contents of this view
136 //
137 // Called when the model is changed. The model may have been
138 // changed by another view or by a state update from the back-end.
135
139
136 // Add missing items to the DOM.
140 // Add missing items to the DOM.
137 var items = this.model.get('values');
141 var items = this.model.get('values');
@@ -216,9 +220,11 b' define(["notebook/js/widgets/widget"], function(widget_manager){'
216 this.update();
220 this.update();
217 },
221 },
218
222
219 // Handles: Backend -> Frontend Sync
220 // Frontent -> Frontend Sync
221 update : function(){
223 update : function(){
224 // Update the contents of this view
225 //
226 // Called when the model is changed. The model may have been
227 // changed by another view or by a state update from the back-end.
222
228
223 // Add missing items to the DOM.
229 // Add missing items to the DOM.
224 var items = this.model.get('values');
230 var items = this.model.get('values');
@@ -298,9 +304,11 b' define(["notebook/js/widgets/widget"], function(widget_manager){'
298 this.update();
304 this.update();
299 },
305 },
300
306
301 // Handles: Backend -> Frontend Sync
302 // Frontent -> Frontend Sync
303 update : function(){
307 update : function(){
308 // Update the contents of this view
309 //
310 // Called when the model is changed. The model may have been
311 // changed by another view or by a state update from the back-end.
304
312
305 // Add missing items to the DOM.
313 // Add missing items to the DOM.
306 var items = this.model.get('values');
314 var items = this.model.get('values');
@@ -25,9 +25,11 b' define(["notebook/js/widgets/widget"], function(widget_manager){'
25 this.update(); // Set defaults.
25 this.update(); // Set defaults.
26 },
26 },
27
27
28 // Handles: Backend -> Frontend Sync
29 // Frontent -> Frontend Sync
30 update : function(){
28 update : function(){
29 // Update the contents of this view
30 //
31 // Called when the model is changed. The model may have been
32 // changed by another view or by a state update from the back-end.
31 this.$el.html(this.model.get('value'));
33 this.$el.html(this.model.get('value'));
32 return IPython.DOMWidgetView.prototype.update.call(this);
34 return IPython.DOMWidgetView.prototype.update.call(this);
33 },
35 },
@@ -44,9 +46,11 b' define(["notebook/js/widgets/widget"], function(widget_manager){'
44 this.update(); // Set defaults.
46 this.update(); // Set defaults.
45 },
47 },
46
48
47 // Handles: Backend -> Frontend Sync
48 // Frontent -> Frontend Sync
49 update : function(){
49 update : function(){
50 // Update the contents of this view
51 //
52 // Called when the model is changed. The model may have been
53 // changed by another view or by a state update from the back-end.
50 this.$el.html(this.model.get('value'));
54 this.$el.html(this.model.get('value'));
51 MathJax.Hub.Queue(["Typeset",MathJax.Hub,this.$el.get(0)]);
55 MathJax.Hub.Queue(["Typeset",MathJax.Hub,this.$el.get(0)]);
52
56
@@ -91,9 +95,11 b' define(["notebook/js/widgets/widget"], function(widget_manager){'
91 },
95 },
92
96
93
97
94 // Handles: Backend -> Frontend Sync
95 // Frontent -> Frontend Sync
96 update: function(){
98 update: function(){
99 // Update the contents of this view
100 //
101 // Called when the model is changed. The model may have been
102 // changed by another view or by a state update from the back-end.
97 if (!this.user_invoked_update) {
103 if (!this.user_invoked_update) {
98 this.$textbox.val(this.model.get('value'));
104 this.$textbox.val(this.model.get('value'));
99 }
105 }
@@ -145,9 +151,11 b' define(["notebook/js/widgets/widget"], function(widget_manager){'
145 this.update(); // Set defaults.
151 this.update(); // Set defaults.
146 },
152 },
147
153
148 // Handles: Backend -> Frontend Sync
149 // Frontent -> Frontend Sync
150 update: function(){
154 update: function(){
155 // Update the contents of this view
156 //
157 // Called when the model is changed. The model may have been
158 // changed by another view or by a state update from the back-end.
151 if (this.$textbox.val() != this.model.get('value')) {
159 if (this.$textbox.val() != this.model.get('value')) {
152 this.$textbox.val(this.model.get('value'));
160 this.$textbox.val(this.model.get('value'));
153 }
161 }
General Comments 0
You need to be logged in to leave comments. Login now