|
12 | 12 | //>>description: Visually groups form control widgets |
13 | 13 | //>>docs: http://api.jqueryui.com/controlgroup/ |
14 | 14 | //>>demos: http://jqueryui.com/controlgroup/ |
15 | | -//>>css.structure: ../themes/base/core.css, ../themes/base/controlgroup.css |
| 15 | +//>>css.structure: ../themes/base/core.css |
| 16 | +//>>css.structure: ../themes/base/controlgroup.css |
16 | 17 | //>>css.theme: ../themes/base/theme.css |
17 | 18 |
|
18 | 19 | ( function( factory ) { |
@@ -71,36 +72,39 @@ return $.widget( "ui.controlgroup", { |
71 | 72 | var widgets, labels, |
72 | 73 | options = {}; |
73 | 74 |
|
74 | | - // We assume everything is in the middle to start because we can't determine |
75 | | - // first / last elements until all enhancments are done. |
76 | | - if ( that[ "_" + widget + "Options" ] ) { |
77 | | - options = that[ "_" + widget + "Options" ]( "middle" ); |
78 | | - } |
79 | | - |
80 | 75 | // Make sure the widget actually exists and has a selector set |
81 | | - if ( $.fn[ widget ] && selector ) { |
82 | | - |
83 | | - // Find instances of this widget inside controlgroup and init them |
84 | | - widgets = that.element.find( selector )[ widget ]( options ); |
85 | | - |
86 | | - widgets.each( function() { |
87 | | - var element = $( this ); |
88 | | - |
89 | | - // Store an instance of the controlgroup to be able to reference it later |
90 | | - var widgetElement = element[ widget ]( "widget" ); |
91 | | - $.data( widgetElement[ 0 ], "ui-controlgroup-data", |
92 | | - element[ widget ]( "instance" ) ); |
93 | | - |
94 | | - childWidgets.push( widgetElement[ 0 ] ); |
95 | | - } ); |
| 76 | + if ( !$.fn[ widget ] || !selector ) { |
| 77 | + return; |
96 | 78 | } else if ( selector && widget === "controlgroupLabel" ) { |
97 | 79 | labels = that.element.find( selector ); |
98 | 80 | labels.each( function() { |
99 | 81 | $( this ).contents().wrapAll( "<span class='ui-controlgroup-label-contents'></span>" ); |
100 | 82 | } ); |
101 | 83 | that._addClass( labels, null, "ui-widget ui-widget-content ui-state-default" ); |
102 | 84 | childWidgets = childWidgets.concat( labels.get() ); |
| 85 | + return; |
103 | 86 | } |
| 87 | + |
| 88 | + // We assume everything is in the middle to start because we can't determine |
| 89 | + // first / last elements until all enhancments are done. |
| 90 | + if ( that[ "_" + widget + "Options" ] ) { |
| 91 | + options = that[ "_" + widget + "Options" ]( "middle" ); |
| 92 | + } |
| 93 | + |
| 94 | + // Find instances of this widget inside controlgroup and init them |
| 95 | + widgets = that.element.find( selector )[ widget ]( options ); |
| 96 | + |
| 97 | + widgets.each( function() { |
| 98 | + var element = $( this ); |
| 99 | + |
| 100 | + // Store an instance of the controlgroup to be able to reference |
| 101 | + // from the outermost element for changing options and refresh |
| 102 | + var widgetElement = element[ widget ]( "widget" ); |
| 103 | + $.data( widgetElement[ 0 ], "ui-controlgroup-data", |
| 104 | + element[ widget ]( "instance" ) ); |
| 105 | + |
| 106 | + childWidgets.push( widgetElement[ 0 ] ); |
| 107 | + } ); |
104 | 108 | } ); |
105 | 109 |
|
106 | 110 | this.childWidgets = $( $.unique( childWidgets ) ); |
|
0 commit comments