src/aria/widgets/controllers/SelectController.js
function (lastTypedKeys, newMatch) {
                var LABEL_META = this.LABEL_META;
                var options = this._dataModel.listContent;
                var keyNbr = lastTypedKeys.length;
                var index = this._dataModel.selectedIdx + (newMatch ? 1 : 0); // start point to search for a match
                for (var ct = 0, optionsLength = options.length; ct < optionsLength; ct++, index++) {
                    if (index >= optionsLength) {
                        index = 0;
                    }
                    var opt = options[index];
                    var prefix = opt[LABEL_META].substr(0, keyNbr);
                    if (prefix == lastTypedKeys) {
                        return index;
                    }
                }
                return -1; // not found
            }
function (lastTypedKeys, newMatch) {
                var LABEL_META = this.LABEL_META;
                var options = this._dataModel.listContent;
                var keyNbr = lastTypedKeys.length;
                var index = this._dataModel.selectedIdx + (newMatch ? 1 : 0); // start point to search for a match
                for (var ct = 0, optionsLength = options.length; ct < optionsLength; ct++, index++) {
                    if (index >= optionsLength) {
                        index = 0;
                    }
                    var opt = options[index];
                    var prefix = opt[LABEL_META].substr(0, keyNbr);
                    if (prefix == lastTypedKeys) {
                        return index;
                    }
                }
                return -1; // not found
            }
function ( lastTypedKeys , newMatch ) { var LABEL_META = this . LABEL_META ; var options = this . _dataModel . listContent ; var keyNbr = lastTypedKeys . length ; var index = this . _dataModel . selectedIdx + ( newMatch ? 1 : 0 ) ; // start point to search for a match for ( var ct = 0 , optionsLength = options . length ; ct < optionsLength ; ct ++ , index ++ ) { if ( index >= optionsLength ) { index = 0 ; } var opt = options [ index ] ; var prefix = opt [ LABEL_META ] . substr ( 0 , keyNbr ) ; if ( prefix == lastTypedKeys ) { return index ; } } return - 1 ; // not found }
Search for an item matching the last typed keys in the options and return its index. An item is matching
if the whole lastTypedKeys string is a prefix of its label.
@param {String} lastTypedKeys
@param {Boolean} newMatch
@return {Number} index of the matching item or -1 if no matching item was found
@protected
Search for an item matching the last typed keys in the options and return its index . An item is matching if the whole lastTypedKeys string is a prefix of its label .