Sha256: b419b3fdb7e02da9fe345bbc70a3c7587dceca82b34ad6823b5eaf8dd31e5d8b

Contents?: true

Size: 1.13 KB

Versions: 6

Compression:

Stored size: 1.13 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.observe("mouseover", function() {
				listItemHtml.addClassName(this.getHoverClassName());
			}.bind(this));
			listItemHtml.observe("mouseout", function() {
				listItemHtml.removeClassName(this.getHoverClassName());
			}.bind(this));
			listItemHtml.observe("click", function(e) { 
				this.click();
				if (this.getStopClickPropogation()) {
					e.stop();
				}
			}.bindAsEventListener(this));
			
			this.bind("selected", function(selected) {
				listItemHtml[selected ? "addClassName" : "removeClassName"](this.getSelectedClassName());
			}.bind(this));
			
			return listItemHtml;
		},
		
		click: function() {
			this.fire("click");	
		},
		
		scrollTo: function() {
			this.fire("scrollTo");
		}
	}
});

Version data entries

6 entries across 6 versions & 1 rubygems

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