This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/components/select-box/select-box-row.js.es6
Joffrey JAFFEUX cad6107624 refactors select-box
Note: this commit also now uses select-box for mobile topics controls
2017-08-16 00:41:56 +02:00

35 lines
729 B
JavaScript

export default Ember.Component.extend({
classNames: "select-box-row",
tagName: "li",
classNameBindings: ["isHighlighted"],
attributeBindings: ["text:title"],
lastHoveredId: null,
mouseEnter() {
this.sendAction("onHover", this.get("content.id"));
},
click() {
this.sendAction("onSelect", this.get("content.id"));
},
didReceiveAttrs() {
this._super();
this.set("isHighlighted", this._isHighlighted());
this.set("text", this.get("content.text"));
},
_isHighlighted() {
if(_.isUndefined(this.get("lastHoveredId"))) {
return this.get("content.id") === this.get("selectedId");
} else {
return this.get("content.id") === this.get("lastHoveredId");
}
},
});