Sha256: 2842fa7ce9a39d15f5078b37ff5fd5fedf703fd6be7aee96c260af578129aec2

Contents?: true

Size: 1005 Bytes

Versions: 8

Compression:

Stored size: 1005 Bytes

Contents

rio.components.Link = rio.Component.create(rio.components.Base, "Link", {
	requireCss: "link",
	attrAccessors: ["content", "href"],
	attrReaders: ["className", ["realLink", false]],
	attrEvents: ["click"],
	styles: ["color"],
	methods: {
		buildHtml: function() {
			var linkHtml = rio.Tag.a("", {
				href: "",
				className: this.getClassName() || "link"
			});

			this.bind("href", function(href) {
				linkHtml.href = href || "";
			});

			this.bind("content", function(content) {
				if (Object.isArray(content)) {
					linkHtml.update();
					for (var i=0, length=content.length; i<length; i++) {
						linkHtml.insert(content[i]);
					}
				} else {
					linkHtml.update(content);
				}
			}.bind(this));

			linkHtml.observe("click", function(e) {
				this.fire("click");
				if(this.getRealLink()) {
					rio.Utils.navigateTo(this.getHref());
				} else {
					e.stop();
				}
			}.bindAsEventListener(this));
			
			linkHtml.applyStyle({ color: this.color });

			return linkHtml;
		}
	}
});

Version data entries

8 entries across 8 versions & 1 rubygems

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