2010-09-10 22:23:13 +00:00
|
|
|
/*
|
2010-11-10 00:55:52 +00:00
|
|
|
* jQuery Mobile Framework: "controlgroup" plugin - corner-rounding for groups of buttons, checks, radios, etc
|
2010-09-10 22:23:13 +00:00
|
|
|
* Copyright (c) jQuery Project
|
2010-11-20 03:47:47 +00:00
|
|
|
* Dual licensed under the MIT or GPL Version 2 licenses.
|
|
|
|
|
* http://jquery.org/license
|
2010-09-10 22:23:13 +00:00
|
|
|
*/
|
2010-11-11 15:49:15 +00:00
|
|
|
(function($, undefined ) {
|
2011-06-28 23:01:27 +00:00
|
|
|
|
|
|
|
|
$.fn.controlgroup = function( options ) {
|
|
|
|
|
|
|
|
|
|
return this.each(function() {
|
|
|
|
|
var $el = $( this ),
|
|
|
|
|
o = $.extend({
|
|
|
|
|
direction: $el.jqmData( "type" ) || "vertical",
|
|
|
|
|
shadow: false
|
|
|
|
|
}, options ),
|
|
|
|
|
groupheading = $el.find( ">legend" ),
|
|
|
|
|
flCorners = o.direction == "horizontal" ? [ "ui-corner-left", "ui-corner-right" ] : [ "ui-corner-top", "ui-corner-bottom" ],
|
|
|
|
|
type = $el.find( "input:eq(0)" ).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();
|
2010-10-05 21:33:56 +00:00
|
|
|
}
|
2010-09-10 22:23:13 +00:00
|
|
|
|
2011-06-28 23:01:27 +00:00
|
|
|
$el.addClass( "ui-corner-all ui-controlgroup ui-controlgroup-" + o.direction );
|
|
|
|
|
|
|
|
|
|
// TODO: This should be moved out to the closure
|
|
|
|
|
// otherwise it is redefined each time controlgroup() is called
|
|
|
|
|
function flipClasses( els ) {
|
|
|
|
|
els.removeClass( "ui-btn-corner-all ui-shadow" )
|
|
|
|
|
.eq( 0 ).addClass( flCorners[ 0 ] )
|
2010-10-18 16:44:44 +00:00
|
|
|
.end()
|
2011-06-28 23:01:27 +00:00
|
|
|
.filter( ":last" ).addClass( flCorners[ 1 ] ).addClass( "ui-controlgroup-last" );
|
2010-09-10 22:23:13 +00:00
|
|
|
}
|
2011-06-28 23:01:27 +00:00
|
|
|
|
|
|
|
|
flipClasses( $el.find( ".ui-btn" + ( o.dontFilterOutInvisible ? "" : ":visible" ) ) );
|
|
|
|
|
flipClasses( $el.find( ".ui-btn-inner" ) );
|
|
|
|
|
|
|
|
|
|
if ( o.shadow ) {
|
|
|
|
|
$el.addClass( "ui-shadow" );
|
2010-09-15 20:43:56 +00:00
|
|
|
}
|
2011-06-28 23:01:27 +00:00
|
|
|
});
|
2010-09-10 22:23:13 +00:00
|
|
|
};
|
|
|
|
|
})(jQuery);
|