3 function MenuBuilder() {
4 /* Treat the top of the menu like a divider */
5 this.lastItemDivider = true;
9 MenuBuilder.prototype = {
10 addConditional: function(conditional, item) {
17 this.lastItemDivider = false;
18 this.items.push(item);
21 addDivider: function() {
22 /* Add a divider if theres not already one at the bottom */
23 if (this.lastItemDivider) return;
24 this.lastItemDivider = true;
25 this.items.push({ divider: true });
28 getItems: function() {
29 /* Don't leave a hanging divider at the bottom */
30 if (this.lastItemDivider) {
38 module.exports = MenuBuilder;