Skip to content

Commit

Permalink
text input: modified text input widget to include clear button on inp…
Browse files Browse the repository at this point in the history
…ut type text. Feature request jquery-archive#1834 - clear input button for text inputs
  • Loading branch information
Collin F committed Nov 13, 2012
1 parent 8c8c3f9 commit eeb69a0
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions js/widgets/forms/textinput.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,29 @@ $.widget( "mobile.textinput", $.mobile.widget, {

input.bind( 'paste cut keyup focus change blur', toggleClear );

} else if ( input.not( ":jqmData(clear-btn='false')" ).is( "[type='text'],:jqmData(clear-btn='true')" ) ) {
focusedEl = input.wrap( "<div class='ui-input-text ui-shadow-inset ui-btn-corner-all ui-btn-shadow" + themeclass + miniclass + "'></div>" ).parent();
clearbtn = $( "<a href='#' class='ui-input-clear' title='" + o.clearSearchButtonText + "'>" + o.clearSearchButtonText + "</a>" )
.bind('click', function( event ) {
input
.val( "" )
.focus()
.trigger( "change" );
clearbtn.addClass( "ui-input-clear-hidden" );
event.preventDefault();
})
.appendTo( focusedEl )
.buttonMarkup({
icon: "delete",
iconpos: "notext",
corners: true,
shadow: true,
mini: o.mini
});

toggleClear();

input.bind( 'paste cut keyup focus change blur', toggleClear );
} else {
input.addClass( "ui-corner-all ui-shadow-inset" + themeclass + miniclass );
}
Expand Down

0 comments on commit eeb69a0

Please sign in to comment.