diff options
author | Lisa Junger <ljunger@thoughtworks.com> | 2015-03-25 11:49:49 +0100 |
---|---|---|
committer | Lisa Junger <ljunger@thoughtworks.com> | 2015-03-25 11:49:49 +0100 |
commit | 1d03082ca064744116ac625766aeac4b41ff82f7 (patch) | |
tree | deaa931da75e14111cc510ba06c9e3dd38701a89 | |
parent | 4cdfcbe713b804442de651da9df9b560ede0fc5e (diff) |
Resets highlighting on search_trigger.
-Issue #291.
-rw-r--r-- | web-ui/app/js/page/events.js | 3 | ||||
-rw-r--r-- | web-ui/app/js/search/results_highlighter.js | 1 | ||||
-rw-r--r-- | web-ui/app/js/search/search_trigger.js | 1 | ||||
-rw-r--r-- | web-ui/test/spec/search/results_highlighter.spec.js | 11 |
4 files changed, 15 insertions, 1 deletions
diff --git a/web-ui/app/js/page/events.js b/web-ui/app/js/page/events.js index f7e626f8..f1f426f7 100644 --- a/web-ui/app/js/page/events.js +++ b/web-ui/app/js/page/events.js @@ -95,7 +95,8 @@ define(function () { perform: 'search:perform', results: 'search:results', empty: 'search:empty', - highlightResults: 'search:highlightResults' + highlightResults: 'search:highlightResults', + resetHighlight: 'search:resetHighlight' }, mail: { here: 'mail:here', diff --git a/web-ui/app/js/search/results_highlighter.js b/web-ui/app/js/search/results_highlighter.js index 9109bca4..2c7d1cc7 100644 --- a/web-ui/app/js/search/results_highlighter.js +++ b/web-ui/app/js/search/results_highlighter.js @@ -60,6 +60,7 @@ define( this.after('initialize', function () { this.on(document, events.search.perform, this.getKeywordsSearch); this.on(document, events.ui.tag.select, this.clearHighlights); + this.on(document, events.search.resetHighlight, this.clearHighlights); this.on(document, events.search.highlightResults, this.highlightResults); }); diff --git a/web-ui/app/js/search/search_trigger.js b/web-ui/app/js/search/search_trigger.js index b43cef0f..4b9cb1dc 100644 --- a/web-ui/app/js/search/search_trigger.js +++ b/web-ui/app/js/search/search_trigger.js @@ -39,6 +39,7 @@ define( }; this.search = function(ev, data) { + this.trigger(document, events.search.resetHighlight); ev.preventDefault(); var input = this.select('input'); var value = input.val(); diff --git a/web-ui/test/spec/search/results_highlighter.spec.js b/web-ui/test/spec/search/results_highlighter.spec.js index 117f4cfd..dde92ffc 100644 --- a/web-ui/test/spec/search/results_highlighter.spec.js +++ b/web-ui/test/spec/search/results_highlighter.spec.js @@ -12,4 +12,15 @@ describeComponent('search/results_highlighter', function () { expect(highlightedWords).toEqual(1); }); + it('resets highlights when a new search is performed', function() { + this.setupComponent('<div id="text">Any one seeing too many open bugs</div>'); + + this.component.attr = {keywords: ["any"]}; + this.component.highlightResults(event, {where: '#text'}); + $(document).trigger(Pixelated.events.search.resetHighlight); + + var highlightedWords = this.component.$node.find('.search-highlight').length; + + expect(highlightedWords).toEqual(0); + }); }); |