diff --git a/apps/common/main/lib/view/SearchBar.js b/apps/common/main/lib/view/SearchBar.js index abe7d33a6..9cdc8b195 100644 --- a/apps/common/main/lib/view/SearchBar.js +++ b/apps/common/main/lib/view/SearchBar.js @@ -131,6 +131,7 @@ define([ if (text) { this.inputSearch.val(text); + this.fireEvent('search:input', [text]); } else { this.inputSearch.val(''); } @@ -149,6 +150,7 @@ define([ setText: function (text) { this.inputSearch.val(text); + this.fireEvent('search:input', [text]); }, getSettings: function() { diff --git a/apps/documenteditor/main/app/controller/LeftMenu.js b/apps/documenteditor/main/app/controller/LeftMenu.js index e0420c0fc..2276dedc2 100644 --- a/apps/documenteditor/main/app/controller/LeftMenu.js +++ b/apps/documenteditor/main/app/controller/LeftMenu.js @@ -806,12 +806,13 @@ define([ this.leftMenu.fireEvent('search:aftershow', this.leftMenu, selectedText); return false; } else if (this.getApplication().getController('Viewport').isSearchBarVisible()) { + var viewport = this.getApplication().getController('Viewport'); if (s === 'replace') { - this.getApplication().getController('Viewport').header.btnSearch.toggle(false); - this.onShowHideSearch(true, this.getApplication().getController('Viewport').searchBar.inputSearch.val()); + viewport.header.btnSearch.toggle(false); + this.onShowHideSearch(true, viewport.searchBar.inputSearch.val()); } else { - selectedText && this.getApplication().getController('Viewport').searchBar.setText(selectedText); - this.getApplication().getController('Viewport').searchBar.focus(); + selectedText && viewport.searchBar.setText(selectedText); + viewport.searchBar.focus(); return false; } } else if (s === 'search') { diff --git a/apps/documenteditor/main/app/controller/Search.js b/apps/documenteditor/main/app/controller/Search.js index c8b85e2fe..e215d0289 100644 --- a/apps/documenteditor/main/app/controller/Search.js +++ b/apps/documenteditor/main/app/controller/Search.js @@ -58,7 +58,9 @@ define([ 'search:back': _.bind(this.onSearchNext, this, 'back'), 'search:next': _.bind(this.onSearchNext, this, 'next'), 'search:input': _.bind(this.onInputSearchChange, this), - 'search:keydown': _.bind(this.onSearchNext, this, 'keydown') + 'search:keydown': _.bind(this.onSearchNext, this, 'keydown'), + 'show': _.bind(this.onSelectSearchingResults, this, true), + 'hide': _.bind(this.onSelectSearchingResults, this, false) }, 'Common.Views.SearchPanel': { 'search:back': _.bind(this.onSearchNext, this, 'back'), @@ -81,7 +83,8 @@ define([ searchText: '', matchCase: false, matchWord: false, - useRegExp: false + useRegExp: false, + isHighlightedResults: false }; }, @@ -329,6 +332,7 @@ define([ }, onShowPanel: function () { + this.onSelectSearchingResults(true); if (this.resultItems && this.resultItems.length > 0 && !this._state.isStartedAddingResults) { var me = this; this.view.$resultsContainer.show(); @@ -345,6 +349,16 @@ define([ onHidePanel: function () { this.hideResults(); + this.onSelectSearchingResults(false); + }, + + onSelectSearchingResults: function (val) { + if (!val && this.getApplication().getController('LeftMenu').isSearchPanelVisible()) return; + + if (this._state.isHighlightedResults !== val) { + this.api.asc_selectSearchingResults(val); + this._state.isHighlightedResults = val; + } }, notcriticalErrorTitle: 'Warning',