@@ -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