Skip to content
Snippets Groups Projects
Commit 8f6607e3 authored by Rodrigo Nascimento's avatar Rodrigo Nascimento
Browse files

Improve popup of emoji

parent 7be5f9eb
No related branches found
No related tags found
No related merge requests found
......@@ -27,8 +27,12 @@ Template.messagePopup.onCreated ->
template.textFilter = new ReactiveVar ''
template.textFilterDelay = val(template.data.textFilterDelay, 0)
template.open = new ReactiveVar false
template.hasData = new ReactiveVar false
template.value = new ReactiveVar
template.trigger = val(template.data.trigger, '@')
......@@ -68,9 +72,11 @@ Template.messagePopup.onCreated ->
if first?
first.className += ' selected'
template.value.set first.getAttribute('data-id')
else
template.value.set undefined
template.onInputKeydown = (event) =>
if template.open.curValue isnt true
if template.open.curValue isnt true or template.hasData.curValue isnt true
return
if event.which in [38, 40]
......@@ -87,7 +93,7 @@ Template.messagePopup.onCreated ->
template.setTextFilter = _.debounce (value) ->
template.textFilter.set(value)
, 200
, template.textFilterDelay
template.onInputKeyup = (event) =>
if template.open.curValue is true and event.which is 27
......@@ -117,6 +123,8 @@ Template.messagePopup.onCreated ->
template.verifySelection()
template.enterValue = ->
if not template.value.curValue? then return
value = template.input.value
caret = getCursorPosition(template.input)
firstPartValue = value.substr 0, caret
......@@ -136,8 +144,10 @@ Template.messagePopup.onCreated ->
filter = template.textFilter.get()
if filter?
result = template.data.getFilter template.data.collection, filter
# if (template.data.collection instanceof Meteor.Collection and result.count? and result.count() is 0) or result?.length is 0
# template.open.set false
if (template.data.collection instanceof Meteor.Collection and result.count? and result.count() is 0) or result?.length is 0
template.hasData.set false
else
template.hasData.set true
template.records.set result
......@@ -181,7 +191,7 @@ Template.messagePopup.events
Template.messagePopup.helpers
isOpen: ->
Template.instance().open.get()
Template.instance().open.get() and Template.instance().hasData.get()
data: ->
template = Template.instance()
......
......@@ -9,6 +9,7 @@ Template.messagePopupConfig.helpers
collection: onlineUsers
template: 'messagePopupUser'
getInput: self.getInput
textFilterDelay: 200
getFilter: (collection, filter) ->
exp = new RegExp(filter, 'i')
Meteor.subscribe 'onlineUsers', filter
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment