converted customButton plugin to widget factory (note: this is just the plugin for native button elements, not to be confused with the buttonMarkup plugin).

renamed method to "button" and updated page.js to match
This commit is contained in:
scottjehl 2010-10-27 20:43:27 -04:00
parent 77b1c3a758
commit e202a72776
2 changed files with 30 additions and 17 deletions

View file

@ -4,23 +4,36 @@
* 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($){
$.fn.customButton = function(){
return $(this).each(function(){
var button = $(this).addClass('ui-btn-hidden').attr('tabindex','-1');
(function ( $ ) {
$.widget( "mobile.button", $.mobile.widget, {
options: {},
_create: function(){
var $el = this.element;
$el
.addClass('ui-btn-hidden')
.attr('tabindex','-1');
//add ARIA role
$('<a href="#" role="button">'+ (button.text() || button.val()) +'</a>')
.buttonMarkup({
theme: button.data('theme'),
icon: button.data('icon'),
iconpos: button.data('iconpos'),
inline: button.data('inline')
})
$( "<a>", {
"href": "#",
"role": "button",
"aria-label": $el.attr( "type" )
} )
.text( $el.text() || $el.val() )
.insertBefore( $el )
.click(function(){
button.click();
$el.click();
return false;
})
.insertBefore(button);
});
};
})(jQuery);
.buttonMarkup({
theme: $el.data("theme"),
icon: $el.data("icon"),
iconpos: $el.data("iconpos"),
inline: $el.data("inline"),
corners: $el.data("corners"),
shadow: $el.data("shadow"),
iconshadow: $el.data("icon-shadow")
});
}
});
})( jQuery );

View file

@ -132,7 +132,7 @@ jQuery.widget( "mobile.page", jQuery.mobile.widget, {
this.element
.find( "button, [type='button'], [type='submit'], [type='reset'], [type='image']" )
.not( ".ui-nojs" )
.customButton();
.button();
this.element
.find( "input, textarea" )