Show More
@@ -410,16 +410,16 b' function(WidgetManager, _, Backbone){' | |||
|
410 | 410 | |
|
411 | 411 | var css = this.model.get('_css'); |
|
412 | 412 | if (css === undefined) {return;} |
|
413 | var that = this; | |
|
414 | _.each(css, function(css_traits, selector){ | |
|
413 | for (var i = 0; i < css.length; i++) { | |
|
415 | 414 | // Apply the css traits to all elements that match the selector. |
|
416 | var elements = that._get_selector_element(selector); | |
|
415 | var selector = css[i][0]; | |
|
416 | var elements = this._get_selector_element(selector); | |
|
417 | 417 | if (elements.length > 0) { |
|
418 | _.each(css_traits, function(css_value, css_key){ | |
|
419 | elements.css(css_key, css_value); | |
|
420 | }); | |
|
418 | var trait_key = css[i][1]; | |
|
419 | var trait_value = css[i][2]; | |
|
420 | elements.css(trait_key ,trait_value); | |
|
421 | 421 | } |
|
422 |
} |
|
|
422 | } | |
|
423 | 423 | }, |
|
424 | 424 | |
|
425 | 425 | _get_selector_element: function (selector) { |
@@ -341,7 +341,7 b' class Widget(LoggingConfigurable):' | |||
|
341 | 341 | |
|
342 | 342 | class DOMWidget(Widget): |
|
343 | 343 | visible = Bool(True, help="Whether the widget is visible.", sync=True) |
|
344 |
_css = |
|
|
344 | _css = List(sync=True) # Internal CSS property list: (selector, key, value) | |
|
345 | 345 | |
|
346 | 346 | def get_css(self, key, selector=""): |
|
347 | 347 | """Get a CSS property of the widget. |
@@ -384,18 +384,17 b' class DOMWidget(Widget):' | |||
|
384 | 384 | of the view that should be styled with common CSS (see |
|
385 | 385 | `$el_to_style` in the Javascript code). |
|
386 | 386 | """ |
|
387 | if not selector in self._css: | |
|
388 | self._css[selector] = {} | |
|
389 | my_css = self._css[selector] | |
|
390 | ||
|
391 | 387 | if value is None: |
|
392 | 388 | css_dict = dict_or_key |
|
393 | 389 | else: |
|
394 | 390 | css_dict = {dict_or_key: value} |
|
395 | 391 | |
|
396 | 392 | for (key, value) in css_dict.items(): |
|
397 | if not (key in my_css and value == my_css[key]): | |
|
398 | my_css[key] = value | |
|
393 | # First remove the selector/key pair from the css list if it exists. | |
|
394 | # Then add the selector/key pair and new value to the bottom of the | |
|
395 | # list. | |
|
396 | self._css = [x for x in self._css if not (x[0]==selector and x[1]==key)] | |
|
397 | self._css += [(selector, key, value)] | |
|
399 | 398 | self.send_state('_css') |
|
400 | 399 | |
|
401 | 400 | def add_class(self, class_names, selector=""): |
General Comments 0
You need to be logged in to leave comments.
Login now