mirror of
https://github.com/Hopiu/jquery-mobile.git
synced 2026-03-17 06:20:26 +00:00
Merge pull request #1960 from rwldrn/jquery.mobile.forms.button.js
jQuery core style guide conformance: jquery.mobile.forms.button.js
This commit is contained in:
commit
2a232a06e0
1 changed files with 41 additions and 33 deletions
|
|
@ -3,11 +3,13 @@
|
|||
* Copyright (c) jQuery Project
|
||||
* Dual licensed under the MIT or GPL Version 2 licenses.
|
||||
* http://jquery.org/license
|
||||
*/
|
||||
(function($, undefined ) {
|
||||
*/
|
||||
|
||||
(function( $, undefined ) {
|
||||
|
||||
$.widget( "mobile.button", $.mobile.widget, {
|
||||
options: {
|
||||
theme: null,
|
||||
theme: null,
|
||||
icon: null,
|
||||
iconpos: null,
|
||||
inline: null,
|
||||
|
|
@ -15,15 +17,16 @@ $.widget( "mobile.button", $.mobile.widget, {
|
|||
shadow: true,
|
||||
iconshadow: true
|
||||
},
|
||||
_create: function(){
|
||||
_create: function() {
|
||||
var $el = this.element,
|
||||
o = this.options;
|
||||
|
||||
//add ARIA role
|
||||
o = this.options,
|
||||
type;
|
||||
|
||||
// Add ARIA role
|
||||
this.button = $( "<div></div>" )
|
||||
.text( $el.text() || $el.val() )
|
||||
.buttonMarkup({
|
||||
theme: o.theme,
|
||||
theme: o.theme,
|
||||
icon: o.icon,
|
||||
iconpos: o.iconpos,
|
||||
inline: o.inline,
|
||||
|
|
@ -32,43 +35,48 @@ $.widget( "mobile.button", $.mobile.widget, {
|
|||
iconshadow: o.iconshadow
|
||||
})
|
||||
.insertBefore( $el )
|
||||
.append( $el.addClass('ui-btn-hidden') );
|
||||
|
||||
//add hidden input during submit
|
||||
var type = $el.attr('type');
|
||||
if( type !== 'button' && type !== 'reset' ){
|
||||
$el.bind("vclick", function(){
|
||||
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(){
|
||||
.append( $el.addClass( "ui-btn-hidden" ) );
|
||||
|
||||
// Add hidden input during submit
|
||||
type = $el.attr( "type" );
|
||||
|
||||
if ( type !== "button" && type !== "reset" ) {
|
||||
|
||||
$el.bind( "vclick", function() {
|
||||
|
||||
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();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
this.refresh();
|
||||
|
||||
},
|
||||
|
||||
enable: function(){
|
||||
this.element.attr("disabled", false);
|
||||
this.button.removeClass("ui-disabled").attr("aria-disabled", false);
|
||||
return this._setOption("disabled", false);
|
||||
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);
|
||||
disable: function() {
|
||||
this.element.attr( "disabled", true );
|
||||
this.button.addClass( "ui-disabled" ).attr( "aria-disabled", true );
|
||||
return this._setOption( "disabled", true );
|
||||
},
|
||||
|
||||
refresh: function(){
|
||||
if( this.element.attr('disabled') ){
|
||||
refresh: function() {
|
||||
if ( this.element.attr( "disabled" ) ) {
|
||||
this.disable();
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
this.enable();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue