parent
daff8ab97c
commit
8e504ca8ff
@ -0,0 +1,46 @@ |
||||
@spotlight = |
||||
hide: -> |
||||
$('.spotlight').addClass('hidden') |
||||
|
||||
show: -> |
||||
$('.spotlight').removeClass('hidden') |
||||
$('.spotlight input').focus() |
||||
|
||||
Template.spotlight.helpers |
||||
autocompleteSettingsRoomSearch: -> |
||||
return { |
||||
limit: 10 |
||||
# inputDelay: 300 |
||||
rules: [ |
||||
{ |
||||
collection: 'UserAndRoom' |
||||
subscription: 'roomSearch' |
||||
field: 'name' |
||||
template: Template.roomSearch |
||||
noMatchTemplate: Template.roomSearchEmpty |
||||
matchAll: true |
||||
filter: { uid: { $ne: Meteor.userId() } } |
||||
sort: 'name' |
||||
} |
||||
] |
||||
} |
||||
|
||||
Template.spotlight.events |
||||
'autocompleteselect input': (event, template, doc) -> |
||||
if doc.type is 'u' |
||||
Meteor.call 'createDirectMessage', doc.username, (error, result) -> |
||||
if error |
||||
return Errors.throw error.reason |
||||
|
||||
if result?.rid? |
||||
FlowRouter.go('direct', { username: doc.username }) |
||||
event.currentTarget.value = '' |
||||
else if doc.type is 'r' |
||||
if doc.t is 'c' |
||||
FlowRouter.go('channel', { name: doc.name }) |
||||
else if doc.t is 'p' |
||||
FlowRouter.go('group', { name: doc.name }) |
||||
|
||||
event.currentTarget.value = '' |
||||
|
||||
spotlight.hide() |
||||
@ -0,0 +1,8 @@ |
||||
<template name="spotlight"> |
||||
<div class="spotlight hidden"> |
||||
<div class="spotlight-input"> |
||||
<i class="icon-search"></i> |
||||
{{> inputAutocomplete settings=autocompleteSettingsRoomSearch id="room-search" class="search" placeholder=tQuickSearch autocomplete="off"}} |
||||
</div> |
||||
</div> |
||||
</template> |
||||
Loading…
Reference in new issue