Sha256: 92c1b3a25b1fb899f46086f567d32b633502bf605847587a81e7f60c9ab12714

Contents?: true

Size: 1.05 KB

Versions: 4

Compression:

Stored size: 1.05 KB

Contents

Spontaneous.Field.Boolean = (function($, S) {
	var dom = S.Dom;
	var BooleanField = new JS.Class(Spontaneous.Field.String, {
		edit: function() {
			var self = this
			, w = dom.div(dom.id(self.css_id()))
			, input = self.input() // ensure we have created the radio inputs $on & $off
			, labels = self.type.labels
			, label = function(label, radio) { return dom.label().text(label).prepend(radio); }
			;
			w.append(label(labels['true'], self.$on), label(labels['false'], self.$off));
			return w;
		},
		generate_input: function() {
			var self = this
			, checked = (this.get('unprocessed_value') == 'true')
			, click = function() { self.editor.field_focus(self.input()); }
			, on = dom.radio({'name':this.form_name(), 'value': 'true', 'checked': checked})
			, off = dom.radio({'name':this.form_name(), 'value': 'false', 'checked': !checked})
			;
			self.$on = on;
			self.$off = off;
			return $(on).add(off).click(click);
		},
		edited_value: function() {
			return this.input().filter(':checked').val();
		}
	});
	return BooleanField;
})(jQuery, Spontaneous);

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
spontaneous-0.2.0.beta5 application/js/field/boolean.js
spontaneous-0.2.0.beta4 application/js/field/boolean.js
spontaneous-0.2.0.beta3 application/js/field/boolean.js
spontaneous-0.2.0.beta2 application/js/field/boolean.js