phorge/webroot/rsrc/js/core/DropdownMenuItem.js
epriestley 181aff8556 Make some dropdown CSS more specific
Summary:
Dropdowns have some `span` rules and such currently. Give them class-based rules instead.

(This allows me to add another <span> to menu items later on without it picking up silly styles.)

Test Plan: In a future diff, added menu items with additional <span>s inside them.

Reviewers: btrahan, chad

Reviewed By: chad

CC: chad, aran

Differential Revision: https://secure.phabricator.com/D7294
2013-10-14 11:50:05 -07:00

57 lines
1 KiB
JavaScript

/**
* @requires javelin-install
* javelin-dom
* @provides phabricator-menu-item
* @javelin
*/
JX.install('PhabricatorMenuItem', {
construct : function(name, action, href) {
this.setName(name);
this.setHref(href || '#');
this._action = action;
},
members : {
_action : null,
render : function() {
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');
}
var attrs = {
href: this.getHref(),
meta: { item: this },
className: classes.join(' ')
};
if (this.getDisabled()) {
return JX.$N('span', attrs, this.getName());
} else {
return JX.$N('a', attrs, this.getName());
}
},
select : function() {
this._action();
}
},
properties : {
name: '',
href: '',
disabled: false,
selected: false
}
});