##// END OF EJS Templates
add locks to update everywhere by using options to pass this...
Jonathan Frederic -
Show More
@@ -33,13 +33,11 b' define(["notebook/js/widgets/widget"], function(widget_manager){'
33 33 this.$checkbox = $('<input />')
34 34 .attr('type', 'checkbox')
35 35 .click(function(el) {
36 that.user_invoked_update = true;
37 36
38 37 // Calling model.set will trigger all of the other views of the
39 38 // model to update.
40 that.model.set('value', that.$checkbox.prop('checked'));
39 that.model.set('value', that.$checkbox.prop('checked'), {updated_view: this});
41 40 that.touch();
42 that.user_invoked_update = false;
43 41 })
44 42 .appendTo(this.$el);
45 43
@@ -47,12 +45,12 b' define(["notebook/js/widgets/widget"], function(widget_manager){'
47 45 this.update(); // Set defaults.
48 46 },
49 47
50 update : function(){
48 update : function(options){
51 49 // Update the contents of this view
52 50 //
53 51 // Called when the model is changed. The model may have been
54 52 // changed by another view or by a state update from the back-end.
55 if (!this.user_invoked_update) {
53 if (options === undefined || options.updated_view != this) {
56 54 this.$checkbox.prop('checked', this.model.get('value'));
57 55
58 56 var disabled = this.model.get('disabled');
@@ -89,12 +87,12 b' define(["notebook/js/widgets/widget"], function(widget_manager){'
89 87 this.update(); // Set defaults.
90 88 },
91 89
92 update : function(){
90 update : function(options){
93 91 // Update the contents of this view
94 92 //
95 93 // Called when the model is changed. The model may have been
96 94 // changed by another view or by a state update from the back-end.
97 if (!this.user_invoked_update) {
95 if (options === undefined || options.updated_view != this) {
98 96 if (this.model.get('value')) {
99 97 this.$button.addClass('active');
100 98 } else {
@@ -118,13 +116,11 b' define(["notebook/js/widgets/widget"], function(widget_manager){'
118 116
119 117 // Handles and validates user input.
120 118 handleClick: function(e) {
121 this.user_invoked_update = true;
122 119
123 120 // Calling model.set will trigger all of the other views of the
124 121 // model to update.
125 this.model.set('value', ! $(e.target).hasClass('active'));
122 this.model.set('value', ! $(e.target).hasClass('active'), {updated_view: this});
126 123 this.touch();
127 this.user_invoked_update = false;
128 124 },
129 125 });
130 126
@@ -44,12 +44,13 b' define(["notebook/js/widgets/widget"], function(widget_manager){'
44 44 this.update();
45 45 },
46 46
47 update : function(){
47 update : function(options){
48 48 // Update the contents of this view
49 49 //
50 50 // Called when the model is changed. The model may have been
51 51 // changed by another view or by a state update from the back-end.
52 52
53 if (options === undefined || options.updated_view != this) {
53 54 // Slider related keys.
54 55 var _keys = ['step', 'max', 'min', 'disabled'];
55 56 for (var index in _keys) {
@@ -105,6 +106,7 b' define(["notebook/js/widgets/widget"], function(widget_manager){'
105 106 this.$label.html(description);
106 107 this.$label.show();
107 108 }
109 }
108 110 return IPython.DOMWidgetView.prototype.update.call(this);
109 111 },
110 112
@@ -114,7 +116,7 b' define(["notebook/js/widgets/widget"], function(widget_manager){'
114 116
115 117 // Calling model.set will trigger all of the other views of the
116 118 // model to update.
117 this.model.set('value', ui.value);
119 this.model.set('value', ui.value, {updated_view: this});
118 120 this.touch();
119 121 },
120 122 });
@@ -141,14 +143,15 b' define(["notebook/js/widgets/widget"], function(widget_manager){'
141 143 this.update(); // Set defaults.
142 144 },
143 145
144 update : function(){
146 update : function(options){
145 147 // Update the contents of this view
146 148 //
147 149 // Called when the model is changed. The model may have been
148 150 // changed by another view or by a state update from the back-end.
149 151
152 if (options === undefined || options.updated_view != this) {
150 153 var value = this.model.get('value');
151 if (!this.changing && parseFloat(this.$textbox.val()) != value) {
154 if (parseFloat(this.$textbox.val()) != value) {
152 155 this.$textbox.val(value);
153 156 }
154 157
@@ -165,6 +168,7 b' define(["notebook/js/widgets/widget"], function(widget_manager){'
165 168 this.$label.html(description);
166 169 this.$label.show();
167 170 }
171 }
168 172 return IPython.DOMWidgetView.prototype.update.call(this);
169 173 },
170 174
@@ -196,13 +200,11 b' define(["notebook/js/widgets/widget"], function(widget_manager){'
196 200
197 201 // Apply the value if it has changed.
198 202 if (numericalValue != this.model.get('value')) {
199 this.changing = true;
200 203
201 204 // Calling model.set will trigger all of the other views of the
202 205 // model to update.
203 this.model.set('value', numericalValue);
206 this.model.set('value', numericalValue, {updated_view: this});
204 207 this.touch();
205 this.changing = false;
206 208 }
207 209 }
208 210 },
@@ -44,12 +44,12 b' define(["notebook/js/widgets/widget"], function(widget_manager){'
44 44 this.update();
45 45 },
46 46
47 update : function(){
47 update : function(options){
48 48 // Update the contents of this view
49 49 //
50 50 // Called when the model is changed. The model may have been
51 51 // changed by another view or by a state update from the back-end.
52
52 if (options === undefined || options.updated_view != this) {
53 53 // Slider related keys.
54 54 var _keys = ['step', 'max', 'min', 'disabled'];
55 55 for (var index in _keys) {
@@ -105,6 +105,7 b' define(["notebook/js/widgets/widget"], function(widget_manager){'
105 105 this.$label.html(description);
106 106 this.$label.show();
107 107 }
108 }
108 109 return IPython.DOMWidgetView.prototype.update.call(this);
109 110 },
110 111
@@ -114,7 +115,7 b' define(["notebook/js/widgets/widget"], function(widget_manager){'
114 115
115 116 // Calling model.set will trigger all of the other views of the
116 117 // model to update.
117 this.model.set('value', ~~ui.value); // Double bit-wise not to truncate decimel
118 this.model.set('value', ~~ui.value, {updated_view: this}); // Double bit-wise not to truncate decimel
118 119 this.touch();
119 120 },
120 121 });
@@ -140,14 +141,14 b' define(["notebook/js/widgets/widget"], function(widget_manager){'
140 141 this.update(); // Set defaults.
141 142 },
142 143
143 update : function(){
144 update : function(options){
144 145 // Update the contents of this view
145 146 //
146 147 // Called when the model is changed. The model may have been
147 148 // changed by another view or by a state update from the back-end.
148
149 if (options === undefined || options.updated_view != this) {
149 150 var value = this.model.get('value');
150 if (!this.changing && parseInt(this.$textbox.val()) != value) {
151 if (parseInt(this.$textbox.val()) != value) {
151 152 this.$textbox.val(value);
152 153 }
153 154
@@ -164,6 +165,7 b' define(["notebook/js/widgets/widget"], function(widget_manager){'
164 165 this.$label.html(description);
165 166 this.$label.show();
166 167 }
168 }
167 169 return IPython.DOMWidgetView.prototype.update.call(this);
168 170 },
169 171
@@ -195,13 +197,11 b' define(["notebook/js/widgets/widget"], function(widget_manager){'
195 197
196 198 // Apply the value if it has changed.
197 199 if (numericalValue != this.model.get('value')) {
198 this.changing = true;
199 200
200 201 // Calling model.set will trigger all of the other views of the
201 202 // model to update.
202 this.model.set('value', numericalValue);
203 this.model.set('value', numericalValue, {updated_view: this});
203 204 this.touch();
204 this.changing = false;
205 205 }
206 206 }
207 207 },
@@ -44,12 +44,13 b' define(["notebook/js/widgets/widget"], function(widget_manager){'
44 44 },
45 45
46 46
47 update: function() {
47 update: function(options) {
48 48 // Update the contents of this view
49 49 //
50 50 // Called when the model is changed. The model may have been
51 51 // changed by another view or by a state update from the back-end.
52 52
53 if (options === undefined || options.updated_view != this) {
53 54 // Set tab titles
54 55 var titles = this.model.get('_titles');
55 56 for (var page_index in titles) {
@@ -75,7 +76,7 b' define(["notebook/js/widgets/widget"], function(widget_manager){'
75 76
76 77 }
77 78 }
78
79 }
79 80 return IPython.DOMWidgetView.prototype.update.call(this);
80 81 },
81 82
@@ -99,7 +100,7 b' define(["notebook/js/widgets/widget"], function(widget_manager){'
99 100
100 101 // Calling model.set will trigger all of the other views of the
101 102 // model to update.
102 that.model.set("selected_index", index);
103 that.model.set("selected_index", index, {updated_view: this});
103 104 that.touch();
104 105 })
105 106 .html('Page ' + index)
@@ -160,12 +161,12 b' define(["notebook/js/widgets/widget"], function(widget_manager){'
160 161 }, this)
161 162 },
162 163
163 update: function() {
164 update: function(options) {
164 165 // Update the contents of this view
165 166 //
166 167 // Called when the model is changed. The model may have been
167 168 // changed by another view or by a state update from the back-end.
168
169 if (options === undefined || options.updated_view != this) {
169 170 // Set tab titles
170 171 var titles = this.model.get('_titles');
171 172 for (var page_index in titles) {
@@ -179,7 +180,7 b' define(["notebook/js/widgets/widget"], function(widget_manager){'
179 180 if (0 <= selected_index && selected_index < this.containers.length) {
180 181 this.select_page(selected_index);
181 182 }
182
183 }
183 184 return IPython.DOMWidgetView.prototype.update.call(this);
184 185 },
185 186
@@ -200,7 +201,7 b' define(["notebook/js/widgets/widget"], function(widget_manager){'
200 201
201 202 // Calling model.set will trigger all of the other views of the
202 203 // model to update.
203 that.model.set("selected_index", index);
204 that.model.set("selected_index", index, {updated_view: this});
204 205 that.touch();
205 206 that.select_page(index);
206 207 });
@@ -55,12 +55,13 b' define(["notebook/js/widgets/widget"], function(widget_manager){'
55 55 this.update();
56 56 },
57 57
58 update : function(){
58 update : function(options){
59 59 // Update the contents of this view
60 60 //
61 61 // Called when the model is changed. The model may have been
62 62 // changed by another view or by a state update from the back-end.
63 63
64 if (options === undefined || options.updated_view != this) {
64 65 var selected_item_text = this.model.get('value');
65 66 selected_item_text = selected_item_text.replace(/ /g, '&nbsp;');
66 67 selected_item_text = selected_item_text.replace(/\n/g, '<br>\n');
@@ -99,6 +100,7 b' define(["notebook/js/widgets/widget"], function(widget_manager){'
99 100 this.$label.html(description);
100 101 this.$label.show();
101 102 }
103 }
102 104 return IPython.DOMWidgetView.prototype.update.call(this);
103 105 },
104 106
@@ -107,7 +109,7 b' define(["notebook/js/widgets/widget"], function(widget_manager){'
107 109
108 110 // Calling model.set will trigger all of the other views of the
109 111 // model to update.
110 this.model.set('value', $(e.target).html(), this);
112 this.model.set('value', $(e.target).html(), {updated_view: this});
111 113 this.touch();
112 114 },
113 115
@@ -134,12 +136,12 b' define(["notebook/js/widgets/widget"], function(widget_manager){'
134 136 this.update();
135 137 },
136 138
137 update : function(){
139 update : function(options){
138 140 // Update the contents of this view
139 141 //
140 142 // Called when the model is changed. The model may have been
141 143 // changed by another view or by a state update from the back-end.
142
144 if (options === undefined || options.updated_view != this) {
143 145 // Add missing items to the DOM.
144 146 var items = this.model.get('values');
145 147 var disabled = this.model.get('disabled');
@@ -191,6 +193,7 b' define(["notebook/js/widgets/widget"], function(widget_manager){'
191 193 this.$label.html(description);
192 194 this.$label.show();
193 195 }
196 }
194 197 return IPython.DOMWidgetView.prototype.update.call(this);
195 198 },
196 199
@@ -199,7 +202,7 b' define(["notebook/js/widgets/widget"], function(widget_manager){'
199 202
200 203 // Calling model.set will trigger all of the other views of the
201 204 // model to update.
202 this.model.set('value', $(e.target).val(), this);
205 this.model.set('value', $(e.target).val(), {updated_view: this});
203 206 this.touch();
204 207 },
205 208 });
@@ -226,12 +229,12 b' define(["notebook/js/widgets/widget"], function(widget_manager){'
226 229 this.update();
227 230 },
228 231
229 update : function(){
232 update : function(options){
230 233 // Update the contents of this view
231 234 //
232 235 // Called when the model is changed. The model may have been
233 236 // changed by another view or by a state update from the back-end.
234
237 if (options === undefined || options.updated_view != this) {
235 238 // Add missing items to the DOM.
236 239 var items = this.model.get('values');
237 240 var disabled = this.model.get('disabled');
@@ -278,6 +281,7 b' define(["notebook/js/widgets/widget"], function(widget_manager){'
278 281 this.$label.html(description);
279 282 this.$label.show();
280 283 }
284 }
281 285 return IPython.DOMWidgetView.prototype.update.call(this);
282 286 },
283 287
@@ -286,7 +290,7 b' define(["notebook/js/widgets/widget"], function(widget_manager){'
286 290
287 291 // Calling model.set will trigger all of the other views of the
288 292 // model to update.
289 this.model.set('value', $(e.target).html(), this);
293 this.model.set('value', $(e.target).html(), {updated_view: this});
290 294 this.touch();
291 295 },
292 296
@@ -313,12 +317,12 b' define(["notebook/js/widgets/widget"], function(widget_manager){'
313 317 this.update();
314 318 },
315 319
316 update : function(){
320 update : function(options){
317 321 // Update the contents of this view
318 322 //
319 323 // Called when the model is changed. The model may have been
320 324 // changed by another view or by a state update from the back-end.
321
325 if (options === undefined || options.updated_view != this) {
322 326 // Add missing items to the DOM.
323 327 var items = this.model.get('values');
324 328 for (var index in items) {
@@ -362,6 +366,7 b' define(["notebook/js/widgets/widget"], function(widget_manager){'
362 366 this.$label.html(description);
363 367 this.$label.show();
364 368 }
369 }
365 370 return IPython.DOMWidgetView.prototype.update.call(this);
366 371 },
367 372
@@ -370,7 +375,7 b' define(["notebook/js/widgets/widget"], function(widget_manager){'
370 375
371 376 // Calling model.set will trigger all of the other views of the
372 377 // model to update.
373 this.model.set('value', $(e.target).html(), this);
378 this.model.set('value', $(e.target).html(), {updated_view: this});
374 379 this.touch();
375 380 },
376 381
@@ -95,14 +95,13 b' define(["notebook/js/widgets/widget"], function(widget_manager){'
95 95 },
96 96
97 97
98 update: function(){
98 update: function(options){
99 99 // Update the contents of this view
100 100 //
101 101 // Called when the model is changed. The model may have been
102 102 // changed by another view or by a state update from the back-end.
103 if (!this.user_invoked_update) {
103 if (options === undefined || options.updated_view != this) {
104 104 this.$textbox.val(this.model.get('value'));
105 }
106 105
107 106 var disabled = this.model.get('disabled');
108 107 this.$textbox.prop('disabled', disabled);
@@ -114,6 +113,7 b' define(["notebook/js/widgets/widget"], function(widget_manager){'
114 113 this.$label.html(description);
115 114 this.$label.show();
116 115 }
116 }
117 117 return IPython.DOMWidgetView.prototype.update.call(this);
118 118 },
119 119
@@ -123,13 +123,11 b' define(["notebook/js/widgets/widget"], function(widget_manager){'
123 123
124 124 // Handles and validates user input.
125 125 handleChanging: function(e) {
126 this.user_invoked_update = true;
127 126
128 127 // Calling model.set will trigger all of the other views of the
129 128 // model to update.
130 this.model.set('value', e.target.value);
129 this.model.set('value', e.target.value, {updated_view: this});
131 130 this.touch();
132 this.user_invoked_update = false;
133 131 },
134 132 });
135 133
@@ -154,11 +152,12 b' define(["notebook/js/widgets/widget"], function(widget_manager){'
154 152 this.update(); // Set defaults.
155 153 },
156 154
157 update: function(){
155 update: function(options){
158 156 // Update the contents of this view
159 157 //
160 158 // Called when the model is changed. The model may have been
161 159 // changed by another view or by a state update from the back-end.
160 if (options === undefined || options.updated_view != this) {
162 161 if (this.$textbox.val() != this.model.get('value')) {
163 162 this.$textbox.val(this.model.get('value'));
164 163 }
@@ -173,6 +172,7 b' define(["notebook/js/widgets/widget"], function(widget_manager){'
173 172 this.$label.html(description);
174 173 this.$label.show();
175 174 }
175 }
176 176 return IPython.DOMWidgetView.prototype.update.call(this);
177 177 },
178 178
@@ -186,7 +186,7 b' define(["notebook/js/widgets/widget"], function(widget_manager){'
186 186
187 187 // Calling model.set will trigger all of the other views of the
188 188 // model to update.
189 this.model.set('value', e.target.value);
189 this.model.set('value', e.target.value, {updated_view: this});
190 190 this.touch();
191 191 },
192 192
General Comments 0
You need to be logged in to leave comments. Login now