Sha256: eb484ba806c237cfb9580625c73c4a2846002adb8ba8e5e2fde5f06eb9460adc

Contents?: true

Size: 1018 Bytes

Versions: 8

Compression:

Stored size: 1018 Bytes

Contents

rio.components.Checkbox = rio.Component.create(rio.components.Base, "Checkbox", {
	require: ["components/label"],
	requireCss: "checkbox",
	attrAccessors: [
		"checked", 
		"label",
		["disabled", false]
	],
	attrReaders: [],
	attrEvents: ["click"],
	methods: {
		buildHtml: function() {
			var randomId = "_rio_label_" + Math.random();

			var checkboxHtml = rio.Tag.input("", {
				id: randomId,
				type: "checkbox"
			});
			var labelHtml = rio.Tag.label("", { 
				htmlFor: randomId,
				className: "checkboxLabel"
			});
			
			this.label.bind(function(label) {
				labelHtml.update(label);
			});
			
			this.bind("checked", function(checked) {
				checkboxHtml.checked = checked;
			});
			
			this.bind("disabled", function(disabled) {
				checkboxHtml.disabled = disabled;
			});
			
			checkboxHtml.observe("click", function() {
				this.setChecked(checkboxHtml.checked);
				this.fire("click");
			}.bind(this));
			
			return rio.Tag.span([checkboxHtml, labelHtml], { className: "checkbox" });
		}
	}
});

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
riojs-0.0.7 public/javascripts/components/checkbox.js
riojs-0.0.6 public/javascripts/components/checkbox.js
riojs-0.0.5 public/javascripts/components/checkbox.js
riojs-0.0.4 public/javascripts/components/checkbox.js
riojs-0.0.3 public/javascripts/components/checkbox.js
riojs-0.0.2 public/javascripts/components/checkbox.js
riojs-0.0.1 public/javascripts/components/checkbox.js
riojs-0.0.0 public/javascripts/components/checkbox.js