Sha256: 7bb2f7c87cdeb617fe7f92a4633b61d7528c71e1193005081397061c74df09e4

Contents?: true

Size: 677 Bytes

Versions: 3

Compression:

Stored size: 677 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(e) {
				this.setState(!this.getState());
				this.fire("toggle");
				e.stop();
			}.bindAsEventListener(this));
			return linkHtml;
		}
	}
});

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
riojs-0.0.7 public/javascripts/components/toggle_button.js
riojs-0.0.6 public/javascripts/components/toggle_button.js
riojs-0.0.5 public/javascripts/components/toggle_button.js