Sha256: 9717b04e7209749cb7e11c3d0f775e68170fbb3a94db295f07a0ad99763b718b
Contents?: true
Size: 1.97 KB
Versions: 30
Compression:
Stored size: 1.97 KB
Contents
(function() { Luca.core.Field = Luca.View.extend({ className: 'luca-ui-text-field luca-ui-field', isField: true, template: 'fields/text_field', labelAlign: 'top', hooks: ["before:validation", "after:validation", "on:change"], statuses: ["warning", "error", "success"], initialize: function(options) { var _ref; this.options = options != null ? options : {}; _.extend(this, this.options); Luca.View.prototype.initialize.apply(this, arguments); this.input_id || (this.input_id = _.uniqueId('field')); this.input_name || (this.input_name = this.name); this.helperText || (this.helperText = ""); if (this.required && !((_ref = this.label) != null ? _ref.match(/^\*/) : void 0)) { this.label || (this.label = "*" + this.label); } this.inputStyles || (this.inputStyles = ""); if (this.disabled) this.disable(); this.updateState(this.state); return this.placeHolder || (this.placeHolder = ""); }, beforeRender: function() { if (Luca.enableBootstrap) this.$el.addClass('control-group'); if (this.required) this.$el.addClass('required'); this.$el.html(Luca.templates[this.template](this)); return this.input = $('input', this.el); }, change_handler: function(e) { return this.trigger("on:change", this, e); }, disable: function() { return $("input", this.el).attr('disabled', true); }, enable: function() { return $("input", this.el).attr('disabled', false); }, getValue: function() { return this.input.attr('value'); }, render: function() { return $(this.container).append(this.$el); }, setValue: function(value) { return this.input.attr('value', value); }, updateState: function(state) { var _this = this; return _(this.statuses).each(function(cls) { _this.$el.removeClass(cls); return _this.$el.addClass(state); }); } }); }).call(this);
Version data entries
30 entries across 30 versions & 1 rubygems