2 * "controlgroup" plugin - corner-rounding for groups of buttons, checks, radios, etc
5 (function( $, undefined ) {
7 $.fn.controlgroup = function( options ) {
9 return this.each(function() {
13 direction: $el.jqmData( "type" ) || "vertical",
15 excludeInvisible: true
17 groupheading = $el.children( "legend" ),
18 flCorners = o.direction == "horizontal" ? [ "ui-corner-left", "ui-corner-right" ] : [ "ui-corner-top", "ui-corner-bottom" ],
19 type = $el.find( "input" ).first().attr( "type" );
21 // Replace legend with more stylable replacement div
22 if ( groupheading.length ) {
23 $el.wrapInner( "<div class='ui-controlgroup-controls'></div>" );
24 $( "<div role='heading' class='ui-controlgroup-label'>" + groupheading.html() + "</div>" ).insertBefore( $el.children(0) );
25 groupheading.remove();
28 $el.addClass( "ui-corner-all ui-controlgroup ui-controlgroup-" + o.direction );
30 // TODO: This should be moved out to the closure
31 // otherwise it is redefined each time controlgroup() is called
32 function flipClasses( els ) {
33 els.removeClass( "ui-btn-corner-all ui-shadow" )
34 .eq( 0 ).addClass( flCorners[ 0 ] )
36 .last().addClass( flCorners[ 1 ] ).addClass( "ui-controlgroup-last" );
39 flipClasses( $el.find( ".ui-btn" + ( o.excludeInvisible ? ":visible" : "" ) ) );
40 flipClasses( $el.find( ".ui-btn-inner" ) );
43 $el.addClass( "ui-shadow" );
48 //auto self-init widgets
49 $( document ).bind( "pagecreate create", function( e ){
50 $( ":jqmData(role='controlgroup')", e.target ).controlgroup({ excludeInvisible: false });