Sha256: 6658db3f771cc1179da88fd79aa65b1636d62446ff76be472eace1923c8abe6a

Contents?: true

Size: 647 Bytes

Versions: 4

Compression:

Stored size: 647 Bytes

Contents

rio.components.ToggleButton = rio.Component.create(rio.components.Base, {
	require: ["components/image"],
	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

4 entries across 4 versions & 1 rubygems

Version Path
riojs-0.0.4 public/javascripts/components/toggle_button.js
riojs-0.0.3 public/javascripts/components/toggle_button.js
riojs-0.0.2 public/javascripts/components/toggle_button.js
riojs-0.0.1 public/javascripts/components/toggle_button.js