Sha256: acdc6668ba1766bb3b5625915c6bda6d2814eddd81bca3a6c0f926ecdf46c3a3

Contents?: true

Size: 615 Bytes

Versions: 1

Compression:

Stored size: 615 Bytes

Contents

rio.components.ToggleButton = rio.Component.create(rio.components.Base, {
	attrReaders: ["offImage", "onImage"],
	attrAccessors: ["state"],
	attrEvents: ["click"],
	methods: {
		buildHtml: function() {
			var imgHtml = new rio.components.Image();
			this.bind("state", function(state) {
				imgHtml.setSrc(state ? this.getOnImage() : this.getOffImage());
			}.bind(this));
			var linkHtml = rio.Tag.a(imgHtml, {
				href: "",
				onclick: "return false;"
			});
			linkHtml.observe("click", function() {
				this.setState(!this.getState());
				this.fire("toggle");
			}.bind(this));
			return linkHtml;
		}
	}
});

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
riojs-0.0.0 public/javascripts/components/toggle_button.js