##// END OF EJS Templates
Address problems found in in-person review
Jonathan Frederic -
Show More
@@ -445,7 +445,7 b' define(["widgets/js/manager",'
445 this.update_attr('font-weight', value); }, this);
445 this.update_attr('font-weight', value); }, this);
446
446
447 this.model.on('change:font_size', function (model, value) {
447 this.model.on('change:font_size', function (model, value) {
448 this.update_attr('font-size', value); }, this);
448 this.update_attr('font-size', this._default_px(value)); }, this);
449
449
450 this.model.on('change:font_family', function (model, value) {
450 this.model.on('change:font_family', function (model, value) {
451 this.update_attr('font-family', value); }, this);
451 this.update_attr('font-family', value); }, this);
@@ -454,7 +454,10 b' define(["widgets/js/manager",'
454 this.update_attr('padding', value); }, this);
454 this.update_attr('padding', value); }, this);
455
455
456 this.model.on('change:margin', function (model, value) {
456 this.model.on('change:margin', function (model, value) {
457 this.update_attr('margin', value); }, this);
457 this.update_attr('margin', this._default_px(value)); }, this);
458
459 this.model.on('change:border_radius', function (model, value) {
460 this.update_attr('border-radius', this._default_px(value)); }, this);
458
461
459 this.after_displayed(function() {
462 this.after_displayed(function() {
460 this.update_visible(this.model, this.model.get("visible"));
463 this.update_visible(this.model, this.model.get("visible"));
@@ -474,9 +477,18 b' define(["widgets/js/manager",'
474 this.update_attr('font-family', this.model.get('font_family'));
477 this.update_attr('font-family', this.model.get('font_family'));
475 this.update_attr('padding', this.model.get('padding'));
478 this.update_attr('padding', this.model.get('padding'));
476 this.update_attr('margin', this.model.get('margin'));
479 this.update_attr('margin', this.model.get('margin'));
480 this.update_attr('border-radius', this.model.get('border_radius'));
477 }, this);
481 }, this);
478 },
482 },
479
483
484 _default_px: function(value) {
485 // Makes browser interpret a numerical string as a pixel value.
486 if (/^\d+\.?(\d+)?$/.test(value.trim())) {
487 return value.trim() + 'px';
488 }
489 return value;
490 },
491
480 update_attr: function(name, value) {
492 update_attr: function(name, value) {
481 // Set a css attr of the widget view.
493 // Set a css attr of the widget view.
482 this.$el.css(name, value);
494 this.$el.css(name, value);
@@ -179,8 +179,8 b' define(['
179 that.popped_out = !that.popped_out;
179 that.popped_out = !that.popped_out;
180 if (!that.popped_out) {
180 if (!that.popped_out) {
181 that.$minimize
181 that.$minimize
182 .removeClass('fa fa-arrow-down')
182 .removeClass('fa-arrow-down')
183 .addClass('fa fa-arrow-up');
183 .addClass('fa-arrow-up');
184
184
185 that.$window
185 that.$window
186 .draggable('destroy')
186 .draggable('destroy')
@@ -193,8 +193,8 b' define(['
193 that.$close.hide();
193 that.$close.hide();
194 } else {
194 } else {
195 that.$minimize
195 that.$minimize
196 .addClass('fa fa-arrow-down')
196 .addClass('fa-arrow-down')
197 .removeClass('fa fa-arrow-up');
197 .removeClass('fa-arrow-up');
198
198
199 that.$window
199 that.$window
200 .removeClass('docked-widget-modal')
200 .removeClass('docked-widget-modal')
@@ -393,6 +393,7 b' class DOMWidget(Widget):'
393 border_color = Unicode(sync=True)
393 border_color = Unicode(sync=True)
394
394
395 border_width = CUnicode(sync=True)
395 border_width = CUnicode(sync=True)
396 border_radius = CUnicode(sync=True)
396 border_style = CaselessStrEnum(values=[ # http://www.w3schools.com/cssref/pr_border-style.asp
397 border_style = CaselessStrEnum(values=[ # http://www.w3schools.com/cssref/pr_border-style.asp
397 'none',
398 'none',
398 'hidden',
399 'hidden',
@@ -425,3 +426,14 b' class DOMWidget(Widget):'
425 default_value='', sync=True)
426 default_value='', sync=True)
426 font_size = CUnicode(sync=True)
427 font_size = CUnicode(sync=True)
427 font_family = Unicode(sync=True)
428 font_family = Unicode(sync=True)
429
430 def __init__(self, *pargs, **kwargs):
431 super(DOMWidget, self).__init__(*pargs, **kwargs)
432
433 def _validate_border(name, old, new):
434 if new is not None and new != '':
435 if name != 'border_width' and not self.border_width:
436 self.border_width = 1
437 if name != 'border_style' and self.border_style == '':
438 self.border_style = 'solid'
439 self.on_trait_change(_validate_border, ['border_width', 'border_style', 'border_color'])
@@ -170,6 +170,7 b' class FloatRangeSlider(_BoundedFloatRange):'
170 help="Vertical or horizontal.", sync=True)
170 help="Vertical or horizontal.", sync=True)
171 _range = Bool(True, help="Display a range selector", sync=True)
171 _range = Bool(True, help="Display a range selector", sync=True)
172 readout = Bool(True, help="Display the current value of the slider next to it.", sync=True)
172 readout = Bool(True, help="Display the current value of the slider next to it.", sync=True)
173 slider_color = Unicode(sync=True)
173
174
174 # Remove in IPython 4.0
175 # Remove in IPython 4.0
175 FloatTextWidget = DeprecatedClass(FloatText, 'FloatTextWidget')
176 FloatTextWidget = DeprecatedClass(FloatText, 'FloatTextWidget')
@@ -174,6 +174,7 b' class IntRangeSlider(_BoundedIntRange):'
174 help="Vertical or horizontal.", sync=True)
174 help="Vertical or horizontal.", sync=True)
175 _range = Bool(True, help="Display a range selector", sync=True)
175 _range = Bool(True, help="Display a range selector", sync=True)
176 readout = Bool(True, help="Display the current value of the slider next to it.", sync=True)
176 readout = Bool(True, help="Display the current value of the slider next to it.", sync=True)
177 slider_color = Unicode(sync=True)
177
178
178 # Remove in IPython 4.0
179 # Remove in IPython 4.0
179 IntTextWidget = DeprecatedClass(IntText, 'IntTextWidget')
180 IntTextWidget = DeprecatedClass(IntText, 'IntTextWidget')
General Comments 0
You need to be logged in to leave comments. Login now