Show More
@@ -24,6 +24,11 b' define([' | |||||
24 | this.update(); // Set defaults. |
|
24 | this.update(); // Set defaults. | |
25 | }, |
|
25 | }, | |
26 |
|
26 | |||
|
27 | update_attr: function(name, value) { | |||
|
28 | // Set a css attr of the widget view. | |||
|
29 | this.$checkbox.css(name, value); | |||
|
30 | }, | |||
|
31 | ||||
27 | handle_click: function() { |
|
32 | handle_click: function() { | |
28 | // Handles when the checkbox is clicked. |
|
33 | // Handles when the checkbox is clicked. | |
29 |
|
34 |
@@ -31,10 +31,30 b' define([' | |||||
31 | .addClass('widget-hreadout') |
|
31 | .addClass('widget-hreadout') | |
32 | .hide(); |
|
32 | .hide(); | |
33 |
|
33 | |||
|
34 | this.model.on('change:slider_color', function(sender, value) { | |||
|
35 | this.$slider.find('a').css('background', value); | |||
|
36 | }, this); | |||
|
37 | ||||
34 | // Set defaults. |
|
38 | // Set defaults. | |
35 | this.update(); |
|
39 | this.update(); | |
36 | }, |
|
40 | }, | |
37 |
|
41 | |||
|
42 | update_attr: function(name, value) { | |||
|
43 | // Set a css attr of the widget view. | |||
|
44 | if (name == 'color') { | |||
|
45 | this.$readout.css(name, value); | |||
|
46 | } else if (name.substring(0, 4) == 'font') { | |||
|
47 | this.$readout.css(name, value); | |||
|
48 | } else if (name.substring(0, 6) == 'border') { | |||
|
49 | this.$slider.find('a').css(name, value); | |||
|
50 | this.$slider_container.css(name, value); | |||
|
51 | } else if (name == 'width' || name == 'height' || name == 'background') { | |||
|
52 | this.$slider_container.css(name, value); | |||
|
53 | } else { | |||
|
54 | this.$slider.css(name, value); | |||
|
55 | } | |||
|
56 | }, | |||
|
57 | ||||
38 | update : function(options){ |
|
58 | update : function(options){ | |
39 | // Update the contents of this view |
|
59 | // Update the contents of this view | |
40 | // |
|
60 | // | |
@@ -221,6 +241,11 b' define([' | |||||
221 | return IntTextView.__super__.update.apply(this); |
|
241 | return IntTextView.__super__.update.apply(this); | |
222 | }, |
|
242 | }, | |
223 |
|
243 | |||
|
244 | update_attr: function(name, value) { | |||
|
245 | // Set a css attr of the widget view. | |||
|
246 | this.$textbox.css(name, value); | |||
|
247 | }, | |||
|
248 | ||||
224 | events: { |
|
249 | events: { | |
225 | // Dictionary of events and their handlers. |
|
250 | // Dictionary of events and their handlers. | |
226 | "keyup input" : "handleChanging", |
|
251 | "keyup input" : "handleChanging", | |
@@ -320,6 +345,17 b' define([' | |||||
320 | } |
|
345 | } | |
321 | return ProgressView.__super__.update.apply(this); |
|
346 | return ProgressView.__super__.update.apply(this); | |
322 | }, |
|
347 | }, | |
|
348 | ||||
|
349 | update_attr: function(name, value) { | |||
|
350 | // Set a css attr of the widget view. | |||
|
351 | if (name.substring(0, 6) == 'border' || name == 'width' || name == 'height' || name == 'background') { | |||
|
352 | this.$progress.css(name, value); | |||
|
353 | } else if (name == 'color') { | |||
|
354 | this.$bar.css('background', value); | |||
|
355 | } else { | |||
|
356 | this.$bar.css(name, value); | |||
|
357 | } | |||
|
358 | }, | |||
323 | }); |
|
359 | }); | |
324 |
|
360 | |||
325 | return { |
|
361 | return { |
@@ -58,6 +58,8 b' define([' | |||||
58 | var items = this.model.get('value_names'); |
|
58 | var items = this.model.get('value_names'); | |
59 | var $replace_droplist = $('<ul />') |
|
59 | var $replace_droplist = $('<ul />') | |
60 | .addClass('dropdown-menu'); |
|
60 | .addClass('dropdown-menu'); | |
|
61 | // Copy the style | |||
|
62 | $replace_droplist.attr('style', this.$droplist.attr('style')); | |||
61 | var that = this; |
|
63 | var that = this; | |
62 | _.each(items, function(item, i) { |
|
64 | _.each(items, function(item, i) { | |
63 | var item_button = $('<a href="#"/>') |
|
65 | var item_button = $('<a href="#"/>') | |
@@ -94,6 +96,29 b' define([' | |||||
94 | return DropdownView.__super__.update.apply(this); |
|
96 | return DropdownView.__super__.update.apply(this); | |
95 | }, |
|
97 | }, | |
96 |
|
98 | |||
|
99 | update_attr: function(name, value) { | |||
|
100 | // Set a css attr of the widget view. | |||
|
101 | if (name.substring(0, 6) == 'border' || name == 'background' || name == 'color') { | |||
|
102 | this.$droplabel.css(name, value); | |||
|
103 | this.$dropbutton.css(name, value); | |||
|
104 | this.$droplist.css(name, value); | |||
|
105 | } if (name.substring(0, 4) == 'font') { | |||
|
106 | this.$droplabel.css(name, value); | |||
|
107 | this.$droplist.css(name, value); | |||
|
108 | } else if (name == 'width') { | |||
|
109 | this.$buttongroup.width(value); | |||
|
110 | var width = value - this.$dropbutton.width(); | |||
|
111 | this.$droplist.css(name, width); | |||
|
112 | this.$droplabel.css(name, width); | |||
|
113 | } else if (name == 'height') { | |||
|
114 | this.$droplist.css(name, value); | |||
|
115 | this.$dropbutton.css(name, value); | |||
|
116 | } else { | |||
|
117 | this.$droplabel.css(name, value); | |||
|
118 | this.$droplist.css(name, value); | |||
|
119 | } | |||
|
120 | }, | |||
|
121 | ||||
97 | handle_click: function (e) { |
|
122 | handle_click: function (e) { | |
98 | // Handle when a value is clicked. |
|
123 | // Handle when a value is clicked. | |
99 |
|
124 |
@@ -18,8 +18,8 b' import collections' | |||||
18 | from IPython.core.getipython import get_ipython |
|
18 | from IPython.core.getipython import get_ipython | |
19 | from IPython.kernel.comm import Comm |
|
19 | from IPython.kernel.comm import Comm | |
20 | from IPython.config import LoggingConfigurable |
|
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 |
|
22 | CaselessStrEnum, Tuple, CUnicode, Int, Set | |
23 | from IPython.utils.py3compat import string_types |
|
23 | from IPython.utils.py3compat import string_types | |
24 |
|
24 | |||
25 | #----------------------------------------------------------------------------- |
|
25 | #----------------------------------------------------------------------------- | |
@@ -380,8 +380,8 b' class Widget(LoggingConfigurable):' | |||||
380 |
|
380 | |||
381 | class DOMWidget(Widget): |
|
381 | class DOMWidget(Widget): | |
382 | visible = Bool(True, help="Whether the widget is visible.", sync=True) |
|
382 | visible = Bool(True, help="Whether the widget is visible.", sync=True) | |
383 |
_css = |
|
383 | _css = Tuple(sync=True, help="CSS property list: (selector, key, value)") | |
384 |
_dom_classes = |
|
384 | _dom_classes = Tuple(sync=True, help="DOM classes applied to widget.$el.") | |
385 |
|
385 | |||
386 | width = CUnicode(sync=True) |
|
386 | width = CUnicode(sync=True) | |
387 | height = CUnicode(sync=True) |
|
387 | height = CUnicode(sync=True) |
@@ -57,6 +57,7 b' class FloatSlider(_BoundedFloat):' | |||||
57 | help="Vertical or horizontal.", sync=True) |
|
57 | help="Vertical or horizontal.", sync=True) | |
58 | _range = Bool(False, help="Display a range selector", sync=True) |
|
58 | _range = Bool(False, help="Display a range selector", sync=True) | |
59 | readout = Bool(True, help="Display the current value of the slider next to it.", sync=True) |
|
59 | readout = Bool(True, help="Display the current value of the slider next to it.", sync=True) | |
|
60 | slider_color = Unicode(sync=True) | |||
60 |
|
61 | |||
61 |
|
62 | |||
62 | class FloatProgress(_BoundedFloat): |
|
63 | class FloatProgress(_BoundedFloat): |
@@ -62,6 +62,7 b' class IntSlider(_BoundedInt):' | |||||
62 | help="Vertical or horizontal.", sync=True) |
|
62 | help="Vertical or horizontal.", sync=True) | |
63 | _range = Bool(False, help="Display a range selector", sync=True) |
|
63 | _range = Bool(False, help="Display a range selector", sync=True) | |
64 | readout = Bool(True, help="Display the current value of the slider next to it.", sync=True) |
|
64 | readout = Bool(True, help="Display the current value of the slider next to it.", sync=True) | |
|
65 | slider_color = Unicode(sync=True) | |||
65 |
|
66 | |||
66 |
|
67 | |||
67 | class IntProgress(_BoundedInt): |
|
68 | class IntProgress(_BoundedInt): |
General Comments 0
You need to be logged in to leave comments.
Login now