jquery-mobile/js/jquery.mobile.controlGroup.js

42 lines
1.4 KiB
JavaScript
Raw Normal View History

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
* Dual licensed under the MIT or GPL Version 2 licenses.
* http://jquery.org/license
2010-09-10 22:23:13 +00:00
*/
(function($, undefined ) {
2010-09-10 22:23:13 +00:00
$.fn.controlgroup = function(options){
2010-12-28 15:15:30 +00:00
return this.each(function(){
var o = $.extend({
direction: $( this ).jqmData( "type" ) || "vertical",
shadow: false
2010-09-10 22:23:13 +00:00
},options);
var groupheading = $(this).find('>legend'),
flCorners = o.direction == 'horizontal' ? ['ui-corner-left', 'ui-corner-right'] : ['ui-corner-top', 'ui-corner-bottom'],
type = $(this).find('input:eq(0)').attr('type');
//replace legend with more stylable replacement div
2010-10-05 22:17:27 +00:00
if( groupheading.length ){
$(this).wrapInner('<div class="ui-controlgroup-controls"></div>');
$('<div role="heading" class="ui-controlgroup-label">'+ groupheading.html() +'</div>').insertBefore( $(this).children(0) );
groupheading.remove();
}
2010-09-10 22:23:13 +00:00
$(this).addClass('ui-corner-all ui-controlgroup ui-controlgroup-'+o.direction);
2010-09-10 22:23:13 +00:00
function flipClasses(els){
els
.removeClass('ui-btn-corner-all ui-shadow')
.eq(0).addClass(flCorners[0])
.end()
.filter(':last').addClass(flCorners[1]).addClass('ui-controlgroup-last');
2010-09-10 22:23:13 +00:00
}
flipClasses($(this).find('.ui-btn'));
flipClasses($(this).find('.ui-btn-inner'));
if(o.shadow){
$(this).addClass('ui-shadow');
}
2010-09-10 22:23:13 +00:00
});
};
})(jQuery);