forked from jquery-archive/jquery-mobile
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjquery.mobile.controlGroup.js
More file actions
59 lines (48 loc) · 2.01 KB
/
jquery.mobile.controlGroup.js
File metadata and controls
59 lines (48 loc) · 2.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
//>>excludeStart("jqmBuildExclude", pragmas.jqmBuildExclude);
//>>description: Visually groups sets of buttons, checks, radios, etc.
//>>label: Controlgroups
//>>group: Forms
//>>css: ../css/themes/default/jquery.mobile.theme.css,../css/structure/jquery.mobile.controlgroup.css
define( [ "jquery", "./jquery.mobile.buttonMarkup" ], function( $ ) {
//>>excludeEnd("jqmBuildExclude");
(function( $, undefined ) {
$.fn.controlgroup = function( options ) {
function flipClasses( els, flCorners ) {
els.removeClass( "ui-btn-corner-all ui-shadow" )
.eq( 0 ).addClass( flCorners[ 0 ] )
.end()
.last().addClass( flCorners[ 1 ] ).addClass( "ui-controlgroup-last" );
}
return this.each(function() {
var $el = $( this ),
o = $.extend({
direction: $el.jqmData( "type" ) || "vertical",
shadow: false,
excludeInvisible: true,
mini: $el.jqmData( "mini" )
}, options ),
groupheading = $el.children( "legend" ),
flCorners = o.direction == "horizontal" ? [ "ui-corner-left", "ui-corner-right" ] : [ "ui-corner-top", "ui-corner-bottom" ],
type = $el.find( "input" ).first().attr( "type" );
// Replace legend with more stylable replacement div
if ( groupheading.length ) {
$el.wrapInner( "<div class='ui-controlgroup-controls'></div>" );
$( "<div role='heading' class='ui-controlgroup-label'>" + groupheading.html() + "</div>" ).insertBefore( $el.children(0) );
groupheading.remove();
}
$el.addClass( "ui-corner-all ui-controlgroup ui-controlgroup-" + o.direction );
flipClasses( $el.find( ".ui-btn" + ( o.excludeInvisible ? ":visible" : "" ) ).not('.ui-slider-handle'), flCorners );
flipClasses( $el.find( ".ui-btn-inner" ), flCorners );
if ( o.shadow ) {
$el.addClass( "ui-shadow" );
}
if ( o.mini ) {
$el.addClass( "ui-mini" );
}
});
};
// The pagecreate handler for controlgroup is in jquery.mobile.init because of the soft-dependency on the wrapped widgets
})(jQuery);
//>>excludeStart("jqmBuildExclude", pragmas.jqmBuildExclude);
});
//>>excludeEnd("jqmBuildExclude");