Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Controlgroup: Prevent the controls from being wrapped multiple times.…

… Fixes #4716 - Calling controlgroup constructor causes fieldset width to shrink.
  • Loading branch information...
commit 352d4b347b9cf356d560044f7c4f3fa4747c5289 1 parent c0a016e
@jaspermdegroot jaspermdegroot authored
Showing with 14 additions and 5 deletions.
  1. +14 −5 js/jquery.mobile.controlGroup.js
View
19 js/jquery.mobile.controlGroup.js
@@ -25,16 +25,25 @@ $.fn.controlgroup = function( options ) {
excludeInvisible: true,
mini: $el.jqmData( "mini" )
}, options ),
- groupheading = $el.children( "legend" ),
+ grouplegend = $el.children( "legend" ),
+ groupheading = $el.children( ".ui-controlgroup-label" ),
+ groupcontrols = $el.children( ".ui-controlgroup-controls" ),
flCorners = o.direction === "horizontal" ? [ "ui-corner-left", "ui-corner-right" ] : [ "ui-corner-top", "ui-corner-bottom" ],
type = $el.find( "input" ).first().attr( "type" );
+ // First unwrap the controls if the controlgroup was already enhanced
+ if ( groupcontrols.length ) {
+ groupcontrols.contents().unwrap();
+ }
$el.wrapInner( "<div class='ui-controlgroup-controls'></div>" );
- // Replace legend with more stylable replacement div
- if ( groupheading.length ) {
- $( "<div role='heading' class='ui-controlgroup-label'>" + groupheading.html() + "</div>" ).insertBefore( $el.children( 0 ) );
- groupheading.remove();
+ if ( grouplegend.length ) {
+ // Replace legend with more stylable replacement div
+ $( "<div role='heading' class='ui-controlgroup-label'>" + grouplegend.html() + "</div>" ).insertBefore( $el.children( 0 ) );
+ grouplegend.remove();
+ } else if ( groupheading.length ) {
+ // Just move the heading if the controlgroup was already enhanced
+ $el.prepend( groupheading );
}
$el.addClass( "ui-corner-all ui-controlgroup ui-controlgroup-" + o.direction );
Please sign in to comment.
Something went wrong with that request. Please try again.