Sha256: 7229b13529ea7b4af03361f30a86ac8a8d13c892219321b55beac6b5c11fc15d

Contents?: true

Size: 882 Bytes

Versions: 19

Compression:

Stored size: 882 Bytes

Contents

Luca.fields.CheckboxField = Luca.core.Field.extend
  form_field: true

  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

Luca.register "checkbox_field", "Luca.fields.CheckboxField"

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
luca-0.8.3 src/components/fields/checkbox_field.coffee
luca-0.8.2 src/components/fields/checkbox_field.coffee
luca-0.8.06 src/components/fields/checkbox_field.coffee
luca-0.8 src/components/fields/checkbox_field.coffee
luca-0.7.92 src/components/fields/checkbox_field.coffee
luca-0.7.91 src/components/fields/checkbox_field.coffee
luca-0.7.9 src/components/fields/checkbox_field.coffee
luca-0.7.8 src/components/fields/checkbox_field.coffee
luca-0.7.7 src/components/fields/checkbox_field.coffee
luca-0.7.6 src/components/fields/checkbox_field.coffee
luca-0.7.5 src/components/fields/checkbox_field.coffee
luca-0.7.4 src/components/fields/checkbox_field.coffee
luca-0.7.3 src/components/fields/checkbox_field.coffee
luca-0.7.2 src/components/fields/checkbox_field.coffee
luca-0.7.0 src/components/fields/checkbox_field.coffee
luca-0.6.9 src/components/fields/checkbox_field.coffee
luca-0.6.8 src/components/fields/checkbox_field.coffee
luca-0.6.7 src/components/fields/checkbox_field.coffee
luca-0.6.6 src/components/fields/checkbox_field.coffee