@quartic/bokehjs
Version:
Interactive, novel data visualization
55 lines (42 loc) • 1.47 kB
text/coffeescript
import * as $ from "jquery"
import "bootstrap/button"
import {Widget, WidgetView} from "./widget"
import {BokehView} from "core/bokeh_view"
import * as p from "core/properties"
import template from "./button_group_template"
export class CheckboxButtonGroupView extends WidgetView
events:
"change input": "change_input"
template: template
initialize: (options) ->
super(options)
()
(, 'change', )
render: () ->
super()
.empty()
html = ()
.appendChild(html)
active = .active
for label, i in .labels
$input = $('<input type="checkbox">').attr(value: "#{i}")
if i in active then $input.prop("checked", true)
$label = $('<label class="bk-bs-btn"></label>')
$label.text(label).prepend($input)
$label.addClass("bk-bs-btn-" + .button_type)
if i in active then $label.addClass("bk-bs-active")
.find('.bk-bs-btn-group').append($label)
return @
change_input: () ->
active = (i for checkbox, i in .find("input") when checkbox.checked)
.active = active
.callback?.execute()
export class CheckboxButtonGroup extends Widget
type: "CheckboxButtonGroup"
default_view: CheckboxButtonGroupView
{
active: [ p.Array, [] ]
labels: [ p.Array, [] ]
button_type: [ p.String, "default" ]
callback: [ p.Instance ]
}