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