This repository has been archived on 2024-07-18. You can view files and clone it, but cannot push or open issues or pull requests.
lwb5/misc/Legacy Worlds.wdgt/lib/LWWidget/Menu/Item.js

38 lines
825 B
JavaScript

LWWidget.Menu.Item = Base.Comp.inherits({
constructor: function (name, text, clickable, selectable, separator) {
this.base();
this.name = name;
this.text = text;
this.clickable = !!clickable;
this.selectable = this.clickable && !!selectable;
this.separator = (typeof separator == 'string') ? separator : '';
this.selected = false;
this.addEvent('Click');
},
draw: function () {
var pfx, sfx;
if (this.clickable && !this.selected) {
pfx = '<a href="#" onclick="Base.Comp.get(' + this._cid + ').click();return false">';
sfx = '</a>';
} else if (this.selectable && this.selected) {
pfx = '<b>';
sfx = '</b>';
} else {
pfx = sfx = '';
}
return pfx + this.text + sfx;
},
click: function () {
if (this.selectable) {
this.selected = true;
}
this.onClick(this);
}
});