diff --git a/apps/common/main/lib/view/SearchPanel.js b/apps/common/main/lib/view/SearchPanel.js index 37df3895c..262c04914 100644 --- a/apps/common/main/lib/view/SearchPanel.js +++ b/apps/common/main/lib/view/SearchPanel.js @@ -81,6 +81,7 @@ define([ }); this.$reaultsNumber = $('#search-adv-results-number'); + this.updateResultsNumber('no-results'); this.btnBack = new Common.UI.Button({ parentEl: $('#search-adv-back'), @@ -231,7 +232,8 @@ define([ }, updateResultsNumber: function (current, count) { - this.$reaultsNumber.text(Common.Utils.String.format(current, count)); + var text = current === 'no-results' ? this.textNoSearchResults : (!count ? this.textNoMatches : Common.Utils.String.format(this.textSearchResults, current + 1, count)); + this.$reaultsNumber.text(text); }, onClickClosePanel: function() { @@ -276,6 +278,10 @@ define([ this.inputText.setValue(val); }, + clearResults: function () { + this.updateResultsNumber('no-results'); + }, + textFind: 'Find', textFindAndReplace: 'Find and replace', textCloseSearch: 'Close search', @@ -295,7 +301,9 @@ define([ textByColumns: 'By columns', textFormulas: 'Formulas', textValues: 'Values', - textSearchOptions: 'Search options' + textSearchOptions: 'Search options', + textNoMatches: 'No matches', + textNoSearchResults: 'No search results' }, Common.Views.SearchPanel || {})); }); \ No newline at end of file diff --git a/apps/documenteditor/main/app/controller/Search.js b/apps/documenteditor/main/app/controller/Search.js index c09206667..a4c1f9922 100644 --- a/apps/documenteditor/main/app/controller/Search.js +++ b/apps/documenteditor/main/app/controller/Search.js @@ -77,6 +77,7 @@ define([ setApi: function (api) { if (api) { this.api = api; + this.api.asc_registerCallback('asc_onSetSearchCurrent', _.bind(this.onUpdateSearchCurrent, this)); } return this; }, @@ -90,6 +91,7 @@ define([ if (opts.textsearch && opts.textsearch.length) { if (!this.api.asc_findText(opts.textsearch, d != 'back', opts.matchcase)) { var me = this; + me.view.updateResultsNumber(undefined, 0); Common.UI.info({ msg: this.textNoTextFound, callback: function() { @@ -104,6 +106,7 @@ define([ if (!_.isEmpty(opts.textsearch)) { if (!this.api.asc_replaceText(opts.textsearch, opts.textreplace, false, opts.matchcase)) { var me = this; + me.view.updateResultsNumber(undefined, 0); Common.UI.info({ msg: this.textNoTextFound, callback: function() { @@ -120,6 +123,12 @@ define([ } }, + onUpdateSearchCurrent: function (current, all) { + if (this.view) { + this.view.updateResultsNumber(current, all); + } + }, + textNoTextFound: 'The data you have been searching for could not be found. Please adjust your search options.', }, DE.Controllers.Search || {})); diff --git a/apps/documenteditor/main/app/controller/Viewport.js b/apps/documenteditor/main/app/controller/Viewport.js index 588e27871..9ae5ac5d0 100644 --- a/apps/documenteditor/main/app/controller/Viewport.js +++ b/apps/documenteditor/main/app/controller/Viewport.js @@ -482,6 +482,7 @@ define([ } if (this.header.btnSearch.pressed) { this.searchBar.show(this.api.asc_GetSelectedText()); + leftMenu.getView('LeftMenu').panelSearch.clearResults(); } else { this.searchBar.hide(); } diff --git a/apps/presentationeditor/main/app/controller/Search.js b/apps/presentationeditor/main/app/controller/Search.js index 48af40a15..34fa0f473 100644 --- a/apps/presentationeditor/main/app/controller/Search.js +++ b/apps/presentationeditor/main/app/controller/Search.js @@ -77,6 +77,7 @@ define([ setApi: function (api) { if (api) { this.api = api; + this.api.asc_registerCallback('asc_onSetSearchCurrent', _.bind(this.onUpdateSearchCurrent, this)); } return this; }, @@ -90,6 +91,7 @@ define([ if (opts.textsearch && opts.textsearch.length) { if (!this.api.asc_findText(opts.textsearch, d != 'back', opts.matchcase)) { var me = this; + me.view.updateResultsNumber(undefined, 0); Common.UI.info({ msg: this.textNoTextFound, callback: function() { @@ -104,6 +106,7 @@ define([ if (!_.isEmpty(opts.textsearch)) { if (!this.api.asc_replaceText(opts.textsearch, opts.textreplace, false, opts.matchcase)) { var me = this; + me.view.updateResultsNumber(undefined, 0); Common.UI.info({ msg: this.textNoTextFound, callback: function() { @@ -120,6 +123,12 @@ define([ } }, + onUpdateSearchCurrent: function (current, all) { + if (this.view) { + this.view.updateResultsNumber(current, all); + } + }, + textNoTextFound: 'The data you have been searching for could not be found. Please adjust your search options.', }, PE.Controllers.Search || {})); diff --git a/apps/presentationeditor/main/app/controller/Viewport.js b/apps/presentationeditor/main/app/controller/Viewport.js index 12ae69ce9..7e8f3fed2 100644 --- a/apps/presentationeditor/main/app/controller/Viewport.js +++ b/apps/presentationeditor/main/app/controller/Viewport.js @@ -534,6 +534,7 @@ define([ } if (this.header.btnSearch.pressed) { this.searchBar.show(this.api.asc_GetSelectedText()); + leftMenu.getView('LeftMenu').panelSearch.clearResults(); } else { this.searchBar.hide(); }