diff --git a/apps/common/main/lib/view/SearchBar.js b/apps/common/main/lib/view/SearchBar.js index e14ee235ba..55b91e3036 100644 --- a/apps/common/main/lib/view/SearchBar.js +++ b/apps/common/main/lib/view/SearchBar.js @@ -165,7 +165,7 @@ define([ onLayoutChanged: function () { var top = $('#app-title').height() + $('#toolbar').height() + 2, - left = Common.Utils.innerWidth() - $('#right-menu').width() - this.options.width - 32; + left = Common.Utils.innerWidth() - ($('#right-menu').is(':visible') ? $('#right-menu').width() : 0) - this.options.width - 32; this.$window.css({left: left, top: top}); }, diff --git a/apps/documenteditor/main/app/controller/Search.js b/apps/documenteditor/main/app/controller/Search.js index 37ec57ebfb..73c936b06a 100644 --- a/apps/documenteditor/main/app/controller/Search.js +++ b/apps/documenteditor/main/app/controller/Search.js @@ -208,12 +208,7 @@ define([ searchSettings.put_MatchCase(this._state.matchCase); searchSettings.put_WholeWords(this._state.matchWord); if (!this.api.asc_replaceText(searchSettings, textReplace, false)) { - this.resultItems = []; - this.view.updateResultsNumber(undefined, 0); - this.view.disableReplaceButtons(true); - this._state.currentResult = 0; - this._state.resultsNumber = 0; - this.view.disableNavButtons(); + this.allResultsWasRemoved(); } } }, @@ -240,11 +235,20 @@ define([ searchSettings.put_WholeWords(this._state.matchWord); this.api.asc_replaceText(searchSettings, textReplace, true); - this.hideResults(); - this.resultItems = []; + this.allResultsWasRemoved(); } }, + allResultsWasRemoved: function () { + this.resultItems = []; + this.hideResults(); + this.view.updateResultsNumber(undefined, 0); + this.view.disableReplaceButtons(true); + this._state.currentResult = 0; + this._state.resultsNumber = 0; + this.view.disableNavButtons(); + }, + onUpdateSearchCurrent: function (current, all) { if (current === -1) return; this._state.currentResult = current; @@ -252,7 +256,7 @@ define([ if (this.view) { this.view.updateResultsNumber(current, all); this.view.disableNavButtons(current, all); - if (this.resultItems.length > 0) { + if (this.resultItems && this.resultItems.length > 0) { this.resultItems.forEach(function (item) { item.selected = false; }); diff --git a/apps/presentationeditor/main/app/controller/Search.js b/apps/presentationeditor/main/app/controller/Search.js index 82efb20efc..6f06a098d5 100644 --- a/apps/presentationeditor/main/app/controller/Search.js +++ b/apps/presentationeditor/main/app/controller/Search.js @@ -191,12 +191,7 @@ define([ searchSettings.put_MatchCase(this._state.matchCase); searchSettings.put_WholeWords(this._state.matchWord); if (!this.api.asc_replaceText(searchSettings, textReplace, false)) { - this.resultItems = []; - this.view.updateResultsNumber(undefined, 0); - this.view.disableReplaceButtons(true); - this._state.currentResult = 0; - this._state.resultsNumber = 0; - this.view.disableNavButtons(); + this.allResultsWasRemoved(); } } }, @@ -209,11 +204,20 @@ define([ searchSettings.put_WholeWords(this._state.matchWord); this.api.asc_replaceText(searchSettings, textReplace, true); - this.hideResults(); - this.resultItems = []; + this.allResultsWasRemoved(); } }, + allResultsWasRemoved: function () { + this.resultItems = []; + this.hideResults(); + this.view.updateResultsNumber(undefined, 0); + this.view.disableReplaceButtons(true); + this._state.currentResult = 0; + this._state.resultsNumber = 0; + this.view.disableNavButtons(); + }, + onUpdateSearchCurrent: function (current, all) { if (current === -1) return; this._state.currentResult = current; @@ -221,7 +225,7 @@ define([ if (this.view) { this.view.updateResultsNumber(current, all); this.view.disableNavButtons(current, all); - if (this.resultItems.length > 0) { + if (this.resultItems && this.resultItems.length > 0) { this.resultItems.forEach(function (item) { item.selected = false; }); diff --git a/apps/spreadsheeteditor/main/app/controller/Search.js b/apps/spreadsheeteditor/main/app/controller/Search.js index c444fab347..869993ac7c 100644 --- a/apps/spreadsheeteditor/main/app/controller/Search.js +++ b/apps/spreadsheeteditor/main/app/controller/Search.js @@ -311,12 +311,7 @@ define([ var me = this; if (this.api.isReplaceAll) { if (!found) { - this.resultItems = []; - this.view.updateResultsNumber(undefined, 0); - this.view.disableReplaceButtons(true); - this._state.currentResult = 0; - this._state.resultsNumber = 0; - this.view.disableNavButtons(); + this.allResultsWasRemoved(); } else { Common.UI.info({ msg: !found-replaced ? Common.Utils.String.format(this.textReplaceSuccess,replaced) : Common.Utils.String.format(this.textReplaceSkipped,found-replaced), @@ -338,16 +333,21 @@ define([ options.asc_setScanByRows(this._state.searchByRows); options.asc_setLookIn(this._state.lookInFormulas ? Asc.c_oAscFindLookIn.Formulas : Asc.c_oAscFindLookIn.Value); if (!this.api.asc_findText(options)) { - this.resultItems = []; - this.view.updateResultsNumber(undefined, 0); - this.view.disableReplaceButtons(true); - this._state.currentResult = 0; - this._state.resultsNumber = 0; - this.view.disableNavButtons(); + this.allResultsWasRemoved(); } } }, + allResultsWasRemoved: function () { + this.resultItems = []; + this.hideResults(); + this.view.updateResultsNumber(undefined, 0); + this.view.disableReplaceButtons(true); + this._state.currentResult = 0; + this._state.resultsNumber = 0; + this.view.disableNavButtons(); + }, + onApiRemoveTextAroundSearch: function (arr) { var me = this; arr.forEach(function (id) { @@ -366,7 +366,7 @@ define([ if (this.view) { this.view.updateResultsNumber(current, all); this.view.disableNavButtons(current, all); - if (this.resultItems.length > 0) { + if (this.resultItems && this.resultItems.length > 0) { this.resultItems.forEach(function (item) { item.selected = false; });