Sha256: 3189709420bbbd56dec3bda0c63081fb42d1b6a1f33a93d54f48c5ce544d4f84

Contents?: true

Size: 1.12 KB

Versions: 2

Compression:

Stored size: 1.12 KB

Contents

rio.components.ListItem = rio.Component.create(rio.components.Base, "ListItem", {
	attrAccessors: [["selected", false]],
	attrReaders: [
		"item", 
		"renderer",
		["className", "listItem"],
		["hoverClassName", "listItemHover"],
		["selectedClassName", "listItemSelected"],
		["stopClickPropogation", false]
	],
	attrEvents: ["click"],
	methods: {
		buildHtml: function() {
			var listItemHtml = this.getRenderer()(this.getItem());
			listItemHtml.rioComponent = this;

			var hoverClass = this.getHoverClassName();
			if (hoverClass && !hoverClass.blank()) {
				listItemHtml.observe("mouseover", function() {
					listItemHtml.addClassName(hoverClass);
				});
				listItemHtml.observe("mouseout", function() {
					listItemHtml.removeClassName(hoverClass);
				});
			}
			
			this.bind("selected", function(selected) {
				listItemHtml[selected ? "addClassName" : "removeClassName"](this.getSelectedClassName());
			}.bind(this));
			
			return listItemHtml;
		},
		
		click: function(e) {
			this.fire("click");	
			if (this.getStopClickPropogation()) {
				e.stop();
			}
		},
		
		scrollTo: function() {
			this.fire("scrollTo");
		}
	}
});

Version data entries

2 entries across 2 versions & 1 rubygems

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