diff --git a/apps/documenteditor/main/app/controller/Search.js b/apps/documenteditor/main/app/controller/Search.js index 93cc06350..4d2527082 100644 --- a/apps/documenteditor/main/app/controller/Search.js +++ b/apps/documenteditor/main/app/controller/Search.js @@ -444,6 +444,10 @@ define([ } }, + getSearchText: function () { + return this._state.searchText; + }, + notcriticalErrorTitle: 'Warning', warnReplaceString: '{0} is not a valid special character for the Replace With box.', textReplaceSuccess: 'Search has been done. {0} occurrences have been replaced', diff --git a/apps/documenteditor/main/app/controller/Viewport.js b/apps/documenteditor/main/app/controller/Viewport.js index eb3209d5d..713133cde 100644 --- a/apps/documenteditor/main/app/controller/Viewport.js +++ b/apps/documenteditor/main/app/controller/Viewport.js @@ -293,7 +293,8 @@ define([ }, this)); } if (this.header.btnSearch.pressed) { - this.searchBar.show(this.api.asc_GetSelectedText()); + var selectedText = this.api.asc_GetSelectedText(); + this.searchBar.show(selectedText && selectedText.trim() || this.getApplication().getController('Search').getSearchText()); } else { this.searchBar.hide(); } diff --git a/apps/presentationeditor/main/app/controller/Search.js b/apps/presentationeditor/main/app/controller/Search.js index 663902bf7..0dbf56eea 100644 --- a/apps/presentationeditor/main/app/controller/Search.js +++ b/apps/presentationeditor/main/app/controller/Search.js @@ -397,6 +397,10 @@ define([ } }, + getSearchText: function () { + return this._state.searchText; + }, + notcriticalErrorTitle: 'Warning', warnReplaceString: '{0} is not a valid special character for the Replace With box.', textReplaceSuccess: 'Search has been done. {0} occurrences have been replaced', diff --git a/apps/presentationeditor/main/app/controller/Viewport.js b/apps/presentationeditor/main/app/controller/Viewport.js index 0b080326c..50500ed56 100644 --- a/apps/presentationeditor/main/app/controller/Viewport.js +++ b/apps/presentationeditor/main/app/controller/Viewport.js @@ -355,7 +355,8 @@ define([ }, this)); } if (this.header.btnSearch.pressed) { - this.searchBar.show(this.api.asc_GetSelectedText()); + var selectedText = this.api.asc_GetSelectedText(); + this.searchBar.show(selectedText && selectedText.trim() || this.getApplication().getController('Search').getSearchText()); } else { this.searchBar.hide(); } diff --git a/apps/spreadsheeteditor/main/app/controller/Search.js b/apps/spreadsheeteditor/main/app/controller/Search.js index 2324dd13b..1eb8e841e 100644 --- a/apps/spreadsheeteditor/main/app/controller/Search.js +++ b/apps/spreadsheeteditor/main/app/controller/Search.js @@ -57,7 +57,13 @@ define([ 'SearchBar': { 'search:back': _.bind(this.onSearchNext, this, 'back'), 'search:next': _.bind(this.onSearchNext, this, 'next'), - 'search:input': _.bind(this.onInputSearchChange, this), + 'search:input': _.bind(function (text) { + if (this._state.searchText === text) { + Common.NotificationCenter.trigger('search:updateresults', this._state.currentResult, this._state.resultsNumber); + return; + } + this.onInputSearchChange(text); + }, this), 'search:keydown': _.bind(this.onSearchNext, this, 'keydown'), 'show': _.bind(this.onSelectSearchingResults, this, true), 'hide': _.bind(this.onSelectSearchingResults, this, false) @@ -559,6 +565,10 @@ define([ } }, + getSearchText: function () { + return this._state.searchText; + }, + textNoTextFound: 'The data you have been searching for could not be found. Please adjust your search options.', textReplaceSuccess: 'Search has been done. {0} occurrences have been replaced', textReplaceSkipped: 'The replacement has been made. {0} occurrences were skipped.', diff --git a/apps/spreadsheeteditor/main/app/controller/Viewport.js b/apps/spreadsheeteditor/main/app/controller/Viewport.js index 1bf0adc1f..90b38270e 100644 --- a/apps/spreadsheeteditor/main/app/controller/Viewport.js +++ b/apps/spreadsheeteditor/main/app/controller/Viewport.js @@ -321,7 +321,8 @@ define([ }, this)); } if (this.header.btnSearch.pressed) { - this.searchBar.show(this.api.asc_GetSelectedText()); + var selectedText = this.api.asc_GetSelectedText(); + this.searchBar.show(selectedText && selectedText.trim() || this.getApplication().getController('Search').getSearchText()); } else { this.searchBar.hide(); }