Sha256: fe31f2f6798e7335094524c695530d2e061e4f5d8989132dca8f91c204e3217c

Contents?: true

Size: 811 Bytes

Versions: 2

Compression:

Stored size: 811 Bytes

Contents

_.component('Luca.fields.CheckboxField').extends('Luca.core.Field').with

  events:
    "change input" : "change_handler"

  change_handler: (e)->
    me = my = $(e.currentTarget)

    @trigger "on:change", @, e

    if me.checked is true
      @trigger "checked"
    else
      @trigger "unchecked"

  className: 'luca-ui-checkbox-field luca-ui-field'

  template: 'fields/checkbox_field'

  hooks: ["checked","unchecked"]

  initialize: (@options={})->
    _.extend @, @options
    _.bindAll @, "change_handler"

    Luca.core.Field::initialize.apply @, arguments

  afterInitialize: ()->
    @input_id ||= _.uniqueId('field')
    @input_name ||= @name
    @input_value ||= 1
    @label ||= @name

  setValue: (checked)->
    @input.attr('checked', checked)

  getValue:()->
    @input.attr('checked') is true

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
luca-0.8.599 src/components/fields/checkbox_field.coffee
luca-0.8.59 src/components/fields/checkbox_field.coffee