Show More
@@ -129,10 +129,11 b' define([' | |||||
129 |
|
129 | |||
130 | var description = this.model.get('description'); |
|
130 | var description = this.model.get('description'); | |
131 | this.$el.attr("title", this.model.get("tooltip")); |
|
131 | this.$el.attr("title", this.model.get("tooltip")); | |
132 |
|
|
132 | this.$el.text(description); | |
|
133 | var icon = this.model.get("icon"); | |||
|
134 | $('<i class="fa"></i>').prependTo(this.$el).addClass(icon); | |||
|
135 | if (description.trim().length === 0 && icon.trim().length ===0) { | |||
133 | this.$el.html(" "); // Preserve button height |
|
136 | this.$el.html(" "); // Preserve button height | |
134 | } else { |
|
|||
135 | this.$el.text(description); |
|
|||
136 | } |
|
137 | } | |
137 | } |
|
138 | } | |
138 | return ToggleButtonView.__super__.update.apply(this); |
|
139 | return ToggleButtonView.__super__.update.apply(this); |
@@ -32,12 +32,12 b' define([' | |||||
32 | */ |
|
32 | */ | |
33 | var description = this.model.get('description'); |
|
33 | var description = this.model.get('description'); | |
34 | this.$el.attr("title", this.model.get("tooltip")); |
|
34 | this.$el.attr("title", this.model.get("tooltip")); | |
35 |
|
|
35 | this.$el.text(description); | |
|
36 | var icon = this.model.get("icon"); | |||
|
37 | $('<i class="fa"></i>').prependTo(this.$el).addClass(icon); | |||
|
38 | if (description.trim().length === 0 && icon.trim().length ===0) { | |||
36 | this.$el.html(" "); // Preserve button height |
|
39 | this.$el.html(" "); // Preserve button height | |
37 | } else { |
|
|||
38 | this.$el.text(description); |
|
|||
39 | } |
|
40 | } | |
40 |
|
||||
41 | if (this.model.get('disabled')) { |
|
41 | if (this.model.get('disabled')) { | |
42 | this.$el.attr('disabled','disabled'); |
|
42 | this.$el.attr('disabled','disabled'); | |
43 | } else { |
|
43 | } else { |
@@ -49,7 +49,7 b' casper.notebook_test(function () {' | |||||
49 | 'Toggle button exists.'); |
|
49 | 'Toggle button exists.'); | |
50 |
|
50 | |||
51 | this.test.assert(this.cell_element_function(bool_index, |
|
51 | this.test.assert(this.cell_element_function(bool_index, | |
52 |
widget_togglebutton_selector, 'html')== |
|
52 | widget_togglebutton_selector, 'html')=='<i class="fa"></i>Title', | |
53 | 'Toggle button labeled correctly.'); |
|
53 | 'Toggle button labeled correctly.'); | |
54 |
|
54 | |||
55 | this.test.assert(this.cell_element_function(bool_index, |
|
55 | this.test.assert(this.cell_element_function(bool_index, |
@@ -29,7 +29,7 b' casper.notebook_test(function () {' | |||||
29 | 'Widget button exists.'); |
|
29 | 'Widget button exists.'); | |
30 |
|
30 | |||
31 | this.test.assert(this.cell_element_function(button_index, |
|
31 | this.test.assert(this.cell_element_function(button_index, | |
32 | widget_button_selector, 'html')=='Title', |
|
32 | widget_button_selector, 'html')=='<i class="fa"></i>Title', | |
33 | 'Set button description.'); |
|
33 | 'Set button description.'); | |
34 |
|
34 | |||
35 | this.cell_element_function(button_index, |
|
35 | this.cell_element_function(button_index, |
@@ -55,10 +55,15 b' class ToggleButton(_Bool):' | |||||
55 | value of the toggle button: True-pressed, False-unpressed |
|
55 | value of the toggle button: True-pressed, False-unpressed | |
56 | description : str |
|
56 | description : str | |
57 | description displayed next to the button |
|
57 | description displayed next to the button | |
|
58 | tooltip: str | |||
|
59 | tooltip caption of the toggle button | |||
|
60 | icon: str | |||
|
61 | font-awesome icon name | |||
58 | """ |
|
62 | """ | |
59 |
|
63 | |||
60 | _view_name = Unicode('ToggleButtonView', sync=True) |
|
64 | _view_name = Unicode('ToggleButtonView', sync=True) | |
61 | tooltip = Unicode(help="Tooltip caption of the toggle button.", sync=True) |
|
65 | tooltip = Unicode(help="Tooltip caption of the toggle button.", sync=True) | |
|
66 | icon = Unicode('', help= "Font-awesome icon.", sync=True) | |||
62 |
|
67 | |||
63 | button_style = CaselessStrEnum( |
|
68 | button_style = CaselessStrEnum( | |
64 | values=['primary', 'success', 'info', 'warning', 'danger', ''], |
|
69 | values=['primary', 'success', 'info', 'warning', 'danger', ''], |
@@ -24,15 +24,25 b' from IPython.utils.warn import DeprecatedClass' | |||||
24 | @register('IPython.Button') |
|
24 | @register('IPython.Button') | |
25 | class Button(DOMWidget): |
|
25 | class Button(DOMWidget): | |
26 | """Button widget. |
|
26 | """Button widget. | |
|
27 | This widget has an `on_click` method that allows you to listen for the | |||
|
28 | user clicking on the button. The click event itself is stateless. | |||
27 |
|
29 | |||
28 | This widget has an `on_click` method that allows you to listen for the |
|
30 | Parameters | |
29 | user clicking on the button. The click event itself is stateless.""" |
|
31 | ---------- | |
|
32 | description : str | |||
|
33 | description displayed next to the button | |||
|
34 | tooltip: str | |||
|
35 | tooltip caption of the toggle button | |||
|
36 | icon: str | |||
|
37 | font-awesome icon name | |||
|
38 | """ | |||
30 | _view_name = Unicode('ButtonView', sync=True) |
|
39 | _view_name = Unicode('ButtonView', sync=True) | |
31 |
|
40 | |||
32 | # Keys |
|
41 | # Keys | |
33 | description = Unicode('', help="Button label.", sync=True) |
|
42 | description = Unicode('', help="Button label.", sync=True) | |
34 | tooltip = Unicode(help="Tooltip caption of the button.", sync=True) |
|
43 | tooltip = Unicode(help="Tooltip caption of the button.", sync=True) | |
35 | disabled = Bool(False, help="Enable or disable user changes.", sync=True) |
|
44 | disabled = Bool(False, help="Enable or disable user changes.", sync=True) | |
|
45 | icon = Unicode('', help= "Font-awesome icon.", sync=True) | |||
36 |
|
46 | |||
37 | button_style = CaselessStrEnum( |
|
47 | button_style = CaselessStrEnum( | |
38 | values=['primary', 'success', 'info', 'warning', 'danger', ''], |
|
48 | values=['primary', 'success', 'info', 'warning', 'danger', ''], |
General Comments 0
You need to be logged in to leave comments.
Login now