Fix Bug 38665 - Show clean 'x' icon on the search box only when useful
Change-Id: I3fc295728f25cce7a326101467146f8ee3415116
This commit is contained in:
@@ -32,6 +32,7 @@
|
||||
this.$element.addClass( 'languagefilter' );
|
||||
this.resultCount = 0;
|
||||
this.$suggestion = $( '#' + this.$element.data( 'suggestion' ) );
|
||||
this.$clear = $( '#'+ this.$element.data( 'clear' ) );
|
||||
this.listen();
|
||||
};
|
||||
|
||||
@@ -51,6 +52,10 @@
|
||||
if ( $.browser.webkit || $.browser.msie ) {
|
||||
this.$element.on( 'keydown', $.proxy( this.keyup, this ) );
|
||||
}
|
||||
if ( this.$clear.length ) {
|
||||
this.$clear.on( 'click' , $.proxy( this.clear, this ) );
|
||||
}
|
||||
this.toggleClear();
|
||||
},
|
||||
|
||||
keyup: function( e ) {
|
||||
@@ -70,6 +75,23 @@
|
||||
that.options.$target.empty();
|
||||
that.search();
|
||||
}, 500 );
|
||||
this.toggleClear();
|
||||
}
|
||||
},
|
||||
|
||||
clear: function() {
|
||||
this.$element.val( '' );
|
||||
this.$element.focus();
|
||||
this.toggleClear();
|
||||
this.search();
|
||||
},
|
||||
|
||||
toggleClear: function() {
|
||||
if ( !this.$clear.length ) return;
|
||||
if ( this.$element.val() ) {
|
||||
this.$clear.show();
|
||||
} else {
|
||||
this.$clear.hide();
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user