Export 0.1.45
[framework/web/web-ui-fw.git] / libs / js / jquery-mobile-1.1.0 / js / jquery.mobile.controlGroup.js
1 //>>excludeStart("jqmBuildExclude", pragmas.jqmBuildExclude);
2 //>>description: Visually groups sets of buttons, checks, radios, etc. 
3 //>>label: Controlgroups
4 //>>group: Forms
5 //>>css: ../css/themes/default/jquery.mobile.theme.css,../css/structure/jquery.mobile.controlgroup.css
6
7 define( [ "jquery", "./jquery.mobile.buttonMarkup" ], function( $ ) {
8 //>>excludeEnd("jqmBuildExclude");
9 (function( $, undefined ) {
10
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 ] )
15                         .end()
16                         .last().addClass( flCorners[ 1 ] ).addClass( "ui-controlgroup-last" );
17         }
18
19         return this.each(function() {
20                 var $el = $( this ),
21                         o = $.extend({
22                                                 direction: $el.jqmData( "type" ) || "vertical",
23                                                 shadow: false,
24                                                 excludeInvisible: true,
25                                                 mini: $el.jqmData( "mini" )
26                                         }, options ),
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" );
30
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();
36                 }
37
38                 $el.addClass( "ui-corner-all ui-controlgroup ui-controlgroup-" + o.direction );
39
40                 flipClasses( $el.find( ".ui-btn" + ( o.excludeInvisible ? ":visible" : "" ) ).not('.ui-slider-handle'), flCorners );
41                 flipClasses( $el.find( ".ui-btn-inner" ), flCorners );
42
43                 if ( o.shadow ) {
44                         $el.addClass( "ui-shadow" );
45                 }
46
47                 if ( o.mini ) {
48                         $el.addClass( "ui-mini" );
49                 }
50
51         });
52 };
53
54 // The pagecreate handler for controlgroup is in jquery.mobile.init because of the soft-dependency on the wrapped widgets
55
56 })(jQuery);
57 //>>excludeStart("jqmBuildExclude", pragmas.jqmBuildExclude);
58 });
59 //>>excludeEnd("jqmBuildExclude");