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 ) {
|
2010-09-10 22:23:13 +00:00
|
|
|
$.fn.controlgroup = function(options){
|
2010-10-11 23:15:02 +00:00
|
|
|
|
2010-12-28 15:15:30 +00:00
|
|
|
return this.each(function(){
|
2010-10-11 23:15:02 +00:00
|
|
|
var o = $.extend({
|
2011-03-25 21:50:40 +00:00
|
|
|
direction: $( this ).jqmData( "type" ) || "vertical",
|
2010-09-15 20:43:56 +00:00
|
|
|
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 ){
|
2010-10-05 22:34:41 +00:00
|
|
|
$(this).wrapInner('<div class="ui-controlgroup-controls"></div>');
|
2010-10-05 21:33:56 +00:00
|
|
|
$('<div role="heading" class="ui-controlgroup-label">'+ groupheading.html() +'</div>').insertBefore( $(this).children(0) );
|
|
|
|
|
groupheading.remove();
|
|
|
|
|
}
|
2010-09-10 22:23:13 +00:00
|
|
|
|
2010-09-15 20:43:56 +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')
|
2010-10-18 16:44:44 +00:00
|
|
|
.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'));
|
2010-09-15 20:43:56 +00:00
|
|
|
if(o.shadow){
|
|
|
|
|
$(this).addClass('ui-shadow');
|
|
|
|
|
}
|
2010-09-10 22:23:13 +00:00
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
})(jQuery);
|