Skip to content

Commit

Permalink
update autocompleter a bit (nothing fancy)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gargaj committed May 25, 2016
1 parent d8c2835 commit d7fd123
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions autocompleter.js
Expand Up @@ -7,6 +7,7 @@ Autocompleter = Class.create({
dropdown: false,
lockSelect: true,
width: null,
placeholder: "",
},options || {});
var instance = this;

Expand All @@ -24,7 +25,7 @@ Autocompleter = Class.create({
parent.insert(this.finalSelection);
}

this.searchBox = new Element("input",{"class":"autocompleteSearch","style":"position:relative"});
this.searchBox = new Element("input",{"class":"autocompleteSearch","style":"position:relative","placeholder":this.options.placeholder});
parent.insert( this.searchBox );

if (this.options.dropdown)
Expand All @@ -41,9 +42,7 @@ Autocompleter = Class.create({
if (this.finalSelection)
{
this.finalSelection.observe("click",function(){
instance.originalElement.value = "";
instance.finalSelection.hide();
instance.searchBox.show();
instance.reset(false);
});
}
this.keyboardSelection = -1;
Expand Down Expand Up @@ -148,6 +147,15 @@ Autocompleter = Class.create({
}
}
},
reset:function(complete)
{
if (complete)
this.searchBox.value = "";
this.originalElement.value = "";
if (this.finalSelection)
this.finalSelection.hide();
this.searchBox.show();
},
selectListItem: function(li)
{
this.autoCompleteList.hide();
Expand Down

0 comments on commit d7fd123

Please sign in to comment.