Show More
@@ -419,9 +419,36 b' define(["widgets/js/manager",' | |||
|
419 | 419 | var old_classes = model.previous('children'); |
|
420 | 420 | this.update_classes(old_classes, new_classes); |
|
421 | 421 | }, this); |
|
422 | this.model.on('change:fore_color', function (model, value) { | |
|
423 | this.update_attr('color', value); }, this); | |
|
424 | this.model.on('change:back_color', function (model, value) { | |
|
425 | this.update_attr('background', value); }, this); | |
|
426 | this.model.on('change:width', function (model, value) { | |
|
427 | this.update_attr('width', value); }, this); | |
|
428 | this.model.on('change:height', function (model, value) { | |
|
429 | this.update_attr('height', value); }, this); | |
|
430 | this.model.on('change:border_color', function (model, value) { | |
|
431 | this.update_attr('border-color', value); }, this); | |
|
432 | this.model.on('change:border_width', function (model, value) { | |
|
433 | this.update_attr('border-width', value); }, this); | |
|
434 | this.model.on('change:border_style', function (model, value) { | |
|
435 | this.update_attr('border-style', value); }, this); | |
|
436 | this.model.on('change:font_style', function (model, value) { | |
|
437 | this.update_attr('font-style', value); }, this); | |
|
438 | this.model.on('change:font_weight', function (model, value) { | |
|
439 | this.update_attr('font-weight', value); }, this); | |
|
440 | this.model.on('change:font_size', function (model, value) { | |
|
441 | this.update_attr('font-size', value); }, this); | |
|
442 | this.model.on('change:font_family', function (model, value) { | |
|
443 | this.update_attr('font-family', value); }, this); | |
|
422 | 444 | this.update_classes([], this.model.get('_dom_classes')); |
|
423 | 445 | }, |
|
424 | 446 | |
|
447 | update_attr: function(name, value) { | |
|
448 | // Set a css attr of the widget view. | |
|
449 | this.$el.css(name, value); | |
|
450 | }, | |
|
451 | ||
|
425 | 452 | update_visible: function(model, value) { |
|
426 | 453 | // Update visibility |
|
427 | 454 | this.$el.toggle(value); |
@@ -16,6 +16,11 b' define([' | |||
|
16 | 16 | }, this); |
|
17 | 17 | }, |
|
18 | 18 | |
|
19 | update_attr: function(name, value) { | |
|
20 | // Set a css attr of the widget view. | |
|
21 | this.$box.css(name, value); | |
|
22 | }, | |
|
23 | ||
|
19 | 24 | render: function(){ |
|
20 | 25 | // Called when view is rendered. |
|
21 | 26 | this.$box = this.$el; |
@@ -18,7 +18,8 b' import collections' | |||
|
18 | 18 | from IPython.core.getipython import get_ipython |
|
19 | 19 | from IPython.kernel.comm import Comm |
|
20 | 20 | from IPython.config import LoggingConfigurable |
|
21 |
from IPython.utils.traitlets import Unicode, Dict, Instance, Bool, List, |
|
|
21 | from IPython.utils.traitlets import Unicode, Dict, Instance, Bool, List, | |
|
22 | CaselessStrEnum, Tuple, CTuple, CUnicode, Int, Set | |
|
22 | 23 | from IPython.utils.py3compat import string_types |
|
23 | 24 | |
|
24 | 25 | #----------------------------------------------------------------------------- |
@@ -381,3 +382,44 b' class DOMWidget(Widget):' | |||
|
381 | 382 | visible = Bool(True, help="Whether the widget is visible.", sync=True) |
|
382 | 383 | _css = CTuple(sync=True, help="CSS property list: (selector, key, value)") |
|
383 | 384 | _dom_classes = CTuple(sync=True, help="DOM classes applied to widget.$el.") |
|
385 | ||
|
386 | width = CUnicode(sync=True) | |
|
387 | height = CUnicode(sync=True) | |
|
388 | ||
|
389 | fore_color = Unicode(sync=True) | |
|
390 | back_color = Unicode(sync=True) | |
|
391 | border_color = Unicode(sync=True) | |
|
392 | ||
|
393 | border_width = CUnicode(sync=True) | |
|
394 | border_style = CaselessStrEnum(values=[ # http://www.w3schools.com/cssref/pr_border-style.asp | |
|
395 | 'none', | |
|
396 | 'hidden', | |
|
397 | 'dotted', | |
|
398 | 'dashed', | |
|
399 | 'solid', | |
|
400 | 'double', | |
|
401 | 'groove', | |
|
402 | 'ridge', | |
|
403 | 'inset', | |
|
404 | 'outset', | |
|
405 | 'initial', | |
|
406 | 'inherit', ''], | |
|
407 | default_value='', sync=True) | |
|
408 | ||
|
409 | font_style = CaselessStrEnum(values=[ # http://www.w3schools.com/cssref/pr_font_font-style.asp | |
|
410 | 'normal', | |
|
411 | 'italic', | |
|
412 | 'oblique', | |
|
413 | 'initial', | |
|
414 | 'inherit', ''], | |
|
415 | default_value='', sync=True) | |
|
416 | font_weight = CaselessStrEnum(values=[ # http://www.w3schools.com/cssref/pr_font_weight.asp | |
|
417 | 'normal', | |
|
418 | 'bold', | |
|
419 | 'bolder', | |
|
420 | 'lighter', | |
|
421 | 'initial', | |
|
422 | 'inherit', ''] + [str(100 * (i+1)) for i in range(9)], | |
|
423 | default_value='', sync=True) | |
|
424 | font_size = CUnicode(sync=True) | |
|
425 | font_family = Unicode(sync=True) |
General Comments 0
You need to be logged in to leave comments.
Login now