Sha256: 20a659dd4d0c2489c8b8474299dc360e36537f122a4bc08c45f25911e0432e42
Contents?: true
Size: 1.35 KB
Versions: 2
Compression:
Stored size: 1.35 KB
Contents
_.component('Luca.core.Field').extends('Luca.View').with className: 'luca-ui-text-field luca-ui-field' isField: true template: 'fields/text_field' labelAlign: 'top' hooks:[ "before:validation", "after:validation", "on:change" ] # see: http://twitter.github.com/bootstrap/base-css.html statuses: [ "warning" "error" "success" ] initialize: (@options={})-> _.extend @, @options Luca.View::initialize.apply(@, arguments) @input_id ||= _.uniqueId('field') @input_name ||= @name @helperText ||= "" @label ||= "*#{ @label }" if @required and not @label?.match(/^\*/) @inputStyles ||= "" @disable() if @disabled @updateState( @state ) @placeHolder ||= "" beforeRender: ()-> if Luca.enableBootstrap @$el.addClass('control-group') @$el.addClass('required') if @required @$el.html Luca.templates[ @template ]( @ ) @input = $('input', @el) change_handler: (e)-> @trigger "on:change", @, e disable: ()-> $("input",@el).attr('disabled', true) enable: ()-> $("input", @el).attr('disabled', false) getValue: ()-> @input.attr('value') render: ()-> $( @container ).append( @$el ) setValue: (value)-> @input.attr('value', value) updateState: (state)-> _( @statuses ).each (cls)=> @$el.removeClass(cls) @$el.addClass(state)
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
luca-0.8.599 | src/core/field.coffee |
luca-0.8.59 | src/core/field.coffee |