summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLea Verou <lea@verou.me>2016-01-29 20:49:32 +0200
committerLea Verou <lea@verou.me>2016-01-29 20:49:32 +0200
commit0248c50f059becf8f2af5fa7ef2147678c94451a (patch)
tree234e68a0dc1a901d322bff53f7aad3af776a192b
parentbeff6382cce9676272ef5418851683b8b07c95d7 (diff)
parent20375edc39bd0ef3852ccf224b68b1dd18b0789b (diff)
downloadawesomplete-0248c50f059becf8f2af5fa7ef2147678c94451a.zip
awesomplete-0248c50f059becf8f2af5fa7ef2147678c94451a.tar.gz
awesomplete-0248c50f059becf8f2af5fa7ef2147678c94451a.tar.bz2
Merge pull request #16830 from vlazar/feature/add-item-and-replace-static-properties
Expose item & replace as static properties.
-rw-r--r--awesomplete.js24
1 files changed, 14 insertions, 10 deletions
diff --git a/awesomplete.js b/awesomplete.js
index 06391ef..d7857e7 100644
--- a/awesomplete.js
+++ b/awesomplete.js
@@ -24,16 +24,8 @@ var _ = function (input, o) {
autoFirst: false,
filter: _.FILTER_CONTAINS,
sort: _.SORT_BYLENGTH,
- item: function (text, input) {
- var html = input === '' ? text : text.replace(RegExp($.regExpEscape(input.trim()), "gi"), "<mark>$&</mark>");
- return $.create("li", {
- innerHTML: html,
- "aria-selected": "false"
- });
- },
- replace: function (text) {
- this.input.value = text;
- }
+ item: _.ITEM,
+ replace: _.REPLACE
}, o);
this.index = -1;
@@ -260,6 +252,18 @@ _.SORT_BYLENGTH = function (a, b) {
return a < b? -1 : 1;
};
+_.ITEM = function (text, input) {
+ var html = input === '' ? text : text.replace(RegExp($.regExpEscape(input.trim()), "gi"), "<mark>$&</mark>");
+ return $.create("li", {
+ innerHTML: html,
+ "aria-selected": "false"
+ });
+};
+
+_.REPLACE = function (text) {
+ this.input.value = text;
+};
+
// Private functions
function configure(instance, properties, o) {