-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathawesomplete_input.coffee
43 lines (36 loc) · 1.21 KB
/
awesomplete_input.coffee
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# awesomplete_input.coffee
"""
Nice autocomplete from this thread: https://github.com/bokeh/bokeh/issues/5596
Project URL: https://leaverou.github.io/awesomplete/
"""
import {TextInput, TextInputView} from "models/widgets/text_input"
import * as p from "core/properties"
export class AwesompleteInputView extends TextInputView
initialize: (options) ->
@awesomplete = null
super(options)
# already called in super
# @listenTo(@model, 'change', @render)
# @render()
render: () ->
super()
#if @awesomplete == null
# fixme, init-ing over here because render() is called in super() ..
$input = @$el.find("input")
$input.addClass("dropdown-input")
@awesomplete = new Awesomplete($input[0])
@awesomplete.list = @model.completions
@awesomplete.minChars = @model.min_chars
@awesomplete.maxItems = @model.max_items
@awesomplete.autoFirst = @model.auto_first
return @
export class AwesompleteInput extends TextInput
type: "AwesompleteInput"
default_view: AwesompleteInputView
# defaults are from awesomplete
@define {
completions: [ p.Array, [] ]
min_chars: [ p.Number, 1 ]
max_items: [ p.Number, 10 ]
auto_first: [ p.Bool, false ]
}