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