[DE] Make new search: add disabling of buttons, fix updating of current result number, fix styles
This commit is contained in:
parent
e7cc5fa105
commit
0cc9581c6d
|
@ -266,7 +266,12 @@ define([
|
|||
},
|
||||
|
||||
updateResultsNumber: function (current, count) {
|
||||
var text = current === 'no-results' ? this.textNoSearchResults : (!count ? this.textNoMatches : Common.Utils.String.format(this.textSearchResults, current + 1, count));
|
||||
var text;
|
||||
if (count > 300) {
|
||||
text = this.textTooManyResults;
|
||||
} else {
|
||||
text = current === 'no-results' ? this.textNoSearchResults : (!count ? this.textNoMatches : Common.Utils.String.format(this.textSearchResults, current + 1, count));
|
||||
}
|
||||
this.$reaultsNumber.text(text);
|
||||
},
|
||||
|
||||
|
@ -315,7 +320,12 @@ define([
|
|||
disableNavButtons: function (resultNumber, allResults) {
|
||||
var disable = this.inputText._input.val() === '';
|
||||
this.btnBack.setDisabled(disable || !allResults || resultNumber === 0);
|
||||
this.btnNext.setDisabled(disable || resultNumber + 1 === allResults);
|
||||
this.btnNext.setDisabled(disable || !allResults || resultNumber + 1 === allResults);
|
||||
},
|
||||
|
||||
disableReplaceButtons: function (disable) {
|
||||
this.btnReplace.setDisabled(disable);
|
||||
this.btnReplaceAll.setDisabled(disable);
|
||||
},
|
||||
|
||||
textFind: 'Find',
|
||||
|
@ -340,7 +350,8 @@ define([
|
|||
textSearchOptions: 'Search options',
|
||||
textNoMatches: 'No matches',
|
||||
textNoSearchResults: 'No search results',
|
||||
textItemEntireCell: 'Entire cell contents'
|
||||
textItemEntireCell: 'Entire cell contents',
|
||||
textTooManyResults: 'There are too many results to show here'
|
||||
|
||||
}, Common.Views.SearchPanel || {}));
|
||||
});
|
|
@ -156,6 +156,9 @@
|
|||
|
||||
#search-adv-results-number {
|
||||
padding-top: 2px;
|
||||
width: calc(100% - 48px);
|
||||
color: @text-secondary-ie;
|
||||
color: @text-secondary;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -229,6 +232,10 @@
|
|||
color: @text-normal-pressed-ie;
|
||||
color: @text-normal-pressed;
|
||||
}
|
||||
|
||||
b {
|
||||
font-style: italic;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -134,7 +134,7 @@ define([
|
|||
|
||||
onInputSearchChange: function (text) {
|
||||
var me = this;
|
||||
if (text.length > 0 && this._state.searchText !== text) {
|
||||
if (this._state.searchText !== text) {
|
||||
this._state.newSearchText = text;
|
||||
this._lastInputChange = (new Date());
|
||||
if (this.searchTimer === undefined) {
|
||||
|
@ -143,8 +143,14 @@ define([
|
|||
|
||||
me.hideResults();
|
||||
me._state.searchText = me._state.newSearchText;
|
||||
if (me.onQuerySearch() && me.view.$el.is(':visible')) {
|
||||
me.api.asc_StartTextAroundSearch();
|
||||
if (me._state.newSearchText !== '' && me.onQuerySearch()) {
|
||||
if (me.view.$el.is(':visible')) {
|
||||
me.api.asc_StartTextAroundSearch();
|
||||
}
|
||||
me.view.disableReplaceButtons(false);
|
||||
} else if (me._state.newSearchText === '') {
|
||||
me.view.updateResultsNumber('no-results');
|
||||
me.view.disableReplaceButtons(true);
|
||||
}
|
||||
clearInterval(me.searchTimer);
|
||||
me.searchTimer = undefined;
|
||||
|
@ -160,6 +166,7 @@ define([
|
|||
searchSettings.put_WholeWords(this._state.matchWord);
|
||||
if (!this.api.asc_findText(searchSettings, d != 'back')) {
|
||||
this.view.updateResultsNumber(undefined, 0);
|
||||
this.view.disableReplaceButtons(true);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -173,6 +180,7 @@ define([
|
|||
searchSettings.put_WholeWords(this._state.matchWord);
|
||||
if (!this.api.asc_replaceText(searchSettings, textReplace, false)) {
|
||||
this.view.updateResultsNumber(undefined, 0);
|
||||
this.view.disableReplaceButtons(true);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -199,7 +207,6 @@ define([
|
|||
|
||||
onStartTextAroundSearch: function () {
|
||||
if (this.view) {
|
||||
this.view.$resultsContainer.show();
|
||||
this._state.isStartedAddingResults = true;
|
||||
}
|
||||
},
|
||||
|
@ -213,6 +220,7 @@ define([
|
|||
|
||||
onApiGetTextAroundSearch: function (data) {
|
||||
if (this.view && this._state.isStartedAddingResults) {
|
||||
if (data.length > 300) return;
|
||||
var me = this;
|
||||
me.resultItems = [];
|
||||
data.forEach(function (item) {
|
||||
|
@ -228,6 +236,8 @@ define([
|
|||
$(el.currentTarget).addClass('selected');
|
||||
}, me));
|
||||
});
|
||||
|
||||
this.view.$resultsContainer.show();
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -262,9 +272,12 @@ define([
|
|||
this.view.setFindText('');
|
||||
}
|
||||
|
||||
if (text !== '' && text === this._state.searchText) {
|
||||
if (text !== '' && text === this._state.searchText) { // search was made
|
||||
this.view.disableReplaceButtons(false);
|
||||
this.hideResults();
|
||||
this.api.asc_StartTextAroundSearch();
|
||||
} else {
|
||||
this.view.disableReplaceButtons(true);
|
||||
}
|
||||
|
||||
this.view.disableNavButtons();
|
||||
|
|
Loading…
Reference in a new issue