Skip to content

Commit

Permalink
Controlgroup: Convert to onevar, fix guard-clause/else, rm tmp var
Browse files Browse the repository at this point in the history
  • Loading branch information
jzaefferer authored and arschmitz committed Oct 8, 2015
1 parent b61a3c7 commit 6ed30a6
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions ui/widgets/controlgroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,15 @@ return $.widget( "ui.controlgroup", {

// First we iterate over each of the items options
$.each( this.options.items, function( widget, selector ) {
var widgets, labels,
options = {};
var labels;
var options = {};

// Make sure the widget actually exists and has a selector set
if ( !$.fn[ widget ] || !selector ) {
return;
} else if ( selector && widget === "controlgroupLabel" ) {
}

if ( widget === "controlgroupLabel" ) {
labels = that.element.find( selector );
labels.each( function() {
$( this ).contents().wrapAll( "<span class='ui-controlgroup-label-contents'></span>" );
Expand All @@ -92,19 +94,19 @@ return $.widget( "ui.controlgroup", {
}

// Find instances of this widget inside controlgroup and init them
widgets = that.element.find( selector )[ widget ]( options );

widgets.each( function() {
var element = $( this );

// Store an instance of the controlgroup to be able to reference
// from the outermost element for changing options and refresh
var widgetElement = element[ widget ]( "widget" );
$.data( widgetElement[ 0 ], "ui-controlgroup-data",
element[ widget ]( "instance" ) );

childWidgets.push( widgetElement[ 0 ] );
} );
that.element
.find( selector )[ widget ]( options )
.each( function() {
var element = $( this );

// Store an instance of the controlgroup to be able to reference
// from the outermost element for changing options and refresh
var widgetElement = element[ widget ]( "widget" );
$.data( widgetElement[ 0 ], "ui-controlgroup-data",
element[ widget ]( "instance" ) );

childWidgets.push( widgetElement[ 0 ] );
} );
} );

this.childWidgets = $( $.unique( childWidgets ) );
Expand Down

0 comments on commit 6ed30a6

Please sign in to comment.