##// END OF EJS Templates
Fix some bugs found by the widget examples,...
Jonathan Frederic -
Show More
@@ -409,39 +409,72 b' define(["widgets/js/manager",'
409 // Public constructor
409 // Public constructor
410 DOMWidgetView.__super__.initialize.apply(this, [parameters]);
410 DOMWidgetView.__super__.initialize.apply(this, [parameters]);
411 this.on('displayed', this.show, this);
411 this.on('displayed', this.show, this);
412 this.after_displayed(function() {
413 this.update_visible(this.model, this.model.get("visible"));
414 this.update_css(this.model, this.model.get("_css"));
415 }, this);
416 this.model.on('change:visible', this.update_visible, this);
412 this.model.on('change:visible', this.update_visible, this);
417 this.model.on('change:_css', this.update_css, this);
413 this.model.on('change:_css', this.update_css, this);
414
418 this.model.on('change:_dom_classes', function(model, new_classes) {
415 this.model.on('change:_dom_classes', function(model, new_classes) {
419 var old_classes = model.previous('children');
416 var old_classes = model.previous('children');
420 this.update_classes(old_classes, new_classes);
417 this.update_classes(old_classes, new_classes);
421 }, this);
418 }, this);
419
422 this.model.on('change:fore_color', function (model, value) {
420 this.model.on('change:fore_color', function (model, value) {
423 this.update_attr('color', value); }, this);
421 this.update_attr('color', value); }, this);
422
424 this.model.on('change:back_color', function (model, value) {
423 this.model.on('change:back_color', function (model, value) {
425 this.update_attr('background', value); }, this);
424 this.update_attr('background', value); }, this);
425
426 this.model.on('change:width', function (model, value) {
426 this.model.on('change:width', function (model, value) {
427 this.update_attr('width', value); }, this);
427 this.update_attr('width', value); }, this);
428
428 this.model.on('change:height', function (model, value) {
429 this.model.on('change:height', function (model, value) {
429 this.update_attr('height', value); }, this);
430 this.update_attr('height', value); }, this);
431
430 this.model.on('change:border_color', function (model, value) {
432 this.model.on('change:border_color', function (model, value) {
431 this.update_attr('border-color', value); }, this);
433 this.update_attr('border-color', value); }, this);
434
432 this.model.on('change:border_width', function (model, value) {
435 this.model.on('change:border_width', function (model, value) {
433 this.update_attr('border-width', value); }, this);
436 this.update_attr('border-width', value); }, this);
437
434 this.model.on('change:border_style', function (model, value) {
438 this.model.on('change:border_style', function (model, value) {
435 this.update_attr('border-style', value); }, this);
439 this.update_attr('border-style', value); }, this);
440
436 this.model.on('change:font_style', function (model, value) {
441 this.model.on('change:font_style', function (model, value) {
437 this.update_attr('font-style', value); }, this);
442 this.update_attr('font-style', value); }, this);
443
438 this.model.on('change:font_weight', function (model, value) {
444 this.model.on('change:font_weight', function (model, value) {
439 this.update_attr('font-weight', value); }, this);
445 this.update_attr('font-weight', value); }, this);
446
440 this.model.on('change:font_size', function (model, value) {
447 this.model.on('change:font_size', function (model, value) {
441 this.update_attr('font-size', value); }, this);
448 this.update_attr('font-size', value); }, this);
449
442 this.model.on('change:font_family', function (model, value) {
450 this.model.on('change:font_family', function (model, value) {
443 this.update_attr('font-family', value); }, this);
451 this.update_attr('font-family', value); }, this);
444 this.update_classes([], this.model.get('_dom_classes'));
452
453 this.model.on('change:padding', function (model, value) {
454 this.update_attr('padding', value); }, this);
455
456 this.model.on('change:margin', function (model, value) {
457 this.update_attr('margin', value); }, this);
458
459 this.after_displayed(function() {
460 this.update_visible(this.model, this.model.get("visible"));
461 this.update_css(this.model, this.model.get("_css"));
462
463 this.update_classes([], this.model.get('_dom_classes'));
464 this.update_attr('color', this.model.get('fore_color'));
465 this.update_attr('background', this.model.get('back_color'));
466 this.update_attr('width', this.model.get('width'));
467 this.update_attr('height', this.model.get('height'));
468 this.update_attr('border-color', this.model.get('border_color'));
469 this.update_attr('border-width', this.model.get('border_width'));
470 this.update_attr('border-style', this.model.get('border_style'));
471 this.update_attr('font-style', this.model.get('font_style'));
472 this.update_attr('font-weight', this.model.get('font_weight'));
473 this.update_attr('font-size', this.model.get('font_size'));
474 this.update_attr('font-family', this.model.get('font_family'));
475 this.update_attr('padding', this.model.get('padding'));
476 this.update_attr('margin', this.model.get('margin'));
477 }, this);
445 },
478 },
446
479
447 update_attr: function(name, value) {
480 update_attr: function(name, value) {
@@ -14,6 +14,12 b' define(['
14 this.model.on('change:children', function(model, value) {
14 this.model.on('change:children', function(model, value) {
15 this.update_children(model.previous('children'), value);
15 this.update_children(model.previous('children'), value);
16 }, this);
16 }, this);
17 this.model.on('change:overflow_x', function(model, value) {
18 this.update_overflow_x();
19 }, this);
20 this.model.on('change:overflow_y', function(model, value) {
21 this.update_overflow_y();
22 }, this);
17 },
23 },
18
24
19 update_attr: function(name, value) {
25 update_attr: function(name, value) {
@@ -26,6 +32,18 b' define(['
26 this.$box = this.$el;
32 this.$box = this.$el;
27 this.$box.addClass('widget-box');
33 this.$box.addClass('widget-box');
28 this.update_children([], this.model.get('children'));
34 this.update_children([], this.model.get('children'));
35 this.update_overflow_x();
36 this.update_overflow_y();
37 },
38
39 update_overflow_x: function() {
40 // Called when the x-axis overflow setting is changed.
41 this.$box.css('overflow-x', this.model.get('overflow_x'));
42 },
43
44 update_overflow_y: function() {
45 // Called when the y-axis overflow setting is changed.
46 this.$box.css('overflow-y', this.model.get('overflow_y'));
29 },
47 },
30
48
31 update_children: function(old_list, new_list) {
49 update_children: function(old_list, new_list) {
@@ -385,6 +385,8 b' class DOMWidget(Widget):'
385
385
386 width = CUnicode(sync=True)
386 width = CUnicode(sync=True)
387 height = CUnicode(sync=True)
387 height = CUnicode(sync=True)
388 padding = CUnicode(sync=True)
389 margin = CUnicode(sync=True)
388
390
389 fore_color = Unicode(sync=True)
391 fore_color = Unicode(sync=True)
390 back_color = Unicode(sync=True)
392 back_color = Unicode(sync=True)
@@ -18,6 +18,16 b' class Box(DOMWidget):'
18 # Using a tuple here to force reassignment to update the list.
18 # Using a tuple here to force reassignment to update the list.
19 # When a proper notifying-list trait exists, that is what should be used here.
19 # When a proper notifying-list trait exists, that is what should be used here.
20 children = Tuple(sync=True, allow_none=False)
20 children = Tuple(sync=True, allow_none=False)
21
22 _overflow_values = ['visible', 'hidden', 'scroll', 'auto', 'initial', 'inherit', '']
23 overflow_x = CaselessStrEnum(
24 values=_overflow_values,
25 default_value='', allow_none=False, sync=True, help="""Specifies what
26 happens to content that is too large for the rendered region.""")
27 overflow_y = CaselessStrEnum(
28 values=_overflow_values,
29 default_value='', allow_none=False, sync=True, help="""Specifies what
30 happens to content that is too large for the rendered region.""")
21
31
22 def __init__(self, children = (), **kwargs):
32 def __init__(self, children = (), **kwargs):
23 kwargs['children'] = children
33 kwargs['children'] = children
General Comments 0
You need to be logged in to leave comments. Login now