Merge pull request #2023 from ONLYOFFICE/feature/search-in-menu
Feature/search in menu
This commit is contained in:
commit
3ab4211953
|
@ -407,8 +407,9 @@ define([
|
||||||
},
|
},
|
||||||
|
|
||||||
selectCandidate: function() {
|
selectCandidate: function() {
|
||||||
var index = this._search.index || 0,
|
var index = (this._search.index && this._search.index != -1) ? this._search.index : 0,
|
||||||
re = new RegExp('^' + ((this._search.full) ? this._search.text : this._search.char), 'i'),
|
re = new RegExp('^' + ((this._search.full) ? this._search.text : this._search.char), 'i'),
|
||||||
|
isFirstCharsEqual = re.test(this.store.at(index).get(this.displayField)),
|
||||||
itemCandidate, idxCandidate;
|
itemCandidate, idxCandidate;
|
||||||
|
|
||||||
for (var i=0; i<this.store.length; i++) {
|
for (var i=0; i<this.store.length; i++) {
|
||||||
|
@ -417,6 +418,8 @@ define([
|
||||||
if (!itemCandidate) {
|
if (!itemCandidate) {
|
||||||
itemCandidate = item;
|
itemCandidate = item;
|
||||||
idxCandidate = i;
|
idxCandidate = i;
|
||||||
|
if(!isFirstCharsEqual)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if (this._search.full && i==index || i>index) {
|
if (this._search.full && i==index || i>index) {
|
||||||
itemCandidate = item;
|
itemCandidate = item;
|
||||||
|
|
|
@ -472,8 +472,9 @@ define([
|
||||||
},
|
},
|
||||||
|
|
||||||
selectCandidate: function() {
|
selectCandidate: function() {
|
||||||
var index = this._search.index || 0,
|
var index = (this._search.index && this._search.index != -1) ? this._search.index : 0,
|
||||||
re = new RegExp('^' + ((this._search.full) ? this._search.text : this._search.char), 'i'),
|
re = new RegExp('^' + ((this._search.full) ? this._search.text : this._search.char), 'i'),
|
||||||
|
isFirstCharsEqual = re.test(this.items[index].caption),
|
||||||
itemCandidate, idxCandidate;
|
itemCandidate, idxCandidate;
|
||||||
|
|
||||||
for (var i=0; i<this.items.length; i++) {
|
for (var i=0; i<this.items.length; i++) {
|
||||||
|
@ -482,6 +483,8 @@ define([
|
||||||
if (!itemCandidate) {
|
if (!itemCandidate) {
|
||||||
itemCandidate = item;
|
itemCandidate = item;
|
||||||
idxCandidate = i;
|
idxCandidate = i;
|
||||||
|
if(!isFirstCharsEqual)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if (this._search.full && i==index || i>index) {
|
if (this._search.full && i==index || i>index) {
|
||||||
itemCandidate = item;
|
itemCandidate = item;
|
||||||
|
@ -1051,8 +1054,9 @@ define([
|
||||||
},
|
},
|
||||||
|
|
||||||
selectCandidate: function() {
|
selectCandidate: function() {
|
||||||
var index = this._search.index || 0,
|
var index = (this._search.index && this._search.index != -1) ? this._search.index : 0,
|
||||||
re = new RegExp('^' + ((this._search.full) ? this._search.text : this._search.char), 'i'),
|
re = new RegExp('^' + ((this._search.full) ? this._search.text : this._search.char), 'i'),
|
||||||
|
isFirstCharsEqual = re.test(this.items[index].caption),
|
||||||
itemCandidate, idxCandidate;
|
itemCandidate, idxCandidate;
|
||||||
|
|
||||||
for (var i=0; i<this.items.length; i++) {
|
for (var i=0; i<this.items.length; i++) {
|
||||||
|
@ -1061,6 +1065,8 @@ define([
|
||||||
if (!itemCandidate) {
|
if (!itemCandidate) {
|
||||||
itemCandidate = item;
|
itemCandidate = item;
|
||||||
idxCandidate = i;
|
idxCandidate = i;
|
||||||
|
if(!isFirstCharsEqual)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if (this._search.full && i==index || i>index) {
|
if (this._search.full && i==index || i>index) {
|
||||||
itemCandidate = item;
|
itemCandidate = item;
|
||||||
|
|
Loading…
Reference in a new issue