@@ -34,16 +34,16 @@ return $.widget( "ui.controlgroup", {
34
34
version : "@VERSION" ,
35
35
defaultElement : "<div>" ,
36
36
options : {
37
+ direction : "horizontal" ,
37
38
disabled : null ,
39
+ excludeInvisible : true ,
38
40
items : {
39
41
"button" : "input[type=button], input[type=submit], input[type=reset], button, a" ,
42
+ "controlgroupLabel" : ".ui-controlgroup-label" ,
40
43
"checkboxradio" : "input[type='checkbox'], input[type='radio']" ,
41
44
"selectmenu" : "select" ,
42
- "spinner" : ".ui-spinner-input" ,
43
- "controlgroupLabel" : ".ui-controlgroup-label"
44
- } ,
45
- direction : "horizontal" ,
46
- excludeInvisible : true
45
+ "spinner" : ".ui-spinner-input"
46
+ }
47
47
} ,
48
48
49
49
_create : function ( ) {
@@ -80,15 +80,16 @@ return $.widget( "ui.controlgroup", {
80
80
// Make sure the widget actually exists and has a selector set
81
81
if ( $ . fn [ widget ] && selector ) {
82
82
83
- // Find instances of this widget inside controlgroup and set options
83
+ // Find instances of this widget inside controlgroup init them
84
84
widgets = that . element . find ( selector ) [ widget ] ( options ) ;
85
85
86
86
widgets . each ( function ( ) {
87
- var element = $ ( this ) ,
87
+ var element = $ ( this ) ;
88
+
89
+ // Store an instance of the controlgroup to be able to refrence
90
+ var widgetElement = element [ widget ] ( "widget" ) ;
88
91
89
- // Set data on the widget element pointing to the this.element of the widget
90
- // and telling us what type of widget this is
91
- widgetElement = element [ widget ] ( "widget" ) . data (
92
+ widgetElement . data (
92
93
"ui-controlgroup-data" ,
93
94
element . data ( "ui-" + widget . charAt ( 0 ) . toUpperCase ( ) + widget . slice ( 1 ) )
94
95
) ;
@@ -101,7 +102,7 @@ return $.widget( "ui.controlgroup", {
101
102
$ ( this ) . contents ( ) . wrapAll ( "<span class='ui-controlgroup-label-contents'></span>" ) ;
102
103
} ) ;
103
104
that . _addClass ( labels , null , "ui-widget ui-widget-content ui-state-default" ) ;
104
- Array . prototype . push . apply ( childWidgets , labels . get ( ) ) ;
105
+ childWidgets = childWidgets . concat ( labels . get ( ) ) ;
105
106
}
106
107
} ) ;
107
108
@@ -120,15 +121,15 @@ return $.widget( "ui.controlgroup", {
120
121
} ,
121
122
122
123
_updateCornerClass : function ( element , position ) {
123
- var direction = this . options . direction === "vertical" ,
124
- remove = "ui-corner-top ui-corner-bottom ui-corner-left ui-corner-right" ,
125
- add = this . _buildSimpleOptions ( position , direction , "label" ) . classes . label ;
124
+ var remove = "ui-corner-top ui-corner-bottom ui-corner-left ui-corner-right" ;
125
+ var add = this . _buildSimpleOptions ( position , "label" ) . classes . label ;
126
126
127
127
this . _removeClass ( element , null , remove ) ;
128
128
this . _addClass ( element , null , add ) ;
129
129
} ,
130
130
131
- _buildSimpleOptions : function ( position , direction , key ) {
131
+ _buildSimpleOptions : function ( position , key ) {
132
+ var direction = this . options . direction === "vertical" ;
132
133
var result = {
133
134
classes : { }
134
135
} ;
@@ -141,24 +142,25 @@ return $.widget( "ui.controlgroup", {
141
142
return result ;
142
143
} ,
143
144
144
- _spinnerOptions : function ( position , direction ) {
145
- var options = this . _buildSimpleOptions ( position , direction , "ui-spinner" ) ;
145
+ _spinnerOptions : function ( position ) {
146
+ var options = this . _buildSimpleOptions ( position , "ui-spinner" ) ;
146
147
147
148
options . classes [ "ui-spinner-up" ] = "" ;
148
149
options . classes [ "ui-spinner-down" ] = "" ;
149
150
150
151
return options ;
151
152
} ,
152
153
153
- _buttonOptions : function ( position , direction ) {
154
- return this . _buildSimpleOptions ( position , direction , "ui-button" ) ;
154
+ _buttonOptions : function ( position ) {
155
+ return this . _buildSimpleOptions ( position , "ui-button" ) ;
155
156
} ,
156
157
157
- _checkboxradioOptions : function ( position , direction ) {
158
- return this . _buildSimpleOptions ( position , direction , "ui-checkboxradio-label" ) ;
158
+ _checkboxradioOptions : function ( position ) {
159
+ return this . _buildSimpleOptions ( position , "ui-checkboxradio-label" ) ;
159
160
} ,
160
161
161
- _selectmenuOptions : function ( position , direction ) {
162
+ _selectmenuOptions : function ( position ) {
163
+ var direction = this . options . direction === "vertical" ;
162
164
return {
163
165
width : direction ? "auto" : false ,
164
166
classes : {
@@ -167,16 +169,12 @@ return $.widget( "ui.controlgroup", {
167
169
"ui-selectmenu-button-closed" : null
168
170
} ,
169
171
first : {
170
- "ui-selectmenu-button-open" :
171
- "ui-corner-" + ( direction ? "top" : "tl" ) ,
172
- "ui-selectmenu-button-closed" :
173
- "ui-corner-" + ( direction ? "top" : "left" )
172
+ "ui-selectmenu-button-open" : "ui-corner-" + ( direction ? "top" : "tl" ) ,
173
+ "ui-selectmenu-button-closed" : "ui-corner-" + ( direction ? "top" : "left" )
174
174
} ,
175
175
last : {
176
- "ui-selectmenu-button-open" :
177
- direction ? null : "ui-corner-tr" ,
178
- "ui-selectmenu-button-closed" :
179
- "ui-corner-" + ( direction ? "bottom" : "right" )
176
+ "ui-selectmenu-button-open" : direction ? null : "ui-corner-tr" ,
177
+ "ui-selectmenu-button-closed" : "ui-corner-" + ( direction ? "bottom" : "right" )
180
178
}
181
179
182
180
} [ position ]
@@ -224,10 +222,7 @@ return $.widget( "ui.controlgroup", {
224
222
225
223
if ( instance && that [ "_" + instance . widgetName + "Options" ] ) {
226
224
instance . element [ instance . widgetName ] (
227
- that [ "_" + instance . widgetName + "Options" ] (
228
- value ,
229
- that . options . direction === "vertical"
230
- )
225
+ that [ "_" + instance . widgetName + "Options" ] ( value )
231
226
) ;
232
227
} else {
233
228
that . _updateCornerClass ( children [ value ] ( ) , value ) ;
0 commit comments