##// END OF EJS Templates
Fixed context errors and a couple of typos to get the tests working again
Jonathan Frederic -
Show More
@@ -38,8 +38,8 b''
38 38
39 39 // Register already-registered widget model types with the comm manager.
40 40 var that = this;
41 _.each(WidgetManager._model_types, function(value, key) {
42 that.comm_manager.register_target(value, $.proxy(that._handle_comm_open, that));
41 _.each(WidgetManager._model_types, function(model_type, model_name) {
42 that.comm_manager.register_target(model_name, $.proxy(that._handle_comm_open, that));
43 43 });
44 44 };
45 45
@@ -86,12 +86,13 b' function(WidgetManager, Underscore, Backbone){'
86 86
87 87 apply_update: function (state) {
88 88 // Handle when a widget is updated via the python side.
89 var that = this;
89 90 _.each(state, function(value, key) {
90 this.key_value_lock = [key, value];
91 that.key_value_lock = [key, value];
91 92 try {
92 this.set(key, this._unpack_models(value));
93 that.set(key, that._unpack_models(value));
93 94 } finally {
94 this.key_value_lock = null;
95 that.key_value_lock = null;
95 96 }
96 97 });
97 98 },
@@ -154,7 +155,7 b' function(WidgetManager, Underscore, Backbone){'
154 155 }
155 156
156 157 // Only sync if there are attributes to send to the back-end.
157 if (attr.length > 0) {
158 if (_.size(attrs) > 0) {
158 159 var callbacks = options.callbacks || {};
159 160 if (this.pending_msgs >= this.msg_throttle) {
160 161 // The throttle has been exceeded, buffer the current msg so
@@ -203,8 +204,9 b' function(WidgetManager, Underscore, Backbone){'
203 204 return value.id;
204 205 } else if (value instanceof Object) {
205 206 var packed = {};
207 var that = this;
206 208 _.each(value, function(sub_value, key) {
207 packed[key] = this._pack_models(sub_value);
209 packed[key] = that._pack_models(sub_value);
208 210 });
209 211 return packed;
210 212 } else {
@@ -216,8 +218,9 b' function(WidgetManager, Underscore, Backbone){'
216 218 // Replace model ids with models recursively.
217 219 if (value instanceof Object) {
218 220 var unpacked = {};
221 var that = this;
219 222 _.each(value, function(sub_value, key) {
220 unpacked[key] = this._unpack_models(sub_value);
223 unpacked[key] = that._unpack_models(sub_value);
221 224 });
222 225 return unpacked;
223 226 } else {
@@ -366,9 +369,10 b' function(WidgetManager, Underscore, Backbone){'
366 369
367 370 var css = this.model.get('_css');
368 371 if (css === undefined) {return;}
372 var that = this;
369 373 _.each(css, function(css_traits, selector){
370 374 // Apply the css traits to all elements that match the selector.
371 var elements = this._get_selector_element(selector);
375 var elements = that._get_selector_element(selector);
372 376 if (elements.length > 0) {
373 377 _.each(css_traits, function(css_value, css_key){
374 378 elements.css(css_key, css_value);
@@ -50,10 +50,11 b' define(["notebook/js/widgets/widget"], function(WidgetManager){'
50 50 // JQuery slider option keys. These keys happen to have a
51 51 // one-to-one mapping with the corrosponding keys of the model.
52 52 var jquery_slider_keys = ['step', 'max', 'min', 'disabled'];
53 var that = this;
53 54 _.each(jquery_slider_keys, function(key, i) {
54 var model_value = this.model.get(key);
55 var model_value = that.model.get(key);
55 56 if (model_value !== undefined) {
56 this.$slider.slider("option", key, model_value);
57 that.$slider.slider("option", key, model_value);
57 58 }
58 59 });
59 60
@@ -49,10 +49,11 b' define(["notebook/js/widgets/widget"], function(WidgetManager){'
49 49 // JQuery slider option keys. These keys happen to have a
50 50 // one-to-one mapping with the corrosponding keys of the model.
51 51 var jquery_slider_keys = ['step', 'max', 'min', 'disabled'];
52 var that = this;
52 53 _.each(jquery_slider_keys, function(key, i) {
53 var model_value = this.model.get(key);
54 var model_value = that.model.get(key);
54 55 if (model_value !== undefined) {
55 this.$slider.slider("option", key, model_value);
56 that.$slider.slider("option", key, model_value);
56 57 }
57 58 });
58 59
@@ -67,10 +67,11 b' define(["notebook/js/widgets/widget"], function(WidgetManager){'
67 67 var items = this.model.get('values');
68 68 var $replace_droplist = $('<ul />')
69 69 .addClass('dropdown-menu');
70 var that = this;
70 71 _.each(items, function(item, i) {
71 72 var item_button = $('<a href="#"/>')
72 73 .text(item)
73 .on('click', $.proxy(this.handle_click, this));
74 .on('click', $.proxy(that.handle_click, that));
74 75 $replace_droplist.append($('<li />').append(item_button));
75 76 });
76 77
@@ -140,20 +141,21 b' define(["notebook/js/widgets/widget"], function(WidgetManager){'
140 141 // Add missing items to the DOM.
141 142 var items = this.model.get('values');
142 143 var disabled = this.model.get('disabled');
144 var that = this;
143 145 _.each(items, function(item, index) {
144 146 var item_query = ' :input[value="' + item + '"]';
145 if (this.$el.find(item_query).length === 0) {
147 if (that.$el.find(item_query).length === 0) {
146 148 var $label = $('<label />')
147 149 .addClass('radio')
148 150 .text(item)
149 .appendTo(this.$container);
151 .appendTo(that.$container);
150 152
151 153 $('<input />')
152 154 .attr('type', 'radio')
153 .addClass(this.model)
155 .addClass(that.model)
154 156 .val(item)
155 157 .prependTo($label)
156 .on('click', $.proxy(this.handle_click, this));
158 .on('click', $.proxy(that.handle_click, that));
157 159 }
158 160
159 161 var $item_element = this.$container.find(item_query);
@@ -230,15 +232,16 b' define(["notebook/js/widgets/widget"], function(WidgetManager){'
230 232 // Add missing items to the DOM.
231 233 var items = this.model.get('values');
232 234 var disabled = this.model.get('disabled');
235 var that = this;
233 236 _.each(items, function(item, index) {
234 237 var item_query = ' :contains("' + item + '")';
235 if (this.$buttongroup.find(item_query).length === 0) {
238 if (that.$buttongroup.find(item_query).length === 0) {
236 239 $('<button />')
237 240 .attr('type', 'button')
238 241 .addClass('btn')
239 242 .text(item)
240 .appendTo(this.$buttongroup)
241 .on('click', $.proxy(this.handle_click, this));
243 .appendTo(that.$buttongroup)
244 .on('click', $.proxy(that.handle_click, that));
242 245 }
243 246
244 247 var $item_element = this.$buttongroup.find(item_query);
@@ -314,14 +317,15 b' define(["notebook/js/widgets/widget"], function(WidgetManager){'
314 317 if (options === undefined || options.updated_view != this) {
315 318 // Add missing items to the DOM.
316 319 var items = this.model.get('values');
320 var that = this;
317 321 _.each(items, function(item, index) {
318 322 var item_query = ' :contains("' + item + '")';
319 if (this.$listbox.find(item_query).length === 0) {
323 if (that.$listbox.find(item_query).length === 0) {
320 324 $('<option />')
321 325 .text(item)
322 326 .attr('value', item)
323 .appendTo(this.$listbox)
324 .on('click', $.proxy(this.handle_click, this));
327 .appendTo(that.$listbox)
328 .on('click', $.proxy(that.handle_click, that));
325 329 }
326 330 });
327 331
@@ -39,8 +39,9 b' define(["notebook/js/widgets/widget"], function(WidgetManager){'
39 39 if (options === undefined || options.updated_view != this) {
40 40 // Set tab titles
41 41 var titles = this.model.get('_titles');
42 var that = this;
42 43 _.each(titles, function(title, page_index) {
43 var accordian = this.containers[page_index];
44 var accordian = that.containers[page_index];
44 45 if (accordian !== undefined) {
45 46 accordian
46 47 .find('.accordion-heading')
@@ -216,8 +217,9 b' define(["notebook/js/widgets/widget"], function(WidgetManager){'
216 217 if (options === undefined || options.updated_view != this) {
217 218 // Set tab titles
218 219 var titles = this.model.get('_titles');
220 var that = this;
219 221 _.each(titles, function(title, page_index) {
220 var tab_text = this.containers[page_index];
222 var tab_text = that.containers[page_index];
221 223 if (tab_text !== undefined) {
222 224 tab_text.text(title);
223 225 }
@@ -80,7 +80,12 b' class CallbackDispatcher(LoggingConfigurable):'
80 80 """Gets the number of arguments in a callback"""
81 81 if callable(callback):
82 82 argspec = inspect.getargspec(callback)
83 nargs = len(argspec[1]) # Only count vargs!
83 if argspec[0] is None:
84 nargs = 0
85 elif argspec[3] is None:
86 nargs = len(argspec[0]) # Only count vargs!
87 else:
88 nargs = len(argspec[0]) - len(argspec[3]) # Subtract number of defaults.
84 89
85 90 # Bound methods have an additional 'self' argument
86 91 if isinstance(callback, types.MethodType):
General Comments 0
You need to be logged in to leave comments. Login now