diff options
author | Noah Loomans <noahloomans@gmail.com> | 2016-12-14 11:07:04 +0100 |
---|---|---|
committer | Noah Loomans <noahloomans@gmail.com> | 2016-12-14 11:07:04 +0100 |
commit | 670976458b5375d27dc525f66b8faa3dc78e799b (patch) | |
tree | a90864d2d549efc6a5bce1b4cab99ffb60676f6d /public/javascripts/search.js | |
parent | cc60c30509e5b084f2b0c01ba22a6e43a446887f (diff) |
extend EventEmitter instaid of property
Diffstat (limited to 'public/javascripts/search.js')
-rw-r--r-- | public/javascripts/search.js | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/public/javascripts/search.js b/public/javascripts/search.js index 0ee3a11..c1e6158 100644 --- a/public/javascripts/search.js +++ b/public/javascripts/search.js @@ -4,9 +4,7 @@ const EventEmitter = require('events') const fuzzy = require('fuzzy') const autocomplete = require('./autocomplete') -const self = {} - -self.events = new EventEmitter() +const self = new EventEmitter() self._nodes = { search: document.querySelector('#search'), @@ -22,7 +20,7 @@ self.submit = function () { autocomplete.removeAllItems() document.body.classList.add('searched') - self.events.emit('search', selectedItem) + self.emit('search', selectedItem) } self._handleSubmit = function (event) { @@ -50,7 +48,7 @@ self._handleTextUpdate = function () { } } -autocomplete.events.on('select', self.submit) +autocomplete.on('select', self.submit) self._nodes.search.addEventListener('submit', self._handleSubmit) self._nodes.input.addEventListener('input', self._handleTextUpdate) |