[DE] Fix highlighting of search results

This commit is contained in:
JuliaSvinareva 2022-03-29 20:49:35 +03:00
parent c10d349a19
commit 1ed6a7b830
3 changed files with 23 additions and 6 deletions

View file

@ -131,6 +131,7 @@ define([
if (text) { if (text) {
this.inputSearch.val(text); this.inputSearch.val(text);
this.fireEvent('search:input', [text]);
} else { } else {
this.inputSearch.val(''); this.inputSearch.val('');
} }
@ -149,6 +150,7 @@ define([
setText: function (text) { setText: function (text) {
this.inputSearch.val(text); this.inputSearch.val(text);
this.fireEvent('search:input', [text]);
}, },
getSettings: function() { getSettings: function() {

View file

@ -806,12 +806,13 @@ define([
this.leftMenu.fireEvent('search:aftershow', this.leftMenu, selectedText); this.leftMenu.fireEvent('search:aftershow', this.leftMenu, selectedText);
return false; return false;
} else if (this.getApplication().getController('Viewport').isSearchBarVisible()) { } else if (this.getApplication().getController('Viewport').isSearchBarVisible()) {
var viewport = this.getApplication().getController('Viewport');
if (s === 'replace') { if (s === 'replace') {
this.getApplication().getController('Viewport').header.btnSearch.toggle(false); viewport.header.btnSearch.toggle(false);
this.onShowHideSearch(true, this.getApplication().getController('Viewport').searchBar.inputSearch.val()); this.onShowHideSearch(true, viewport.searchBar.inputSearch.val());
} else { } else {
selectedText && this.getApplication().getController('Viewport').searchBar.setText(selectedText); selectedText && viewport.searchBar.setText(selectedText);
this.getApplication().getController('Viewport').searchBar.focus(); viewport.searchBar.focus();
return false; return false;
} }
} else if (s === 'search') { } else if (s === 'search') {

View file

@ -58,7 +58,9 @@ define([
'search:back': _.bind(this.onSearchNext, this, 'back'), 'search:back': _.bind(this.onSearchNext, this, 'back'),
'search:next': _.bind(this.onSearchNext, this, 'next'), 'search:next': _.bind(this.onSearchNext, this, 'next'),
'search:input': _.bind(this.onInputSearchChange, this), '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': { 'Common.Views.SearchPanel': {
'search:back': _.bind(this.onSearchNext, this, 'back'), 'search:back': _.bind(this.onSearchNext, this, 'back'),
@ -81,7 +83,8 @@ define([
searchText: '', searchText: '',
matchCase: false, matchCase: false,
matchWord: false, matchWord: false,
useRegExp: false useRegExp: false,
isHighlightedResults: false
}; };
}, },
@ -329,6 +332,7 @@ define([
}, },
onShowPanel: function () { onShowPanel: function () {
this.onSelectSearchingResults(true);
if (this.resultItems && this.resultItems.length > 0 && !this._state.isStartedAddingResults) { if (this.resultItems && this.resultItems.length > 0 && !this._state.isStartedAddingResults) {
var me = this; var me = this;
this.view.$resultsContainer.show(); this.view.$resultsContainer.show();
@ -345,6 +349,16 @@ define([
onHidePanel: function () { onHidePanel: function () {
this.hideResults(); 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', notcriticalErrorTitle: 'Warning',