2010-09-10 22:23:13 +00:00
|
|
|
/*
|
2010-11-10 00:55:52 +00:00
|
|
|
* jQuery Mobile Framework : "button" plugin - links that proxy to native input/buttons
|
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-10-28 00:43:27 +00:00
|
|
|
$.widget( "mobile.button", $.mobile.widget, {
|
2010-11-11 03:54:57 +00:00
|
|
|
options: {
|
2010-11-11 04:08:22 +00:00
|
|
|
theme: null,
|
|
|
|
|
icon: null,
|
|
|
|
|
iconpos: null,
|
|
|
|
|
inline: null,
|
|
|
|
|
corners: true,
|
|
|
|
|
shadow: true,
|
|
|
|
|
iconshadow: true
|
2010-11-11 03:54:57 +00:00
|
|
|
},
|
2010-10-28 00:43:27 +00:00
|
|
|
_create: function(){
|
2010-11-02 03:53:06 +00:00
|
|
|
var $el = this.element,
|
2010-12-06 16:40:28 +00:00
|
|
|
o = this.options;
|
2010-10-28 00:43:27 +00:00
|
|
|
|
2010-10-11 01:17:49 +00:00
|
|
|
//add ARIA role
|
2010-12-06 16:40:28 +00:00
|
|
|
this.button = $( "<div></div>" )
|
2010-10-28 00:43:27 +00:00
|
|
|
.text( $el.text() || $el.val() )
|
|
|
|
|
.buttonMarkup({
|
2010-11-11 03:54:57 +00:00
|
|
|
theme: o.theme,
|
|
|
|
|
icon: o.icon,
|
|
|
|
|
iconpos: o.iconpos,
|
|
|
|
|
inline: o.inline,
|
|
|
|
|
corners: o.corners,
|
|
|
|
|
shadow: o.shadow,
|
|
|
|
|
iconshadow: o.iconshadow
|
2010-12-06 16:40:28 +00:00
|
|
|
})
|
|
|
|
|
.insertBefore( $el )
|
|
|
|
|
.append( $el.addClass('ui-btn-hidden') );
|
|
|
|
|
|
|
|
|
|
//add hidden input during submit
|
2011-03-01 22:04:48 +00:00
|
|
|
var type = $el.attr('type');
|
|
|
|
|
if( type !== 'button' && type !== 'reset' ){
|
2011-03-08 16:52:17 +00:00
|
|
|
$el.bind("vclick", function(){
|
2010-12-06 16:40:28 +00:00
|
|
|
var $buttonPlaceholder = $("<input>",
|
|
|
|
|
{type: "hidden", name: $el.attr("name"), value: $el.attr("value")})
|
|
|
|
|
.insertBefore($el);
|
|
|
|
|
|
|
|
|
|
//bind to doc to remove after submit handling
|
|
|
|
|
$(document).submit(function(){
|
|
|
|
|
$buttonPlaceholder.remove();
|
|
|
|
|
});
|
2010-10-28 00:43:27 +00:00
|
|
|
});
|
2010-12-06 16:40:28 +00:00
|
|
|
}
|
2011-03-23 22:42:54 +00:00
|
|
|
this.refresh();
|
2010-12-06 16:40:28 +00:00
|
|
|
|
2010-11-17 15:27:35 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
|
|
enable: function(){
|
|
|
|
|
this.element.attr("disabled", false);
|
|
|
|
|
this.button.removeClass("ui-disabled").attr("aria-disabled", false);
|
|
|
|
|
return this._setOption("disabled", false);
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
disable: function(){
|
|
|
|
|
this.element.attr("disabled", true);
|
|
|
|
|
this.button.addClass("ui-disabled").attr("aria-disabled", true);
|
|
|
|
|
return this._setOption("disabled", true);
|
2011-03-23 22:42:54 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
|
|
refresh: function(){
|
|
|
|
|
if( this.element.attr('disabled') ){
|
|
|
|
|
this.disable();
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
this.enable();
|
|
|
|
|
}
|
2010-10-28 00:43:27 +00:00
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
})( jQuery );
|