jquery-mobile/js/jquery.mobile.forms.button.js
2010-11-10 22:54:57 -05:00

55 lines
No EOL
1.2 KiB
JavaScript

/*
* jQuery Mobile Framework : "button" plugin - links that proxy to native input/buttons
* Copyright (c) jQuery Project
* Dual licensed under the MIT (MIT-LICENSE.txt) and GPL (GPL-LICENSE.txt) licenses.
* Note: Code is in draft form and is subject to change
*/
(function ( $ ) {
$.widget( "mobile.button", $.mobile.widget, {
options: {
theme: undefined,
icon: undefined,
iconpos: undefined,
inline: undefined,
corners: undefined,
shadow: undefined,
iconshadow: undefined
},
_create: function(){
var $el = this.element,
o = this.options,
type = $el.attr('type');
$el
.addClass('ui-btn-hidden')
.attr('tabindex','-1');
//add ARIA role
$( "<a>", {
"href": "#",
"role": "button",
"aria-label": $el.attr( "type" )
} )
.text( $el.text() || $el.val() )
.insertBefore( $el )
.click(function(){
if( type == "submit" ){
$(this).closest('form').submit();
}
else{
$el.click();
}
return false;
})
.buttonMarkup({
theme: o.theme,
icon: o.icon,
iconpos: o.iconpos,
inline: o.inline,
corners: o.corners,
shadow: o.shadow,
iconshadow: o.iconshadow
});
}
});
})( jQuery );