Skip to content

Commit 5bfa8f4

Browse files
committed
Add js default values for widget-button
1 parent 63bf664 commit 5bfa8f4

File tree

3 files changed

+21
-8
lines changed

3 files changed

+21
-8
lines changed

ipywidgets/static/widgets/js/widget_bool.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ define([
9999
_model_name: "ToggleButtonModel",
100100
tooltip: "",
101101
icon: "",
102-
button_style: "primary",
102+
button_style: "",
103103
}),
104104
});
105105

ipywidgets/static/widgets/js/widget_button.js

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,21 @@ if (typeof define !== 'function') { var define = require('./requirejs-shim')(mod
77
define([
88
"./widget",
99
"jquery",
10+
"underscore",
1011
"bootstrap",
11-
], function(widget, $){
12+
], function(widget, $, _) {
13+
14+
var ButtonModel = widget.DOMWidgetModel.extend({
15+
defaults: _.extend({}, widget.DOMWidgetModel.prototype.defaults, {
16+
description: "",
17+
tooltip: "",
18+
disabled: false,
19+
icon: "",
20+
button_style: "",
21+
_view_name: "ButtonView",
22+
_model_name: "ButtonModel"
23+
}),
24+
});
1225

1326
var ButtonView = widget.DOMWidgetView.extend({
1427
render: function() {
@@ -23,12 +36,12 @@ define([
2336

2437
this.update(); // Set defaults.
2538
},
26-
39+
2740
update: function() {
2841
/**
2942
* Update the contents of this view
3043
*
31-
* Called when the model is changed. The model may have been
44+
* Called when the model is changed. The model may have been
3245
* changed by another view or by a state update from the back-end.
3346
*/
3447
this.$el.prop("disabled", this.model.get("disabled"));
@@ -61,7 +74,7 @@ define([
6174
// Dictionary of events and their handlers.
6275
'click': '_handle_click',
6376
},
64-
77+
6578
_handle_click: function() {
6679
/**
6780
* Handles when the button is clicked.
@@ -71,6 +84,7 @@ define([
7184
});
7285

7386
return {
74-
'ButtonView': ButtonView,
87+
ButtonView: ButtonView,
88+
ButtonModel: ButtonModel
7589
};
7690
});

ipywidgets/widgets/widget_button.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ class Button(DOMWidget):
2929
font-awesome icon name
3030
"""
3131
_view_name = Unicode('ButtonView', sync=True)
32+
_model_name = Unicode('ButtonModel', sync=True)
3233

33-
# Keys
3434
description = Unicode('', help="Button label.", sync=True)
3535
tooltip = Unicode(help="Tooltip caption of the button.", sync=True)
3636
disabled = Bool(False, help="Enable or disable user changes.", sync=True)
@@ -41,7 +41,6 @@ class Button(DOMWidget):
4141
sync=True, help="""Use a predefined styling for the button.""")
4242

4343
def __init__(self, **kwargs):
44-
"""Constructor"""
4544
super(Button, self).__init__(**kwargs)
4645
self._click_handlers = CallbackDispatcher()
4746
self.on_msg(self._handle_button_msg)

0 commit comments

Comments
 (0)