Skip to content
This repository was archived by the owner on Oct 8, 2021. It is now read-only.

Commit 489262c

Browse files
Textinput: clear button not optional for Search.
1 parent 93651b4 commit 489262c

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

js/widgets/forms/textinput.js

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ $.widget( "mobile.textinput", $.mobile.widget, {
3030
theme = o.theme || $.mobile.getInheritedTheme( this.element, "c" ),
3131
themeclass = " ui-body-" + theme,
3232
miniclass = o.mini ? " ui-mini" : "",
33+
isSearch = input.is( "[type='search'], :jqmData(type='search')" ),
3334
focusedEl,
3435
clearbtn,
3536
clearBtnText = o.clearSearchButtonText || o.clearBtnText;
@@ -58,20 +59,14 @@ $.widget( "mobile.textinput", $.mobile.widget, {
5859
input[0].setAttribute( "autocomplete", "off" );
5960
}
6061

61-
var searchNeedsIcon = input.is( "[type='search'], :jqmData(type='search')" ),
62-
searchNeedsClearBtn = searchNeedsIcon && !input.is( ":jqmData(clear-btn='false')" ),
63-
searchNeedsIconNoBtn = searchNeedsIcon && !searchNeedsClearBtn,
64-
textNeedsClearBtn = input.is( "[type='text'], textarea" ) && !!o.clearBtn,
65-
needsClearBtn = textNeedsClearBtn || ( searchNeedsIcon && searchNeedsClearBtn );
66-
6762
//"search" and "text" input widgets
68-
if ( searchNeedsIcon ) {
63+
if ( isSearch ) {
6964
focusedEl = input.wrap( "<div class='ui-input-search ui-shadow-inset ui-btn-corner-all ui-btn-shadow ui-icon-searchfield" + themeclass + miniclass + "'></div>" ).parent();
70-
} else if ( textNeedsClearBtn ) {
65+
} else if ( !!o.clearBtn && !isSearch ) {
7166
focusedEl = input.wrap( "<div class='ui-input-text ui-shadow-inset ui-corner-all ui-btn-shadow" + themeclass + miniclass + "'></div>" ).parent();
7267
}
7368

74-
if( needsClearBtn ) {
69+
if( !!o.clearBtn || isSearch ) {
7570
clearbtn = $( "<a href='#' class='ui-input-clear' title='" + clearBtnText + "'>" + clearBtnText + "</a>" )
7671
.bind( "click", function( event ) {
7772
input
@@ -94,7 +89,7 @@ $.widget( "mobile.textinput", $.mobile.widget, {
9489

9590
input.bind( "paste cut keyup focus change blur", toggleClear );
9691
}
97-
else if( !searchNeedsIconNoBtn ) { //special case
92+
else if( !o.clearBtn && !isSearch ) {
9893
input.addClass( "ui-corner-all ui-shadow-inset" + themeclass + miniclass );
9994
}
10095

0 commit comments

Comments
 (0)