diff options
author | Vladislav Zarakovsky <vlad.zar@gmail.com> | 2016-02-05 11:17:10 +0300 |
---|---|---|
committer | Vladislav Zarakovsky <vlad.zar@gmail.com> | 2016-02-05 11:17:10 +0300 |
commit | 626baf50ca4854ca856e207b287d1b1509be970f (patch) | |
tree | 86272aa7fbff5a0722138f152cc8561abd668c75 | |
parent | 71d52f767ca9d5114332bcb1faff56696f0c31d2 (diff) | |
download | awesomplete-626baf50ca4854ca856e207b287d1b1509be970f.zip awesomplete-626baf50ca4854ca856e207b287d1b1509be970f.tar.gz awesomplete-626baf50ca4854ca856e207b287d1b1509be970f.tar.bz2 |
Expose this.suggestions and $.siblingIndex as public API
-rw-r--r-- | awesomplete.js | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/awesomplete.js b/awesomplete.js index 4024391..950a5ac 100644 --- a/awesomplete.js +++ b/awesomplete.js @@ -189,7 +189,7 @@ _.prototype = { if (selected) { var allowed = $.fire(this.input, "awesomplete-select", { text: selected.textContent, - data: this._suggestions[elementSiblingIndex(selected)], + data: this.suggestions[$.siblingIndex(selected)], origin: origin || selected }); @@ -210,14 +210,14 @@ _.prototype = { // Populate list with options that match this.ul.innerHTML = ""; - this._suggestions = this._list + this.suggestions = this._list .filter(function(item) { return me.filter(item, value); }) .sort(this.sort) .slice(0, this.maxItems); - this._suggestions.forEach(function(text) { + this.suggestions.forEach(function(text) { me.ul.appendChild(me.item(text, value)); }); @@ -291,12 +291,6 @@ function configure(instance, properties, o) { } } -function elementSiblingIndex(el) { - /* eslint-disable no-cond-assign */ - for (var i = 0; el = el.previousElementSibling; i++); - return i; -} - // Helpers var slice = Array.prototype.slice; @@ -360,7 +354,13 @@ $.fire = function(target, type, properties) { $.regExpEscape = function (s) { return s.replace(/[-\\^$*+?.()|[\]{}]/g, "\\$&"); -} +}; + +$.siblingIndex = function (el) { + /* eslint-disable no-cond-assign */ + for (var i = 0; el = el.previousElementSibling; i++); + return i; +}; // Initialization |