From aa798d9ca190b1a242d33028647766af131b60cf Mon Sep 17 00:00:00 2001 From: Santhosh Thottingal Date: Fri, 10 Aug 2012 11:43:49 +0530 Subject: [PATCH] Fix Bug 38666 - When searching no specific region should be highlighted in the map Clicking again on a region deselect it When searching, remove selection from regions. Change-Id: Ife70639a864f9d13d02406d1229316782a32ed3c --- src/jquery.uls.core.js | 13 +++++++++++-- src/jquery.uls.languagefilter.js | 12 +++++++++--- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/jquery.uls.core.js b/src/jquery.uls.core.js index 74f939b..d536799 100644 --- a/src/jquery.uls.core.js +++ b/src/jquery.uls.core.js @@ -115,8 +115,14 @@ that.$languageFilter.languagefilter( { $target: lcd, languages: that.languages, - success: $.proxy( that.success, that ), - noresults: $.proxy( that.noresults, that ), + success: function() { + $( '.regionselector' ).removeClass( 'active' ); + that.success(); + }, + noresults: function() { + $( '.regionselector' ).removeClass( 'active' ); + that.noresults(); + }, searchAPI: that.options.searchAPI, onSelect: $.proxy( that.onSelect, that ) } ); @@ -129,6 +135,9 @@ // clear the search field. that.$languageFilter.val( '' ); that.success(); + }, + noresult: function() { + that.$languageFilter.languagefilter( 'clear' ); } } ); diff --git a/src/jquery.uls.languagefilter.js b/src/jquery.uls.languagefilter.js index ee28065..b703901 100644 --- a/src/jquery.uls.languagefilter.js +++ b/src/jquery.uls.languagefilter.js @@ -325,9 +325,14 @@ }, click: function( e ) { - e.stopPropagation(); - e.preventDefault(); - this.show(); + if( this.$element.hasClass( 'active' ) ) { + this.$element.removeClass( 'active' ); + if ( this.options.noresult ) { + this.options.noresult.call(); + } + } else { + this.show(); + } } }; @@ -351,6 +356,7 @@ $.fn.regionselector.defaults = { $target: null, // Where to render the results success: null, // callback if any results found. + noresult: null, // callback when no results to show languages: null };