Skip to content

Commit 3330634

Browse files
committed
Controlgroup: fixup for spinner and label
1 parent 6c1390d commit 3330634

4 files changed

Lines changed: 29 additions & 12 deletions

File tree

demos/controlgroup/default.html

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
#car-type-button {
1717
width: 120px;
1818
}
19-
.ui-controlgroup-horizontal .ui-spinner {
20-
width: 50px;
19+
.ui-controlgroup-horizontal .ui-spinner-input {
20+
width: 20px;
2121
}
2222
</style>
2323
<script src="../../external/requirejs/require.js"></script>
@@ -26,13 +26,15 @@
2626
$( ".controlgroup-vertical" ).controlgroup({
2727
"direction": "vertical"
2828
});
29+
$( ".button" ).button();
2930
</script>
3031
</head>
3132
<body>
3233
<div class="widget">
3334
<h1>Controlgroup</h1>
3435
<fieldset>
3536
<legend>Rental Car</legend>
37+
<button class="button">button</button>
3638
<div class="controlgroup">
3739
<select id="car-type">
3840
<option>Compact car</option>

tests/unit/controlgroup/common.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ common.testWidget( "controlgroup", {
1212
items: {
1313
"button": "input[type=button], input[type=submit], input[type=reset], button, a",
1414
"checkboxradio": "input[type='checkbox'], input[type='radio']",
15-
"selectmenu": "select"
15+
"selectmenu": "select",
16+
"spinner": ".ui-spinner-input",
17+
"controlgroupLabel": ".ui-controlgroup-label"
1618
},
1719
direction: "horizontal",
1820
excludeInvisible: true,

themes/base/controlgroup.css

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
.ui-controlgroup {
1313
vertical-align: middle;
14+
display: inline-block;
1415
}
1516
.ui-controlgroup > .ui-controlgroup-item {
1617
float: left;
@@ -31,8 +32,9 @@
3132
.ui-controlgroup-vertical .ui-controlgroup-item {
3233
box-sizing: border-box;
3334
}
34-
.ui-controlgroup-label {
35-
padding: .4em 1em;
35+
.ui-controlgroup .ui-controlgroup-label {
36+
font-size: .83em;
37+
padding: .6em 1em;
3638
}
3739
.ui-controlgroup-horizontal .ui-controlgroup-label + .ui-controlgroup-item {
3840
border-left: none;

ui/widgets/controlgroup.js

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,25 +80,25 @@ return $.widget( "ui.controlgroup", {
8080
// Make sure the widget actually exists and has a selector set
8181
if ( $.fn[ widget ] && selector ) {
8282

83-
// Find instances of this widget inside controlgroup and run method or set options
83+
// Find instances of this widget inside controlgroup and set options
8484
widgets = that.element.find( selector )[ widget ]( options );
8585

86-
// Don't set data or add to the collection if the method is destroy
8786
widgets.each( function() {
88-
var element = $( this );
87+
var element = $( this ),
8988

9089
// Set data on the widget element pointing to the this.element of the widget
9190
// and telling us what type of widget this is
92-
var widgetElement =
93-
element[ widget ]( "widget" ).data( "ui-controlgroup-data", element.data( "ui-" +
94-
widget.charAt(0).toUpperCase() + widget.slice(1) ) );
91+
widgetElement = element[ widget ]( "widget" ).data(
92+
"ui-controlgroup-data",
93+
element.data( "ui-" + widget.charAt(0).toUpperCase() + widget.slice(1) )
94+
);
9595

9696
childWidgets.push( widgetElement[ 0 ] );
9797
} );
9898
} else if ( selector && widget === "controlgroupLabel" ) {
9999
labels = that.element.find( selector );
100100
that._addClass( labels, null, "ui-widget ui-widget-content ui-state-default" );
101-
Array.prototype.push.apply( childWidgets, labels );
101+
Array.prototype.push.apply( childWidgets, labels.get() );
102102
}
103103
} );
104104

@@ -116,6 +116,15 @@ return $.widget( "ui.controlgroup", {
116116
} );
117117
},
118118

119+
_updateCornerClass: function( element, position ) {
120+
var remove = "ui-corner-top ui-corner-bottom ui-corner-left ui-corner-right",
121+
add =
122+
this._buildSimpleOptions( position, this.options.direction, "label" ).classes.label;
123+
124+
this._removeClass( element, null, remove );
125+
this._addClass( element, null, add );
126+
},
127+
119128
_buildSimpleOptions: function( position, direction, key ) {
120129
var result = {
121130
classes: {}
@@ -217,6 +226,8 @@ return $.widget( "ui.controlgroup", {
217226
that.options.direction === "vertical"
218227
)
219228
);
229+
} else {
230+
that._updateCornerClass( children[ value ](), value );
220231
}
221232
} );
222233

0 commit comments

Comments
 (0)