2012-01-04 16:52:13 -08:00
|
|
|
/**
|
|
|
|
|
* @requires javelin-install
|
|
|
|
|
* javelin-dom
|
|
|
|
|
* @provides phabricator-menu-item
|
|
|
|
|
* @javelin
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
JX.install('PhabricatorMenuItem', {
|
|
|
|
|
|
2012-01-16 22:17:18 -08:00
|
|
|
construct : function(name, action, href) {
|
2012-01-05 20:29:16 -08:00
|
|
|
this.setName(name);
|
2012-01-16 22:17:18 -08:00
|
|
|
this.setHref(href || '#');
|
2012-01-04 16:52:13 -08:00
|
|
|
this._action = action;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
members : {
|
|
|
|
|
_action : null,
|
|
|
|
|
|
|
|
|
|
render : function() {
|
2013-10-14 11:50:05 -07:00
|
|
|
var classes = [];
|
|
|
|
|
classes.push('dropdown-menu-item');
|
|
|
|
|
|
|
|
|
|
if (this.getSelected()) {
|
|
|
|
|
classes.push('dropdown-menu-item-selected');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (this.getDisabled()) {
|
|
|
|
|
classes.push('dropdown-menu-item-disabled');
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-12 17:08:35 -07:00
|
|
|
var attrs = {
|
|
|
|
|
href: this.getHref(),
|
|
|
|
|
meta: { item: this },
|
2013-10-14 11:50:05 -07:00
|
|
|
className: classes.join(' ')
|
2013-10-12 17:08:35 -07:00
|
|
|
};
|
|
|
|
|
|
2012-01-05 14:41:11 -08:00
|
|
|
if (this.getDisabled()) {
|
2013-10-12 17:08:35 -07:00
|
|
|
return JX.$N('span', attrs, this.getName());
|
2012-01-05 14:41:11 -08:00
|
|
|
} else {
|
2012-01-05 20:29:16 -08:00
|
|
|
return JX.$N('a', attrs, this.getName());
|
2012-01-05 14:41:11 -08:00
|
|
|
}
|
2012-01-04 16:52:13 -08:00
|
|
|
},
|
|
|
|
|
|
|
|
|
|
select : function() {
|
|
|
|
|
this._action();
|
|
|
|
|
}
|
2012-01-05 14:41:11 -08:00
|
|
|
},
|
|
|
|
|
|
|
|
|
|
properties : {
|
2013-10-12 17:08:35 -07:00
|
|
|
name: '',
|
|
|
|
|
href: '',
|
|
|
|
|
disabled: false,
|
|
|
|
|
selected: false
|
2012-01-04 16:52:13 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
});
|