[DE PE] Make new search: add nav buttons disabling

This commit is contained in:
JuliaSvinareva 2022-03-14 21:22:14 +03:00
parent 4c4e478007
commit c56c0b47be
8 changed files with 27 additions and 2 deletions

View file

@ -80,6 +80,9 @@ define([
Common.UI.Window.prototype.render.call(this);
this.inputSearch = this.$window.find('#search-bar-text');
this.inputSearch.on('input', _.bind(function () {
this.disableNavButtons();
}, this));
this.btnBack = new Common.UI.Button({
parentEl: $('#search-bar-back'),
@ -113,6 +116,8 @@ define([
this.on('animate:before', _.bind(this.focus, this));
Common.NotificationCenter.on('search:updateresults', _.bind(this.disableNavButtons, this));
return this;
},
@ -127,6 +132,7 @@ define([
this.inputSearch.val('');
}
this.disableNavButtons();
this.focus();
},
@ -167,6 +173,12 @@ define([
this.fireEvent('search:show', [true, this.inputSearch.val()]);
},
disableNavButtons: function (resultNumber, allResults) {
var disable = this.inputSearch.val() === '';
this.btnBack.setDisabled(disable || !allResults || resultNumber === 0);
this.btnNext.setDisabled(disable);
},
textFind: 'Find'
}, Common.UI.SearchBar || {}));

View file

@ -72,6 +72,7 @@ define([
validateOnBlur: false,
style: 'width: 100%;'
});
this.inputText._input.on('input', _.bind(this.disableNavButtons, this));
this.inputReplace = new Common.UI.InputField({
el: $('#search-adv-replace-text'),
@ -161,6 +162,7 @@ define([
me.$resultsContainer.scroller.update({alwaysVisibleY: true});
});
Common.NotificationCenter.on('search:updateresults', _.bind(this.disableNavButtons, this));
if (window.SSE) {
this.cmbWithin = new Common.UI.ComboBox({
el: $('#search-adv-cmb-within'),
@ -223,6 +225,7 @@ define([
this.$resultsContainer.outerHeight($('#search-box').outerHeight() - $('#search-header').outerHeight() - $('#search-adv-settings').outerHeight());
this.$resultsContainer.scroller.update({alwaysVisibleY: true});
this.disableNavButtons();
this.fireEvent('show', this );
},
@ -302,6 +305,12 @@ define([
this.updateResultsNumber('no-results');
},
disableNavButtons: function (resultNumber, allResults) {
var disable = this.inputText._input.val() === '';
this.btnBack.setDisabled(disable || !allResults || resultNumber === 0);
this.btnNext.setDisabled(disable);
},
textFind: 'Find',
textFindAndReplace: 'Find and replace',
textCloseSearch: 'Close search',

View file

@ -968,6 +968,7 @@ define([
} else if (text !== undefined) {
this.leftMenu.panelSearch.setFindText('');
}
this.leftMenu.panelSearch.disableNavButtons();
this.leftMenu.panelSearch.focus();
},

View file

@ -152,6 +152,7 @@ define([
if (this.view) {
this.view.updateResultsNumber(current, all);
}
Common.NotificationCenter.trigger('search:updateresults', current, all);
},
onStartTextAroundSearch: function () {

View file

@ -271,7 +271,6 @@ define([
if (this.panelSearch) {
if (this.btnSearchBar.pressed) {
this.panelSearch.show();
this.fireEvent('search:aftershow', this);
} else {
this.panelSearch.hide();
}
@ -418,6 +417,7 @@ define([
this.btnSearchBar.toggle(true);
this.onBtnMenuClick(this.btnSearchBar);
this.onCoauthOptions();
this.fireEvent('search:aftershow', this);
}
}
/** coauthoring end **/

View file

@ -823,6 +823,7 @@ define([
} else if (text !== undefined) {
this.leftMenu.panelSearch.setFindText('');
}
this.leftMenu.panelSearch.disableNavButtons();
this.leftMenu.panelSearch.focus();
},

View file

@ -139,6 +139,7 @@ define([
if (this.view) {
this.view.updateResultsNumber(current, all);
}
Common.NotificationCenter.trigger('search:updateresults', current, all);
},
textNoTextFound: 'The data you have been searching for could not be found. Please adjust your search options.',

View file

@ -255,7 +255,6 @@ define([
if (this.panelSearch) {
if (this.btnSearchBar.pressed) {
this.panelSearch.show();
this.fireEvent('search:aftershow', this);
} else {
this.panelSearch.hide();
}
@ -375,6 +374,7 @@ define([
this.btnSearchBar.toggle(true);
this.onBtnMenuClick(this.btnSearchBar);
this.onCoauthOptions();
this.fireEvent('search:aftershow', this);
}
}
/** coauthoring end **/