Skip to content

Commit

Permalink
Add a customizable Classname parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
capripot committed Sep 10, 2018
1 parent 8706952 commit df56d16
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 15 deletions.
18 changes: 12 additions & 6 deletions dist/autocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/*
* @license MIT
*
* Autocomplete.js v2.7.1
* Autocomplete.js v2.7.2
* Developed by Baptiste Donaux
* http://autocomplete-js.com
*
Expand Down Expand Up @@ -182,6 +182,7 @@ var AutoComplete = /** @class */ (function () {
return merge;
};
AutoComplete.defaults = {
Classname: "autocomplete",
Delay: 150,
EmptyMessage: "No result here",
Highlight: {
Expand Down Expand Up @@ -210,9 +211,10 @@ var AutoComplete = /** @class */ (function () {
if (this.DOMResults.getAttribute("class").indexOf("open") != -1) {
var liActive = this.DOMResults.querySelector("li.active");
if (liActive !== null) {
var params = this;
event.preventDefault();
this._Select(liActive);
this.DOMResults.setAttribute("class", "autocomplete");
this.DOMResults.setAttribute("class", params.Classname);
}
}
},
Expand Down Expand Up @@ -277,10 +279,11 @@ var AutoComplete = /** @class */ (function () {
Not: true
}],
Callback: function () {
var params = this;
var oldValue = this.Input.getAttribute("data-autocomplete-old-value"), currentValue = this._Pre();
if (currentValue !== "" && currentValue.length >= this._MinChars()) {
if (!oldValue || currentValue != oldValue) {
this.DOMResults.setAttribute("class", "autocomplete open");
this.DOMResults.setAttribute("class", params.Classname + " open");
}
AutoComplete.prototype.cache(this, function (response) {
this._Render(this._Post(response));
Expand Down Expand Up @@ -392,9 +395,10 @@ var AutoComplete = /** @class */ (function () {
* Manage the open
*/
_Focus: function () {
var params = this;
var oldValue = this.Input.getAttribute("data-autocomplete-old-value");
if ((!oldValue || this.Input.value != oldValue) && this._MinChars() <= this.Input.value.length) {
this.DOMResults.setAttribute("class", "autocomplete open");
this.DOMResults.setAttribute("class", params.Classname + " open");
}
},
/**
Expand All @@ -411,13 +415,15 @@ var AutoComplete = /** @class */ (function () {
});
},
_Close: function () {
this.DOMResults.setAttribute("class", "autocomplete");
var params = this;
this.DOMResults.setAttribute("class", params.Classname);
},
/**
* Position the results HTML element
*/
_Position: function () {
this.DOMResults.setAttribute("class", "autocomplete");
var params = this;
this.DOMResults.setAttribute("class", params.Classname);
this.DOMResults.setAttribute("style", "top:" + (this.Input.offsetTop + this.Input.offsetHeight) + "px;left:" + this.Input.offsetLeft + "px;width:" + this.Input.clientWidth + "px;");
},
/**
Expand Down
Loading

0 comments on commit df56d16

Please sign in to comment.