[DE PE SSE] Fix search

This commit is contained in:
JuliaSvinareva 2022-04-29 16:07:59 +03:00
parent aa91f6263c
commit f1744a3737
4 changed files with 40 additions and 32 deletions

View file

@ -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});
},

View file

@ -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;
});

View file

@ -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;
});

View file

@ -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;
});