Sha256: bdf21828cefab59f96f533338736e8b0eed321f2899b6bb47a08d0622ad6224b

Contents?: true

Size: 1.3 KB

Versions: 30

Compression:

Stored size: 1.3 KB

Contents

(function() {

  Luca.fields.CheckboxField = Luca.core.Field.extend({
    form_field: true,
    events: {
      "change input": "change_handler"
    },
    change_handler: function(e) {
      var me, my;
      me = my = $(e.currentTarget);
      this.trigger("on:change", this, e);
      if (me.checked === true) {
        return this.trigger("checked");
      } else {
        return this.trigger("unchecked");
      }
    },
    className: 'luca-ui-checkbox-field luca-ui-field',
    template: 'fields/checkbox_field',
    hooks: ["checked", "unchecked"],
    initialize: function(options) {
      this.options = options != null ? options : {};
      _.extend(this, this.options);
      _.bindAll(this, "change_handler");
      return Luca.core.Field.prototype.initialize.apply(this, arguments);
    },
    afterInitialize: function() {
      this.input_id || (this.input_id = _.uniqueId('field'));
      this.input_name || (this.input_name = this.name);
      this.input_value || (this.input_value = 1);
      return this.label || (this.label = this.name);
    },
    setValue: function(checked) {
      return this.input.attr('checked', checked);
    },
    getValue: function() {
      return this.input.attr('checked') === true;
    }
  });

  Luca.register("checkbox_field", "Luca.fields.CheckboxField");

}).call(this);

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
luca-0.9.76 vendor/assets/luca-ui/components/fields/checkbox_field.js
luca-0.9.7 vendor/assets/luca-ui/components/fields/checkbox_field.js
luca-0.9.65 vendor/assets/luca-ui/components/fields/checkbox_field.js
luca-0.9.6 vendor/assets/luca-ui/components/fields/checkbox_field.js
luca-0.9.42 vendor/assets/luca-ui/components/fields/checkbox_field.js
luca-0.9.4 vendor/assets/luca-ui/components/fields/checkbox_field.js
luca-0.9.2 vendor/assets/luca-ui/components/fields/checkbox_field.js
luca-0.9.1 vendor/assets/luca-ui/components/fields/checkbox_field.js
luca-0.9.0 vendor/assets/luca-ui/components/fields/checkbox_field.js
luca-0.8.599 vendor/assets/luca-ui/components/fields/checkbox_field.js
luca-0.8.59 vendor/assets/luca-ui/components/fields/checkbox_field.js
luca-0.8.3 vendor/assets/luca-ui/components/fields/checkbox_field.js
luca-0.8.2 vendor/assets/luca-ui/components/fields/checkbox_field.js
luca-0.8.06 vendor/assets/luca-ui/components/fields/checkbox_field.js
luca-0.8 vendor/assets/luca-ui/components/fields/checkbox_field.js
luca-0.7.92 vendor/assets/luca-ui/components/fields/checkbox_field.js
luca-0.7.91 vendor/assets/luca-ui/components/fields/checkbox_field.js
luca-0.7.9 vendor/assets/luca-ui/components/fields/checkbox_field.js
luca-0.7.8 vendor/assets/luca-ui/components/fields/checkbox_field.js
luca-0.7.7 vendor/assets/luca-ui/components/fields/checkbox_field.js