1 //>>excludeStart("jqmBuildExclude", pragmas.jqmBuildExclude);
2 //>>description: Visually groups sets of buttons, checks, radios, etc.
3 //>>label: Controlgroups
5 //>>css: ../css/themes/default/jquery.mobile.theme.css,../css/structure/jquery.mobile.controlgroup.css
7 define( [ "jquery", "./jquery.mobile.buttonMarkup" ], function( $ ) {
8 //>>excludeEnd("jqmBuildExclude");
9 (function( $, undefined ) {
11 $.fn.controlgroup = function( options ) {
12 function flipClasses( els, flCorners ) {
13 els.removeClass( "ui-btn-corner-all ui-shadow" )
14 .eq( 0 ).addClass( flCorners[ 0 ] )
16 .last().addClass( flCorners[ 1 ] ).addClass( "ui-controlgroup-last" );
19 return this.each(function() {
22 direction: $el.jqmData( "type" ) || "vertical",
24 excludeInvisible: true,
25 mini: $el.jqmData( "mini" )
27 groupheading = $el.children( "legend" ),
28 flCorners = o.direction == "horizontal" ? [ "ui-corner-left", "ui-corner-right" ] : [ "ui-corner-top", "ui-corner-bottom" ],
29 type = $el.find( "input" ).first().attr( "type" );
31 // Replace legend with more stylable replacement div
32 if ( groupheading.length ) {
33 $el.wrapInner( "<div class='ui-controlgroup-controls'></div>" );
34 $( "<div role='heading' class='ui-controlgroup-label'>" + groupheading.html() + "</div>" ).insertBefore( $el.children(0) );
35 groupheading.remove();
38 $el.addClass( "ui-corner-all ui-controlgroup ui-controlgroup-" + o.direction );
40 flipClasses( $el.find( ".ui-btn" + ( o.excludeInvisible ? ":visible" : "" ) ).not('.ui-slider-handle'), flCorners );
41 flipClasses( $el.find( ".ui-btn-inner" ), flCorners );
44 $el.addClass( "ui-shadow" );
48 $el.addClass( "ui-mini" );
54 // The pagecreate handler for controlgroup is in jquery.mobile.init because of the soft-dependency on the wrapped widgets
57 //>>excludeStart("jqmBuildExclude", pragmas.jqmBuildExclude);
59 //>>excludeEnd("jqmBuildExclude");