@@ -62,43 +62,52 @@ $.widget( "ui.controlgroup", {
62
62
" ui-corner-bottom ui-corner-left ui-corner-tl ui-corner-tr" ) ;
63
63
} ,
64
64
65
- _callChildMethod : function ( method , filter ) {
65
+ _callChildMethod : function ( method ) {
66
66
var that = this ;
67
67
$ . each ( this . options . items , function ( widget , selector ) {
68
68
var options = { } ;
69
- switch ( widget ) {
70
- case "button" :
71
- options . classes = {
72
- "ui-button" : null
73
- } ;
74
- break ;
75
- case "checkboxradio" :
76
- options . classes = {
77
- "ui-checkbox-label" : null ,
78
- "ui-radio-label" : null
79
- } ;
80
- break ;
81
- case "selectmenu" :
82
- options . classes = {
83
- "ui-selectmenu-button-open" : null ,
84
- "ui-selectmenu-button-closed" : null
85
- } ;
86
- break ;
69
+ if ( that [ "_" + widget + "_options" ] ) {
70
+ options = that [ "_" + widget + "_options" ] ( ) ;
87
71
}
88
72
if ( $ . fn [ widget ] && selector ) {
89
- that . element . children ( selector ) . not ( filter ) [ widget ] ( method ?
73
+ that . element . children ( selector ) [ widget ] ( method ?
90
74
method : options ) ;
91
75
}
92
76
} ) ;
93
77
} ,
94
78
79
+ _button_options : function ( ) {
80
+ return {
81
+ classes : {
82
+ "ui-button" : ""
83
+ }
84
+ } ;
85
+ } ,
86
+
87
+ _checkboxradio_options : function ( ) {
88
+ return {
89
+ classes : {
90
+ "ui-checkbox-label" : "" ,
91
+ "ui-radio-label" : ""
92
+ }
93
+ } ;
94
+ } ,
95
+
96
+ _selectmenu_options : function ( ) {
97
+ return {
98
+ classes : {
99
+ "ui-selectmenu-button-open" : "" ,
100
+ "ui-selectmenu-button-closed" : ""
101
+ }
102
+ } ;
103
+ } ,
104
+
95
105
_setOption : function ( key , value ) {
96
106
var original = this . options [ key ] ;
97
107
98
108
this . _super ( key , value ) ;
99
109
if ( key === "direction" ) {
100
- this . element . removeClass ( "ui-controlgroup-" + original )
101
- . addClass ( "ui-controlgroup-" + value ) ;
110
+ this . element . removeClass ( "ui-controlgroup-" + original ) ;
102
111
}
103
112
if ( key === "disabled" ) {
104
113
this . _callChildMethod ( value ? "disable" : "enable" ) ;
@@ -108,21 +117,11 @@ $.widget( "ui.controlgroup", {
108
117
109
118
} ,
110
119
111
- refresh : function ( ) {
120
+ _refresh_selectmenu : function ( ) {
112
121
var firstClasses = { } ,
113
122
lastClasses = { } ,
114
123
vertical = ( this . options . direction === "vertical" ) ;
115
- this . element . addClass ( this . _classes ( "ui-controlgroup ui-controlgroup-" +
116
- this . options . direction ) ) ;
117
- this . _callChildMethod ( undefined ) ;
118
- this . visible = this . element . children ( ".ui-button" ) . removeClass ( function ( index , css ) {
119
- return ( css . match ( / u i - c o r n e r - [ a - z ] * / g ) || [ ] ) . join ( " " ) ;
120
- } ) . filter ( this . options . excludeInvisible ? ":visible" : "*" ) ;
121
124
122
- this . first = this . visible . filter ( ":first" )
123
- . addClass ( "ui-corner-" + ( vertical ? "top" : "left" ) ) ;
124
- this . last = this . visible . filter ( ":last" )
125
- . addClass ( "ui-corner-" + ( vertical ? "bottom" : "right" ) ) ;
126
125
if ( $ . ui . selectmenu ) {
127
126
if ( this . first . is ( ".ui-selectmenu-button" ) && ! vertical ) {
128
127
firstClasses [ "ui-selectmenu-button-open" ] = "ui-corner-tl" ;
@@ -143,6 +142,28 @@ $.widget( "ui.controlgroup", {
143
142
}
144
143
this . element . find ( this . options . items . selectmenu ) . selectmenu ( "refresh" ) ;
145
144
}
145
+ } ,
146
+
147
+ refresh : function ( ) {
148
+ var that = this ,
149
+ vertical = ( this . options . direction === "vertical" ) ;
150
+ this . element . addClass ( this . _classes ( "ui-controlgroup ui-controlgroup-" +
151
+ this . options . direction ) ) ;
152
+ this . _callChildMethod ( undefined ) ;
153
+ this . visible = this . element . children ( ".ui-button" ) . removeClass ( function ( index , css ) {
154
+ return ( css . match ( / u i - c o r n e r - [ a - z ] * / g ) || [ ] ) . join ( " " ) ;
155
+ } ) . filter ( this . options . excludeInvisible ? ":visible" : "*" ) ;
156
+
157
+ this . first = this . visible . eq ( 0 )
158
+ . addClass ( "ui-corner-" + ( vertical ? "top" : "left" ) ) ;
159
+ this . last = this . visible . last ( )
160
+ . addClass ( "ui-corner-" + ( vertical ? "bottom" : "right" ) ) ;
161
+
162
+ $ . each ( this . options . items , function ( widget ) {
163
+ if ( that [ "_refresh_" + widget ] ) {
164
+ that [ "_refresh_" + widget ] ( ) ;
165
+ }
166
+ } ) ;
146
167
this . _callChildMethod ( "refresh" ) ;
147
168
148
169
}
0 commit comments