src/aria/widgets/controllers/MultiAutoCompleteController.js
function (suggestionToBeAdded) {
                var allSuggestions = ariaUtilsJson.copy(this.selectedSuggestions, false);
                var res = [];
                var maxOptions = this.maxOptions;
                var length = suggestionToBeAdded.length;
                if (maxOptions && allSuggestions.length + length > maxOptions) {
                    length = maxOptions - allSuggestions.length;
                }
                if (length > 0) {
                    for (var k = 0; k < length; k++) {
                        if (this._editedSuggestionIndex != -1) {
                            allSuggestions.splice(this._editedSuggestionIndex, 0, suggestionToBeAdded[k]);
                            this._editedSuggestionIndex += 1;
                        } else {
                            allSuggestions.push(suggestionToBeAdded[k]);
                        }
                        res[k] = suggestionToBeAdded[k];
                    }
                    this._editedSuggestionIndex = -1;
                    this.selectedSuggestions = allSuggestions;
                }
                return res;
            }
function (suggestionToBeAdded) {
                var allSuggestions = ariaUtilsJson.copy(this.selectedSuggestions, false);
                var res = [];
                var maxOptions = this.maxOptions;
                var length = suggestionToBeAdded.length;
                if (maxOptions && allSuggestions.length + length > maxOptions) {
                    length = maxOptions - allSuggestions.length;
                }
                if (length > 0) {
                    for (var k = 0; k < length; k++) {
                        if (this._editedSuggestionIndex != -1) {
                            allSuggestions.splice(this._editedSuggestionIndex, 0, suggestionToBeAdded[k]);
                            this._editedSuggestionIndex += 1;
                        } else {
                            allSuggestions.push(suggestionToBeAdded[k]);
                        }
                        res[k] = suggestionToBeAdded[k];
                    }
                    this._editedSuggestionIndex = -1;
                    this.selectedSuggestions = allSuggestions;
                }
                return res;
            }
function ( suggestionToBeAdded ) { var allSuggestions = ariaUtilsJson . copy ( this . selectedSuggestions , false ) ; var res = [ ] ; var maxOptions = this . maxOptions ; var length = suggestionToBeAdded . length ; if ( maxOptions && allSuggestions . length + length > maxOptions ) { length = maxOptions - allSuggestions . length ; } if ( length > 0 ) { for ( var k = 0 ; k < length ; k ++ ) { if ( this . _editedSuggestionIndex != - 1 ) { allSuggestions . splice ( this . _editedSuggestionIndex , 0 , suggestionToBeAdded [ k ] ) ; this . _editedSuggestionIndex += 1 ; } else { allSuggestions . push ( suggestionToBeAdded [ k ] ) ; } res [ k ] = suggestionToBeAdded [ k ] ; } this . _editedSuggestionIndex = - 1 ; this . selectedSuggestions = allSuggestions ; } return res ; }
Pushes new suggestions to the array of selectedSuggestions and return the array of new suggestions.
@protected
@param {Object} suggestionToBeAdded
@return {Array}
Pushes new suggestions to the array of selectedSuggestions and return the array of new suggestions .