Permalink
Browse files

Button: Update _create method to add enhanced option

  • Loading branch information...
arschmitz committed Jul 3, 2013
1 parent 8ff2c9b commit d455be8d27db22bcf1ccef237af3caa17f4366a5
Showing with 19 additions and 31 deletions.
  1. +19 −31 js/widgets/forms/button.js
View
@@ -22,51 +22,39 @@ $.widget( "mobile.button", {
},
_create: function() {
var $button,
$el = this.element,
isInput = $el[ 0 ].tagName === "INPUT",
classes = "ui-btn";
var isInput = $el[ 0 ].tagName === "INPUT";
if ( isInput ) {
classes += " ui-input-btn";
$.extend( this, {
isInput: isInput,
button: null
});
// TODO: data-class and data-id options. See https://github.com/jquery/jquery-mobile/issues/3577
if ( !!~$el[ 0 ].className.indexOf( "ui-btn-left" ) ) {
classes += " ui-btn-left";
}
if ( !!~$el[ 0 ].className.indexOf( "ui-btn-right" ) ) {
classes += " ui-btn-right";
}
this.refresh( true );
this._setOptions( this.options );
},
this.button = $( "<div></div>" )
[ "text" ]( $el.val() )
.insertBefore( $el )
.addClass( classes )
.append( $el );
_enhance: function() {
if ( isInput ) {
$button = this.button;
this.element.wrap( this._button () );
this.button = this.element.parent();
this._on( $el, {
this._on( {
focus: function() {
$button.addClass( $.mobile.focusClass );
this.widget().addClass( $.mobile.focusClass );
},
blur: function() {
$button.removeClass( $.mobile.focusClass );
this.widget().removeClass( $.mobile.focusClass );
}
});
} else {
this.button = $el.addClass( classes );
this.widget().addClass( classes );
}
},
$.extend( this, {
isInput: isInput,
buttonClasses: classes,
styleClasses: ""
});
this.refresh( true );
this._setOptions( this.options );
_button: function() {
return $("<div class='ui-btn ui-input-btn" + this.options.class + "' id='" + this.options.id + "'>" + this.element.val() + "<div>");
},
widget: function() {

0 comments on commit d455be8

Please sign in to comment.