Skip to content

Commit af5ba9b

Browse files
committed
Button: Move all dom minipulation in _create into its own method
This is to support easy implementation of mobiles enhanced option
1 parent 46d9396 commit af5ba9b

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

ui/button.js

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,20 @@ $.widget( "ui.button", {
8282
this.options.disabled = this.element.prop( "disabled" ) || false;
8383
}
8484

85+
this._enhance();
86+
87+
if ( this.element.is( "a" ) ) {
88+
this._on({
89+
"keyup": function( event ) {
90+
if ( event.keyCode === $.ui.keyCode.SPACE ) {
91+
this.element[0].click();
92+
}
93+
}
94+
});
95+
}
96+
},
97+
98+
_enhance: function() {
8599
this._setOption( "disabled", this.options.disabled );
86100

87101
this.element.addClass( baseClasses ).attr( "role", "button" );
@@ -94,20 +108,9 @@ $.widget( "ui.button", {
94108
this.element.html( this.options.label );
95109
}
96110
}
97-
98111
if ( this.options.icon ) {
99112
this._updateIcon( this.options.icon )._updateTooltip();
100113
}
101-
102-
if ( this.element.is( "a" ) ) {
103-
this._on({
104-
"keyup": function( event ) {
105-
if ( event.keyCode === $.ui.keyCode.SPACE ) {
106-
this.element[0].click();
107-
}
108-
}
109-
});
110-
}
111114
},
112115

113116
_updateTooltip: function() {

0 commit comments

Comments
 (0)